Commit Graph
2310 Commits
Author SHA1 Message Date
Krish DholakiaandGitHub 7f2e188ee2 Add bridge for /chat/completion -> /responses API (#11632)
* refactor(responses/): refactor to move responses_to_completion in separate folder

future work to support completion_to_responses bridge

allow calling codex mini via chat completions (and other endpoints)

* Revert "refactor(responses/): refactor to move responses_to_completion in separate folder"

This reverts commit ff87cb895812283d107f47e8e528bcebe93d8015.

* feat: initial responses api bridge

write it like a custom llm - requires lesser 'new' components

* style: add __init__'s and bubble up the responses api bridge

* feat(responses/transformation): working sync completion -> responses and back bridge (non-streaming)

* feat(responses/): working async (non-streaming) completion <-> responses bridge

Allows calling codex mini via proxy

* feat(responses/): working sync + async streaming for base model response iterator

* fix: reduce function size

maintain <50 LOC

* fix(main.py): safely handle responses api model check

* fix: fix linting errors
2025-06-11 22:20:18 -07:00
Krrish Dholakia e46ef9d642 test: update test with new kwargs 2025-06-11 22:19:17 -07:00
Krish DholakiaandGitHub 4be0ec8e35 GA Multi-instance rate limiting v2 Requirements + New - specify token rate limit type - output / input / total (#11646)
* feat(parallel_request_limiter_v3.py): allows admin to enforce token rate limit based on just output tokens

Useful when trying to rate limit for primarily self hosted model use-cases

* test(test_parallel_request_limiter_v3.py): add unit test for token rate limit type

* feat(parallel_request_limiter_v3.py): return remaining token limits in header

* feat: return rate limit headers in response

* feat(parallel_request_limiter_v3.py): working rate limit response headers

* feat(parallel_request_limiter_v3.py): fix rate limit tracking for tpm when rpm also set

* feat(parallel_request_limiter_v3.py): show headers for key/user/team

* feat(parallel_request_limiter_v3.py): decrement max parallel request limiter on failure event

* feat(parallel_request_limiter_v3.py): add in-memory cache implementation of parallel request rate limiter

allows rate limiter to work even without redis cache setup

Work for GA of parallel request limiter v3

* refactor(proxy/hooks/__init__.py): replace with new parallel request handler

* test: update testing

* fix: fix ruff check

* fix: revert ga of multi instance rate limiting - needs more work to pass testing
2025-06-11 22:05:13 -07:00
DelandGitHub 33c134c6ac Enable System Proxy Support for aiohttp Transport (#11616)
* feat: enable proxy for aiohttp, fixes 11389

* chore: add test for aiohttp trust env

* style: format litellm/__init__.py
2025-06-11 21:13:37 -07:00
688e65b2b2 [Feat] Perf fix - ensure deepgram provider uses async httpx calls (#11641)
* Checkpoint before follow-up message

* Add comprehensive tests for Deepgram transcription functionality

* clean up transform

* just use 1 test

* test cleanup

* test fix get_complete_url

* test rename file

* refactor deepgram URL construction

* add logging_obj.pre_call

* fix unused imports

* feat - add async deepgram support

* test_audio_transcription_async

* fix python 3.8 test

---------

Co-authored-by: Cursor Agent <cursoragent@cursor.com>
2025-06-11 18:32:01 -07:00
Ishaan JaffandGitHub 02b02c739b [Feat] MCP - Add support for streamablehttp_client MCP Servers (#11628)
* feat - add https mcp support

* fixes for MCP http integration

* fix code QA

* bump mcp dep

* test_mcp_server_manager_https_server

* test mcp server https

* fix linting error

* bump mcp in poetry

* fix import streamablehttp_client

* fix streamablehttp_client

* fix streamablehttp_client

* add streamablehttp_client
2025-06-11 17:09:46 -07:00
Cole McIntosh 12a61fce4a [Feat] Enhance Mistral model support with reasoning capabilities
* Added support for reasoning parameters in magistral models, including "reasoning_effort" and "thinking".
* Updated the MistralConfig class to handle reasoning system prompts.
* Implemented tests to verify reasoning functionality and ensure correct parameter mapping for magistral models.
* Enhanced the model prices JSON to reflect new reasoning capabilities.
2025-06-11 17:13:06 -06:00
0cb7dd7577 [Feat] Add provider specific params for deepgram/ (#11638)
* Checkpoint before follow-up message

* Add comprehensive tests for Deepgram transcription functionality

* clean up transform

* just use 1 test

* test cleanup

* test fix get_complete_url

* test rename file

* refactor deepgram URL construction

* add logging_obj.pre_call

* fix unused imports

---------

Co-authored-by: Cursor Agent <cursoragent@cursor.com>
2025-06-11 15:36:45 -07:00
Ishaan JaffandGitHub f3f7bc1537 [Feat] Add Background mode for Responses API - OpenAI, AzureOpenAI (#11640)
* feat: add background as supported param responses create

* add background param for responses API
2025-06-11 15:36:25 -07:00
Ishaan JaffandGitHub 91010cda8f [Bug Fix] Add audio/ogg mapping for Audio MIME types (#11635)
* Add audio/ogg mapping

* test_vertex_ai_gemini_audio_ogg

* test_vertex_ai_gemini_audio_ogg
2025-06-11 14:19:53 -07:00
aeaf2d185a fix inference endpoints (#11630) (#11631)
Co-authored-by: célina <hanouticelina@gmail.com>
2025-06-11 10:45:54 -07:00
Krrish Dholakia ec52600f98 test: handle fireworks ai instability 2025-06-11 10:09:28 -07:00
Krish DholakiaandGitHub 39de3610be fix(internal_user_endpoints.py): support user with + in email on us… (#11601)
* fix(internal_user_endpoints.py): support user with `+` in email on user info

ensures user is correctly parsed from input

* fix(factory.py): support vertex function call args as None

handles empty string in args for vertex gemini calls

* docs(langfuse_integration.md): pin langfuse sdk version on docs

* fix(vertex_ai/): return empty dict, instead of none when empty string given

* refactor: reduce function size

* fix: fix linting errors

* fix: revert check

* fix(internal_user_endpoints.py): fix check

* test: update tests

* test: update tests
2025-06-10 22:13:10 -07:00
Ishaan JaffandGitHub 4dc9626fd5 [Feat] New LLM API Endpoint - Add List input items for Responses API (#11602)
* (feat) add list_input_items

* add alist_input_items to router

* add GET input_items for responses API

* test_basic_openai_list_input_items_endpoint

* TestTransformListInputItemsRequest

* test_ensure_initialize_azure_sdk_client_always_used
2025-06-10 15:47:16 -07:00
55cd5f096c [Feat] LiteLLM Allow setting Uvicorn Keep Alive Timeout (#11594)
* Add keepalive timeout option for uvicorn server configuration

* docs Keepalive Timeout

---------

Co-authored-by: Cursor Agent <cursoragent@cursor.com>
2025-06-10 13:30:19 -07:00
Krrish Dholakia 798a5c0a20 refactor: remove bad tests - mixes docker testing with code testing 2025-06-10 09:28:16 -07:00
Krish DholakiaandGitHub c569056ea8 Show remaining users on UI (#11568)
* docs(deploy.md): move docker recommendation to `main-stable`

* feat(enterprise/internal_user_endpoints.py): expose endpoint for checking available premium users

* feat(usage_indictor.tsx): add new element to help track remaining premium users

* feat(usage_indicator.tsx): show premium user remaining usage

allows users with user caps to know how much is left

* fix(vertex_and_google_ai_studio_gemini.py): bubble up stream is not finished, even if stop reason is given

prevents early completion of stream

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

* fix(streaming_handler.py): respect is_finished = False in hidden params

internal logic for preventing ending stream early

* fix(litellm_license.py): add function to check if user is over limit

* fix(internal_user_endpoints.py): add function to check if user is over limit

* refactor: move test

* docs(customer_endpoints.py): document new param
2025-06-09 22:04:45 -07:00
Low Jian ShengandGitHub ac30462270 Fix gemini tool call indexes (#11558)
* fix index in gemini tool calls

* pass in the right index

* remove print

* add unit test for _transform_parts
2025-06-09 19:07:36 -07:00
c6d0878160 [Feat] Add Lasso Guardrail to LiteLLM (#11565)
* Feature/lasso guardrail (#9002)

* first version of lasso guardrail in litellm

* update to the new Lasso API

* change  prod api_base and kill the request when lasso detect issue.

* change test for now api, local test pass

* add async tests

* all tests pass

* add docs for the new lasso guardrail

* Remove support for modes other than pre_call in Lasso guardrail

* code structure and naming

* only pre_call docs

* fix lint errors

* move test to the new location  follows the same directory structure as litellm/.

* add lasso guard

* docs lasso docs

* add lasso guardrail

* fix lasso guardrail

---------

Co-authored-by: oroxenberg <oro@lasso.security>
2025-06-09 18:47:26 -07:00
Ishaan JaffandGitHub 9241fca2f5 Fix: Adds support for choosing the default region based on where the model is available (#11566)
* fix: vtx default region for global only models

* track gemini-2.5-pro-preview-05-06

* fix is_global_only_vertex_model

* test_is_global_only_vertex_model

* test_get_vertex_region_global_only_model

* fix json format

* fix get_supported_regions
2025-06-09 18:29:44 -07:00
cd8ec4556f [Feat] Add reasoning_effort support for perplexity models (#11562)
* fix: add reasoning_effort for pplx

* docs pplx reasoning

* [tests] add mock tests for pplx reasoning (#11564)

* Add tests for Perplexity reasoning models and effort parameter

* tests perplexity reasoning effort

---------

Co-authored-by: Cursor Agent <cursoragent@cursor.com>

* test pplx reasoning effort

---------

Co-authored-by: Cursor Agent <cursoragent@cursor.com>
2025-06-09 17:07:31 -07:00
9b87fde633 [Bug fix]: aiohttp fixes for transfer encoding error on aiohttp transport (#11561)
* fix: fixes for transfer encoding error on aiohttp transport

* Update tests/test_litellm/llms/custom_httpx/test_aiohttp_transport.py

Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>

---------

Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
2025-06-09 16:14:34 -07:00
LaurienandGitHub 0c50f8bcc9 Update enduser spend and budget reset date based on budget duration (#8460) 2025-06-08 08:39:14 -07:00
Krish DholakiaandGitHub 8dd8615a54 Ensure consistent 'created' across all chunks + set tool call id for ollama streaming calls (#11528)
* fix(streaming_handler.py): maintain same 'created' across all chunks

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

* test: add unit test to ensure created is always the same across all chunks

* fix(types/utils.py): set a tool call id, if missing in delta tool call

Ensures stream chunk builder can reconstruct tool calls correctly

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

* fix(responses/transformation.py): support passing mcp server tool call to anthropic

allows switching between openai and anthropic for mcp tool calling

* fix(ollama/chat/transformation.py): set tool call id's when missing
2025-06-07 20:50:07 -07:00
Krish DholakiaandGitHub 2654d3b0b1 Support env var vertex credentials for passthrough + ignore space id on watsonx deployment (throws Json validation errors) (#11527)
* fix(router.py): support vertex credentials set in env var for passthrough

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

* fix(watsonx/common_utils.py): do not pass space_id on watsonx deployment requests - raises Json validation error

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

* test: update unit test
2025-06-07 20:31:05 -07:00
Krish DholakiaandGitHub 17d2711cf4 UI - fix invitation link + ensure team models returned when team has 'all-proxy-models' + team only models (#11524)
* fix(onboarding_link.tsx): fix adding ui/invitation id

* fix(onboarding_link.tsx): update invitation link function to handle w/ and w/out custom server path cases

* fix(model_checks.py): ensure team only models returned when all proxy models set for team
2025-06-07 15:19:52 -07:00
Krish DholakiaandGitHub e3c66418b8 Litellm anthropic mcp support (#11474)
* feat(anthropic/): initial commit adding working mcp tool call support

pass in mcp tool via `tools` and litellm will handle translating it to the right anthropic param

* feat(anthropic/): map openai mcp tool to anthropic mcp tool

allows usage within responses api

* fix(databricks/transformation.py): fix databricks linting error

* test(test_anthropic_chat_transformation.py): fix test

* test: update test

* fix(anthropic/chat/transformation.py): add dummy tool call
2025-06-07 15:11:55 -07:00
Krish DholakiaandGitHub c42740a4b9 Simplify experimental multi-instance rate limiter - more accurate (#11424)
* refactor: comment out circuit breaker

causes incorrect rate limiting in high traffic

* fix(base_routing_strategy.py): don't reset value if redis val is lower than current in-memory value

Fixes issue where redis might be trailing in-memory value

* fix(parallel_request_limiter_v2.py): if in-memory higher than redis, don't reset value; add previous slot keys to redis increment to correctly 'get' them

* fix(parallel_request_limiter_v3.py): v3 implementation of parallel request limiter

does not use background redis syncing - increments redis in call

 simplify rate limiting logic, to improve accuracy

* fix: fix ruff errors

* fix(parallel_request_limiter_v3.py): don't decrement limit on post call success - causes double decrements

* fix(parallel_request_limiter_v3.py): working accurate multi-instance logic

ensured just 100 requests allowed on 100 users, 10 ramp up, 100 rpm limit key, 2 instances

* fix(parallel_request_limiter_v3.py): working accurate rate limiting with time window resets

allows rate limiting to work across multiple windows

* test: add unit tests for v3 rate limiter

* fix(parallel_request_limiter_v3.py): return window value into in-memory cache

allows in-memory cache checks to be used correctly

* refactor(parallel_request_limiter_v3.py): refactor rate limiting to work for multiple window/counter key pairs

enables using for user/team/model rate limiting

* feat(parallel_request_limiter_v3.py): working rate limiting, across key/user/team/end-user

* fix(parallel_request_limiter_v3.py): add model specific rate limiting

* fix(parallel_request_limiter_v3.py): ignore if no rate limits set

skip unecessary rate limit checks - if no limits set

* fix(parallel_request_limiter_v3.py): initial commit bringing token rate limits back

* fix(parallel_request_limiter_v3.py): increment by value in list + update assertions to handle tokens + max parallel requests

* test(parallel_request_limiter_v3.py): more testing

* fix(parallel_request_limiter.py): working in-memory cache limiter

* fix(redis_cache.py): ignore linting error - use safe hasattr

* fix(parallel_request_limiter_v3.py): fix linting error

* refactor: remove redundant parallel_Request_limiter_v2.py

old / inaccurate implementation

* test: update tests

* style: cleanup

* test: update test

* docs(config_settings.md): document new env var

* test(test_base_routing_strategy.py): update test
2025-06-07 11:10:55 -07:00
Krish DholakiaandGitHub bc7dd9fa6d Litellm dev 06 06 2025 p1 (#11496)
* fix(proxy/_types.py): add key masking to audit logs - prevent leaking sk- keys

* fix(navbar.tsx): fix getting image url when proxy base url is null
2025-06-07 09:12:16 -07:00
Ishaan Jaff bc835c6044 test_lm_studio_completion 2025-06-06 20:41:00 -07:00
Ishaan JaffandGitHub 362e358a77 [Feat] Allow using litellm.completion with /v1/messages API Spec (use gpt-4, gemini etc with claude code) (#11502)
* feat: add anthropic stream wrapper

* feat: add AnthropicExperimentalPassThroughConfig

* feat: working non streaming anthropic

* feat: working streaming anthropic-litellm bridge

* test - anthropic OpenAI bridge tests

* fix: add sync support for anthropic_messages

* fix: using is async check

* fix: ensure streams are SSE

* fix: imports

* fix code qa check

* fix: linting errors

* test_sync_openai_messages

* cleanup remove stash file
2025-06-06 20:35:53 -07:00
Ishaan Jaff 08d6f3e142 Revert "Enhance proxy CLI with Rich formatting and improved user experience (#11420)"
This reverts commit 3b911ba1b2.
2025-06-06 17:55:45 -07:00
Cole McIntoshandGitHub 3b911ba1b2 Enhance proxy CLI with Rich formatting and improved user experience (#11420)
* Enhance proxy CLI with Rich formatting and improved user experience

- Integrated Rich library for better console output in `proxy_cli.py`, including version display, health check results, and test completion responses.
- Updated health check and test completion methods to provide progress indicators and formatted tables.
- Refactored feedback display in `proxy_server.py` to use Rich for a more visually appealing user interface.
- Adjusted tests in `test_proxy_cli.py` to mock console output instead of using print statements, ensuring compatibility with Rich formatting.

* fix linting error

* refactor(proxy_cli.py): simplify DB setup logging

- Removed progress indicators for IAM token generation and environment variable decryption to simplify the code.
- Consolidated the logic for generating the database URL and setting environment variables.
- Enhanced error handling for configuration loading and database setup, ensuring clearer feedback

* Update test-linting workflow to include proxy-dev dependencies in Poetry installation

* Enhance proxy server initialization with Rich console for improved model display. Added support for loading model parameters from environment variables and refined provider identification logic. Fallback to original print formatting if Rich is not available.

* Refactor feedback handling: Moved feedback message generation and custom warning display to utils.py. Enhanced feedback box with rich formatting and fallback to ASCII for environments without rich. Cleaned up proxy_server.py by removing obsolete code.

* fix linting error

* Refactor model initialization display: Moved model initialization logic to a new utility function `display_model_initialization` for improved readability and maintainability. Enhanced model provider extraction with a dedicated function. Fallback to basic logging if Rich console is unavailable.

* Refactor model provider extraction: Replace the `_extract_provider_from_model` function with a more robust approach using `get_llm_provider`. Implement fallback logic for provider identification and improve error handling. Ensure compatibility with Rich console for model initialization display.
2025-06-06 17:16:53 -07:00
Cole McIntoshandGitHub e191e72746 Fix: Respect user_header_name property for budget selection and user identification (#11419)
* Refactor get_end_user_id_from_request_body to support user ID retrieval from custom headers and multiple request body formats. Enhance tests to cover various scenarios including header precedence and fallback mechanisms.

* Refactor get_end_user_id_from_request_body function to accept request_body as the first parameter, improving clarity and flexibility. Update tests for compatibility and add new cases to ensure correct functionality across various request body formats.

* Update _user_api_key_auth_builder and user_api_key_auth to pass request object to get_end_user_id_from_request_body, enhancing user ID retrieval from request data.

* refactor(auth_utils.py): update get_end_user_id_from_request_body to accept request_headers instead of request, and adjust related function calls in user_api_key_auth and tests

* refactor(tests): update mock request handling in LLM pass-through endpoint tests

- Replaced the Request object with a Mock for better flexibility in testing.
- Enhanced mock setup to include user API key handling and virtual key retrieval.
- Updated test calls to reflect changes in mock request structure and added necessary patches for new dependencies.

* refactor(vertex_and_google_ai_studio_gemini.py): remove redundant variable declaration for url_context_metadata, linting error
2025-06-06 14:21:02 -07:00
Cole McIntoshandGitHub 1ceb9f9621 Merge pull request #11455 from colesmcintosh/429-fireworks-mapping
Fix Fireworks AI rate limit exception mapping - detect "rate limit" text in error messages
2025-06-06 15:06:15 -06:00
Krrish Dholakia 0c9f992af0 test: update to handle gemini-flash empty responses 2025-06-06 13:37:29 -07:00
96cba0148b [Bug Fix] Fix: _transform_responses_api_content_to_chat_completion_content` doesn't support file content type (#11494)
* Handle file content type transformation in responses api (#11310)

* Handle file content type transformation in responses api

* change to use input_file

* -

* TestLiteLLMCompletionResponsesConfig

* test: TestLiteLLMCompletionResponsesConfig

* fix: fix linting

---------

Co-authored-by: Jayme Gordon <jayme_gordon@icloud.com>
2025-06-06 13:20:46 -07:00
Ishaan JaffandGitHub fdaad51015 Feat: add add azure endpoint for image endpoints (#11482)
* feat: add add azure endpoint for image endpoints

* test: azure image routes working as expected

* test azure routes
2025-06-06 10:38:37 -07:00
Krrish Dholakia 1af0b62578 refactor: cleanup huggingface rerank transformation 2025-06-06 10:30:44 -07:00
Krrish Dholakia e5f228abd5 fix(utils.py): handle litellm proxy case for checking model info 2025-06-06 09:24:41 -07:00
Krrish Dholakia e2da29c54d test: update test 2025-06-06 09:15:08 -07:00
Krrish Dholakia 3608db5ffe fix(prometheus.py): update tests 2025-06-06 09:12:54 -07:00
Krrish Dholakia 398fef8391 fix(bedrock/): add generic support for tool calling on bedrock models
Closes https://github.com/BerriAI/litellm/issues/11430
2025-06-05 23:37:02 -07:00
Krish DholakiaandGitHub 603bd73a17 Gemini - web search cost tracking + Update max output tokens for nova models
* fix(vertex_and_google_ai_studio_gemini.py): add web search request tracking

Enables cost calculation for google web search

* fix(vertex_and_gemini): use common processing logic across stream / non-stream calls

* fix(vertex_And_google_ai_studio_Gemini.py): fix initial choice

* fix: fix linting error

* fix: add initial support for google search cost tracking

* fix(tool_call_cost_tracking.py): working tool cost tracking for gemini

* fix(vertex_ai/gemini/cost_calculator.py): add google web search tool cost tracking for vertex ai

Closes LIT-210

* fix: fix check

* build(model_prices_and_context_window.json): fix amazon nova max output tokens

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

* fix: fix ruff check
2025-06-05 23:25:18 -07:00
cainiaoitandGitHub be12416863 feat: add HuggingFace rerank provider support (#11438)
++ feat: add HuggingFace rerank provider support

feat: add HuggingFace rerank provider support

feat: add HuggingFace rerank provider support

feat: add HuggingFace rerank provider support

feat: add HuggingFace rerank provider support
2025-06-05 23:23:01 -07:00
Pedro AzevedoandGitHub 5d516aace1 fix: supports_function_calling works with llm_proxy models (#11381)
* Add tests for function calling support in LiteLLM proxy models

- Introduced a new test script `test_proxy_function_calling.py` to validate function calling capabilities for both direct and proxied models.
- Created a comprehensive test suite in `tests/litellm_utils_tests/test_proxy_function_calling.py` using pytest, covering various model configurations and edge cases.
- Implemented parameterized tests to ensure consistency between direct and proxied model function calling support.
- Added tests for specific proxy models, edge cases, and import verification for the `supports_function_calling` function.
- Included a demonstration test to highlight the current issue with proxy model resolution.

* feat: add fallback handling for litellm_proxy models in model info retrieval

* feat: enhance proxy function calling tests with custom model name handling and documentation

* fix: add type ignore comments for custom logger callback initialization

* fix: remove styling diff

* fix: style

* fix(utils.py): remove outdated comment regarding litellm_proxy models

* feat(utils.py): add proxy model handling for underlying model extraction

* feat(utils.py): enhance model name handling for litellm_proxy integration

* refactor(utils.py): remove unused _handle_proxy_model_names function
2025-06-05 23:15:33 -07:00
Ishaan JaffandGitHub c99daef689 [Fix]: /v1/messages - return streaming usage statistics when using litellm with bedrock models (#11469)
* fix: using litellm with claude code bedrock

* fix: usage for bedrock with /messages

* fix: bedrock_sse_wrapper

* tests: test for test_chunk_parser_usage_transformation

* test fix
2025-06-05 21:18:19 -07:00
Ishaan JaffandGitHub f0cb80ec50 [Feat] Return response_id == upstream response ID for VertexAI + Google AI studio (Stream+Non stream) (#11456)
* fix: vertexAI return responseID

* fix: vertexAI return responseID

* test_vertex_ai_response_id

* test: test_vertex_ai_streaming_response_id

* test_vertex_ai_streaming_response_id
2025-06-05 20:18:55 -07:00
Ishaan JaffandGitHub 23627d6a26 [Fix] [Bug]: Knowledge Base Call returning error (#11467)
* fix:get_and_pop_recognised_vector_store_tools

* test: tools wwith vector stores

* test - bedrock kb tools

* fix: add clear comment

* fix: vector store tools
2025-06-05 18:24:36 -07:00
Ishaan JaffandGitHub 18ea65218b [Feat] Make batch size for maximum retention in spend logs a controllable parameter (#11459)
* feat: add SPEND_LOG_CLEANUP_BATCH_SIZE

* docs update

* test: test_cleanup_batch_size_env_var
2025-06-05 17:11:51 -07:00