Commit Graph

23009 Commits

Author SHA1 Message Date
Ishaan Jaff 4b4e2dfde4 test base email 2025-07-01 20:33:21 -07:00
Ishaan Jaff 66fafa3a7f [Feat] Polish - add better error validation when users configure prometheus metrics and labels to control cardinality (#12182)
* self._pretty_print_invalid_metric_error

* docs prometheus.md

* test prom validation checks

* update metric name

* fix _pretty_print_validation_errors

* fix linting

* test prometheus

* test fixes - prometheus
2025-07-01 20:17:17 -07:00
Samuel Boyd a5c2475ecf OpenMeter integration error handling fix (#12147)
* fix - tuple was never falsy so never triggered the exception

* test - add test suite for openmeter integration

* refactor - move tests for openmeter integration
2025-07-01 18:12:54 -07:00
Ishaan Jaff 4e7115bc34 Bug Fix - responses api fix got multiple values for keyword argument 'litellm_trace_id' (#12225)
* fix - handling trace id arg on responses api

* test_async_response_api_handler_merges_trace_id_without_error

* test_anthropic_with_responses_api
2025-07-01 18:12:22 -07:00
Ishaan Jaff a6527e5010 [Feat] Add litellm-proxy cli login for starting to use litellm proxy (#12216)
* add handlers for auth commands

* add login, logout, whoami

* refactor auth

* add CLI Authentication Flow

* add SSO sign in constants

* add itellm-session-token

* fixes for managing state with cli

* use locally stored context for cli session

* add litellm banner + interactive shell

* update main.py

* update auth to show commands

* fix ui sso render

* add TestCLISSOCallbackFunction

* update banner.py

* remove file

* fix cli sso success

* TestTokenUtilities

* fix code qa

* fix execute_command

* fix cli_sso_callback

* fix import

* Authentication using CLI
2025-07-01 18:11:19 -07:00
Jason Roberts cc480f94c9 Fix/move panw prisma airs test file location per feedback on PR #12116 (#12175)
* Move PANW Prisma AIRS test per feedback on PR #12116

- Move test to tests/test_litellm/proxy/guardrails/guardrail_hooks/

* Remove test file from old location
2025-07-01 18:08:04 -07:00
Zayd 7ef590df84 Passes through extra_ properties on "custom" llm provider (#12185)
* Passes through headers on "custom" llm provider

* add test

* adds extra_body support for custom llm providers
2025-07-01 18:07:38 -07:00
Ciprian Tomoiaga b3b4c65ac4 Fix default parameters for ollama-chat (#12201) 2025-07-01 17:59:04 -07:00
Cole McIntosh f47254ecab Fix: Preserve full path structure for Gemini custom api_base (#12215)
* Fix: Preserve full path structure for Gemini custom api_base (Fixes #11959)

This fix addresses an issue where custom api_base URLs (like Cloudflare AI Gateway)
were not working correctly with Google AI Studio (Gemini) models.

The problem was that the _check_custom_proxy method was simply appending the endpoint
to the custom base URL, resulting in malformed URLs like:
https://gateway.ai.cloudflare.com/v1/my-id/my-gateway/google-ai-studio:generateContent

Instead of the correct format:
https://gateway.ai.cloudflare.com/v1/my-id/my-gateway/google-ai-studio/v1beta/models/gemini-2.5-flash:generateContent

Changes:
- Modified _check_custom_proxy to preserve the full path structure from the original URL
- Extracts the path from the original Google AI URL and appends it to the custom base
- Maintains backward compatibility for Vertex AI models (unchanged behavior)
- Added comprehensive tests to verify the fix works correctly

Fixes #11959

* Fix: Update test to match actual Gemini URL format and fix double colon issue

- Fixed test expectation to include the full model path with 'gemini/' prefix
- Fixed double colon issue in Vertex AI URL construction when using custom api_base
- All tests now pass successfully
2025-07-01 17:56:22 -07:00
Eliza Huang f6589d81ec Update Vertex Model Garden doc to use SDK for deploy + chat completion (#12219)
* Update Vertex Model Garden documentation to deploy + use OpenAI Chat Completion tutorial.

* update anchor description
2025-07-01 17:54:44 -07:00
Jugal D. Bhatt 923004db1b Merge pull request #12218 from BerriAI/email_template
Customizable Email template - Subject and Signature
2025-07-02 06:15:41 +05:30
Jugal D. Bhatt 1513cb5756 Merge pull request #12223 from BerriAI/mcp_error_handling
added error handling for MCP tools not found or invalid server
2025-07-02 06:15:06 +05:30
Ishaan Jaff 2e3a0222e6 Revert "test_anthropic_with_responses_api"
This reverts commit 2f0bdf887e80f85669fb0bae9fcede16863d658e.
2025-07-01 17:43:21 -07:00
Ishaan Jaff 648e8d6533 test_anthropic_with_responses_api 2025-07-01 17:43:21 -07:00
Krish Dholakia 9582c88eab Non-anthropic (gemini/openai/etc.) models token usage returned when calling /v1/messages (#12184)
* fix(proxy_server.py): handle empty config yaml

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

* fix(gemini/common_utils.py): replace models/ as expected, instead of using 'strip'

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

* fix(anthropic/experimental_pass_through/messages/transformation.py): check for env var when selecting api key

* fix(anthropic/transformation.py): return tool_use content block start on anthropic bridge

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

* fix(anthropic/streaming_iterator.py): fix setting index in block

ensure index is set just once and increments correctly when a new block is created

* fix(anthropic/adapters/handler.py): update logging obj with stream options value if set

* feat(anthropic/streaming_iterator.py): return usage from chat completion to messages bridge

enables usage tracking for non-anthropic models

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

* fix(streaming_iterator.py): safely access usage chunk

* fix: suppress linting error

* test: update tests

* fix: fix streaming errors
2025-07-01 17:41:48 -07:00
Jugal Bhatt 072100bbab revert 2025-07-01 17:27:26 -07:00
Jugal Bhatt 3b35ab857f added ruff fixes 2025-07-01 17:24:11 -07:00
Jugal Bhatt 27e6ef5f39 added error handling for MCP tools not found 2025-07-01 17:12:01 -07:00
Jugal D. Bhatt 514224d190 Merge pull request #12213 from BerriAI/pydantic_bump
update pydantic version
2025-07-02 05:00:13 +05:30
Jugal Bhatt e53eb6eb37 change logger 2025-07-01 16:28:53 -07:00
Jugal Bhatt 7e6d27e6c3 change logger 2025-07-01 16:28:34 -07:00
Jugal Bhatt fefc5fc33a add warning message for non premium users 2025-07-01 16:27:31 -07:00
Jugal Bhatt a6922e68fb add verbose docs 2025-07-01 15:50:30 -07:00
Jugal Bhatt 0834ab79cd add docs changes 2025-07-01 15:25:23 -07:00
Jugal Bhatt b63d64dcf5 add subject and signature tests 2025-07-01 15:15:40 -07:00
Jugal Bhatt 5f47dde7e9 update poetry lock 2025-07-01 14:35:28 -07:00
Jugal Bhatt 69670001de email_templates 2025-07-01 14:34:15 -07:00
Jugal D. Bhatt 31d5ebc5a6 Merge pull request #12207 from BerriAI/mcp_url_issue
added changes to mcp url wrapping
2025-07-02 02:17:05 +05:30
Cole McIntosh abe364c2bc Fix: Ensure exception is not None before checking its string representation (#12209)
The test_keys_delete_error_handling test was failing with:
- ConnectionError when the mock wasn't properly applied
- The test was checking str(result.exception) without first verifying exception exists

This fix adds an explicit check that result.exception is not None before
attempting to convert it to string, preventing potential AttributeError
and making the test more robust.
2025-07-01 12:30:31 -07:00
Jugal Bhatt fd011eec62 update pydantic version 2025-07-01 11:37:23 -07:00
Tim O'Farrell e50789730d Fix allow strings in calculate cost (#12200)
* Allow strings in calculate cost

Sometimes the cost per unit is a string (e.g.: If a value like "3e-7" was read from the config.yaml)

* Add comprehensive tests for string cost value handling

- Added test_string_cost_values() to test basic string cost conversion functionality
- Added test_calculate_cost_component_with_string_values() to test the calculate_cost_component function directly
- Added test_string_cost_values_edge_cases() to test mixed string/float costs and error handling
- Added test_string_cost_values_with_threshold() to test string costs with threshold pricing
- Enhanced _get_token_base_cost() to handle string-to-float conversion for base costs and threshold costs
- Enhanced generic_cost_per_token() to handle string-to-float conversion for audio and reasoning token costs
- All tests cover scientific notation (e.g., '3e-7'), decimal notation (e.g., '0.000001'), and error handling for invalid strings
- Maintains backward compatibility with existing float cost values

* Dry up code

* Fixed case where number was an integer

* Allowing None

---------

Co-authored-by: openhands <openhands@all-hands.dev>
2025-07-01 11:37:15 -07:00
Jugal Bhatt e2cb701fd9 added changes to mcp url wrapping
add mcp server url wrapping

Add mcp url wrapping
2025-07-01 11:10:45 -07:00
raz-alon 0dd50ea336 Fix: correct user_id validation logic in Anthropic… (#11432)
* fix(transformation.py): correct user_id validation logic in AnthropicConfig

* fix conflict
2025-07-01 08:17:14 -07:00
Krrish Dholakia 7ec1def253 bump: version 1.73.6 → 1.73.7 2025-06-30 22:00:25 -07:00
Krish Dholakia 49ed3065f6 VertexAI Anthropic - streaming cost tracking w/ prompt caching fixes (#12188)
* fix(rebuild-usage-object---ensure-cache_tokens-is-set): Ensures cache tokens is correctly set

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

* test(test_stream_chunk_builder_utils.py): add unit test to ensure cached tokens is part of stream chunk builder

Ensures standardized values are used
2025-06-30 22:00:10 -07:00
Ishaan Jaff 847c4514c4 test fix - test_anthropic_messages_passthrough.py 2025-06-30 21:56:31 -07:00
Krish Dholakia ee9dd158dd Fix - handle empty config.yaml + Fix gemini /models - replace models/ as expected, instead of using 'strip' (#12189)
* fix(proxy_server.py): handle empty config yaml

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

* fix(gemini/common_utils.py): replace models/ as expected, instead of using 'strip'

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

* fix(anthropic/experimental_pass_through/messages/transformation.py): check for env var when selecting api key

* docs(config_settings.md): add api key to docs
2025-06-30 21:56:03 -07:00
Krrish Dholakia 5188c67c6c docs: update docs 2025-06-30 21:39:42 -07:00
Guanghua Ding e6111f032b fix - support anthropic_messages call types and add max tokens validation (#12162) 2025-06-30 20:19:34 -07:00
Young Han 042f6b187e [Bug Fix] Fix Error code: 307 for LlamaAPI Streaming Chat (#11946)
* fix: add follow_redirects to avoid 307 error code

* feat: add error 307 test case

* feat: add follow_redirects=True to AsyncClient
2025-06-30 16:52:42 -07:00
Ishaan Jaff d65a9fdcc7 [Bug Fix] Using /messages with lowest latency routing (#12180)
* add validate_anthropic_api_metadata

* fixes for lowest latency deployment

* add _select_metadata_field

* test_anthropic_messages_litellm_router_latency_metadata_tracking
2025-06-30 15:57:19 -07:00
Krzysztof Szafranek 2e467a6c99 Use the -d flag in docs instead of -D (#12179) 2025-06-30 15:25:42 -07:00
Ishaan Jaff c1d495f09e [Bug Fix] Allow passing litellm_params when using generateContent API endpoint (#12177)
* add _add_generic_litellm_params_to_request

* fix type

* fix: setup_result.litellm_params

* fix passing litellm params

* test_api_base_and_api_key_passthrough

* fixes for passing litellm params

* fix linting errors
2025-06-30 15:17:46 -07:00
Ishaan Jaff d727d63a81 [Feat] Add new AWS SQS Logging Integration (#12176)
* add aws_sqs

* add sqs controls

* add SQS to registry

* fix url lib parse

* fixes AWS SQS

* test_async_sqs_logger_flush

* fix test

* fix SQS logger auth

* add AWS SQS

* add aws sqs

* docs logging

* test_async_sqs_logger_flush

* test_async_sqs_logger_flush

* add SQS logger

* update SQS logging

* use constants for SQS
2025-06-30 14:02:49 -07:00
Krrish Dholakia 4978d7ad00 docs(lakera_ai.md): detail supported params 2025-06-30 13:18:49 -07:00
Cole McIntosh a7594196cd fix: support Cursor IDE tool_choice format {"type": "auto"} (#12168)
* fix: support Cursor IDE tool_choice format {"type": "auto"}

- Update validate_chat_completion_tool_choice to normalize {"type": "auto"} to "auto"
- Handles Cursor IDE sending non-standard tool_choice format
- Add comprehensive tests for tool choice validation

Fixes #12098

* fix: return full tool_choice object for Cursor IDE format

Based on PR feedback, updated validate_chat_completion_tool_choice to return
the full tool_choice dictionary instead of just extracting the type string.
This maintains consistency with downstream code that expects the full object
structure.

- Changed behavior: {"type": "auto"} now returns {"type": "auto"} instead of "auto"
- Updated tests to reflect the new expected behavior
- Ensures compatibility with code that passes tool_choice to optional_params

Addresses feedback from PR #12168
2025-06-30 12:39:58 -07:00
Ishaan Jaff 4bb732d30f docs slack support 2025-06-30 10:57:10 -07:00
Kobi Kadosh cff0030d05 Update management_cli.md (#12157)
add quotes to the uv tool install command the current will fail.
2025-06-30 10:54:16 -07:00
Ishaan Jaff b7cb05114c docs add slack support 2025-06-30 10:45:37 -07:00
Ishaan Jaff 6b464248c7 chore - add slack support link 2025-06-30 10:23:53 -07:00