Commit graph

8121 commits

Author SHA1 Message Date
Jugal Bhatt
5ad698f2cc Revert "Fix - add safe divide by 0 for most places to prevent crash"
This reverts commit 265d40e390.
2025-08-14 14:21:07 -07:00
Krish Dholakia
f360e0ead2
Merge pull request #13590 from BerriAI/litellm_bedrock_api_header
[LLM translation] Refactor Anthropic Configurations and Add Support for `anthropic_beta` Headers
2025-08-14 11:32:18 -07:00
Jugal D. Bhatt
1beba93cc8
Fix - add safe divide by 0 for most places to prevent crash (#13624) 2025-08-14 11:17:49 -07:00
Ishaan Jaff
5bb96af818
[Feat] Add reasoning_effort param for hosted_vllm provider (#13620)
* add reasoning_effort to hosted_vllm

* test_hosted_vllm_supports_reasoning_effort

* Reasoning Effort
2025-08-14 10:10:30 -07:00
Cole McIntosh
dea98a315b
fix(volcengine): handle thinking disabled parameter properly (#13598)
* fix(volcengine): handle thinking disabled parameter properly

When thinking is set to {"type": "disabled"} in volcengine provider config,
skip adding the parameter to extra_body entirely instead of passing it through.
This prevents "thinking: undefined" from appearing in request logs.

Fixes #13039

* test(volcengine): fix and enhance thinking parameter tests

- Fixed existing test that expected broken behavior
- Added comprehensive test coverage for all thinking parameter scenarios:
  * thinking disabled → omitted from extra_body
  * thinking enabled → included in extra_body
  * thinking None → included in extra_body as None
  * custom thinking values → included in extra_body
  * no thinking parameter → empty result

All tests passing, verifying the fix for issue #13039
2025-08-14 09:10:06 -07:00
Ishaan Jaff
cd893134b7 test team endpoints 2025-08-13 18:43:50 -07:00
Ishaan Jaff
086621e3d3 test_handle_jwt.py 2025-08-13 17:27:50 -07:00
Ishaan Jaff
8e76f8e7d0
[Feat] Team Member Rate Limits + Support for using with JWT Auth (#13601)
* fix - assign tpm/rpm limit onJWT

* add team member rpm/tpm limits

* update - rate limiter v3 with team member rate limits

* update utils

* fixes for LiteLLM_BudgetTable

* undo change

* add TeamMemberBudgetHandler

* add _process_team_member_budget_data

* add get_team_membership

* add safe_get_team_member_rpm_limit and safe_get_team_member_tpm_limit

* LiteLLM_TeamMembership

* add LiteLLM_TeamMembership rate limit for JWTs

* fix

* tests
2025-08-13 17:21:36 -07:00
Ishaan Jaff
75bcfbb76a
[Feat] New model vertex_ai/deepseek-ai/deepseek-r1-0528-maas (#13594)
* add ertex_ai/deepseek-ai/deepseek-r1-0528-maas

* fix init

* test_model_info_for_vertex_ai_deepseek_model
2025-08-13 13:44:45 -07:00
Jugal Bhatt
26e62c9bd8 Update Test for Anthropic Messages Configuration
- Renamed `AmazonAnthropicClaude3MessagesConfig` to `AmazonAnthropicClaudeMessagesConfig` in the test file to align with recent refactoring.
- Adjusted the instantiation of the configuration class in the test to reflect the new naming convention.
2025-08-13 11:53:11 -07:00
Jugal Bhatt
c2310bcccc Refactor Anthropic Configurations in Tests
- Updated test cases to use the renamed `AmazonAnthropicClaudeConfig` instead of `AmazonAnthropicClaude3Config` for consistency with recent changes.
- Adjusted imports and assertions in test files to reflect the new configuration class name.
2025-08-13 11:52:41 -07:00
Jugal Bhatt
3990f61bed Refactor Anthropic Configurations and Add Support for anthropic_beta Headers
- Renamed `AmazonAnthropicClaude3Config` and `AmazonAnthropicClaude3MessagesConfig` to `AmazonAnthropicClaudeConfig` and `AmazonAnthropicClaudeMessagesConfig` respectively for consistency.
- Implemented `get_anthropic_beta_from_headers` function to extract and handle `anthropic-beta` headers across various transformations.
- Updated request transformations in `AmazonConverseConfig` and `AmazonInvokeConfig` to include `anthropic_beta` parameters based on user headers.
- Added tests to ensure proper handling of `anthropic_beta` headers in different scenarios.
2025-08-13 11:47:59 -07:00
Krish Dholakia
5e45fcdff0
Merge pull request #13375 from colesmcintosh/fix/ollama-gpt-oss-thinking-field 2025-08-13 07:58:57 -07:00
Krzysztof Gąsiorowski
0b28930ad4
[Fix] Hide sensitive data in /model/info - azure entra client_secret (#13577)
* Remove litellm_params.client_secret from /model/info

Added pop of client_secret (Azure provider secret) from litellm_params in remove_sensitive_info_from_deployment used by /model/info endpoints

* Added test for litellm.proxy.common_utils.openai_endpoint_utils.remove_sensitive_info_from_deployment
2025-08-13 07:35:53 -07:00
Dor Zion
6a1f5bdc2f
Add Noma Security guardrail support 2025-08-13 13:39:21 +03:00
nielsbosma
fe54da79a1 test(braintrust-logging): add span_name tests for events
Add tests to verify custom and default span_name in BraintrustLogger,
including async, metadata merging, and span name behavior.
2025-08-13 12:26:14 +02:00
Krish Dholakia
6afaf5721a
[Fix] Streaming - consistent 'finish_reason' chunk index (#13560)
* feat(model_response_utils.py): new function to check if modelresponsestream is empty

used for checking https://github.com/BerriAI/litellm/issues/13348

* fix(streaming_handler.py): skip chunk if empty

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

* fix(streaming_handler.py): add is_empty logic to async flow
2025-08-12 23:21:57 -07:00
Krish Dholakia
f00e891004
LiteLLM SDK <-> Proxy: support user param + Prisma - remove use_prisma_migrate flag - redundant as this is now default (#13555)
* fix(litellm_proxy/chat/transformation.py): support 'user' and all other openai chat completion params

Fixes issue where 'user' was not being sent in request to litellm proxy via sdk

* fix(prisma_migration.py): remove 'use_prisma_migrate' flag, is now default

* docs: cleanup docs

* fix(proxy_cli.py): remove --use_prisma_migrate flag

* refactor: remove references to use_prisma_migrate env var

This is now the default flow for db migrations
2025-08-12 22:03:39 -07:00
Ishaan Jaff
74ddd21067
[Bug fix] SCIM Team Memberships - handle metadata (#13553)
* test_update_group_metadata_serialization_issue

* fixes for update_group

* test_update_group_metadata_serialization_issue
2025-08-12 20:53:12 -07:00
Jorge Piedrahita Ortiz
6a77780c0e
Feat/sambanova embeddings (#13308)
* add sambanova embeddings

* fmt

* minor fix

* add sambanova embeddings call

* fmt

* include embeddings in sambanova docs

* add sambanova embeddigns unit test

* remove unused import

* minor fix

* fmt

* update sambanova embeding to inherit from BaseEmbeddingConfig

* fmt

* fmt

* hot fix

* fmt
2025-08-12 17:15:26 -07:00
Ishaan Jaff
afe159bb8b
[Feat] GEMINI CLI Integration - Add /countTokens endpoint support (#13545)
* stash changes for token counter

* working TokenCountRequest

* working acount_tokens

* add GoogleAIStudioTokenCounter

* re-use validate_environment

* fixes count_tokens

* fixes google_count_tokens

* fixes token counter base class

* fix TokenCountResponse

* fix - use BaseTokenCounter

* add should_use_token_counting_api

* fixes for GoogleAIStudioTokenCounter

* fixes for should_use_token_counting_api

* fixes for google_count_tokens

* fixes for /messages count_tokens

* fixes for should_use_token_counting_api

* working e2e gemini token counter

* ruff check fixes

* fixes for token counter

* fixes for TokenCountResponse

* cleanup TokenCountRequest

* add TokenCountDetailsResponse

* fix use well typed Responses

* fix typing for TokenCountDetailsResponse

* test_vertex_ai_gemini_token_counting_with_contents

* fixes for TokenCountDetailsResponse

* test fixes

* test_factory_registration

* test_proxy_token_counter.py

* TestGoogleAIStudioTokenCounter

* fix token_counter
2025-08-12 16:19:58 -07:00
Timothy Lowrimore
c0d82545d3
Merge branch 'main' into heroku-llms 2025-08-12 09:02:51 -06:00
Krrish Dholakia
79e262d12b feat(common_utils.py): make default azure openai responses api use /openai/v1/responses logic
Fixes https://github.com/BerriAI/litellm/issues/13527#issuecomment-3177882103
2025-08-11 23:40:05 -07:00
Krrish Dholakia
2aacf64db1 test: add unit tests 2025-08-11 22:58:58 -07:00
Ishaan Jaff
008ea864a7
[Feat] - Add key/team logging for Langfuse OTEL Logger (#13512)
* feat - add key/team logging for LF

* test_construct_dynamic_otel_headers_with_langfuse_keys

* update LangfuseOtelLogger

* test_construct_dynamic_otel_headers_with_langfuse_keys

* cleanup

* OpenTelemetryConfig fixes

* fix code qa checks

* TestLangfuseOtelIntegration
2025-08-11 22:06:25 -07:00
Krrish Dholakia
bc9d0484e4 fix(cooldown_cache.py): mask error string to avoid leaking sensitive prompt data
Fixes https://github.com/BerriAI/litellm/issues/13329
2025-08-11 18:37:57 -07:00
NULL
f3dcae2528
feat: add CometAPI provider support with chat completions and streaming (#13458)
* feat: add CometAPI support with config, error handling and tests

* fix: specify type for extra_body in CometAPIConfig

---------

Signed-off-by: NULL <129579691+TensorNull@users.noreply.github.com>
2025-08-11 18:06:37 -07:00
Ishaan Jaff
9f78287000
[Bug Fix]: Azure OpenAI GPT-5 max_tokens + reasoning param support (#13510)
* add AzureOpenAIGPT5Config

* add AzureOpenAIGPT5Config

* add AzureOpenAIGPT5Config

* add AzureOpenAIGPT5Config

* test_azure_gpt5_supports_reasoning_effort

* test_azure_gpt5_reasoning

* test_azure_gpt5_reasoning

* ruff check fixes

* docs azure gpt5
2025-08-11 15:40:53 -07:00
Timothy Lowrimore
95d9e30448
Merge branch 'main' into heroku-llms 2025-08-11 09:45:52 -06:00
Cole McIntosh
d5d7e00d34 Enhance chunk parsing for Ollama streaming responses
Updated the chunk_parser method to return a ModelResponseStream when handling 'thinking' field content, allowing UIs to render reasoning information. Adjusted tests to verify the new behavior, ensuring that reasoning content is correctly returned in the response.
2025-08-11 07:02:25 -06:00
Cole McIntosh
7a1c6efa0a
Merge branch 'BerriAI:main' into fix/ollama-gpt-oss-thinking-field 2025-08-11 06:54:51 -06:00
Krish Dholakia
9f6f96d76c
Litellm dev 08 07 2025 p1 (#13418)
* fix(router.py): support base model for model group usage

allows model group info to show accurate cost information for azure models

* fix(router.py): fix changes

* test: add unit tests

* build(pyproject.toml): bump openai version requirements

support custom tool from responses api

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

* docs(responses_api.md): add verbosity + free-form function calling parameters

* docs(responses_api.md): add cfg + minimal reasoning to docs

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

* docs(responses_api.md): add proxy examples to docs

* refactor: fix ruff error
2025-08-09 16:30:04 -07:00
Ishaan Jaff
f60a9cf908
[Bug]: Fix JWTs access not working with model groups (#13474)
* fix can_team_access_model

* test_find_team_with_model_access_model_group
2025-08-09 16:14:51 -07:00
Jugal D. Bhatt
67833590d6
[Proxy changes] Litellm add model price reload schedule for multi-pod (#13470)
* added mcp guardrails doc in mcp.md

* add button to reload models

* Added button changes

* added button for scheduling reload

* add multi pod support to reloading the model price json

* fix ruff
2025-08-09 16:12:13 -07:00
Krish Dholakia
1c8761111f
Router - reduce p99 latency w/ redis enabled by 50% + OTEL - track pre_call hook latency (#13362)
* feat(proxy/utils.py): track pre-call hooks in OTEL

some pre call hooks can cause latency in high traffic - make sure this is tracked

* fix(router.py): move redis call on deployment_callback_on_success to pipeline operation

reduces p99 latency by half when redis is enabled

* fix(parallel_request_limiter_v3.py): only run check if any item has rate limits set

Prevents unnecessary latency added by rate limit checks

* test: add unit tests

* Latency Improvements: only track tpm/rpm usage when set on deployment+ LLM Caching - use an in-memory cache to reduce redis calls + OTEL - track time spent on LLM caching (#13472)

* fix(router.py): only track usage for deployments with tpm/rpm set

ensures additional latency avoided for non-tpm/rpm models

* fix(caching_handler.py): log time spent on request get cache to OTEL

enables easy debugging of call latency

* fix(caching_handler.py): use dual cache object for in-memory caching + trace redis call within caching handler

* fix(caching_handler.py): working in-memory cache for redis calls

ensures dual cache works when redis cache setup for llm calls

makes calls quicker by only checking redis when in-memory cache missed for llm api call

* test: remove redundant test

* test: add unit tests
2025-08-09 16:09:51 -07:00
Ishaan Jaff
60306d34a0
[Bug Fix] Allow using Swagger for /chat/completions (#13469)
* fix get_openapi_schema

* fixes for ProxyChatCompletionRequest

* TestSwaggerChatCompletions

* fix working request body

* fix - add "messages"

* fix messages

* TestSwaggerChatCompletions

* test_messages_field_has_example

* ruff check fix
2025-08-09 15:35:45 -07:00
Jugal D. Bhatt
1270df08a4
[Proxy + UI] Litellm add reload model api and button (#13464)
* added mcp guardrails doc in mcp.md

* add button to reload models

* Added button changes

* remove the model_reload
2025-08-09 13:52:56 -07:00
Jugal D. Bhatt
10a1fe21c5
[LLM Translation] Litellm azure o series drop params (#13353)
* added route check

* fix ruff

* Added support for dropping o_series params

* Added ruff fix

* fix tests
2025-08-09 13:52:45 -07:00
Ishaan Jaff
eb4bd26f24
[Bug Fix] - Get Routes (#13466)
* fixes get_routes_for_mounted_app

* fix - use _safe_get_endpoint_name

* fix code QA check

* test_get_routes_for_mounted_app_with_static_files

* test fixes
2025-08-09 12:52:23 -07:00
Ishaan Jaff
a843e876a8
[Feat] Working e2e flow for Responses API session management with media (#13456)
* add MultimodalContent on chat UI

* add multi modal img on chat ui

* utils for responses API imgs

* add code snippet with imgs

* chat UI add imgs

* add imge upload

* chat ui allow adding images

* fix chat send button

* fix button styles

* fix clear chat

* fixes session management

* fixes for session management

* QA fix _should_check_cold_storage_for_full_payload

* test_should_check_cold_storage_for_full_payload
2025-08-08 18:28:10 -07:00
Cole McIntosh
66cc88ffb4
Merge branch 'BerriAI:main' into fix/ollama-gpt-oss-thinking-field 2025-08-08 15:06:30 -06:00
Ishaan Jaff
3b65733af8
[Bug fix] - Error creating standard logging object - can't register atexit after shutdownLitellm fixes standard logging payload (#13436)
* fix: _generate_cold_storage_object_key

* _get_configured_cold_storage_custom_logger

* test_e2e_generate_cold_storage_object_key_runtime_error_handled
2025-08-08 12:38:26 -07:00
Jugal D. Bhatt
51c2ff7c15
fix user membership issue (#13433) 2025-08-08 12:00:58 -07:00
Ishaan Jaff
3a35c82884
[Feat] Add reasoning_effort to OpenAIGPT5Config (#13434)
* add reasoning_effort toi OpenAIGPT5Config

* test_gpt5_supports_reasoning_effort
2025-08-08 11:57:12 -07:00
Davide Pugliese
81f2563338 Enhance logging for containers 2025-08-08 18:28:35 +02:00
Ishaan Jaff
9761ba7c7a
[Bug Fix] Responses api session management for streaming responses (#13396)
* fix proxy config

* fix(responses api): fix streaming ID consistency and tool format handling (#12640)

* fix(responses): ensure streaming chunk IDs use consistent encoding format

Fixes streaming ID inconsistency where streaming responses used raw provider IDs
while non-streaming responses used properly encoded IDs with provider context.

Changes:
- Updated LiteLLMCompletionStreamingIterator to accept provider context
- Added _encode_chunk_id() method using same logic as non-streaming responses
- Modified chunk transformation to encode all streaming item_ids with resp_ prefix
- Updated handlers to pass custom_llm_provider and litellm_metadata to streaming iterator

Impact:
- Streaming chunk IDs now format: resp_<base64_encoded_provider_context>
- Enables session continuity when using streaming response IDs as previous_response_id
- Allows provider detection and load balancing with streaming responses
- Maintains backward compatibility with existing streaming functionality

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

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

* fix(types): add explicit Optional[str] type annotation for model_id

This resolves MyPy type checking error where model_id could be None
but wasn't explicitly typed as Optional[str].

* fix(types): handle None case for litellm_metadata access

Prevents 'Item None has no attribute get' error by checking for None
before accessing litellm_metadata dictionary.

* test: add comprehensive tests for streaming ID consistency

Adds unit and E2E tests to verify streaming chunk IDs are properly encoded
with consistent format across streaming responses.

## Tests Added

### Unit Test (test_reasoning_content_transformation.py)
- `test_streaming_chunk_id_encoding()`: Validates the `_encode_chunk_id()` method
  correctly encodes chunk IDs with `resp_` prefix and provider context

### E2E Tests (test_e2e_openai_responses_api.py)
- `test_streaming_id_consistency_across_chunks()`: Tests that all streaming chunk IDs
  are properly encoded across multiple chunks in a real streaming response
- `test_streaming_response_id_as_previous_response_id()`: Tests the core use case -
  using streaming response IDs for session continuity with `previous_response_id`

## Key Testing Approach
- Uses **Gemini** (non-OpenAI model) to test the transformation logic rather than
  OpenAI passthrough, since the streaming ID consistency issue occurs when LiteLLM
  transforms responses rather than just passing through to native OpenAI responses API
- Tests validate that streaming chunk IDs now use same encoding as non-streaming responses
- Verifies session continuity works with streaming responses

Addresses @ishaan-jaff's request for unit tests covering the streaming ID consistency fix.

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

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

* fix(lint): remove unused imports in transformation.py

Removes unused imports to fix CI linting errors:
- GenericResponseOutputItem
- OutputFunctionToolCall

* test: remove E2E tests from openai_endpoints_tests

Remove streaming ID consistency E2E tests as requested by @ishaan-jaff.
Keep only the mock/unit test in test_reasoning_content_transformation.py

* revert: remove streaming chunk ID encoding to original behavior

This reverts the streaming chunk ID encoding changes to understand the original issue better.
Original behavior was:
- Streaming chunks: raw provider IDs
- Streaming final response: raw IDs (PROBLEM!)
- Non-streaming final response: encoded IDs (correct)

The real issue: streaming final response IDs were not encoded, breaking session continuity.

* fix(responses): encode streaming final response IDs to match OpenAI behavior

Fixes streaming ID inconsistency to match OpenAI's Responses API behavior:
- Streaming chunks: raw message IDs (like OpenAI's msg_xxx)
- Final response: encoded IDs (like OpenAI's resp_xxx)

This enables session continuity by ensuring streaming final response IDs
have the same encoded format as non-streaming responses, allowing them
to be used as previous_response_id in follow-up requests.

Changes:
- Add custom_llm_provider and litellm_metadata to LiteLLMCompletionStreamingIterator
- Update handlers to pass provider context to streaming iterator
- Apply _update_responses_api_response_id_with_model_id to final streaming response
- Keep streaming chunks as raw IDs to match OpenAI format

Impact:
- Session continuity works with streaming responses
- Load balancing can detect provider from streaming final response IDs
- Format matches OpenAI's Responses API exactly

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

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

* test: update unit test to match correct OpenAI-compatible behavior

Updates the unit test to verify streaming chunk IDs are raw (not encoded)
to match OpenAI's responses API format:
- Streaming chunks: raw message IDs (like msg_xxx)
- Final response: encoded IDs (like resp_xxx)

This reflects the correct behavior implemented in the fix.

---------

Co-authored-by: Claude <noreply@anthropic.com>

* cleanup

* TestBaseResponsesAPIStreamingIterator

---------

Co-authored-by: Javier de la Torre <jatorre@carto.com>
Co-authored-by: Claude <noreply@anthropic.com>
2025-08-07 20:13:24 -07:00
Ishaan Jaff
7695882d8a test_supports_tool_choice 2025-08-07 16:56:45 -07:00
Ishaan Jaff
2037037258
[Bug Fix] OpenAI gpt-5 series does not support "max_tokens" parameter and temperature values that are not = 1 (#13390)
* add OpenAIGPT5Config

* add map_openai_params for gpt5

* add OpenAIGPT5Config

* add OpenAI gpt 5 transform

* docs gpt 5 openai
2025-08-07 16:35:00 -07:00
Ishaan Jaff
e8c081b8ff test_stream_chunk_builder_litellm_usage_chunks 2025-08-07 15:22:52 -07:00
Cole McIntosh
b66f4a7d4b
Merge branch 'BerriAI:main' into fix/ollama-gpt-oss-thinking-field 2025-08-07 15:14:38 -06:00