Skip to content

[Feature]: Add header support for spend_logs_metadata #14008

@TeddyAmkie

Description

@TeddyAmkie

The Feature

Currently, spend_logs_metadata can only be provided in the request body under litellm_metadata. Some clients would like to supply this metadata via headers (similar to how x-litellm-tags works).

Motivation, pitch

Use Case / Motivation:
• Easier to inject spend metadata at the infra/gateway level without mutating request bodies.
• Standardizes header-based tagging and metadata handling.
• Aligns with how x-litellm-tags is already supported.

Proposed Behavior:

Header:
x-litellm-spend-logs-metadata: {"owner":"team-data-ai-ml","feature":"a-feature","product":"personal","environment":"development"}

Expected Result:
• spend_logs_metadata is available in spend logs exactly as if it had been passed in the body.
• This allows consistent spend attribution without requiring body mutation.

LiteLLM is hiring a founding backend engineer, are you interested in joining us and shipping to all our users?

Yes

Twitter / LinkedIn details

No response

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions