Commit Graph
4111 Commits
Author SHA1 Message Date
Jón LevyandGitHub 555d7b8be8 feat(bedrock): Add bearer token authentication support for AgentCore (#16556) 2025-11-13 08:17:36 -08:00
491f57a349 feat: Add support for reasoning_effort="none" for Gemini models (#16548)
Implements support for reasoning_effort="none" parameter for Gemini models,
providing significant cost savings (up to 96% cheaper) by disabling thinking
budget while maintaining response quality.

Changes:
- Added "supports_reasoning": true to gemini-2.0-flash-thinking-exp-01-21 in model config
- Implemented mapping for reasoning_effort="none" to thinkingConfig {thinkingBudget: 0, includeThoughts: false}
- Added unit test to verify the mapping works correctly

Performance impact:
- Without reasoning_effort: ~313 tokens
- With reasoning_effort="none": ~12 tokens (96% cheaper)

Closes #16420

Co-authored-by: Krish Dholakia <krrishdholakia@gmail.com>
2025-11-12 19:41:07 -08:00
Cesar GarciaandGitHub 049d45ea90 fix(gemini): Preserve non-ASCII characters in function call arguments (#16550)
Fixes #16533

Before this fix, non-ASCII characters (Japanese, Spanish, Chinese, etc.)
in function call arguments were being escaped as Unicode sequences.

Example:
- Before: "やあ" → "\u3084\u3042"
- After: "やあ" → "やあ" (preserved)

Changes:
- Add ensure_ascii=False to json.dumps() in _transform_parts()
- Add test for Japanese and Spanish Unicode character preservation

This is not a breaking change as both formats are equivalent in JSON.
The fix improves readability and aligns with OpenAI's behavior.
2025-11-12 19:01:38 -08:00
Sameer KankuteandGitHub 018bd2e039 Add Gemini image edit support (#16430)
* Add gemini image edit support

* fix lint errors

* fix lint errors

* fix lint errors

* Add docs
2025-11-12 18:48:27 -08:00
yuneng-jiangandGitHub 8bf491c939 [Fix] /spend/logs/ui Access Control (#16446)
* RBAC for /spend/logs/ui

* Addressing comments
2025-11-12 18:44:21 -08:00
yuneng-jiangandGitHub cb27d6c456 [Fix] UI - Delete Callbacks Failing (#16473)
* Temp commit for branch switching

* Created normalize callback name util function and tests
2025-11-12 18:43:37 -08:00
Sameer KankuteandGitHub 92bd12c862 Fix raising wrong 429 error on wrong exception (#16482)
* fix raising wrong 429 error on wrong exception

* remove double re import
2025-11-12 18:41:12 -08:00
Sameer KankuteandGitHub 394da34a0b Add all gemini image models support in image generation (#16526) 2025-11-12 18:26:44 -08:00
yuneng-jiangandGitHub 898f15c33c Add Langfuse OTEL and SQS to health check (#16514) 2025-11-12 18:25:30 -08:00
Ishaan JaffandGitHub b30439257b [Feat] Add RunwayML Img Gen API support (#16557)
* TestRunwaymlImageGeneration

* fix RUNWAYML

* rename

* fix rename

* get_runwayml_image_generation_config

* get_runwayml_image_generation_config

* TestRunwaymlImageGeneration

* add RUNWAYML_POLLING_TIMEOUT

* fix rnwayml transform img gen

* runwayml_image_cost_calculator

* runwayml_image_cost_calculator

* docs runwayml

* fix runwayML polling

* test_get_first_default_fallback
2025-11-12 18:20:14 -08:00
YutaSaitoandGitHub 2843dab7fe fix: allow tool call even when server name prefix is missing (#16425)
* fix: allow tool call even when server name prefix is missing

* fix: test

* fix: test

* fix: test
2025-11-12 13:50:52 -08:00
Ishaan JaffandGitHub 061b7b2713 [Fix] Bedrock Embeddings - Ensure correct aws_region is used when provided dynamically (#16547)
* test_bedrock_embedding_uses_correct_region_when_specified

* fix aws_region_name in bedrock embeddings
2025-11-12 12:38:58 -08:00
Ishaan JaffandGitHub abde56391b [Fix] - Bedrock Knowledge Bases - add support for filtering kb queries (#16543)
* test_e2e_bedrock_knowledgebase_retrieval_with_llm_api_call_with_tools_and_filters

* fix vs registry

* fix merging params

* test_bedrock_kb_request_body_has_transformed_filters

* fix typing / linting
2025-11-12 12:38:50 -08:00
Mubashir OsmaniandGitHub e6bbf3ce81 fix: app_roles missing from jwt payload (#16448)
* fix: jwt app_roles missing

* add test
2025-11-12 12:07:04 -08:00
Jean-Adrien DucastaingandGitHub 086e557d78 fix: use vllm passthrough config for hosted vllm provider instead of raising error (#16537)
* fix(passthrough): use VLLM passthrough config for hosted VLLM provider instead of raising an error

* test(passthrough): add tests for hosted VLLM passthrough configuration and routing

* fix account linking for CLA
2025-11-12 09:12:14 -08:00
Sameer KankuteandGitHub 517eb0ee10 Use safe loading of creds (#16479) 2025-11-11 19:16:29 -08:00
Andrew MaguireandGitHub bd15250960 fix: Add atexit handlers to flush callbacks for async completions (#16487)
Fixes #16486

## Problem
Callbacks configured via litellm.success_callback (e.g., PostHog, LangSmith)
were not being invoked for litellm.acompletion() in short-lived scripts.
The callbacks worked correctly for synchronous completions but async
completions would queue callbacks that were lost when the script exited
before GLOBAL_LOGGING_WORKER could process them.

Root cause: asyncio.run() closes the event loop immediately after the
async function completes, preventing the background worker from processing
queued callbacks.

## Solution
Implemented a two-level atexit handler approach:

1. GLOBAL_LOGGING_WORKER atexit handler (logging_worker.py):
   - Processes remaining callbacks from queue before exit
   - Creates new event loop to run pending coroutines synchronously
   - Applies time and iteration limits to prevent blocking shutdown

2. Integration-specific atexit handlers (posthog.py as example):
   - Flushes internal queue to external service
   - Uses synchronous HTTP client for reliable delivery
   - Each integration needs its own handler due to varying sync APIs

## Changes
- litellm/litellm_core_utils/logging_worker.py:
  - Added _flush_on_exit() method
  - Registered atexit handler in __init__
  - Processes up to MAX_ITERATIONS_TO_CLEAR_QUEUE events
  - Time-limited to MAX_TIME_TO_CLEAR_QUEUE seconds

- litellm/integrations/posthog.py:
  - Added _flush_on_exit() method
  - Registered atexit handler in __init__
  - Groups events by credentials for batch sending
  - Uses sync_client for reliable HTTP delivery

- tests/logging_callback_tests/test_posthog.py:
  - Added test_async_callback_atexit_handler_exists()
  - Added test_posthog_atexit_flushes_internal_queue()
  - Added test_sync_callback_not_affected_by_atexit()

## Testing
- All existing tests pass
- Manual end-to-end testing confirms fix:
  - Async events now arrive in PostHog
  - Sync events continue working (no regression)
- Unit tests verify atexit handlers registered and functional

## Impact
- Fixes async callback delivery for ALL integrations using GLOBAL_LOGGING_WORKER
- No breaking changes - only adds missing functionality
- Sync path unchanged - no performance impact
2025-11-11 19:12:53 -08:00
Alan PonnachanandGitHub 8cb610b8b2 Sanitize null token values in provider responses (#16493) 2025-11-11 19:08:00 -08:00
yuneng-jiangandGitHub ba674f241c [Fix] Use user budget instead of key budget when creating new team (#16074)
* Use end user budget instead of key budget when creating new team

* Fixed implementation to use user's max budget from the UserTable instead of EndUserTable
2025-11-11 18:55:05 -08:00
yuneng-jiangandGitHub 67478a9074 [Fix] Litellm tags usage add request_id (#16111)
* Add request_id into tag spend

* Linting
2025-11-11 18:53:48 -08:00
Ishaan JaffandGitHub 50b5cf5215 [Feat] New Provider - Add RunwayML Provider for video generations (#16505)
* add RUNWAYML

* init folders

* add RunwayMLVideoConfig

* add RUNWAYML_DEFAULT_API_VERSION

* add RunwayMLVideoConfig

* fix getting status

* add async_transform_video_content_response

* add runwayml transform_video_content_response

* fix config.yaml

* add runwayml docs

* add runwayml to videos

* docs runwayml video gen

* add new models to model cost map

* TestRunwayMLVideoTransformation

* fix linting errors
2025-11-11 18:48:23 -08:00
443bada425 Add Zscaler AI Guard hook (#15691)
* Add Zscaler AI Guard hook

Co-authored-by: Angela Tao <atao@zscaler.com>

* Fix lint error, update document

* Fix lint error, update document

* update document

* fix mypy type error

* fix mypy issue

* fix test

* fix test

* improve document

* remove unuseful code

* use litellm httphandler

* update test cases

* revover guardrail_initializers.py and guardrail_registry.py

* remove unuse import

* app apply_guardrail

* remove functions repleased by apply_guardrail, update test and doc

* remove functions repleased by apply_guardrail, update test and doc

---------

Co-authored-by: Angela Tao <atao@zscaler.com>
2025-11-11 15:34:27 -08:00
Ishaan JaffandGitHub 5c9f50d584 [AI Gateway] - End User Budgets - Allow pointing max_end_user budget to an id, so the default ID applies to all end users (#16456)
* add _apply_budget_limits_to_end_user_params

* add _apply_budget_limits_to_end_user_params

* add _apply_budget_limits_to_end_user_params

* test_default_budget_applied_to_end_user_without_budget

* docs fix

* fix config
2025-11-11 08:20:13 -08:00
Ishaan JaffandGitHub e94186629d [Fix] Bedrock Knowledge bases - ensure users can access search_results for both stream + non stream response to /chat/completions (#16459)
* fix message with provider_specific_fields

* test_provider_specific_fields_in_proxy_http_response

* test_provider_specific_fields_in_proxy_http_response
2025-11-11 08:19:57 -08:00
Daniel SabanovandGitHub 0ecc38519e [Bug] Updated spend would not be sent to CloudZero (#16201)
* Address a bug where cloudzero spend is not sent to cloudzero if a spend
update happens

* revert change unrelated to PR

* use polars for mocking instead of sqlite
2025-11-10 19:43:15 -08:00
yellowsubmarine372andGitHub b6dbd4fa28 fix: apply provided timeout value to ClientTimeout.total (#16395) 2025-11-10 19:37:42 -08:00
Alan PonnachanandGitHub 5f12e4be1e fix(langfuse): Handle null usage values to prevent validation errors (#16396)
* langfuse null validation fix

* formatting
2025-11-10 19:34:56 -08:00
Alan PonnachanandGitHub 7b292ccdf5 router fallback for unknown models (#16419) 2025-11-10 19:33:01 -08:00
Matt CowgerandGitHub e0d6774ec1 fix: update model_cost_map_url to use environment variable (#16429)
* fix: update model_cost_map_url to use environment variable, to match behavior to documentation in docs/my-website/docs/proxy/sync_models_github.md

* Add an appropriate test.
2025-11-10 19:30:44 -08:00
Alan PonnachanandGitHub df33f36c06 Correctly handle date filters in /spend/logs endpoint (#16443) 2025-11-10 19:26:55 -08:00
Val MiscenkoandGitHub 19e6e60d30 fix: remove strict master_key check in add_deployment (#16453)
Allows proxy to save spend logs without requiring master_key.
  Decryption now gracefully handles both encrypted and unencrypted values.
2025-11-10 19:23:13 -08:00
Sameer KankuteandGitHub 6cab77f53f Added thinking streaming support for mistral (#16434) 2025-11-10 18:41:45 -08:00
Sameer KankuteandGitHub be3c09e6d5 Add GET list of providers endpoint (#16432) 2025-11-10 18:38:09 -08:00
Ishaan JaffandGitHub 8140d85d28 [Bug Fix] - LiteLLM Usage shows key_hash- (#16471)
* test_get_logging_payload_api_key_preserved_when_standard_logging_payload_is_none

* fix get_logging_payload

* test_api_key_preserved_through_failure_hook_to_database
2025-11-10 18:15:52 -08:00
912be308b2 fix: allow internal users to access video generation routes (#16472)
Fixes #16470

Video generation endpoints (/v1/videos, /videos/{video_id}, etc.) were
incorrectly restricted to proxy_admin role only. These routes are now
added to openai_routes list, making them accessible to internal_user
role as they should be - video generation is a legitimate user feature,
not a management/admin operation.

Changes:
- Added 8 video route patterns to LiteLLMRoutes.openai_routes in _types.py
- Added comprehensive tests verifying internal_user and virtual key access
- All existing route permission tests continue to pass

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

Co-authored-by: Claude <noreply@anthropic.com>
2025-11-10 17:44:16 -08:00
Ishaan JaffandGitHub dc76b6c76e [Fix] Management Endpoints - Fixes inconsistent error responses in customer management endpoints. Non-existent user errors now return proper 404 status codes with consistent error schema format across all endpoints. (#16450)
* fix: ensure end user endpoints use "handle_exception_on_proxy" correctly

* test 404 on info and update for non-existent user

* test 404 for no customer found

* fix 404 handling for customer endpoints

* test_error_schema_consistency

* test_customer_endpoints_error_schema_consistency
2025-11-10 17:16:53 -08:00
Ishaan Jaffer 8c1dd78c13 fix imports 2025-11-08 18:01:32 -08:00
Krish DholakiaandGitHub 06906534b3 feat(audio_transcriptions/): calculate duration of audio file for cost calculation + feat (image_generations): cost tracking accuracy improved with output_format, quality, size values fixed per openai model
* feat(audio_transcriptions/): calculate duration of audio file for cost calculation

Fixes https://github.com/BerriAI/litellm/issues/11846

Closes https://github.com/BerriAI/litellm/issues/14605

* fix(cost_calculator.py): correctly use base model, when set

Fixes issue where azure base model was being ignored

* feat(cost_calculator.py): fix default cost tracking quality param for image generation

* feat(image_generations/): return output_format, quality, size

aligns response to openai spec and improves cost tracking accuracy

* fix(cost_calculator.py): refactor cost calculation for image generation to use image response instead of hidden params

* build: update build

* fix: fix cost calculation

* build: update poetry lock

* fix: fix ruff checks

* fix: fix aembedding

* fix: fix ruff errors

* fix: modify to catch errors

* fix: test

* fix: loosen test to handle openai lib out of sync

* fix: fix base models

* fix: fix usage object
2025-11-08 16:24:31 -08:00
86d73c918c Adds support for returning Azure Content Policy error information when exceptions from Azure OpenAI occur (#16231)
* add provider_specific_fields to ContentPolicyViolationError

* use provider_specific_fields in ProxyException

* update openai_exception_handler

* fix use exception checker for content policy violation azure

* add AzureOpenAIExceptionMapping

* test_azure_with_content_safety_error

* Accessing Provider-Specific Error Details

* TestExceptionCheckers

* unit test got provider_specific_fields=

* add clear types for error dict

* fix test_azure_with_content_safety_error

---------

Co-authored-by: Ishaan Jaff <ishaanjaffer0324@gmail.com>
2025-11-08 16:04:36 -08:00
Sameer KankuteGitHubCopilot Autofix powered by AI <62310815+github-advanced-security[bot]@users.noreply.github.com>Ishaan Jaffer
e037d9315d Add Vertex and Gemini Videos API with Cost Tracking + UI support (#16323)
* Use video id for videos api

* remove mock code

* Potential fix for code scanning alert no. 3630: Clear-text logging of sensitive information

Co-authored-by: Copilot Autofix powered by AI <62310815+github-advanced-security[bot]@users.noreply.github.com>

* remove print statements

* Update video prefix for 'video_'

* Add veo with openai videos unified specs

* Add videos testing to UI

* remove mock code

* Remove not need ui changes:

* Fix mypy errors related to gemini

* fix test_transform_video_create_request

* Add vertex ai veo config

* Add vertex ai veo config

* Add cost tracking for gemini and add optional param passing

* fix bugs related to vertex ai veo

* Add Gemini Veo Video Generation in Openai Videos Unified Spec (#16229)

* Add veo with openai videos unified specs

* Add videos testing to UI

* remove mock code

* Remove not need ui changes:

* Fix mypy errors related to gemini

* fix test_transform_video_create_request

* Add contant video duration for gemini and vertex

* Fix litellm_mapped_tests tests

* fix azure videos issue

* Added doc for videos vertex ai

* fix seconds param error

* fix lint errors

* test_transform_video_create_response_cost_tracking_no_duration

---------

Co-authored-by: Copilot Autofix powered by AI <62310815+github-advanced-security[bot]@users.noreply.github.com>
Co-authored-by: Ishaan Jaffer <ishaanjaffer0324@gmail.com>
2025-11-08 16:03:51 -08:00
Krish DholakiaandGitHub 202eaeb1a2 Revert "(feat) Audio transcription - cost tracking + (feat) image generation …" (#16409)
This reverts commit c96da44265.
2025-11-08 15:38:16 -08:00
Krish DholakiaandGitHub c96da44265 (feat) Audio transcription - cost tracking + (feat) image generation - accurate cost tracking based on output_format/quality/size
* feat(audio_transcriptions/): calculate duration of audio file for cost calculation

Fixes https://github.com/BerriAI/litellm/issues/11846

Closes https://github.com/BerriAI/litellm/issues/14605

* fix(cost_calculator.py): correctly use base model, when set

Fixes issue where azure base model was being ignored

* feat(cost_calculator.py): fix default cost tracking quality param for image generation

* feat(image_generations/): return output_format, quality, size

aligns response to openai spec and improves cost tracking accuracy

* fix(cost_calculator.py): refactor cost calculation for image generation to use image response instead of hidden params

* build: update build

* fix: fix cost calculation

* build: update poetry lock

* fix: fix ruff checks

* fix: fix aembedding

* fix: fix ruff errors

* fix: modify to catch errors

* fix: test

* fix: loosen test to handle openai lib out of sync
2025-11-08 15:30:46 -08:00
Krish DholakiaandGitHub bce8a5d6b7 Revert "(feat) audio transcriptions cost tracking (for azure/other non-openai…" (#16402)
This reverts commit 9a88fe0861.
2025-11-08 14:24:51 -08:00
Ishaan Jaffer e4c31add58 test_dd_llms_obs_redaction 2025-11-08 14:23:42 -08:00
Ishaan Jaffer 1bf284abca test_delete_callbacks_in_db 2025-11-08 14:05:44 -08:00
Ishaan Jaffer a4c008c433 test_datadog_message_redaction 2025-11-08 14:02:24 -08:00
Krish DholakiaandGitHub 9a88fe0861 (feat) audio transcriptions cost tracking (for azure/other non-openai models) + (fix) image generations - accurate cost tracking for dalle3/gpt-image-1 - uses the correct max image quality (#16076)
* feat(audio_transcriptions/): calculate duration of audio file for cost calculation

Fixes https://github.com/BerriAI/litellm/issues/11846

Closes https://github.com/BerriAI/litellm/issues/14605

* fix(cost_calculator.py): correctly use base model, when set

Fixes issue where azure base model was being ignored

* feat(cost_calculator.py): fix default cost tracking quality param for image generation

* feat(image_generations/): return output_format, quality, size

aligns response to openai spec and improves cost tracking accuracy

* fix(cost_calculator.py): refactor cost calculation for image generation to use image response instead of hidden params

* build: update build

* fix: fix cost calculation

* build: update poetry lock

* fix: fix ruff checks
2025-11-08 13:54:37 -08:00
Ishaan Jaffer 993c75d10b test_redaction_responses_api 2025-11-08 13:43:22 -08:00
Ishaan Jaffer c43fcf2ded test_redaction_responses_api 2025-11-08 13:39:40 -08:00
6fb0a8fc58 Added xai responses support (#16391)
* Added xai responses support

* add the xai provider config above

* remove init file

* remove init file

* Fix f string lint error

---------

Co-authored-by: Ishaan Jaffer <ishaanjaffer0324@gmail.com>
2025-11-08 12:30:09 -08:00