Commit graph

33689 commits

Author SHA1 Message Date
Yuneng Jiang
af9aa2ccf2
chore: fixes 2026-04-04 23:47:27 -07:00
Julio Quinteros Pro
1d9353937b
Update litellm/proxy/proxy_server.py
Co-authored-by: greptile-apps[bot] <165735046+greptile-apps[bot]@users.noreply.github.com>
2026-02-28 14:07:02 -03:00
Julio Quinteros Pro
df7415f498 Revert "fix(proxy): isolate get_config failures from model loading in sync loop"
This reverts commit 5f2b973672.
2026-02-26 17:48:32 -03:00
Julio Quinteros Pro
5f2b973672 fix(proxy): isolate get_config failures from model loading in sync loop
A database timeout (httpcore.ReadTimeout) during get_config() in
_update_llm_router would propagate and prevent ALL DB models from
loading into the router. This was the root cause of a customer issue
where 51 DB models were invisible despite valid data and correct
encryption keys.

Now get_config() failures are caught separately so model
add/delete operations still proceed. Similarly, _delete_deployment
catches get_config failures and safely skips cleanup rather than
crashing the entire sync cycle.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-02-26 17:47:41 -03:00
Julio Quinteros Pro
bb176f4a10 fix(proxy): use filtered router count for search pagination of DB-only models
Greptile review caught a pagination bug: _get_db_only_models used
len(all_models) (full unfiltered router list) for the take calculation.
When searching with a large router (e.g. 50 models, page size 50), the
take would be 0 even though only 1 router model matched the search,
causing DB-only models to never be fetched.

Fix: accept filtered_router_count parameter and use it for pagination.
Added regression test with 50 router models where only 1 matches search.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-02-26 16:52:08 -03:00
Julio Quinteros Pro
2159261da4 fix(logging): upgrade silent deployment failures from DEBUG to WARNING
Three places where deployment loading failures were invisible:

1. router.py:upsert_deployment - caught exceptions at DEBUG level, now
   WARNING with model_name and model_id included
2. router.py:set_model_list (init path) - used .exception() without
   model identifiers, now WARNING with model_name, model_id, and exc_info
3. proxy_server.py:_add_deployment - had no per-model try/except, so a
   single bad model could crash the entire sync loop. Now each model is
   wrapped individually, failures logged at WARNING with identifiers,
   and a summary count logged at the end

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-02-26 16:49:18 -03:00
Julio Quinteros Pro
a5ae04d831 fix(proxy): show DB models in model list even when router sync fails
When models are added via the UI, they are saved to the database and then
synced into the router. If the sync fails silently (e.g. due to decryption
errors, invalid params with ignore_invalid_deployments=True), the models
become invisible in the /v2/model/info response because the endpoint only
reads from llm_router.model_list.

The search path already queried the DB as a fallback, but the non-search
path did not. This fix extracts the DB-query logic into _get_db_only_models()
and calls it in all cases, ensuring DB models that failed to load into the
router still appear in the model management UI.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-02-26 16:33:55 -03:00
yuneng-jiang
50bf2da05e
Merge pull request #22137 from BerriAI/litellm_key_info_crash_fix
[Fix] /key/aliases: Add pagination and search to prevent OOMs
2026-02-26 10:27:10 -08:00
Harshit Jain
4d2fab49a7
Merge pull request #22164 from Harshit28j/litellm_custom_auth_budget_fix
fix: custom auth budget issue
2026-02-26 23:38:38 +05:30
yuneng-jiang
857a324f7a Merge remote-tracking branch 'origin' into litellm_key_info_crash_fix 2026-02-26 10:04:54 -08:00
michelligabriele
ae13a40c01
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-02-26 09:30:03 -08:00
Sameer Kankute
1790a6bf82
Merge pull request #21604 from michelligabriele/fix/websearch-thinking-blocks
fix(websearch_interception): preserve thinking blocks in agentic loop follow-up messages
2026-02-26 22:26:38 +05:30
Julio Quinteros Pro
4419c7a5f9
Merge pull request #22198 from BerriAI/fix/mcp-server-test-mock-mismatch
fix(tests): update MCP server test mocks to match production API
2026-02-26 13:16:40 -03:00
Julio Quinteros Pro
ace49b18d3 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-02-26 13:11:57 -03:00
Sameer Kankute
6600c86dbd
Merge pull request #22170 from BerriAI/litellm_fix_video_veo_vertex
Fix: Passing of image and parameters in videos api
2026-02-26 18:55:25 +05:30
Sameer Kankute
ec31845469
Merge pull request #22092 from BerriAI/litellm_fix_tts_vertex_ai
Add audio as supported openai param
2026-02-26 18:51:53 +05:30
Sameer Kankute
61d2f28545 Fix based on review 2026-02-26 18:49:25 +05:30
Sameer Kankute
16d6c279da
Merge pull request #22180 from BerriAI/litellm_fix_vllm_test
Add JSON exact match test for vLLM embeddings
2026-02-26 18:43:52 +05:30
Sameer Kankute
dc1e97d345
Merge pull request #22144 from BerriAI/litellm_allowed_openai_params_embeddings
fix(embeddings): allow dimensions param passthrough via allowed_openai_params for non-text-embedding-3 OpenAI models
2026-02-26 18:41:47 +05:30
Sameer Kankute
2772c88864
Merge pull request #22142 from BerriAI/litellm_fix_mcp_server_ip
Return Clear error message why no tools are available / IP Filtering occured
2026-02-26 18:41:22 +05:30
Sameer Kankute
e1df85ebea
Merge pull request #22166 from BerriAI/litellm_oss_staging_02_26_2026
Litellm oss staging 02 26 2026
2026-02-26 18:41:04 +05:30
Sameer Kankute
81455dbd57
Merge pull request #22187 from BerriAI/revert-22099-fix/improve-auth-exception-logging
Revert "fix(proxy): improve auth exception logging levels and add structured context"
2026-02-26 18:39:04 +05:30
Sameer Kankute
95b8fb823b
Revert "fix(proxy): improve auth exception logging levels and add structured …"
This reverts commit efeaf650aa.
2026-02-26 18:38:52 +05:30
Sameer Kankute
87b4fed967
Merge pull request #22186 from BerriAI/main
merge main
2026-02-26 18:21:38 +05:30
Sameer Kankute
27f9903765
Merge pull request #22184 from BerriAI/litellm_bump_litellm_26_02
Bump litellm version to 1.81.16
2026-02-26 18:19:10 +05:30
Sameer Kankute
678200ee48 Bump litellm version to 1.81.16 2026-02-26 18:18:03 +05:30
Sameer Kankute
d9cd3ea185
Merge pull request #22181 from mubashir1osmani/fix/arize-phoenix-nested-traces-test-update
fix(test): update Phoenix OTEL test
2026-02-26 17:12:17 +05:30
mubashir1osmani
3c595f6fd2 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-02-26 06:40:24 -05:00
Sameer Kankute
1a3d4c80db Add JSON exact match test for vLLM embeddings 2026-02-26 16:49:34 +05:30
Sameer Kankute
ecbefc0735
Merge pull request #22169 from mubashir1osmani/fix/arize-phoenix-nested-traces
fix: arize phoenix nested traces
2026-02-26 16:24:20 +05:30
mubashir1osmani
96bcee0b0a 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-02-26 04:59:17 -05:00
Harshit28j
39af85da53 fix: req changes 2026-02-26 15:19:32 +05:30
Sameer Kankute
aeb723816f Fix: Passing of image and parameters in videos api 2026-02-26 14:49:46 +05:30
Roni Frantchi
475bb94f5a
fix(adapter): populate cache_read_input_tokens from prompt_tokens_details for OpenAI/Azure (#22090)
* fix(adapter): populate cache_read_input_tokens from prompt_tokens_details

The Anthropic adapter's translate_openai_response_to_anthropic checked
only the private _cache_read_input_tokens attr (set by Anthropic/DeepSeek)
but not prompt_tokens_details.cached_tokens (set by OpenAI/Azure).

Use prompt_tokens_details.cached_tokens directly — it is already extracted
and is the standard field populated by all providers.

Fixes #22089

* fix(adapter): apply same cache_read_input_tokens fix to streaming path

The streaming path in translate_streaming_openai_response_to_anthropic
had the same bug — relying on _cache_read_input_tokens instead of
prompt_tokens_details.cached_tokens.
2026-02-26 00:10:18 -08:00
Jins K Joy
296a138195
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-02-26 00:09:14 -08:00
Benedikt Óskarsson
efeaf650aa
fix(proxy): improve auth exception logging levels and add structured context (#22099)
* fix(proxy): improve auth exception logging levels and add structured context

Downgrade expected auth failures (ProxyException, HTTPException < 500,
BudgetExceededError) from ERROR to WARNING log level to reduce noise from
routine rejected requests (e.g. missing/invalid API keys on polled endpoints
like /schedule/model_cost_map_reload/status).

Unexpected exceptions and HTTPException with status >= 500 still log at
ERROR with full traceback.

Enrich log messages with structured context: route, HTTP method, masked
API key (using existing abbreviate_api_key), error type, and error code.
All fields also passed via log extra dict for log aggregation tools.

Fixes #21293

* Update tests/test_litellm/proxy/auth/test_auth_exception_handler.py

Co-authored-by: greptile-apps[bot] <165735046+greptile-apps[bot]@users.noreply.github.com>

---------

Co-authored-by: greptile-apps[bot] <165735046+greptile-apps[bot]@users.noreply.github.com>
2026-02-26 00:08:35 -08:00
Gaurav Singh
f3e31bc8ef
fix(proxy): honor MAX_STRING_LENGTH_PROMPT_IN_DB from config env vars (#22106)
* fix(proxy): honor MAX_STRING_LENGTH_PROMPT_IN_DB from config env vars

* fix(proxy): reuse constants fallback for MAX_STRING_LENGTH_PROMPT_IN_DB runtime resolver

* test(proxy): restore PEP8 spacing between spend tracking tests
2026-02-26 00:06:18 -08:00
Sameer Kankute
4d68151d03
Merge pull request #22151 from BerriAI/litellm_fix_cicd_26_02
[Fix] CICD 26/02/26
2026-02-26 13:30:23 +05:30
Sameer Kankute
e8cfe39418 Fix code qa for agent_id 2026-02-26 13:21:57 +05:30
Ishaan Jaff
965ca117bc
feat(realtime guardrails): end_session_after_n_fails + Endpoint Settings wizard step (#22165)
* feat(realtime guardrails): end_session_after_n_fails + Endpoint Settings wizard step

Adds per-session violation thresholds and an optional endpoint-settings step
to the guardrail wizard for /v1/realtime.

Backend:
- Add end_session_after_n_fails, on_violation, realtime_violation_message fields
  to BaseLitellmParams (no DB migration — stored in existing JSON column)
- Store same fields on CustomGuardrail instance attrs
- Pass through in litellm_content_filter initializer
- Track _violation_count per RealTimeStreaming session; close backend_ws when
  on_violation=end_session OR violation count >= end_session_after_n_fails
- Use realtime_violation_message as the spoken text (falls back to guardrail
  error string if not configured)

UI (add_guardrail_form.tsx):
- Rename "Default Categories" step to "Topics"
- Add step 5 "Endpoint Settings (Optional)" for content filter guardrails
- Call type dropdown shows /v1/realtime
- Settings are in a collapsed accordion (closed by default)
- "End session after X violations" + on_violation radio + spoken message field

Tests: 2 new tests in test_realtime_streaming.py
- test_end_session_after_n_fails_closes_connection
- test_on_violation_end_session_closes_on_first_fail

* fix(test): move inline imports to module level in realtime streaming tests

* Update ui/litellm-dashboard/src/components/guardrails/add_guardrail_form.tsx

Co-authored-by: greptile-apps[bot] <165735046+greptile-apps[bot]@users.noreply.github.com>

---------

Co-authored-by: greptile-apps[bot] <165735046+greptile-apps[bot]@users.noreply.github.com>
2026-02-25 23:49:03 -08:00
Sameer Kankute
24fd841e83 Fix code qa 2026-02-26 13:16:09 +05:30
Ishaan Jaff
819581f6bf
fix(realtime): guardrails with pre_call/post_call mode now work on realtime WebSocket (#22161)
* fix(realtime): guardrails with pre_call/post_call mode now work on realtime WebSocket; return error directly to consumer

* fix(realtime guardrails): address code review feedback

- Restore session.update injection for audio/VAD path, but only when
  realtime_input_transcription guardrails are configured (not pre_call).
  Forward session.created to the client first so no error arrives before
  the client sees the session.
- Change _swallow_next_response_create bool to int counter so consecutive
  blocked items are handled correctly.
- Extract _build_litellm_metadata() helper to eliminate duplicated
  metadata-building logic across OpenAI/Azure/XAI provider branches.
- Plumb litellm_metadata and user_api_key_dict to Azure and XAI handlers
  so guardrails work for those providers too.
- Add tests for session.update injection, no-inject for pre_call-only,
  and consecutive-block counter.

* simplify: remove response.create swallowing after guardrail block

When an item is blocked, the error event is already sent to the client.
The subsequent response.create from the client is fine to forward through —
the LLM may respond to previous context which is acceptable behavior.
Removing the swallow counter eliminates unnecessary state tracking.
2026-02-25 23:43:13 -08:00
Sameer Kankute
8f8ebbec8d Fix test_vertex_passthrough_forwards_anthropic_beta_header 2026-02-26 13:06:25 +05:30
Harshit28j
14badde13c fix: custom auth budget issue 2026-02-26 13:03:01 +05:30
Sameer Kankute
8bbbd1e465 Fix gaurdrail code qa 2026-02-26 13:00:59 +05:30
Sameer Kankute
143e8dfe27 Fix pass through tests 2026-02-26 12:55:59 +05:30
Ishaan Jaff
3545584a00
Development environment setup (#22160)
* feat: add pretty view for realtime API logs in dashboard

- Create RealtimePrettyView component that renders structured session
  config, conversation turns with transcripts, and token breakdowns
- Update PrettyMessagesView to detect realtime responses (via
  isRealtimeResponse helper) and delegate to the new component
- Session card shows model, voice, modalities, temperature, instructions
  in a collapsible panel
- Conversation turns show status, per-turn token usage, and audio/text
  transcripts with appropriate icons
- Add 24 tests for RealtimePrettyView and 3 tests for PrettyMessagesView
- All 75 LogDetailsDrawer tests pass

Co-authored-by: Ishaan Jaff <ishaan-jaff@users.noreply.github.com>

* chore: remove dev_config.yaml from tracked files

Co-authored-by: Ishaan Jaff <ishaan-jaff@users.noreply.github.com>

* feat: show turn count in realtime pretty view session header and output header

- Add purple 'N turns' tag to Session card header for at-a-glance turn count
- Add 'Turns: N' to the Output section header next to tokens/cost
- Extend SectionHeader to accept optional turnCount prop
- Add 3 new tests for turn count display (singular, plural, output header)

Co-authored-by: Ishaan Jaff <ishaan-jaff@users.noreply.github.com>

* fix: address Greptile review feedback

- Remove response.audio.done and conversation.item.created from
  isRealtimeResponse() detection since the view doesn't render them;
  prevents misleading fallback for responses with only those events
- Remove dead code: index >= 0 is always true in .map() callback

Co-authored-by: Ishaan Jaff <ishaan-jaff@users.noreply.github.com>

---------

Co-authored-by: Cursor Agent <cursoragent@cursor.com>
Co-authored-by: Ishaan Jaff <ishaan-jaff@users.noreply.github.com>
2026-02-25 23:20:03 -08:00
Sameer Kankute
82025bff6e Fix code qa 2026-02-26 12:47:52 +05:30
Sameer Kankute
0debe92605 Fix_mapped tests part 2 2026-02-26 12:43:39 +05:30
Sameer Kankute
9c7f8138e1 FIx : litellm/tests/test_litellm/proxy/management_endpoints/test_key_management_endpoints.py 2026-02-26 12:43:06 +05:30