Skip to content

Feature(LiteLLM): Add opt-in toggle to capture prompts/responses in spend logs - #583

Open
marazik wants to merge 1 commit into
AsyncFuncAI:mainfrom
marazik:feature/litellm-prompt-logging
Open

Feature(LiteLLM): Add opt-in toggle to capture prompts/responses in spend logs#583
marazik wants to merge 1 commit into
AsyncFuncAI:mainfrom
marazik:feature/litellm-prompt-logging

Conversation

@marazik

@marazik marazik commented Aug 30, 2026

Copy link
Copy Markdown
Contributor

Summary

Adds an opt-in way to make LiteLLM capture full prompts and responses in
its spend logs, for anyone debugging or auditing what's actually being
sent to/from the model through the LiteLLM proxy.

  • store_prompts_in_spend_logs is added to litellm-config.yml,
    commented out by default — no change to existing behavior unless a
    user explicitly uncomments it.
  • When enabled, LiteLLM populates the response field of the
    LiteLLM_SpendLogs table (Postgres) with the actual response content
    (chat completion text, or embedding vectors), viewable via the Admin
    UI's Logs page or by querying the DB directly. Note: messages (the
    request/prompt side) is not captured by this setting in the pinned
    LiteLLM version (v1.83.10-stable) — that's a separate, pre-existing
    limitation of the proxy's logging code, unrelated to this change.
  • store_model_in_db (already present, unrelated to logging — it governs
    whether models/config added via the Admin UI or API get persisted to
    the DB) is kept enabled and now has its own explanatory comment, since
    it was previously undocumented.

Why commented out by default

Consistent with the rest of the LiteLLM integration series: fully opt-in,
zero impact on default behavior for anyone not using this feature.

Note

LiteLLM's own Admin UI empty-state hint suggests enabling both
store_model_in_db and store_prompts_in_spend_logs together, which is
misleading — store_model_in_db is unrelated to prompt/response capture
and has no effect on it. Verified directly: with store_model_in_db: true
already active throughout, toggling only store_prompts_in_spend_logs
was what flipped response from empty to populated. This PR documents
each setting accurately and separately to avoid that confusion.

Testing

Verified on this branch by enabling the flag, sending chat and embedding
requests directly through the LiteLLM proxy, and confirming response is
populated in LiteLLM_SpendLogs (via direct Postgres query, and visually
in the Admin UI Logs page) when the toggle is on, and remains empty ({})
when it's left commented out — for both acompletion and aembedding
call types.

store_prompts_in_spend_logs is added commented-out by default, so behavior
is unchanged unless explicitly enabled. store_model_in_db is kept on and
documented, since it's an unrelated setting (DB-persisted model management,
not logging).

@greptile-apps greptile-apps Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Your trial has ended. Reactivate Greptile to resume code reviews.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

1 participant