litellm/tests/llm_translation
Ishaan Jaff 29e3fd5d79
[Release Fix] (#22411)
* fix(lint): suppress PLR0915 for 3 complex methods that exceed 50-statement limit

- streaming_iterator.py: _process_event (84 statements)
- transformation.py: translate_messages_to_responses_input (51 statements)
- transformation.py: transform_realtime_response (54 statements)

Co-authored-by: Ishaan Jaff <ishaan-jaff@users.noreply.github.com>

* fix(mypy): resolve type errors in public_endpoints, user_api_key_auth, common_utils, transformation

- public_endpoints.py: fix _cached_endpoints type annotation
- user_api_key_auth.py: accept Optional[str] for end_user_id parameter
- common_utils.py: add NewProjectRequest/UpdateProjectRequest to Union type
- transformation.py: add ChatCompletionRedactedThinkingBlock and list[Any] to content type

Co-authored-by: Ishaan Jaff <ishaan-jaff@users.noreply.github.com>

* fix(proxy-extras): bump version to 0.4.50 and sync schema

- Bump litellm-proxy-extras from 0.4.49 to 0.4.50
- Sync schema.prisma with main proxy schema
- Includes new LiteLLM_ClaudeCodePluginTable model
- Includes new @@index([startTime, request_id]) on SpendLogs
- Update version references in requirements.txt and pyproject.toml

Co-authored-by: Ishaan Jaff <ishaan-jaff@users.noreply.github.com>

* fix(router): use string id in test_add_deployment and add defensive str() in register_model

- Change test to use string '100' instead of int 100 for model_info.id
- Add str() conversion in register_model to prevent AttributeError on non-string keys

Co-authored-by: Ishaan Jaff <ishaan-jaff@users.noreply.github.com>

* fix(security): update minimatch to 10.2.4 to fix CVE-2026-27903 and CVE-2026-27904

- Run npm audit fix in docs/my-website
- Updates minimatch from 10.2.1 to 10.2.4 (fixes HIGH severity ReDoS vulnerabilities)

Co-authored-by: Ishaan Jaff <ishaan-jaff@users.noreply.github.com>

* fix(test): update realtime guardrail test assertions to match actual guardrail behavior

- test_text_message_blocked_by_guardrail_no_ai_response: allow guardrail's own block
  message text in response.done (previously expected empty content)
- test_voice_transcript_blocked_by_guardrail: allow guardrail to send response.cancel
  + block message + response.create flow (previously expected no response.create)

Co-authored-by: Ishaan Jaff <ishaan-jaff@users.noreply.github.com>

* fix: revert proxy-extras version in requirements.txt and pyproject.toml

The litellm-proxy-extras 0.4.50 is not published to PyPI yet, so consumer
references must stay at 0.4.49. Only the source package pyproject.toml
should be bumped to 0.4.50 for the publish_proxy_extras CI job.

Co-authored-by: Ishaan Jaff <ishaan-jaff@users.noreply.github.com>

* fix: make transcript delta check optional in voice guardrail test

The guardrail sends an error event (guardrail_violation) when blocking
voice transcripts; it does not always produce transcript deltas. Remove
the assertion requiring response.audio_transcript.delta since the error
event is the primary signal that blocked content was handled.

Co-authored-by: Ishaan Jaff <ishaan-jaff@users.noreply.github.com>

* Add missing env keys to documentation: LITELLM_MAX_STREAMING_DURATION_SECONDS and LITELLM_USE_CHAT_COMPLETIONS_URL_FOR_ANTHROPIC_MESSAGES

These two environment variables were used in code but not documented in the
environment variables reference section of config_settings.md, causing the
test_env_keys.py CI test to fail.

Co-authored-by: Ishaan Jaff <ishaan-jaff@users.noreply.github.com>

* Fix 13 mypy type errors across 6 files

- in_flight_requests_middleware.py: Fix type: ignore error codes from
  [union-attr] to [attr-defined], add [arg-type] for Gauge **kwargs
- transformation.py: Add [assignment] ignore for output_format reassignment,
  add fallback empty string for tool use id to fix arg-type
- responses/main.py: Remove redundant type annotation on second
  secret_fields assignment to fix no-redef
- streaming_iterator.py: Add [assignment] ignores for intermediate
  cache token assignments
- handler.py: Add [typeddict-item] ignore for AnthropicMessagesRequest
  construction from dict
- public_endpoints.py: Add [arg-type] ignore for _load_endpoints()
  return type mismatch with SupportedEndpoint model

Co-authored-by: Ishaan Jaff <ishaan-jaff@users.noreply.github.com>

* fix: add auth overrides to spend tracking tests, fix realtime guardrail assertion, update UI minimatch

- Add app.dependency_overrides for user_api_key_auth in 4 spend tracking tests
  that were returning 401 Unauthorized (error_code, error_message,
  error_code_and_key_alias, key_hash)
- Fix realtime guardrail test to check ANY error event for guardrail_violation
  instead of just the first (OpenAI may send its own errors first)
- Update ui/litellm-dashboard/package-lock.json to fix minimatch vulnerability

Co-authored-by: Ishaan Jaff <ishaan-jaff@users.noreply.github.com>

* Fix failing MCP e2e and create_mcp_server UI tests

Test 1 (test_independent_clients_no_shared_session):
- Add allow_all_keys: true to MCP servers in test config. With master_key
  and no DB, get_allowed_mcp_servers returned empty, causing 0 tools and
  403 on tool calls. allow_all_keys bypasses per-key restrictions.
- Add asyncio.sleep(0.5) between client connections to allow MCP SDK
  TaskGroup cleanup and avoid ExceptionGroup on connection close (MCP #915).

Test 2 (create_mcp_server 'auth value is provided'):
- Use userEvent.setup({ delay: null }) for instant keystrokes to avoid
  timeout from default typing delay on CI.
- Increase per-test timeout to 15000ms for CI environments.

Co-authored-by: Ishaan Jaff <ishaan-jaff@users.noreply.github.com>

* fix: stabilize proxy unit tests for parallel execution

- test_response_polling_handler: add xdist_group to prevent heavy import OOM
- test_db_schema_migration: use temp dir for worker isolation, sync schema.prisma index
- test_custom_tokenizer_bug: use lighter tokenizer to prevent OOM in parallel

Co-authored-by: Ishaan Jaff <ishaan-jaff@users.noreply.github.com>

* fix: add auth overrides to more spend tracking and model info tests

- Fix test_ui_view_spend_logs_pagination missing auth override (401)
- Fix test_view_spend_tags missing auth override (401)
- Fix test_view_spend_tags_no_database missing auth override (401)
- Fix test_empty_model_list.py to use app.dependency_overrides instead of patch()
  for FastAPI dependency injection auth

Co-authored-by: Ishaan Jaff <ishaan-jaff@users.noreply.github.com>

* fix(test): use patch.object for aiohttp transport test to work in parallel execution

The @patch decorator was not intercepting the static method call in parallel
xdist workers. Using patch.object on the directly-imported class is more reliable.

Co-authored-by: Ishaan Jaff <ishaan-jaff@users.noreply.github.com>

* fix(security): update minimatch from 10.2.1 to 10.2.4 in Dockerfile

The Docker image was explicitly pinning minimatch@10.2.1 which has HIGH
severity ReDoS vulnerabilities (GHSA-7r86-cg39-jmmj, GHSA-23c5-xmqv-rm74).
Update to 10.2.4 which includes fixes for both CVEs.

Co-authored-by: Ishaan Jaff <ishaan-jaff@users.noreply.github.com>

* fix(ui): prevent MCP and TeamInfo test timeouts on CI

- Add userEvent.setup({ delay: null }) to all tests using userEvent in both files
- Add timeout: 15000 to tests with significant user interaction (typing, multiple clicks)
- Fixes: create_mcp_server Bearer Token test, TeamInfo cancel button test

Co-authored-by: Ishaan Jaff <ishaan-jaff@users.noreply.github.com>

* fix: stabilize parallel test execution and aiohttp transport test

- test_aiohttp_handler: rewrite transport test to not rely on static method mock
  (consistently fails in parallel xdist workers)
- test_proxy_cli: add xdist_group to prevent timeout during heavy imports
- test_swagger_chat_completions: add xdist_group to prevent timeout

Co-authored-by: Ishaan Jaff <ishaan-jaff@users.noreply.github.com>

* fix(security): add serialize-javascript override to fix GHSA-5c6j-r48x-rmvq

Add npm override for serialize-javascript>=7.0.3 in docs/my-website
to fix HIGH severity RCE vulnerability via RegExp.flags.
Also bump minimatch override to >=10.2.4.

Co-authored-by: Ishaan Jaff <ishaan-jaff@users.noreply.github.com>

* Fix flaky tests: remove broken Vertex model, add retries for Anthropic

- Remove vertex_ai/meta/llama-4-scout-17b-16e-instruct-maas from
  test_partner_models_httpx_streaming - consistently returns 400 BadRequest
- Add @pytest.mark.flaky(retries=6, delay=10) to test_function_call_parsing
  for transient Anthropic API overload errors
- Add @pytest.mark.flaky(retries=6, delay=10) to test_openai_stream_options_call
  for transient Anthropic InternalServerError

Co-authored-by: Ishaan Jaff <ishaan-jaff@users.noreply.github.com>

* fix(ci): add xdist_group(proxy_heavy) to prevent OOM in parallel proxy tests

- Add pytestmark = pytest.mark.xdist_group('proxy_heavy') to test_proxy_utils.py
- Change test_db_schema_migration.py from schema_migration to proxy_heavy group
- Add @pytest.mark.xdist_group('proxy_heavy') to test_proxy_server.py::test_health

Groups heavy proxy tests to run on same worker, avoiding worker OOM crashes.

Co-authored-by: Ishaan Jaff <ishaan-jaff@users.noreply.github.com>

* Fix vertex AI qwen global endpoint test to mock vertexai module import

The test_vertex_ai_qwen_global_endpoint_url test was failing because the
VertexAIPartnerModels.completion() method tries to 'import vertexai' before
any of the mocked code runs. In environments without google-cloud-aiplatform
installed, this import fails with a VertexAIError(status_code=400).

Fix by:
- Adding patch.dict('sys.modules', {'vertexai': MagicMock()}) to mock the
  vertexai module import
- Adding vertex_ai_location parameter to the acompletion call for completeness

Co-authored-by: Ishaan Jaff <ishaan-jaff@users.noreply.github.com>

* fix(ci): add xdist_group to health endpoint and watsonx tests for parallel stability

- test_health_liveliness_endpoint: add xdist_group('proxy_health') to prevent timeout
- test_watsonx_gpt_oss tests: add xdist_group('watsonx_heavy') to prevent mock interference

Co-authored-by: Ishaan Jaff <ishaan-jaff@users.noreply.github.com>

* fix(test): pre-populate WatsonX IAM token cache to prevent parallel test interference

The watsonx prompt transformation test was failing in parallel execution because
litellm.module_level_client.post mock was being interfered with by other tests.
Pre-populating the IAM token cache avoids the HTTP call entirely.

Co-authored-by: Ishaan Jaff <ishaan-jaff@users.noreply.github.com>

* fix(test): add spend data polling with retries for e2e pass-through tests

- test_vertex_with_spend.test.js: Replace 15s fixed wait with polling loop
  (up to 6 attempts, 10s apart) for spend data to appear in DB
- Increase test timeout from 25s to 90s to accommodate polling
- base_anthropic_messages_tool_search_test.py: Add flaky(retries=3) for
  streaming test that depends on live Anthropic API

Co-authored-by: Ishaan Jaff <ishaan-jaff@users.noreply.github.com>

* fix(ci): reduce parallel workers from 8 to 4 for proxy tests to prevent OOM

- litellm_proxy_unit_testing_part2: -n 8 -> -n 4
- litellm_mapped_tests_proxy_part2: -n 8 -> -n 4, timeout 60 -> 120
- Worker crashes consistently caused by too many parallel proxy tests
  each loading the full FastAPI app and heavy dependency tree

Co-authored-by: Ishaan Jaff <ishaan-jaff@users.noreply.github.com>

* fix(db): add migration for SpendLogs composite index (startTime, request_id)

The @@index([startTime, request_id]) was added to schema.prisma but had no
corresponding migration. This caused test_aaaasschema_migration_check to fail
because prisma migrate diff detected the missing index.

Co-authored-by: Ishaan Jaff <ishaan-jaff@users.noreply.github.com>

* fix(db): add migration for MCP available_on_public_internet default change to true

The schema.prisma changed the default for available_on_public_internet from
false to true, but no migration was created. This caused the schema migration
test to detect drift.

Co-authored-by: Ishaan Jaff <ishaan-jaff@users.noreply.github.com>

* fix(test): increase server wait time and add retry to flaky external API tests

- test_basic_python_version.py: increase server startup wait from 60s to 90s
  for slower CI environments (fixes installing_litellm_on_python_3_13)
- test_a2a_agent.py: add flaky(retries=3, delay=5) for non-streaming test
  that depends on live A2A agent endpoint

Co-authored-by: Ishaan Jaff <ishaan-jaff@users.noreply.github.com>

* fix(test): add flaky retries to all intermittent external API tests for 0-fail CI

Co-authored-by: Ishaan Jaff <ishaan-jaff@users.noreply.github.com>

* fix(test): add auth overrides to file endpoint tests that return 500

The test_target_storage tests were getting 500 because the FastAPI auth
dependency wasn't overridden. Added app.dependency_overrides for proper
auth bypass in test environment.

Co-authored-by: Ishaan Jaff <ishaan-jaff@users.noreply.github.com>

---------

Co-authored-by: Cursor Agent <cursoragent@cursor.com>
Co-authored-by: Ishaan Jaff <ishaan-jaff@users.noreply.github.com>
2026-02-28 09:46:35 -08:00
..
fixtures test fix 2025-10-16 18:00:46 -07:00
realtime [Release Fix] (#22411) 2026-02-28 09:46:35 -08:00
test-skill [Feat] New API - Claude Skills API (Anthropic) (#17042) 2025-11-24 15:01:40 -08:00
test_llm_response_utils Merge remote-tracking branch 'origin/main' into litellm_perf_skip_throwaway_usage 2026-02-24 14:51:57 -08:00
test_skills_data Remove Apache 2 license from SKILL.md (#22322) 2026-02-27 19:33:55 -08:00
base_audio_transcription_unit_tests.py fix: use fastuuid helper (#14903) 2025-09-25 15:47:01 -07:00
base_embedding_unit_tests.py Litellm dev 12 25 2025 p2 (#7420) 2024-12-25 18:35:34 -08:00
base_llm_unit_tests.py fix img URL for tests 2025-11-22 09:41:15 -08:00
base_rerank_unit_tests.py [Feat] Add Nvidia NIM Rerank Support (#15152) 2025-10-02 18:58:52 -07:00
conftest.py [Perf] Improvements for Async Success Handler (Logging Callbacks) - Approx +130 RPS (#13905) 2025-08-23 13:13:23 -07:00
dog.wav (feat) Support audio param in responses streaming (#6312) 2024-10-18 19:16:14 +05:30
duck.png fix vertex ai multimodal embedding translation (#9471) 2025-03-24 23:23:28 -07:00
gettysburg.wav Litellm dev 12 25 2025 p2 (#7420) 2024-12-25 18:35:34 -08:00
guinea.png fix vertex ai multimodal embedding translation (#9471) 2025-03-24 23:23:28 -07:00
log.xt Litellm dev 04 05 2025 p2 (#9774) 2025-04-07 21:02:52 -07:00
Readme.md LiteLLM Minor Fixes & Improvements (11/29/2024) (#6965) 2024-12-01 05:24:11 -08:00
test_a2a.py [Feat] Allow calling A2A agents through LiteLLM /chat/completions API (#20358) 2026-02-03 12:52:33 -08:00
test_anthropic_completion.py Fix sonnet 3.7 tests 2026-02-20 17:29:16 -08:00
test_aws_base_llm.py Add support for AWS assume_role with a session token 2025-08-23 22:37:21 -07:00
test_azure_agents.py [Fixes] A2a Gateway - ensure azure foundry agents work (#17943) 2025-12-13 16:08:03 -08:00
test_azure_ai.py [Feat] v2 - Logs view with side panel and improved UX (#20091) 2026-01-30 18:34:13 -08:00
test_azure_o_series.py TestAzureOpenAIO3Mini 2025-12-20 23:18:19 +05:30
test_azure_openai.py fix: support prompt_cache_key for OpenAI and Azure chat completions (#20989) 2026-02-11 12:25:29 -08:00
test_bedrock_agentcore.py fix(agentcore): simplify agentcore streaming (#17141) 2026-01-19 05:20:24 -08:00
test_bedrock_agents.py test: skip test with invalid arn 2025-09-09 20:35:44 -07:00
test_bedrock_anthropic_regression.py Add Anthropic caching and context tests 2026-02-02 13:25:47 +05:30
test_bedrock_common_utils.py fix(bedrock): strip throughput tier suffixes from model names (#19147) 2026-01-15 18:43:10 -08:00
test_bedrock_completion.py fix: apply custom video pricing from deployment model_info (#21923) 2026-02-23 20:44:02 -08:00
test_bedrock_dynamic_auth_params_unit_tests.py Add comprehensive tests for AWS external ID support 2025-09-15 19:56:31 +02:00
test_bedrock_embedding.py [Fix] Bedrock Embeddings - Ensure correct aws_region is used when provided dynamically (#16547) 2025-11-12 12:38:58 -08:00
test_bedrock_govcloud.py feat(bedrock): Add Claude 4.5 to US Gov Cloud (#16957) 2025-11-21 19:06:26 -08:00
test_bedrock_gpt_oss.py test fix 2025-10-17 11:18:29 -07:00
test_bedrock_invoke_tests.py [Release Fix] (#22411) 2026-02-28 09:46:35 -08:00
test_bedrock_llama.py Add bedrock llama4 pricing + handle llama4 templating on bedrock invoke route (#10582) 2025-05-06 16:06:24 -07:00
test_bedrock_moonshot.py Add tests for kimi 2 bedrock model 2026-01-08 10:07:33 +05:30
test_bedrock_nova_embedding.py fix(cost-calc): use per-image pricing for Bedrock multimodal embeddings (#21646) 2026-02-20 08:51:21 -08:00
test_bedrock_nova_json.py Extract 'thinking' from nova response + Add 'drop_params' support for gpt-image-1 (#10680) 2025-05-08 23:01:38 -07:00
test_clarifai_completion.py (Refactor) Code Quality improvement - Use Common base handler for clarifai/ (#7125) 2024-12-09 21:04:48 -08:00
test_cloudflare.py (Refactor) Code Quality improvement - Use Common base handler for cloudflare/ provider (#7127) 2024-12-10 10:12:22 -08:00
test_cohere.py fix(tests): add flaky retries to flaky CI tests (#21795) 2026-02-21 11:56:29 -08:00
test_containers_api.py [Feat] Containers API - add new container API file management + UI Interface (#17745) 2025-12-09 17:33:26 -08:00
test_convert_dict_to_image.py Fix None values in usage field for gpt-image-1 model responses (#11448) 2025-06-05 13:19:18 -07:00
test_databricks.py fix: test_databricks_embeddings[True] 2026-01-06 14:20:30 +05:30
test_deepgram.py Litellm dev 12 28 2024 p3 (#7464) 2024-12-28 19:18:58 -08:00
test_deepseek_completion.py test_deepseek_mock_completion 2026-01-17 16:36:42 -08:00
test_elevenlabs.py Integrate eleven labs text-to-speech (#16573) 2025-11-24 18:49:30 -08:00
test_evals_api.py fix(tests): add flaky retries to flaky CI tests (#21795) 2026-02-21 11:56:29 -08:00
test_fireworks_ai_translation.py fix img URL for tests 2025-11-22 09:41:15 -08:00
test_gemini.py fix(tests): mock test_claude_tool_use_with_gemini to fix flaky CI (#21832) 2026-02-21 14:34:54 -08:00
test_gemini_image_usage.py fix: ci test 2026-01-17 09:17:31 +09:00
test_gigachat.py bugfix: Remove user messages merging 2026-02-03 12:58:28 +00:00
test_gpt4o_audio.py Add gemini audio input support + handle special tokens in sagemaker response (#9640) 2025-03-29 19:23:09 -07:00
test_groq.py Add grok reasoning content 2026-01-27 16:34:57 +05:30
test_hosted_vllm_embedding_e2e.py move e2e to llm translation 2026-02-17 22:33:13 +05:30
test_huggingface_chat_completion.py Revert "Revert "fix tests (#12286)"" 2025-07-03 12:08:27 -07:00
test_hyperbolic.py Revert "Litellm dev 07 21 2025 p1 (#12848)" 2025-07-22 18:28:36 -07:00
test_infinity.py [Feat] Use aiohttp transport by default - 97% lower median latency (#11097) 2025-05-23 22:55:35 -07:00
test_jina_ai.py Litellm 12 02 2024 (#6994) 2024-12-02 22:00:01 -08:00
test_lambda_ai.py [Performance] Use O(1) Set lookups for model routing (#13879) 2025-08-21 22:56:46 -07:00
test_langgraph.py [Feat] New Provider - add langgraph (#17783) 2025-12-10 12:30:35 -08:00
test_litellm_proxy_provider.py [Bug Fix] image_edit() function returns APIConnectionError with litellm_proxy - Support for both image edits and image generations (#13735) 2025-08-18 18:26:32 -07:00
test_minimax_tts.py Add support for minmax tts 2025-12-23 21:53:53 +05:30
test_mistral_api.py test: reduce mistral direct tests b/c of rate limit errors 2025-08-23 11:15:03 -07:00
test_model_cost_map_resilience.py [Stability] Investigate + fix issue where model cost map became poorly formatted (#20895) 2026-02-10 15:17:01 -08:00
test_morph.py fix morph api tests 2025-07-22 18:44:44 -07:00
test_nvidia_nim.py TestNvidiaNim 2025-12-13 16:38:11 -08:00
test_openai.py test_openai_codex_stream 2026-02-14 12:28:18 -08:00
test_openai_o1.py test_streaming_response 2025-10-31 19:10:38 -07:00
test_openrouter.py fix: ci test 2026-01-17 09:17:31 +09:00
test_optional_params.py Fix: add stop param as supported for openai and azure 2026-02-19 11:26:38 +05:30
test_perplexity_reasoning.py Revert "Update perplexity cost tracking (#15743)" (#16345) 2025-11-06 19:00:45 -08:00
test_prompt_caching.py (feat) openai prompt caching (non streaming) - add prompt_tokens_details in usage response (#6039) 2024-10-03 23:31:10 +05:30
test_prompt_factory.py Preserve forwarding server side called tools 2026-02-27 11:31:45 +05:30
test_replicate.py Add all replicate models in model cost map 2026-01-12 15:19:49 +05:30
test_rerank.py test_rerank_custom_callbacks 2025-11-01 09:25:29 -07:00
test_router_llm_translation_tests.py fix(tests): move test_router_azure_acompletion to llm_translation testing (#21837) 2026-02-21 14:41:53 -08:00
test_sambanova_chat_transformation.py [Bug fix] Fixes SambaNova API rejecting requests when message content is passed as a list format (#16612) 2025-11-13 17:03:14 -08:00
test_skills_api.py [Feat] New API - Claude Skills API (Anthropic) (#17042) 2025-11-24 15:01:40 -08:00
test_skills_e2e.py test_slack_gif_skill_creates_gif 2025-12-20 21:35:25 +05:30
test_snowflake.py snowflake test fix 2025-11-21 17:12:55 -08:00
test_text_completion.py Add inference providers support for Hugging Face (#8258) (#9738) (#9773) 2025-04-05 10:50:15 -07:00
test_text_completion_unit_tests.py fix(openai): use optimized async http client for text completions (#17831) 2025-12-11 14:54:26 -08:00
test_together_ai.py [Feat] Use aiohttp transport by default - 97% lower median latency (#11097) 2025-05-23 22:55:35 -07:00
test_triton.py fix(triton/completion/transformation.py): remove bad_words / stop wor… (#10163) 2025-04-19 11:23:37 -07:00
test_unit_test_bedrock_invoke.py [Oct Staging Branch] (#15460) 2025-10-17 17:52:25 -07:00
test_v0.py feat: add v0 provider support (#12751) 2025-07-18 18:26:44 -07:00
test_voyage_ai.py Add support for voyage-context-3 embedding model 2025-08-22 00:15:12 +05:30
test_watsonx.py chore: allow passing scope id for watsonx inferencing (#18959) 2026-01-14 03:47:20 +05:30
test_xai.py Fix usage in xai 2026-02-19 18:48:30 +05:30

Unit tests for individual LLM providers.

Name of the test file is the name of the LLM provider - e.g. test_openai.py is for OpenAI.