Commit Graph
21050 Commits
Author SHA1 Message Date
ryan-crabbeandGitHub 4f2fe3378f Merge pull request #23666 from BerriAI/litellm_fix-default-user-perms-not-synced-with-ui
fix: align DefaultInternalUserParams Pydantic default with runtime fallback
2026-03-16 11:58:30 -07:00
Sameer KankuteandGitHub 3dccdde9c8 Merge pull request #23686 from BerriAI/litellm_oss_staging_03_14_2026
Litellm oss staging 03 14 2026
2026-03-16 20:00:17 +05:30
Sameer KankuteandGitHub 71dfd0115c Merge pull request #23737 from BerriAI/litellm_create-character-endpoint-fixes
[Feat] Add create character endpoints and other new videos Endpoints
2026-03-16 19:53:35 +05:30
Sameer Kankute 1a6eb016bf fix(critical): remove @abstractmethod from video character/edit/extension methods
Convert all 8 new video methods from @abstractmethod to concrete implementations
that raise NotImplementedError. This prevents breaking external third-party
BaseVideoConfig subclasses at import time.

Methods affected:
- transform_video_create_character_request/response
- transform_video_get_character_request/response
- transform_video_edit_request/response
- transform_video_extension_request/response

External integrators can now upgrade without instantiation errors; NotImplementedError
is only raised when operations are actually called on unsupported providers.

This restores backward compatibility with the project's policy.

Made-with: Cursor
2026-03-16 19:48:28 +05:30
Sameer Kankute 2ec4ce178c fix(routing): include avideo_create_character and avideo_get_character in router-first routing
Add avideo_create_character and avideo_get_character to the list of video endpoints
that use router-first routing when a model is provided (either from decoded IDs or
target_model_names).

Previously only avideo_edit and avideo_extension were in the router-first block.
This ensures both character endpoints benefit from multi-deployment load balancing
and model resolution, making them consistent with the other video operations.

This allows:
- avideo_create_character: Router picks among multiple deployments when target_model_names is set
- avideo_get_character: Router assists with multi-model environments for consistency

Made-with: Cursor
2026-03-16 19:21:18 +05:30
Sameer Kankute ddf62e0651 fix(critical): add HTTP error checks before parsing response bodies in video handlers
Add response.raise_for_status() before transform_*_response() calls in all eight
video character/edit/extension handler methods (sync and async):

- video_create_character_handler / async_video_create_character_handler
- video_get_character_handler / async_video_get_character_handler
- video_edit_handler / async_video_edit_handler
- video_extension_handler / async_video_extension_handler

Without these checks, httpx does not raise on 4xx/5xx responses, so provider
errors (e.g., 401 Unauthorized) pass directly to Pydantic model constructors,
causing ValidationError instead of meaningful HTTP errors. The raise_for_status()
ensures the exception handler receives proper HTTPStatusError for translation into
actionable messages.

Made-with: Cursor
2026-03-16 19:20:03 +05:30
Sameer Kankute 1ccf67dd93 fix(greptile-review): address backward compatibility and code quality issues
- Remove duplicate DecodedCharacterId TypedDict from litellm/types/videos/main.py
- Remove dead LITELLM_MANAGED_VIDEO_CHARACTER_COMPLETE_STR constant from litellm/types/utils.py
- Add FastAPI Form validation for name field in video_create_character endpoint

Made-with: Cursor
2026-03-16 19:17:06 +05:30
Sameer KankuteandGitHub b796ee9f03 Merge pull request #23530 from Sameerlite/litellm_preserve-final-streaming-attributes
fix(streaming): preserve custom attributes on final stream chunk
2026-03-16 19:12:41 +05:30
Sameer KankuteandGitHub 0bbdd2a249 Merge pull request #23715 from BerriAI/litellm_anthropic_beta_header_order
Refactor: Filtering beta header after transformation
2026-03-16 19:07:08 +05:30
Sameer KankuteandGitHub 10d5475ce8 Merge pull request #23547 from Sameerlite/litellm_blog-webrtc
docs(blog): add WebRTC blog post link
2026-03-16 19:06:32 +05:30
Sameer KankuteandGitHub ab377f396e Merge pull request #23718 from BerriAI/litellm_fix_vertex_ai_batch
Fix: Vertex ai Batch Output File Download Fails with 500
2026-03-16 19:05:49 +05:30
Sameer KankuteandGitHub 9beec825d4 Merge branch 'main' into litellm_create-character-endpoint-fixes 2026-03-16 17:58:16 +05:30
Sameer Kankute 14a691ffd5 Add new videos transformation 2026-03-16 17:56:21 +05:30
Sameer Kankute 8dab5dec88 Add new videos endpoints routing and init 2026-03-16 17:54:35 +05:30
Sameer Kankute c33889200a Add new videos endpoints 2026-03-16 17:54:03 +05:30
Sameer Kankute 79c787b85d Add new videos endpoints 2026-03-16 17:53:54 +05:30
Sameer Kankute 94405b6218 fix(types): use direct FileTypes import in video schemas
Avoid the temporary Any alias and use a concrete FileTypes import compatible with type checks.

Made-with: Cursor
2026-03-16 16:13:11 +05:30
Sameer Kankute 4a7ef7b1d2 fix(video): enforce character endpoint video MIME handling
Use typed character response models and video multipart helpers so /videos/characters forwards uploaded MP4 files with video/* content type.

Made-with: Cursor
2026-03-16 16:12:07 +05:30
Sameer Kankute 61519d6c65 fix(video): decode managed character ids robustly
Support missing base64 padding in managed character/video IDs so copied encoded IDs still decode to the original upstream character ID.

Made-with: Cursor
2026-03-16 16:11:21 +05:30
yuneng-jiangandClaude Opus 4.6 8f56ddb9c6 Merge remote main into litellm_ci_optimize
Resolved conflict in test_claude_agent_sdk.py by keeping main's additions.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-16 00:50:22 -07:00
Sameer Kankute 22b333cae6 Fix downloading vertex ai files 2026-03-16 12:08:06 +05:30
cd37ee1459 fix: make db migration failure exit opt-in via --enforce_prisma_migration_check (#23675)
* fix: improve db migration failure messaging and fix pyright errors in proxy_cli

- Clarify --skip_db_migration_check messaging so users know how to opt
  into warn-and-continue behavior when database setup fails
- Fix pyright reportArgumentType error by casting get_secret result to str
- Fix pyright reportPossiblyUnboundVariable by initializing litellm_settings

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>

* fix: replace --skip_db_migration_check with --enforce_prisma_migration_check

Flip the default behavior: database migration failures now warn and
continue by default. Only when --enforce_prisma_migration_check (or
ENFORCE_PRISMA_MIGRATION_CHECK=true) is explicitly set will the proxy
exit on migration failure.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>

---------

Co-authored-by: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-15 23:21:23 -07:00
Krish DholakiaandGitHub ca4329aeb9 Root cause fix - migrate all logging update to use 1 function - for centralized kwarg updates (#23659)
* fix: Fixes https://github.com/BerriAI/litellm/issues/23185

* fix(responses/main.py): ensure litellm metadata custom cost works

* refactor: move all logging updates to a common function, to have just 1 place to update logging kwarg updates
2026-03-15 23:21:01 -07:00
Sameer Kankute 1a8f8c6d52 Refactor: Filtering beta header after transformation 2026-03-16 10:47:15 +05:30
yuneng-jiangandClaude Opus 4.6 4fc0975d22 Fix flaky e2e batch test: set batch_processed=True on completion in retrieve_batch
The retrieve_batch endpoint sets batch status to "complete" but never set
batch_processed=True, permanently blocking file deletion. CheckBatchCost
(the safety net) also excluded completed batches from its primary query,
so batch_processed was never set by either path.

Three fixes:
1. update_batch_in_database sets batch_processed=True when status reaches
   "complete", with old-schema fallback retry
2. CheckBatchCost primary query no longer excludes complete/completed
   (batch_processed=False filter prevents reprocessing)
3. retrieve_batch early-return now includes "complete" (DB-normalized
   spelling) to avoid unnecessary provider re-polls

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-15 18:18:32 -07:00
yuneng-jiangandClaude Opus 4.6 a75964f040 Fix batch retrieve double-encoding: resolve output_file_id via DB lookup instead of hooks
The previous approach populated _hidden_params to trigger the managed files
hook, but the hook also re-encodes response.id (batch ID), causing double-
encoding when the DB already stores unified IDs. Instead, resolve raw
output_file_id/error_file_id to unified IDs via a direct DB lookup (same
pattern as resolve_input_file_id_to_unified), which avoids the hook entirely.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-15 15:27:40 -07:00
yuneng-jiangandClaude Opus 4.6 31e6393458 Fix flaky proxy_e2e_azure_batches_tests: populate _hidden_params for DB-cached batch retrieval
When a completed batch is served from the DB cache, _hidden_params was empty,
causing the managed files hook to skip output_file_id translation from raw
provider IDs to unified IDs. This fix populates unified_batch_id and model_id
on the early-return path, with a guard against double-encoding when the DB
already stores unified IDs.

Also reduces file deletion retry delay (20s→5s), reruns (5→2), and CI timeout
(30m→15m) to cut worst-case runtime from ~16min to ~4min.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-15 15:13:30 -07:00
brtydse100RheagalFiregreptile-apps[bot] <165735046+greptile-apps[bot]@users.noreply.github.com>
dd1ea3d39e Support multiple headers mapped to the customer user role (#23664)
* added the header mapping feature

* added tests

* final cleanup

* final cleanup

* added missing test and logic

* fixed header sending bug

* Update litellm/proxy/auth/auth_utils.py

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

* added back init file in responses + fixed test_auth_utils.py  int local_testing

---------

Co-authored-by: greptile-apps[bot] <165735046+greptile-apps[bot]@users.noreply.github.com>
2026-03-15 14:20:45 +05:30
bbarwikandRheagalFire 7ed9be55b1 fix: merge annotations from all streaming chunks in stream_chunk_builder
Previously, stream_chunk_builder only took annotations from the first
chunk that contained them, losing any annotations from later chunks.

This is a problem because providers like Gemini/Vertex AI send grounding
metadata (converted to annotations) in the final streaming chunk, while
other providers may spread annotations across multiple chunks.

Changes:
- Collect and merge annotations from ALL annotation-bearing chunks
  instead of only using the first one
2026-03-15 14:20:45 +05:30
yuneng-jiang 82fc819abf Merge remote-tracking branch 'origin' into litellm_internal_dev_03_14_2026 2026-03-14 18:35:03 -07:00
b96f033c90 fix: prisma migrate deploy failures on pre-existing instances (#23655)
* fix: prisma migrate deploy failures on pre-existing instances

Fixes failed migrations due to idempotent schema changes on pre-existing litellm instances.

Problems:
1. P3018 recovery handler never returned True on successful resolution, causing "Database setup failed after multiple retries" even when the final recovery succeeded
2. _roll_back_migration exceptions escaped the P3018 handler, preventing _resolve_specific_migration from running
3. Migration SQL used ADD COLUMN/DROP COLUMN without IF [NOT] EXISTS, failing if schema was already modified

Changes:
- Add return True after successful P3018 idempotent error recovery
- Wrap _roll_back_migration in try/except to allow recovery continuation even if rollback fails
- Make migration.sql idempotent with IF NOT EXISTS / IF EXISTS clauses

Co-Authored-By: Claude Haiku 4.5 <noreply@anthropic.com>

* test: add migration SQL idempotency safety tests

Adds TestMigrationSQLIdempotency test class that statically validates all
migration SQL files created after 2026-03-11 use idempotent DDL:
- ADD COLUMN must use IF NOT EXISTS
- DROP COLUMN must use IF EXISTS
- DROP INDEX must use IF EXISTS
- CREATE INDEX must use IF NOT EXISTS

This prevents the class of errors where prisma migrate deploy fails on
pre-existing instances because the schema was already modified.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>

* fix: also catch TimeoutExpired in P3018 rollback handler

_roll_back_migration uses subprocess.run with timeout=60, so it can raise
subprocess.TimeoutExpired in addition to CalledProcessError. Without
catching this, a slow database during rollback would escape the handler
and bypass _resolve_specific_migration — the same class of bug.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>

* fix: make all 85 migration SQL files idempotent, remove test cutoff

Fixed all existing migration files to use IF [NOT] EXISTS for DDL
statements (ADD COLUMN, DROP COLUMN, DROP INDEX, CREATE INDEX).
Removed the date cutoff from the idempotency tests so they now
validate all migrations, not just recent ones.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>

* fix: make migration failure non-fatal by default, add --require_db_migration flag

By default the proxy now warns and continues when database migration
fails. Pass --require_db_migration (or set REQUIRE_DB_MIGRATION=true)
to restore the previous behavior of exiting with an error.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>

* fix: wrap _resolve_specific_migration in try/except, guard RENAME COLUMN and ADD CONSTRAINT

Three fixes:

1. _resolve_specific_migration in the P3018 handler was not wrapped in
   try/except, so failures there would bypass the return True and
   propagate unexpectedly — partially defeating the rollback fix.

2. Bare RENAME COLUMN in 20260303000000_update_tool_table_policies was
   non-idempotent. Wrapped in DO $$ IF EXISTS block. Also wrapped all
   28 bare ADD CONSTRAINT statements across 9 migration files in
   DO $$ IF NOT EXISTS (pg_constraint) blocks.

3. Added test_rename_column_is_guarded and test_add_constraint_is_guarded
   to TestMigrationSQLIdempotency for full DDL coverage.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>

* fix: retry after resolving idempotent migration, guard DROP CONSTRAINT

Three fixes:

1. Both P3009 and P3018 idempotent handlers returned True after
   resolving a single migration, exiting before remaining pending
   migrations were applied. Now they continue the retry loop so
   prisma migrate deploy runs again for any remaining migrations.

2. Two migration files had bare DROP CONSTRAINT without a DO $$ IF
   EXISTS guard, which fails if the constraint was already dropped.
   Wrapped both in idempotent DO $$ blocks.

3. Added test_drop_constraint_is_guarded to catch unguarded DROP
   CONSTRAINT in future migrations.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>

* fix: P3009 try/except, CREATE TABLE IF NOT EXISTS, restore fail-fast default

Four fixes:

1. P3009 idempotent handler now has the same try/except around
   _roll_back_migration and _resolve_specific_migration as the P3018
   handler. Previously a rollback or resolve failure in the P3009 path
   would propagate and leave the migration unresolved.

2. Added IF NOT EXISTS to all 57 bare CREATE TABLE statements across
   34 migration files. Added test_create_table_uses_if_not_exists to
   catch this pattern.

3. Reverted the backwards-incompatible default behavior change: the
   proxy now fails fast on migration failure (original behavior).
   Added --skip_db_migration_check / SKIP_DB_MIGRATION_CHECK to
   opt into warn-and-continue instead.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>

---------

Co-authored-by: Claude Haiku 4.5 <noreply@anthropic.com>
2026-03-14 16:54:21 -07:00
yuneng-jiang d28e42d7ce chore: update Next.js build artifacts (2026-03-14 23:50 UTC, node v22.16.0) 2026-03-14 16:50:13 -07:00
yuneng-jiangandGitHub cda8fbef50 Merge pull request #23668 from BerriAI/litellm_fix_redaction_filter_logging_v2
fix: redact secrets from proxy log output
2026-03-14 16:47:59 -07:00
yuneng-jiangandClaude Opus 4.6 1d753c3fa6 [Fix] Allow team admins to query /user/filter/ui when scope_user_search_to_org is enabled
When scope_user_search_to_org flag is ON, team admins (non-org-admins) were
getting 403 because the code only checked for ORG_ADMIN role in org memberships.
Now checks all org memberships (any role) and falls back to the API key's team_id
to resolve the org.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-14 16:38:34 -07:00
Ryan Crabbe 47ddd0d0bf fix: redact secrets from proxy log output
Add SecretRedactionFilter to scrub API keys, tokens, and credentials
from all log records (messages, args, tracebacks, extra fields).

- Enable redaction by default; opt out with LITELLM_DISABLE_REDACT_SECRETS=true
- Redact patterns: sk-*, Bearer tokens, x-api-key values, base64 creds
- Handle JSON formatter exception hooks and percent-style format args
- Snapshot dict iteration to avoid RuntimeError during concurrent logging
2026-03-14 15:52:31 -07:00
Ryan Crabbe 6970e1000c fix: align DefaultInternalUserParams Pydantic default with runtime fallback
The Pydantic default for user_role was INTERNAL_USER, but all runtime
provisioning paths (SSO, SCIM, JWT) fall back to INTERNAL_USER_VIEW_ONLY
when no settings are saved. This caused the UI to show "Internal User"
on fresh instances while new users actually got "Internal Viewer".
2026-03-14 15:28:37 -07:00
yuneng-jiangandClaude Opus 4.6 2bd527e62e [Fix] Prevent second responses_api_bridge_check from overwriting first
The second `responses_api_bridge_check` call unconditionally overwrote
`responses_api_model_info` set by the first call. For models using the
`responses/` prefix (e.g. `azure/responses/<deployment>`), the first
check correctly detected `mode: "responses"` and stripped the prefix,
but the second check then overwrote it with an empty dict since the
model no longer started with `responses/`.

Skip the second check when the first already detected responses mode.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-14 15:19:14 -07:00
374c3458d5 feat: add sagemaker_nova provider for Amazon Nova models on SageMaker (#21542)
* feat: add sagemaker_nova provider for Nova models on SageMaker

Add support for custom/fine-tuned Amazon Nova models (Nova Micro, Nova Lite,
Nova 2 Lite) deployed on SageMaker Inference real-time endpoints.

Nova uses OpenAI-compatible request/response format with additional
Nova-specific parameters (top_k, reasoning_effort, allowed_token_ids,
truncate_prompt_tokens) and requires stream:true in the request body.
Nova endpoints also reject 'model' in the request body.

Changes:
- New provider: sagemaker_nova/<endpoint-name>
- SagemakerNovaConfig inherits from SagemakerChatConfig
- Override transform_request to strip 'model' from request body
- Override supports_stream_param_in_request_body (True for Nova)
- Extend get_supported_openai_params with Nova-specific params
- Refactored SagemakerChatConfig to use custom_llm_provider param
  instead of hardcoded strings (backwards-compatible)
- Consolidated main.py routing for sagemaker_chat and sagemaker_nova
- 22 unit tests + 9 integration tests (skip-gated)
- Documentation with SDK, streaming, multimodal, and proxy examples
- All tests verified against live SageMaker Nova endpoint

* fix: move integration tests to tests/local_testing/ per test directory policy

* fix: remove unused module-level SagemakerNovaConfig instance

The sagemaker_nova_config singleton was never imported or used — the
ProviderConfigManager creates its own instance via the lambda registered
in utils.py. Removing this leftover boilerplate.

---------

Co-authored-by: Krish Dholakia <krrishdholakia@gmail.com>
2026-03-14 15:10:01 -07:00
yuneng-jiangandGitHub a2708f332f Merge pull request #23658 from BerriAI/litellm_internal_dev_03_13_2026
[Infra] Merge internal dev 3/13 with main
2026-03-14 14:22:27 -07:00
yuneng-jiang e4fa6f51c9 Merge remote-tracking branch 'origin' into litellm_internal_dev_03_14_2026 2026-03-14 14:22:01 -07:00
Krish DholakiaandGitHub 47c38403ff Litellm dev 03 14 2026 p1 (#23653)
* fix: Fixes https://github.com/BerriAI/litellm/issues/23185

* fix(responses/main.py): ensure litellm metadata custom cost works
2026-03-14 13:21:10 -07:00
yuneng-jiangandGitHub 94eabffe01 Merge pull request #22390 from Harshit28j/litellm_langfuse-session-trace-fix
Fix Langfuse failure path kwargs inconsistency
2026-03-14 12:49:04 -07:00
yuneng-jiangandGitHub e76c1f2fde Merge pull request #23651 from BerriAI/litellm_fix_ci_failures_03_14
[Fix] CI failures: mypy type error, ruff lint, and flaky router test
2026-03-14 12:47:30 -07:00
yuneng-jiangandClaude Opus 4.6 03231f3b26 [Fix] CI failures: mypy type error, ruff lint, and flaky router test
- Fix mypy arg-type error in background_streaming.py by adding proper
  type annotation and cast for terminal_status
- Fix ruff F401 false positive for httpx import in vantage_destination.py
  caused by from __future__ import annotations
- Fix flaky test_arouter_responses_api_bridge by providing a properly
  structured mock response to prevent exception mapping errors

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-14 12:43:03 -07:00
Harshit JainandGitHub 4f04d2648e Merge branch 'main' into litellm_langfuse-session-trace-fix 2026-03-15 01:09:49 +05:30
yuneng-jiangandGitHub 0066ad7291 Merge pull request #23649 from Harshit28j/litellm_tests_leak
add tests for fix
2026-03-14 12:32:39 -07:00
Krish DholakiaandGitHub 8abf2d8e34 fix: Fixes https://github.com/BerriAI/litellm/issues/23185 (#23647) 2026-03-14 12:30:52 -07:00
yuneng-jiangandClaude Opus 4.6 d049d35612 [Fix] Drop unnecessary timeout param from get_async_httpx_client call
The default timeout (600s) from AsyncHTTPHandler is sufficient.
Removes the explicit timeout param to keep the call simple.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-14 12:26:25 -07:00
yuneng-jiangandClaude Opus 4.6 fbad073a1f [Fix] Use cached async HTTP client in Vantage destination
Replace per-request `httpx.AsyncClient` with `get_async_httpx_client`
to avoid the +500ms latency penalty from creating new clients per
request. Updates tests to mock the cached client factory.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-14 12:23:40 -07:00
yuneng-jiangandClaude Opus 4.6 6abdf5adde [Fix] Responses bridge variable mismatch and outdated CI tests
Fix genuine regression in responses_api_bridge_check where the second
call assigned to `model_info` instead of `responses_api_model_info`,
preventing gpt-5.4 + tools + reasoning_effort from routing to the
Responses API bridge.

Also update outdated tests:
- Vantage tests: match "csv" file key and use supported column names
- Anthropic caching test: add "type": "custom" to expected tool payload
- Claude Agent SDK test: remove non-deterministic LLM content assertion

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-14 12:12:35 -07:00