Commit Graph
76 Commits
Author SHA1 Message Date
Sameer Kankute bb363f0307 Fix: test_bedrock_optional_params_embeddings_dimension 2026-02-02 17:49:18 +05:30
Sameer Kankute be0bb975c0 Fix test_aaamodel_prices_and_context_window_json_is_valid 2026-02-02 17:46:37 +05:30
0c006794f1 litellm_fix_mapped_tests_core: fix test isolation and mock injection issues (#20209)
* litellm_fix_mapped_tests_core: fix test isolation and mock injection issues

## Problem
Four tests in litellm_mapped_tests_core were failing:
1. test_register_model_with_scientific_notation - KeyError due to test isolation issues
2. test_search_uses_registry_credentials - Mock not being called due to incorrect patch path
3. test_send_email_missing_api_key - Real API calls despite mocking
4. test_stream_transformation_error_sync - Mock not effective, real API called

## Solution

### test_register_model_with_scientific_notation
- Use unique model name to avoid conflicts with other tests
- Clear LRU caches before test to prevent stale data
- Clean up model_cost entry after test

### test_search_uses_registry_credentials
- Use patch.object() on the actual base_llm_http_handler instance
- String-based patching for instance methods can fail; direct object patching is more reliable

### test_send_email_missing_api_key
- Directly inject mock HTTP client into logger instance
- This bypasses any caching issues that could cause the fixture mock to be ineffective

### test_stream_transformation_error_sync
- Patch litellm.completion directly instead of the handler module's litellm reference
- This ensures the mock is effective regardless of import order

## Regression
These tests were affected by LRU caching added in #19606 and HTTP client caching.

* fix(test): use patch.object for container API tests to fix mock injection

## Problem
test_retrieve_container_basic tests were failing because mocks weren't
being applied correctly. The tests used string-based patching:
  patch('litellm.containers.main.base_llm_http_handler')

But base_llm_http_handler is imported at module level, so the mock wasn't
intercepting the actual handler calls, resulting in real HTTP requests
to OpenAI API.

## Solution
Use patch.object() to directly mock methods on the imported handler
instance. Import base_llm_http_handler in the test file and patch like:
  patch.object(base_llm_http_handler, 'container_retrieve_handler', ...)

This ensures the mock is applied to the actual object being used,
regardless of import order or caching.

* fix(test): add missing Prometheus metric labels to test_proxy_failure_metrics

Add client_ip, user_agent, model_id labels to expected metric patterns.
These labels were added in PRs #19717 and #19678 but test wasn't updated.

* fix(test_resend_email): use direct mock injection for all email tests

Extend the mock injection pattern used in test_send_email_missing_api_key
to all other tests in the file:
- test_send_email_success
- test_send_email_multiple_recipients

Instead of relying on fixture-based patching and respx mocks which can
fail due to import order and caching issues, directly inject the mock
HTTP client into the logger instance. This ensures mocks are always used
regardless of test execution order.

* fix(test): use patch.object for image_edit and vector_store tests

- test_image_edit_merges_headers_and_extra_headers: import base_llm_http_handler
  and use patch.object instead of string path patching
- test_search_uses_registry_credentials: import module and patch via
  module.base_llm_http_handler to ensure we patch the right instance

---------

Co-authored-by: Ishaan Jaff <ishaanjaffer0324@gmail.com>
2026-01-31 17:53:54 -08:00
shin-bot-litellmandGitHub 7db4594200 litellm_fix(test): allow comment field in schema and exclude robotics models from tpm check (#20139) 2026-01-31 07:32:33 -08:00
d4031c8ba6 Add OpenRouter Kimi K2.5 (#19872)
Co-authored-by: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-28 22:34:48 -08:00
Chesars 45eb35938b fix: drop_params not dropping prompt_cache_key for non-OpenAI providers
Fixes #19225

Add prompt_cache_key and other missing OpenAI Chat Completions params
to DEFAULT_CHAT_COMPLETION_PARAM_VALUES so drop_params: true works.

Also fix additional_drop_params to filter extra params for all providers,
not just OpenAI/Azure.
2026-01-19 08:49:03 -03:00
Ishaan JaffandGitHub 1b00576711 [Feat] New Model - Azure Model Router on LiteLLM AI Gateway (#19054)
* fix - azure model router integration

* fix:_check_provider_match

* fix:_get_response_model

* tests azure model router

* test_azure_ai_model_router_streaming_model_in_chunk

* fix LlmProviders.AZURE.value

* test_azure_ai_model_router_streaming_cost_with_stream_options

* def test_get_model_from_chunks_azure_model_router():

* _get_model_from_chunks

* docs azure model router

* azure model router
2026-01-13 18:31:43 -08:00
932f06104d fix: include IMAGE token count in cost calculation for Gemini models (#18876)
* fix: include IMAGE token count as separate usage count and pricing

* fix: remove duplicate TypedDict key and variable definitions

- Remove duplicate input_cost_per_image_token in ModelInfoBase TypedDict
- Remove duplicate image_tokens variable declaration in _calculate_usage()

Fixes MyPy errors:
- types/utils.py:146: Duplicate TypedDict key
- vertex_and_google_ai_studio_gemini.py:1541: Name already defined

---------

Co-authored-by: Thomas Rehn <271119+tremlin@users.noreply.github.com>
2026-01-12 17:03:42 +05:30
Ryan MalloyandGitHub c2366194d4 fix(anthropic): prevent dropping thinking when any message has thinking_blocks (#18929)
* fix(anthropic): prevent dropping thinking when any message has thinking_blocks

When Claude returns multiple assistant messages in a conversation, some may
have thinking_blocks while others may not (Claude's behavior varies). The
previous logic only checked the LAST assistant message with tool_calls,
dropping the thinking param if it had no thinking_blocks.

This caused errors when earlier messages still contained thinking_blocks:
"When thinking is disabled, an assistant message cannot contain thinking"

The fix adds a new check: only drop thinking if NO assistant messages
have thinking_blocks. If any message has thinking_blocks, we keep
thinking enabled.

Fixes #18926

* chore: re-trigger CI
2026-01-12 16:29:44 +05:30
Cesar GarciaandGitHub c19c97591e fix: align max_tokens with max_output_tokens for consistency (#18820)
* fix: align max_tokens with max_output_tokens for consistency

Fixed inconsistent max_tokens definitions in model_prices_and_context_window.json.
According to LiteLLM convention, max_tokens should equal max_output_tokens when available.

Models fixed:
- deepseek-chat: 131072 → 8192 (now equals max_output_tokens)
- dashscope/qwen-flash: 1000000 → 32768 (now equals max_output_tokens)
- databricks/databricks-gemma-3-12b: 128000 → 32000 (now equals max_output_tokens)

This ensures consistency across all providers where max_tokens represents
the maximum number of tokens that can be generated in the output.

* fix: align max_tokens with max_output_tokens for 244 models

- Fix 244 models where max_tokens != max_output_tokens
- Add test to validate max_tokens consistency and prevent regressions

According to model_prices_and_context_window.json spec:
- max_tokens is a LEGACY parameter
- Should always equal max_output_tokens when both are present

This ensures consistency across all model definitions.
2026-01-10 00:37:45 +05:30
Sameer KankuteandGitHub 2baec27657 Revert "feat(model_cost): add display_name, model_vendor, and model_version metadata to model entries" 2026-01-06 15:29:42 +05:30
Nik 13db8e10dc feat: add display_name, model_vendor, and model_version metadata 2026-01-05 11:01:36 -08:00
Sameer KankuteandGitHub c47079ba3a Merge pull request #18062 from Chesars/fix/groq-deprecated-models
fix: remove deprecated Groq models and update model registry
2025-12-23 12:06:27 +05:30
Ishaan Jaffer c1b116c5f5 fix 2025-12-20 13:54:05 +05:30
yuneng-jiang 087dfbf648 Merge remote-tracking branch 'origin' into litellm_email_budget_alerts_2 2025-12-17 11:37:49 -08:00
jk-f5andGitHub 576580244f fix(azure_ai): return AzureAnthropicConfig for Claude models in get_provider_chat_config (#18086)
Claude models on Azure AI were incorrectly using AzureAIStudioConfig,
causing tool calls to fail with invalid_request_error because tools
remained in OpenAI format instead of being transformed to Anthropic format.
2025-12-17 11:24:04 +05:30
Chesars 7b6a00d3df fix: remove deprecated Groq models and update model registry
- Remove 20 deprecated/unavailable Groq models from registry
- Add groq/meta-llama/llama-guard-4-12b (new safety model)
- Add supports_vision to Llama 4 models (maverick, scout)
- Update Groq documentation with current model list
- Clean up test file references to deprecated models

Fixes #18043
2025-12-16 13:06:33 -03:00
yuneng-jiang 9907a0d93c Tests 2025-12-15 18:04:27 -08:00
Peter ChanthamynavongandGitHub f8e7e153d5 fix(cache): handle string content in is_cached_message (#17853)
Fixes #17821

The `is_cached_message` function crashed with TypeError when message
content was a string instead of a list of content blocks.

Changes:
- Add explicit `isinstance(content, list)` check before iteration
- Add `isinstance(content_item, dict)` check inside loop to skip non-dict items
- Use `.get()` for safer nested dict access
- Follow same pattern as `extract_ttl_from_cached_messages` (same module)

Tests:
- Add TestIsCachedMessage class with 9 test cases covering:
  - String content (the reported bug)
  - None content
  - Missing content key
  - Empty list content
  - List with/without cache_control
  - Mixed content types (strings + dicts)
  - Wrong cache_control type
2025-12-12 03:59:52 -08:00
Dima-MediatorandGitHub a0d4d0b304 Gemini models: capture image_tokens and support cost_per_output_image_token in costs calculations (#16912) 2025-11-21 19:59:24 -08:00
Jack CherngandGitHub 2ab34f9a52 Fix HostedVLLMRerankConfig will not be used (#16352)
* Fix HostedVLLMRerankConfig will not be used

Signed-off-by: Jun-Fei Cherng <jfcherng@realtek.com>

* Fix no usage statistics in rerank with hosted_vllm

Signed-off-by: Jun-Fei Cherng <jfcherng@realtek.com>

* Revise typo in comment

Signed-off-by: Jun-Fei Cherng <jfcherng@realtek.com>

---------

Signed-off-by: Jun-Fei Cherng <jfcherng@realtek.com>
2025-11-07 19:11:59 -08:00
0c743e1adc Add E2E Container API Support (#16136)
* Add v1 cut of container api

* fix lint errors

* Add proxy support to container apis & logging support (#16049)

* Add proxy support to container apis

* Add logging support

* Add cost tracking support for containers and documentation

* Add new constant documentation

* Add container cost in model map

* fix failing azure tests

* Update tests based on model map changes

* fix model map tests

* fix model map tests

* Container modeshould be container

* Container tests fix

* Merge branch 'main' into litellm_sameer_oct_staging_2

---------

Co-authored-by: Ishaan Jaffer <ishaanjaffer0324@gmail.com>
2025-11-01 14:03:51 -07:00
Ishaan Jaffer 33371d18f4 test fix claude-sonnet-4-5-20250929 2025-10-28 19:05:13 -07:00
Ishaan Jaffer 1b49dba1dd fix claude-sonnet-4-5 2025-10-28 17:37:08 -07:00
Krrish Dholakia da3988b768 fix: fix test 2025-10-25 15:43:16 -07:00
Sameer KankuteandGitHub 0f9996a4d0 Litellm sameer oct staging (#15806)
* Addd v2/chat support for cohere

* fix streaming

* Use v2_transformation for logging passthrough:

* Use v2_transformation for logging passthrough:

* Add test for checking if document and citation_options is getting passed

* Update the cohere model

* Add cost tracking for vertex ai passthrough batch jobs

* Add full passthrough support

* refactor code according to the comments

* Add passthrough handler

* remove invalid params

* Updated documentation

* Updated documentation

* Updated documentation

* Correct the import

* Add openai videos generation and retrieval support

* add retrieval endpoint

* Add docs

* Add imports

* remove orjson

* remove double import

* fix openai videos format

* remove mock code

* remove not required comments

* Add tests

* Add tests

* Add other video endpoints

* Fix cost calculation and transformation

* Fixed mypy tests

* remove not used imports

* fix documentation for get batch req (#15742)

* Add grounding info to responses API (#15737)

* Add grounding info to responses API

* fix lint errors

* Use typed objects for annotations

* Use typed objects for annotations

* fix mypy error

* Litellm fix json serialize alreting 2 (#15741)

* fix json serializable error for alerts

* Add test

* fix mypt errors

* fix mypt errors

* Add Qwen3 imported model support for AWS Bedrock (#15783)

* Add qwen imported model support

* fix mypy errors

* fix empty user message error (#15784)

* fix typed dict for list

* Add azure supported videos endpoint

* fix mapped tests

* add azure sora models to model map

* Add OpenAI video generation and content retrieval support (#15745)

* Add openai videos generation and retrieval support

* add retrieval endpoint

* Add docs

* Add imports

* remove orjson

* remove double import

* fix openai videos format

* remove mock code

* remove not required comments

* Add tests

* Add tests

* Add other video endpoints

* Fix cost calculation and transformation

* Fixed mypy tests

* remove not used imports

* fix typed dict for list

* fix mypy errors

* move directory

* make v2 chat default

* Fix mypy tests

* Fix mypy tests

* Fix mypy tests

* Fix mypy tests

* Revert "Add Azure Video Generation Support with Sora Integration"

* refactor videos repo

* add test

* Add azure openai videos support

* Add azure openai videos support

* Add router endpoint support for videos

* fix mypy error

* add azure models

* fix mapped test

* fix mypy error

* Add proxy router test

* Add proxy router test

* remove deprecated model name from tests

* fix import error

* fix import error

* Add gaurdrail integration in videos endpoint

* Add logging support for videos endpoint

* Add final documentation supporting videos integration

* fix model name and document input

* Update literals to avoid mypy errors

* Remove unused imports and print statements

* revert guardrail support for video generation and video remix

* revert guardrail support for video generation and video remix

* Fix failing mapped and llm translation tests
2025-10-24 12:17:22 -07:00
Ishaan Jaffer 74b8a1dbdf test_aaamodel_prices_and_context_window_json_is_valid 2025-10-23 08:47:08 -07:00
Ishaan Jaffer 8780b1af6f test fix 2025-10-17 18:55:05 -07:00
Sameer KankuteandGitHub 138bdbb6d8 fix mapped tests 1 (#15445)
* fix mapped tests

* fix mapped tests
2025-10-11 08:33:08 -07:00
Ishaan Jaffer eb72990aa6 test_get_valid_models_with_cli_pattern 2025-09-23 16:46:40 -07:00
Ishaan Jaffer 8016bcb1b9 test fix 2025-09-23 14:41:30 -07:00
Ishaan Jaffer f8c1f519c9 test_aaamodel_prices_and_context_window_json_is_valid 2025-09-23 14:26:38 -07:00
Ishaan JaffGitHubCopilot Autofix powered by AI <62310815+github-advanced-security[bot]@users.noreply.github.com>
b9ffa98c55 [Feat] Proxy CLI: Create a python method to login using litellm proxy (#14782)
* fix: cli auth with SSO okta

* fix: add LITTELM_CLI_SERVICE_ACCOUNT_NAME

* fix: get_litellm_cli_user_api_key_auth

* use existing_key CLI

* fix: use existing key

* test auth commands

* test_cli_sso_callback_regenerate_vs_create_flow

* feat: add CLI Token Utilities

* fix: get_stored_api_key

* move file

* fix: get_valid_models

* fix config.yaml

* TestCLITokenUtils

* TestGetValidModelsWithCLI

* fix: tie user id to keys created through CLI

* fix: add teams interface to CLI

* add /keys/update to the list client commands

* fix /sso/cli/poll to return the user_id

* fix: working TeamsManagementClient

* fix CLI Login command

* fixes for auth

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

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

* ruff fix

---------

Co-authored-by: Copilot Autofix powered by AI <62310815+github-advanced-security[bot]@users.noreply.github.com>
2025-09-22 21:28:38 -07:00
Krrish Dholakia 22d3e492f9 fix(test_utils.py): fix test 2025-09-16 19:17:44 -07:00
Krrish Dholakia e735808614 test(test_utils.py): fix cache creation tokens 2025-09-16 19:03:16 -07:00
Ishaan Jaff 69ef062f55 fix tiered_pricing test 2025-09-11 19:56:44 -07:00
Ishaan JaffandGitHub 51d5255452 [Bug]: Azure OpenAI & AI Foundry Reject Image Generation Payload Due to extra_body Injection in LiteLLM v1.76.3 (#14475)
* add request body azure img gen

* fix test_get_optional_params_image_gen_filters_empty_values

* test_azure_image_generation_request_body

* test_azure_image_generation_request_body
2025-09-11 19:39:06 -07:00
Ishaan Jaff 1227b54fa6 test_get_model_info_gemini 2025-09-06 13:43:42 -07:00
Krish DholakiaandGitHub f67339a86c Merge pull request #14028 from onlylhf/volcengine-embedding-support
Add Volcengine embedding module with handler and transformation logic
2025-09-04 21:01:25 -07:00
Ishaan Jaff 1237be04a5 test_aaamodel_prices_and_context_window_json_is_valid 2025-09-04 07:58:20 -07:00
Ishaan Jaff be7c762882 add video_generation 2025-09-03 18:25:27 -07:00
Ishaan Jaff 61b2209827 test_proxy_function_calling_support_consistency 2025-09-02 07:22:52 -07:00
Ishaan Jaff d37be48a80 test: llama-3.3-70b-versatile 2025-09-01 20:14:12 -07:00
Ishaan Jaff 7656cb3d6e test fix 2025-09-01 17:04:47 -07:00
Ishaan Jaff de6b08e76e test_supports_tool_choice 2025-08-30 10:35:16 -07:00
Ishaan Jaff 562790cb31 fix: /v1/realtime check 2025-08-29 18:38:14 -07:00
李海峰 2d0a57a719 Add Volcengine embedding module with handler and transformation logic
- Implemented VolcEngineEmbeddingHandler for synchronous and asynchronous embedding requests.
- Created VolcEngineEmbeddingConfig for transforming requests and responses to/from Volcengine format.
- Added integration tests for embedding functionality, covering various scenarios including error handling and parameter validation.
- Established test structure for Volcengine embedding, ensuring compliance with LiteLLM testing patterns.
- Included comprehensive tests for parameter mapping, request transformation, and response handling.
2025-08-28 15:05:11 +08:00
Ishaan Jaff 76f78f7b2a fix: LITELLM_LOG_FILE test 2025-08-27 08:25:24 -07:00
Ishaan JaffandGitHub ab7efaa832 test_pre_process_non_default_params (#13990) 2025-08-26 19:15:17 -07:00
Krish DholakiaandGitHub be30bc68ae Merge pull request #13759 from kankute-sameer/litellm_feat_correct_cost_calculations
Add long context support for claude-4-sonnet
2025-08-19 22:30:25 -07:00