Feature(LiteLLM): Add opt-in toggle to capture prompts/responses in spend logs - #583
Open
marazik wants to merge 1 commit into
Open
Feature(LiteLLM): Add opt-in toggle to capture prompts/responses in spend logs#583marazik wants to merge 1 commit into
marazik wants to merge 1 commit into
Conversation
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).
There was a problem hiding this comment.
Your trial has ended. Reactivate Greptile to resume code reviews.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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_logsis added tolitellm-config.yml,commented out by default — no change to existing behavior unless a
user explicitly uncomments it.
responsefield of theLiteLLM_SpendLogstable (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(therequest/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 governswhether 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_dbandstore_prompts_in_spend_logstogether, which ismisleading —
store_model_in_dbis unrelated to prompt/response captureand has no effect on it. Verified directly: with
store_model_in_db: truealready active throughout, toggling only
store_prompts_in_spend_logswas what flipped
responsefrom empty to populated. This PR documentseach 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
responseispopulated in
LiteLLM_SpendLogs(via direct Postgres query, and visuallyin the Admin UI Logs page) when the toggle is on, and remains empty (
{})when it's left commented out — for both
acompletionandaembeddingcall types.