Repository navigation
fix(litellm): use allowlist for span metadata - #578
Merged
Merged
Conversation
LiteLLM accepts provider credentials and transport headers directly on
instrumented calls. For example:
```python
litellm.completion(
model="openai/example-model",
messages=[{"role": "user", "content": "Hello"}],
api_key=os.environ["OPENAI_API_KEY"],
extra_headers={"Authorization": f"Bearer {token}"},
)
```
Cloud-provider credentials can also be supplied as kwargs:
```python
litellm.completion(
model="azure/example-deployment",
messages=[...],
azure_ad_token=os.environ["AZURE_AD_TOKEN"],
)
```
Previously, every kwarg other than the selected input and model flowed
into span metadata and then into the logs upload:
```text
litellm.completion kwargs
├── messages --------------------------> span.input
├── model -----------------------------> span.metadata.model
└── api_key / headers / cloud secrets -> span.metadata -> POST /logs3
```
Build LiteLLM span metadata from an allowlist of known-safe request
parameters instead. Credentials, transport headers, and unknown future
kwargs now fall outside the logging boundary:
```text
call kwargs -> safe metadata allowlist -> span.metadata -> POST /logs3
└── credentials and unknown kwargs dropped
```
Apply the same metadata builder to completion, rerank, and transcription
payloads. Extend the cassette-backed OpenRouter regression coverage to
verify that `api_key` is absent while only displaying metadata key names
on assertion failure.
Validation:
- nox -s "test_litellm(latest)" "test_litellm(1.74.0)"
- make lint
Luca Forstner (lforst)
approved these changes
Jul 16, 2026
Abhijeet Prasad (AbhiPrasad)
enabled auto-merge (squash)
July 16, 2026 13:25
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.
LiteLLM accepts provider credentials and transport headers directly on instrumented calls. For example:
Cloud-provider credentials can also be supplied as kwargs:
Previously, every kwarg other than the selected input and model flowed into span metadata and then into the logs upload:
Build LiteLLM span metadata from an
_SAFE_METADATA_KEYS._SAFE_METADATA_KEYShas a lot of keys, but I kept this because it maintains existing behaviour in case folks are using the other metadata keys for stuff.