Commit graph

6887 commits

Author SHA1 Message Date
Sameer Kankute
5485772a5a Fix encrypted content streaming affinity issue 2026-03-03 18:16:00 +05:30
Sameer Kankute
c500ca0090 Add Regression tests for image_url blocks in assistant message content. 2026-03-03 18:16:00 +05:30
Sameer Kankute
47e39add39 Add tests for messages to responses transformation: 2026-03-03 18:16:00 +05:30
Sameer Kankute
3e6b253cd6 Add v1 for anthropic responses transformation 2026-03-03 18:16:00 +05:30
Sameer Kankute
9aee0ee462 Preserve forwarding server side called tools 2026-03-03 18:16:00 +05:30
Sameer Kankute
7d338ae89b Fix converse handling for parallel_tool_calls 2026-03-03 18:15:58 +05:30
Harshit Jain
e3fc3a4cec perf(spendlogs): optimize old spendlog deletion cron job 2026-03-03 18:15:52 +05:30
Emerson Gomes
17cff584bc fix(cost): use token usage for gemini/vertex image generation when available
- compute image_generation cost from usage token metadata for vertex/gemini\n- map ImageUsage to Usage and reuse generic_cost_per_token\n- fallback to output_cost_per_image when usage metadata missing\n- add tests for token-based path and fallback path
2026-03-03 18:15:52 +05:30
Emerson Gomes
5eece691db feat(vertex): add gemini-3.1-flash-image-preview model DB support
- add gemini-3.1-flash-image-preview + vertex_ai alias entries\n- set pricing to Gemini 3.1 Flash Image Preview rates\n- mirror updates in packaged backup model map\n- update llm cost calc regression test to cover new model
2026-03-03 18:15:52 +05:30
Harshit28j
b73d3a35ca fix: req changes 2026-03-03 18:15:52 +05:30
Harshit28j
3db85ca017 feat: add tags in project 2026-03-03 18:15:52 +05:30
Sameer Kankute
ec90e1b8c3 Revert "Fix mapping of parallel_tool_calls for bedrock converse" 2026-03-03 18:15:52 +05:30
yuneng-jiang
2851ed3ff8 [Feature] Add /public/endpoints endpoint for provider endpoint support
Add new /public/endpoints endpoint that returns which providers support each LiteLLM
endpoint (e.g., chat_completions, embeddings). The endpoint reads from a local backup
JSON file bundled with the package, caches the result in-process, and transforms the
raw provider-centric data into an endpoint-centric response format.

Changes:
- Add litellm/provider_endpoints_support_backup.json (copy of root source file)
- Add Pydantic response models (EndpointProvider, SupportedEndpoint, SupportedEndpointsResponse)
- Add /public/endpoints route with transformation and caching logic
- Add 16 comprehensive tests covering HTTP layer and transformation functions

Co-Authored-By: Claude Haiku 4.5 <noreply@anthropic.com>
2026-03-03 18:15:52 +05:30
Dharamendra Kumar
ca417ff2f9 Restore 2026-03-03 18:15:52 +05:30
Dharamendra Kumar
d3946caa37 Update test to righ place 2026-03-03 18:15:52 +05:30
Dharamendra Kumar
9d1f3ae2eb [Fix] Enhance MidStreamFallbackError to preserve original status code and attributes
- Updated MidStreamFallbackError to retrieve and maintain the original status code from the wrapped exception.
- Ensured that message, request, and response fields remain consistent after calling the parent constructor.
- Added unit tests to verify the correct propagation of status codes and attributes in various scenarios.
2026-03-03 18:15:52 +05:30
Ryan Crabbe
faf79c5c72 fix: remove cache eviction close that kills in-use httpx clients 2026-03-03 18:15:52 +05:30
yuneng-jiang
3cb1a3c449 Revert "[Feature] Add /public/supported_endpoints endpoint" 2026-03-03 18:15:52 +05:30
yuneng-jiang
99b5406546 fix +Inf user budget metric when metadata max_budget is None
Same bug as team budget: _assemble_user_object fetched user info from DB
but only used budget_reset_at, discarding max_budget. When the key cache
has a stale None for user_max_budget, _safe_get_remaining_budget returns
+Inf. Now falls back to DB max_budget when metadata value is None.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-03-03 18:15:52 +05:30
yuneng-jiang
b765ae2ae2 remove orphan comment from test file
Co-Authored-By: Claude Haiku 4.5 <noreply@anthropic.com>
2026-03-03 18:15:52 +05:30
yuneng-jiang
745064d458 fixing inf budget 2026-03-03 18:15:52 +05:30
Ishaan Jaff
e40a2a2bd6 fix(realtime): fix guardrails not firing for Gemini/Vertex AI and provider_config realtime WebSocket sessions (#22168)
* fix(gemini): enable inputAudioTranscription and handle transcription events for realtime guardrails

Gemini sends inputTranscription/outputTranscription inside serverContent separately from modelTurn/turnComplete. This adds handling to convert them into OpenAI-compatible events so the guardrail pipeline can inspect voice input, and enables inputAudioTranscription in the session setup config.

Made-with: Cursor

* fix(vertex_ai): enable inputAudioTranscription in realtime session config

Add inputAudioTranscription to the Vertex AI realtime setup so the backend returns transcripts of user speech, allowing guardrails to inspect voice input.

Made-with: Cursor

* fix(realtime): pass user_api_key_dict and guardrail metadata through async_realtime handler

The base LLM HTTP handler's async_realtime method was not accepting or forwarding user_api_key_dict and litellm_metadata to RealTimeStreaming. This meant guardrails configured with default_on=false were silently skipped for all provider_config-based realtime connections (Gemini, Vertex AI, etc). Also fixes wss:// connections when SSL_VERIFY=False by overriding ssl=False for secure WebSocket URLs.

Made-with: Cursor

* fix(realtime): forward guardrail metadata for generic provider_config and vertex_ai paths

The _arealtime function was not passing user_api_key_dict or litellm_metadata to base_llm_http_handler.async_realtime() for the generic provider_config path and the vertex_ai-specific path. This broke guardrail resolution since RealTimeStreaming.request_data was empty, causing should_run_guardrail to return False.

Made-with: Cursor

* fix(realtime): voice guardrail responses and block duplicate response.create on text input

When a guardrail blocks voice input, send a conversation.item.create + response.create to the backend so the LLM voices the guardrail message as audio instead of only returning text. Also adds pending_guardrail_message tracking to suppress the automatic response.create the client sends after a blocked text message, and broadens _has_audio_transcription_guardrails to match pre_call/post_call modes.

Made-with: Cursor

* test(realtime): update guardrail tests for broadened audio transcription check and add integration tests

Update existing tests to reflect that pre_call guardrails now correctly trigger the audio/VAD session.update injection. Add integration test file for live OpenAI realtime guardrail testing.

Made-with: Cursor

* fix(realtime): instruct LLM to say exact guardrail message verbatim

The previous prompt gave the LLM creative freedom to paraphrase the guardrail violation message. Now it instructs the LLM to repeat the exact configured message word for word.

Made-with: Cursor

* fix(realtime): preserve wss ssl semantics and move live guardrail test

Keep TLS enabled for wss realtime sessions while honoring SSL_VERIFY=False via a no-verify SSLContext, move the OpenAI live guardrail test into llm_translation, and dedupe duplicated guardrail-detection helpers to prevent drift.

Made-with: Cursor
2026-03-03 18:15:52 +05:30
Ishaan Jaff
cbeaebf826 _add_dd_apm_tags_for_litellm_call_id (#22219) 2026-03-03 18:15:52 +05:30
yuneng-jiang
76da970446 Move provider_endpoints_support.json into litellm package
The file was at the repo root and excluded from pip distributions. Moving it to litellm/proxy/public_endpoints/ alongside the other provider JSON files ensures it is packaged correctly. Updates all references in the endpoint handler, coverage tests, and release notes instructions.

Co-Authored-By: Claude Haiku 4.5 <noreply@anthropic.com>
2026-03-03 18:15:52 +05:30
yuneng-jiang
77dc425e9e [Feature] Add /public/supported_endpoints endpoint
Return all supported endpoints and which providers support them. Includes endpoint display names, URL paths, and per-provider support lists. Results are cached for the process lifetime.

Also adds comprehensive test coverage for the new endpoint.

Co-Authored-By: Claude Haiku 4.5 <noreply@anthropic.com>
2026-03-03 18:15:52 +05:30
Ryan Crabbe
b83d922279 refactor: remove shutdown cleanup, rely solely on startup wipe
Phase 2 (per-worker mark_process_dead on shutdown) only ever fired
when all workers shut down together, making it redundant — Phase 1
wipes everything on next startup anyway. This aligns with the
prometheus_client docs: just wipe the directory between runs.
2026-03-03 18:15:51 +05:30
Ryan Crabbe
02d5b7bde5 refactor: remove periodic dead PID cleanup, trim redundant tests
Startup wipe + graceful shutdown cleanup are sufficient. Remove
hourly mark_dead_pids scan, its helpers, and redundant test cases.
2026-03-03 18:15:51 +05:30
Ryan Crabbe
66e6b8c3dc parameterize test 2026-03-03 18:15:51 +05:30
Ryan Crabbe
8c1e9bc877 test: redundant tests 2026-03-03 18:15:51 +05:30
Ryan Crabbe
7edaab6792 feat: add prometheus multiprocess directory cleanup
Adds cleanup utilities for PROMETHEUS_MULTIPROC_DIR to prevent
unbounded RAM/disk growth from stale .db files in multi-worker setups.

Three-part lifecycle aligned with upstream prometheus_client docs:
1. Startup: wipe entire directory before workers fork (clean slate)
2. Shutdown: mark_process_dead() for own PID (removes gauge_live* only)
3. Periodic (hourly): scan for dead PIDs and call mark_process_dead()

Counter/histogram files are never individually deleted at runtime to
avoid partial counter resets that cause false spikes in rate()/increase().

Also auto-creates PROMETHEUS_MULTIPROC_DIR when prometheus callback is
configured with multiple workers and the env var is not already set.
2026-03-03 18:15:51 +05:30
Ishaan Jaff
bc5482a66f [Feat] Add control for setting upperbound on chunk processing time (#22209)
* add LITELLM_MAX_STREAMING_DURATION_SECONDS

* add add LITELLM_MAX_STREAMING_DURATION_SECONDS

* fix: address Greptile review - rename constant, add sync check, add tests

- Rename MAX_STREAMING_CHUNK_DURATION_S → MAX_STREAMING_DURATION_S (misleading "CHUNK")
- Add _check_max_streaming_duration to SyncResponsesAPIStreamingIterator.__next__
- Add 8 unit tests covering both CustomStreamWrapper and ResponsesAPI paths
- Fix pre-existing pyright errors in streaming_handler.py

Made-with: Cursor

* add add LITELLM_MAX_STREAMING_DURATION_SECONDS
2026-03-03 18:15:51 +05:30
yuneng-jiang
7612d6b0c1 use raw SQL in key_aliases to avoid loading full rows into memory
Replace Prisma ORM count/find_many calls with two query_raw calls that
only project the key_alias column. The Prisma client wrapper does not
support SELECT projection via find_many, so raw SQL is used to keep
memory usage proportional to the page size rather than total key count.
Update tests to mock query_raw instead of count/find_many.

Co-Authored-By: Claude Haiku 4.5 <noreply@anthropic.com>
2026-03-03 18:15:51 +05:30
yuneng-jiang
83982d1b75 remove unsupported select param from find_many call
LiteLLM_VerificationTokenActions.find_many() does not support the
select keyword argument. Remove it and drop the corresponding test.

Co-Authored-By: Claude Haiku 4.5 <noreply@anthropic.com>
2026-03-03 18:15:51 +05:30
yuneng-jiang
a1eadb4406 optimize key_aliases to select only key_alias column and add unit tests
Add select={"key_alias": True} to the find_many call so only the alias
column is fetched from the database instead of full token rows. Add
five unit tests in test_key_management_endpoints.py covering response
shape, pagination skip/take computation, search filter injection,
absence of contains filter when no search term is given, and the
select-only-alias optimization.

Co-Authored-By: Claude Haiku 4.5 <noreply@anthropic.com>
2026-03-03 18:15:51 +05:30
yuneng-jiang
8696c33d7b [Fix] /key/aliases: Add pagination and search to prevent OOMs
The /key/aliases endpoint previously fetched all key aliases from the database without limit, causing OOM crashes with large key sets. Added page, size, and search query parameters with database-level filtering to enable paginated and searchable key alias retrieval. Updated the response to include pagination metadata (total_count, current_page, total_pages, size) matching the /v2/model/info pattern.

Co-Authored-By: Claude Haiku 4.5 <noreply@anthropic.com>
2026-03-03 18:15:51 +05:30
Harshit28j
d883d01de0 fix: req changes 2026-03-03 18:15:51 +05:30
Harshit28j
38c88d1022 fix: custom auth budget issue 2026-03-03 18:15:51 +05:30
michelligabriele
b46af6de3e test(mcp): add e2e test for stateless StreamableHTTP behavior (#22033)
Adds TestProxyMcpStatelessBehavior to test_proxy_mcp_e2e.py with a test
that verifies two independent MCP clients can connect, initialize, and
call tools without sharing session state. This catches the regression
from PR #19809 where stateless=False broke clients that don't manage
mcp-session-id headers.

Regression test for #20242
2026-03-03 18:15:51 +05:30
michelligabriele
0fcae5b210 fix(websearch_interception): preserve thinking blocks in agentic loop follow-up messages
When extended thinking is enabled, the websearch interception agentic loop
builds a follow-up assistant message with only tool_use blocks. Anthropic's
API requires assistant messages to start with thinking/redacted_thinking
blocks when thinking is enabled, causing a 400 Bad Request.

Extract thinking blocks from the model's initial response, thread them
through the agentic loop, and prepend them to the follow-up assistant
message — matching the pattern used by anthropic_messages_pt in factory.py.

Fixes the error: "Expected 'thinking' or 'redacted_thinking', but found
'tool_use'"
2026-03-03 18:15:51 +05:30
Julio Quinteros Pro
13ee2e2bc4 fix(tests): update MCP server test mocks to match production API
The tests were mocking `filter_server_ids_by_ip` but the production
code in server.py now calls `filter_server_ids_by_ip_with_info` which
returns a (server_ids, blocked_count) tuple. Update all 8 mock sites
to use the correct method name and return signature.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-03 18:15:51 +05:30
Sameer Kankute
10de52a807 Fix: Passing of image and parameters in videos api 2026-03-03 18:15:50 +05:30
Sameer Kankute
63b922de4b Add JSON exact match test for vLLM embeddings 2026-03-03 18:15:50 +05:30
Sameer Kankute
b0def4f18d fix(embeddings): allow dimensions param passthrough via allowed_openai_params for non-text-embedding-3 OpenAI models
When calling non-text-embedding-3 models routed through the openai provider
(e.g. nvidia/llama-3.2-nv-embedqa-1b-v2), passing `dimensions` previously
raised an UnsupportedParamsError unconditionally. This fix threads
`allowed_openai_params` through the embedding call stack so that providers
can opt-in to passing `dimensions` by including it in the list.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-03-03 18:15:50 +05:30
Sameer Kankute
c78013e020 Return Clear error message why no tools are available / IP Filtering occured 2026-03-03 18:15:50 +05:30
Sameer Kankute
833fd870db Revert "fix(proxy): improve auth exception logging levels and add structured …"
This reverts commit efeaf650aa.
2026-03-03 18:15:50 +05:30
mubashir1osmani
cb6708c052 fix(test): update Phoenix OTEL test for dedicated TracerProvider architecture
The old test assumed ArizePhoenixLogger reused the global TracerProvider.
With the nested traces fix, Phoenix now creates its own dedicated provider
and produces litellm_proxy_request + litellm_request + raw_gen_ai_request
spans independently.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
2026-03-03 18:15:50 +05:30
mubashir1osmani
dfdf651099 fix(arize-phoenix): enable nested traces coexistence with otel callback
- ArizePhoenixLogger now creates spans on its own dedicated TracerProvider
  instead of trying to reuse parent spans from the global otel TracerProvider
  (which were invisible in Phoenix since they go to a different exporter)
- Auto-initialize ArizePhoenixLogger when otel callback is configured and
  Phoenix env vars (PHOENIX_API_KEY, PHOENIX_COLLECTOR_*) are detected
- Use exact type check in get_custom_logger_compatible_class to prevent
  ArizePhoenixLogger (subclass) from being returned when looking up otel
- Fix tool_permission guardrail to check non-function tools like
  code_interpreter (previously skipped with `type != "function"`)

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
2026-03-03 18:15:50 +05:30
Sameer Kankute
708b241297 Fix test_vertex_passthrough_forwards_anthropic_beta_header 2026-03-03 18:15:50 +05:30
Sameer Kankute
eb7a6040c1 Fix pass through tests 2026-03-03 18:15:50 +05:30
Sameer Kankute
2fec2907b7 Fix_mapped tests part 2 2026-03-03 18:15:50 +05:30