Skip to content

[Bug]: turn_off_message_logging Does Not Redact Request Messages in proxy_server_request Field When Stored to Database #16336

Description

@RupertoXTI

What happened?

Bug: turn_off_message_logging Does Not Redact Request Messages in proxy_server_request Field When Stored to Database

Description

When using turn_off_message_logging: true with store_prompts_in_spend_logs: true, the response is correctly redacted in spend logs, but the request messages remain unredacted. This creates a security/privacy issue where sensitive request data is stored in the database despite redaction being enabled.

Environment

  • LiteLLM Version: main-stable (latest as of 2025-11-06)
  • Database: PostgreSQL
  • Deployment: Docker Compose

Configuration

model_list:
  - model_name: gpt-4.1-mini
    litellm_params:
      model: gpt-4.1-mini
      api_base: https://litellm.com
      api_key: sk-xxxxx

general_settings:
  store_model_in_db: true
  store_prompts_in_spend_logs: true

litellm_settings:
  turn_off_message_logging: true

Expected Behavior

When turn_off_message_logging: true is set, both request and response should be redacted before being stored in the LiteLLM_SpendLogs table.

Actual Behavior

  • Response: Correctly shows {"text": "redacted-by-litellm"}
  • Request: Full unredacted request messages are stored in the proxy_server_request field in metadata column

Reproduction Steps

  1. Configure LiteLLM proxy with the config above and the docker-compose.yml found in the repository
  2. Run docker-compose up
  3. Make a request:
curl --location 'http://0.0.0.0:4000/chat/completions' \
  --header 'Content-Type: application/json' \
  --header 'Authorization: Bearer sk-1234' \
  --data '{
    "model": "gpt-4.1-mini",
    "messages": [
      {
        "role": "user",
        "content": "what llm are you"
      }
    ]
  }'
  1. Navigate to the UI and find the logs
  2. Find your request
  3. Find that the log for the request shows the response redacted but the request fully present without any redaction

Relevant log output

Are you a ML Ops Team?

No

What LiteLLM version are you on ?

1.79.0-stable

Twitter / LinkedIn details

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions