Commit graph

33633 commits

Author SHA1 Message Date
Ryan Crabbe
7f77cd4e00 clean up docstring 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
Julio Quinteros Pro
087d80980e fix(mypy): add union-attr suppression to all backend_ws method calls
Address Greptile review: apply type: ignore[union-attr] consistently
on all backend_ws.send(), .recv(), and .close() calls, not just the
three that CI flagged.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-03 18:15:51 +05:30
Julio Quinteros Pro
e65bcf3ee0 fix(mypy): suppress attr-defined errors on websocket send/close calls
CI MyPy resolves CLIENT_CONNECTION_CLASS as Optional[ClientConnection]
and flags .send() and .close() as attr-defined errors. These methods
exist at runtime on the websocket connection object. Add type: ignore
comments to unblock the linting CI.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
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
d6d81854f2 Fix based on review 2026-03-03 18:15:50 +05:30
Sameer Kankute
10de52a807 Fix: Passing of image and parameters in videos api 2026-03-03 18:15:50 +05:30
Sameer Kankute
f38295fd02 Add audio as supported openai param 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
2225247447 Remove logger 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
Sameer Kankute
2c28725a66 Bump litellm version to 1.81.16 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
Jins K Joy
bb962a609b Adjust input and output cost per token for mistral-small-2503 (#22097)
* Adjust input and output cost per token for mistral-small-2503

Cost per million for mistral-small-2503 is not correct.

In Azure Documentation:
Pay-as-you-go (per 1,000 tokens)
$0.0001
Model input
$0.0003
Model output

* Update input and output cost per token for model
2026-03-03 18:15:50 +05:30
Sameer Kankute
8bb4b00daa Fix code qa for agent_id 2026-03-03 18:15:50 +05:30
Sameer Kankute
a1be8177ed Fix code qa 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
84b908413f Fix gaurdrail code qa 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
34460655d7 Fix code qa 2026-03-03 18:15:50 +05:30
Sameer Kankute
2fec2907b7 Fix_mapped tests part 2 2026-03-03 18:15:50 +05:30
Sameer Kankute
393b5715b2 FIx : litellm/tests/test_litellm/proxy/management_endpoints/test_key_management_endpoints.py 2026-03-03 18:15:50 +05:30
Sameer Kankute
113af3f334 Fix code qa 2026-03-03 18:15:50 +05:30
Sameer Kankute
b09bfbfd85 Fix : enterprise tests 2026-03-03 18:15:50 +05:30
Sameer Kankute
24424abec8 Fix test_standard_logging_payload_includes_guardrail_information 2026-03-03 18:15:50 +05:30
Sameer Kankute
57d0ea2ae9 Fix: test_gaurdrails* 2026-03-03 18:15:50 +05:30
Sameer Kankute
f435a0fbd7 Fix: litellm/tests/test_litellm/proxy/common_utils/test_http_parsing_utils.py 2026-03-03 18:15:50 +05:30
Sameer Kankute
3b7055a6b1 Fix code qa 2026-03-03 18:15:50 +05:30
Sameer Kankute
06a65e9c44 FIx test_read_request* 2026-03-03 18:15:50 +05:30
Sameer Kankute
fa6f30bdbc Fix test_pass_through_request_logging_failure 2026-03-03 18:15:50 +05:30
Sameer Kankute
ade9603a63 Fix: test_sentence[te_6] 2026-03-03 18:15:49 +05:30
Sameer Kankute
d6e95a613e Fix test_async_gcs_pub_sub_v1 2026-03-03 18:15:42 +05:30
Sameer Kankute
722d041b17 Fix UI build 2026-03-03 18:15:41 +05:30
Sameer Kankute
8dd1888497 Fix code qa for _types.py 2026-03-03 18:15:37 +05:30
Sameer Kankute
04dcb20f03 Fix test_perform_health_check_filters_by_model_id 2026-03-03 18:15:37 +05:30
Sameer Kankute
5ed564aeca Fix mypy issues 2026-03-03 18:15:35 +05:30