litellm/litellm/integrations
yucheng-berri 14c4a6f1f2
fix(langfuse): upload base64 media and export its reference from the langfuse callback (#53934)
* fix(langfuse): upload base64 media and export its reference from the langfuse callback

The v2 SDK replaced base64 payloads in a trace's input, output and metadata with
Langfuse media references and uploaded the bytes before ingestion. The v4 export
channel sends spans through litellm's own exporter, which had no such step, so
images reached Langfuse inline and multiplied the stored trace size on servers
that do not extract them.

The export channel now replaces data URIs and the Anthropic and Vertex typed
blocks with the same references and uploads the bytes through the Langfuse media
REST API on one background thread per channel.

* fix(langfuse): bound queued media by bytes and stop trusting the storage response

Media the uploader has no room for now stays inline in the span, the cap counts
decoded bytes, and a failed upload makes flush report failure. The storage PUT
no longer follows redirects and Langfuse is told the storage status without the
storage response body. A data URI followed by text is left as it is, trace level
media is registered without an observation, and queued uploads get five seconds
to finish at shutdown.

* fix(langfuse): validate upload URLs for request-supplied hosts and queue an attribute's media as a whole

A Langfuse host that comes with a key's or team's credentials now has the upload
URLs it returns checked with validate_url, so it cannot point the upload at an
internal address. A host the operator configured keeps naming its own storage.
The media of one attribute is queued all together or not at all, so an attribute
that stays inline no longer leaves part of its media uploading.

* fix(langfuse): keep media inline while Langfuse cannot store it

A Langfuse with no media route or bucket, or one whose upload URL is refused, answers the same
way for every payload. After the first such answer the uploader turns media away, so the exporter
keeps it inline, and one upload per pause checks whether Langfuse takes media again.

* fix(langfuse): re-send a media registration that does not reach Langfuse

The span export keeps trying through a short Langfuse outage, so a trace could arrive with a
reference whose single registration attempt had failed. Registration now waits out the same delays.

* fix(langfuse): replace base64 media in model parameters

A call rejected before the provider, such as an unknown model or a failed key check, is logged
with its request body as the model parameters, which left the image inline in those traces.

* Revert "fix(langfuse): replace base64 media in model parameters"

This reverts commit 3a4894c78e.

* fix(langfuse): leave the media storage response body unread

Only the status of the storage PUT is used, and an upload URL can answer with a body of any size.

* fix(langfuse): always export the media reference, as the Langfuse SDK does

Drops the pause that kept media inline after the media API failed. A self-hosted Langfuse needs a media bucket, as its docs state.

* fix(langfuse): read the HTTP client from the handler on every media upload

litellm closes a pooled client once its cache entry expires (one hour plus
the close grace) and the handler opens another. The uploader held the first
client, so later uploads raised 'client has been closed' and traces kept a
reference with no file. The span exporter already reads handler.client per
request.

* perf(langfuse): skip the media parse for values that only mention base64

extract_media parsed and walked any value that held the text base64 or
mime_type. It now parses only a value that holds a base64 data URI, or a
content type key next to a data key, which every payload it replaces has.

* test(langfuse): check media-free values by their output only

* fix(langfuse): stop validating the media upload URL for key and team hosts

The Langfuse host on a key or team is not validated by default, so checking only the
upload URL it returns added no protection. The check resolved DNS on the proxy and
refused storage that is private or reachable only through an egress proxy, which left
the trace with a media reference and no file.

* fix(langfuse): restart the media upload thread in a forked child

A fork copies the upload queue but none of the parent's threads, so a child forked after
the first logged call wrote media references that nothing uploaded. The child now gets
its own queue and thread, and the parent keeps uploading what it had queued.

* fix(langfuse): upload Gemini inline_data parts as media

The Langfuse SDK replaces Gemini inline_data and inlineData parts with a media reference. The callback now does the same, so a Gemini-native request with an image no longer stores its base64 inline.

* fix(langfuse): size the media upload queue from an env setting and stop keeping media inline when it is full

LANGFUSE_MEDIA_QUEUE_MAX_BYTES sets how many decoded bytes wait for upload per
export channel, 100 MB when unset. Media that does not fit is no longer kept
inline in the span: the span carries the reference, the upload is skipped with
a warning and counted as failed, as the Langfuse SDK does when its queue is
full.

* fix(langfuse): give a forked child its own failure lock

A lock a parent thread held at the fork stays locked in the child. The queue
test now holds the first upload until the second has been turned away.
2026-11-27 11:29:16 -08:00
..
_types style: unify ruff format width on 120 (#31518) 2026-06-27 12:39:29 -07:00
agentops fix(caching): key cached async clients by a per-loop token instead of id(loop) (#48877) 2026-10-29 13:14:48 -07:00
arize refactor(types): replace Unknown with proven types in 162 more files (#54089) 2026-11-23 22:58:19 -08:00
azure_sentinel refactor(types): replace Unknown with proven types in 131 more files (#54045) 2026-11-24 04:55:42 +00:00
azure_storage refactor(types): replace Unknown with proven types in 245 files (#53774) 2026-11-23 10:05:26 -08:00
bitbucket refactor(types): replace Unknown with proven types in 162 more files (#54089) 2026-11-23 22:58:19 -08:00
clickhouse refactor(types): replace Unknown with proven types in 162 more files (#54089) 2026-11-23 22:58:19 -08:00
cloudzero refactor(types): replace Unknown with proven types in 390 files (#53715) 2026-11-24 03:33:11 +00:00
code_interpreter_interception refactor(types): replace Unknown with proven types in 225 files (#53687) 2026-11-24 00:11:50 +00:00
compression_interception refactor(typing): clear basedpyright Any errors across 35 files (#53599) 2026-11-24 00:39:02 +00:00
custom_logger_v2 fix(proxy): start and serve the proxy with a database on Python 3.10 and prisma 0.13+ (#54416) 2026-11-26 00:09:17 +00:00
datadog refactor: build Datadog and rerank request headers without mutation (#54830) 2026-11-27 08:19:33 +00:00
deepeval refactor(types): replace Unknown with proven types in 131 more files (#54119) 2026-11-24 02:26:51 -08:00
dotprompt refactor(types): give bare dict, list and tuple returns proven types in 133 files (#54321) 2026-11-25 01:30:02 +00:00
email_templates feat(proxy): add team budget percentage email alerts (#52859) 2026-11-19 16:21:25 -08:00
focus fix(openai)!: apply drop_params to reasoning objects on openai/ chat, openai/responses/ and /v1/messages (#53865) 2026-11-24 04:16:41 +00:00
gcs_bucket refactor(types): type the json, headers and params of the shared HTTP client's request methods and their callers (#54743) 2026-11-26 20:16:27 +00:00
gcs_pubsub refactor(types): replace Unknown with proven types in 390 files (#53715) 2026-11-24 03:33:11 +00:00
generic_api refactor(types): type the kwargs reads in the Braintrust, Datadog, Langsmith, Literal AI and generic API loggers (#54686) 2026-11-26 11:01:13 +00:00
generic_prompt_management refactor(types): give bare dict, list and tuple returns proven types in 133 files (#54321) 2026-11-25 01:30:02 +00:00
gitlab refactor(typing): clear 102 basedpyright Any errors across 21 files (#54586) 2026-11-25 19:03:46 -08:00
langfuse fix(langfuse): upload base64 media and export its reference from the langfuse callback (#53934) 2026-11-27 11:29:16 -08:00
lens refactor(typing): clear 102 basedpyright Any errors across 21 files (#54586) 2026-11-25 19:03:46 -08:00
levo refactor(typing): widen delete_nested_value to Mapping and drop two unused Span aliases (#48001) 2026-10-24 19:39:27 +00:00
litellm_agent refactor(types): replace Unknown with proven types in 390 files (#53715) 2026-11-24 03:33:11 +00:00
mavvrik_focus refactor(typing): clear 1143 basedpyright Any errors across 273 files (#46574) 2026-10-15 21:08:47 +00:00
newrelic refactor(types): type the dict-style accessors on the response models and their read sites (#54620) 2026-11-26 04:15:22 +00:00
opentelemetry_utils refactor(types): annotate repeated bare-container parameters across method families (#54268) 2026-11-24 14:13:19 -08:00
opik refactor(types): replace Unknown with proven types in 390 files (#53715) 2026-11-24 03:33:11 +00:00
otel feat(langfuse_otel): group calls that share a metadata trace_id into one trace (#54408) 2026-11-26 00:58:20 +00:00
pointfive perf(types): defer pydantic schema builds via shared LiteLLMBaseModel (#44720) 2026-10-05 22:10:08 -07:00
prometheus_helpers Type the kwargs reads in the Prometheus logger (#54711) 2026-11-26 14:20:22 +00:00
prompt_cache_alerts fix(logging): stop keeping a full response copy nobody reads (#52524) 2026-11-18 11:51:01 -08:00
SlackAlerting fix(alerting): retire completed requests and prevent hanging alert starvation (#54493) 2026-11-25 13:05:51 -08:00
ternary refactor: clean up fresh tech debt in per-user Copilot auth, Ternary FOCUS export and telemetry (#45769) 2026-10-15 04:29:27 +00:00
vantage refactor(typing): clear 1143 basedpyright Any errors across 273 files (#46574) 2026-10-15 21:08:47 +00:00
vector_store_integrations refactor(types): replace Unknown with proven types in 225 files (#53687) 2026-11-24 00:11:50 +00:00
weave refactor(types): replace Unknown with proven types in 225 files (#53687) 2026-11-24 00:11:50 +00:00
websearch_interception refactor(types): give bare dict, list and tuple returns proven types in 133 files (#54321) 2026-11-25 01:30:02 +00:00
zerobus perf(types): defer pydantic schema builds via shared LiteLLMBaseModel (#44720) 2026-10-05 22:10:08 -07:00
__init__.py
additional_logging_utils.py refactor(types): replace Unknown with proven types in 245 files (#53774) 2026-11-23 10:05:26 -08:00
anthropic_cache_control_hook.py refactor(types): give bare dict, list and tuple returns proven types in 133 files (#54321) 2026-11-25 01:30:02 +00:00
argilla.py refactor(types): type the json, headers and params of the shared HTTP client's request methods and their callers (#54743) 2026-11-26 20:16:27 +00:00
athina.py refactor(types): replace Unknown with proven types in 225 files (#53687) 2026-11-24 00:11:50 +00:00
batch_line_item_objects.py feat(batches): store each batch line's request and response in S3 and GCS (#41691) 2026-10-15 11:32:56 -07:00
batch_utils.py fix(azure_sentinel): split batches under the 1MB ingestion cap (#39880) 2026-09-05 17:15:36 -07:00
braintrust_logging.py refactor(types): type the json, headers and params of the shared HTTP client's request methods and their callers (#54743) 2026-11-26 20:16:27 +00:00
braintrust_mock_client.py refactor(types): type the json, headers and params of the shared HTTP client's request methods and their callers (#54743) 2026-11-26 20:16:27 +00:00
callback_configs.json feat(otel): add option to disable background service spans (#54478) 2026-11-25 12:28:04 -08:00
custom_batch_logger.py feat(tracing): add OTLP trace ingestion and reads (#43915) 2026-09-30 21:12:29 +00:00
custom_guardrail.py fix(guardrails)!: close gaps in bedrock tool call and tool description scans (#54169) 2026-11-25 06:56:15 +00:00
custom_logger.py fix(gemini): return an error instead of an empty 200 when a Gemini image request gets no image (#29125) 2026-11-25 20:55:23 +00:00
custom_prompt_management.py refactor(types): give bare dict, list and tuple returns proven types in 133 files (#54321) 2026-11-25 01:30:02 +00:00
custom_secret_manager.py refactor(types): give bare dict, list and tuple returns proven types in 133 files (#54321) 2026-11-25 01:30:02 +00:00
custom_sso_handler.py feat(lint): enforce Final on locals and freeze function parameters (LIT010, LIT011) 2026-08-04 12:54:39 -07:00
customer_budget_webhook.py fix(proxy): alert on customer org, customer team, and customer member budgets (#51579) 2026-11-13 09:16:33 -08:00
dynamodb.py refactor(types): replace Unknown with proven types in 390 files (#53715) 2026-11-24 03:33:11 +00:00
email_alerting.py refactor(typing): clear about 1,100 basedpyright Any errors across 303 files (#49986) 2026-11-06 13:31:15 -08:00
galileo.py refactor(types): replace Unknown with proven types in 390 files (#53715) 2026-11-24 03:33:11 +00:00
greenscale.py refactor(types): replace Unknown with proven types in 162 more files (#54089) 2026-11-23 22:58:19 -08:00
helicone.py refactor(types): type the json, headers and params of the shared HTTP client's request methods and their callers (#54743) 2026-11-26 20:16:27 +00:00
helicone_mock_client.py feat(lint): enforce Final on locals and freeze function parameters (LIT010, LIT011) 2026-08-04 12:54:39 -07:00
humanloop.py refactor(types): give bare dict, list and tuple returns proven types in 133 files (#54321) 2026-11-25 01:30:02 +00:00
lago.py refactor(types): replace Unknown with proven types in 225 files (#53687) 2026-11-24 00:11:50 +00:00
langsmith.py refactor(types): type the kwargs reads in the Braintrust, Datadog, Langsmith, Literal AI and generic API loggers (#54686) 2026-11-26 11:01:13 +00:00
langsmith_mock_client.py feat(lint): enforce Final on locals and freeze function parameters (LIT010, LIT011) 2026-08-04 12:54:39 -07:00
langtrace.py refactor(types): replace Unknown with proven types in 131 more files (#54045) 2026-11-24 04:55:42 +00:00
literal_ai.py refactor(types): type the kwargs reads in the Braintrust, Datadog, Langsmith, Literal AI and generic API loggers (#54686) 2026-11-26 11:01:13 +00:00
logfire_logger.py refactor(types): type the parameters of Logging.update_from_kwargs and the Logfire logger's kwargs (#54693) 2026-11-26 12:40:24 +00:00
lunary.py refactor(types): replace Unknown with proven types in 131 more files (#54045) 2026-11-24 04:55:42 +00:00
mlflow.py refactor(types): replace Unknown with proven types in 86 files (#53803) 2026-11-24 12:45:20 +00:00
mock_client_factory.py refactor(types): replace Unknown with proven types in 225 files (#53687) 2026-11-24 00:11:50 +00:00
model_deprecation_email.py feat(alerts): add management controls and opt-in daily summaries (#51418) 2026-11-12 10:06:07 -08:00
openmeter.py refactor(types): replace Unknown with proven types in 82 more files (#53918) 2026-11-23 17:36:22 -08:00
opentelemetry.py feat(langfuse_otel): group calls that share a metadata trace_id into one trace (#54408) 2026-11-26 00:58:20 +00:00
performance_alert_notifications.py feat(alerts): add management controls and opt-in daily summaries (#51418) 2026-11-12 10:06:07 -08:00
posthog.py refactor(types): replace Unknown with proven types in 225 files (#53687) 2026-11-24 00:11:50 +00:00
posthog_mock_client.py feat(lint): enforce Final on locals and freeze function parameters (LIT010, LIT011) 2026-08-04 12:54:39 -07:00
prefix_block_hashes.py feat(proxy): opt-in prefix block hashes in spend logs for workload replay (#52120) 2026-11-16 22:52:42 -08:00
prometheus.py Type the kwargs reads in the Prometheus logger (#54711) 2026-11-26 14:20:22 +00:00
prometheus_metrics_endpoint.py perf(prometheus): render /metrics off the event loop and coalesce concurrent scrapes (#37702) 2026-08-20 16:08:22 -07:00
prometheus_services.py refactor(types): replace Unknown with proven types in 390 files (#53715) 2026-11-24 03:33:11 +00:00
prompt_layer.py refactor(types): type the json, headers and params of the shared HTTP client's request methods and their callers (#54743) 2026-11-26 20:16:27 +00:00
prompt_management_base.py refactor(types): give bare dict, list and tuple returns proven types in 133 files (#54321) 2026-11-25 01:30:02 +00:00
Readme.md (Feat) - Add GCS Pub/Sub Logging integration for sending DB SpendLogs to BigQuery (#7976) 2025-01-24 20:57:20 -08:00
rubrik.py refactor(types): type bare dict data and request_data parameters across method families (#54192) 2026-11-24 08:39:27 -08:00
s3.py refactor(types): replace Unknown with proven types in 131 more files (#54045) 2026-11-24 04:55:42 +00:00
s3_v2.py refactor(s3-log): move the rust-backed s3 logger from s3_v3 to s3_v2 (#51893) 2026-11-14 22:24:23 -08:00
shadow_eval_logger.py refactor(types): replace Unknown with proven types in 245 files (#53774) 2026-11-23 10:05:26 -08:00
sqs.py refactor(types): replace Unknown with proven types in 131 more files (#54119) 2026-11-24 02:26:51 -08:00
supabase.py refactor(types): replace Unknown with proven types in 131 more files (#54119) 2026-11-24 02:26:51 -08:00
test_httpx.py fix(utils.py): improved predibase exception mapping 2024-06-08 14:32:43 -07:00
traceloop.py refactor(types): replace Unknown with proven types in 131 more files (#54045) 2026-11-24 04:55:42 +00:00
weights_biases.py refactor(types): replace Unknown with proven types in 390 files (#53715) 2026-11-24 03:33:11 +00:00

Integrations

This folder contains logging integrations for litellm

eg. logging to Datadog, Langfuse, Prometheus, s3, GCS Bucket, etc.