litellm/tests/llm_translation
Mateo Wang 33c363d4d4
Extend the record/replay proxy to chat, embeddings, moderations, rerank, and Anthropic (#29847)
* test(ci): extend record/replay proxy to chat, embeddings, moderations, rerank, anthropic

The record/replay proxy that took the gpt-image-1 spend E2E off the live OpenAI
path now fronts every provider, so the other real-provider E2Es stop paying for
and depending on live calls each commit. It keys per upstream and selects a
non-OpenAI provider by a /__recorder_upstream/<host>/ path prefix carried on the
model's api_base, since some litellm handlers (cohere rerank) drop custom
request headers. Wired into build_and_test (chat, embeddings, moderations,
image), the otel job (cohere rerank), and the anthropic-messages job via a
reusable start_openai_record_replay_proxy command.

Dropped the time.time()/uuid prompt cache-busters in the build_and_test chat
tests, whose config has the response cache off, so identical requests are
recordable. The image spend test now asserts a repeat call still bills spend,
failing loudly if the proxy response cache is ever turned on.

Responses, the anthropic passthrough, bedrock, and fake-endpoint tests are left
live: their lifecycles, api_base assertions, providers, or fake targets make a
stateless body-keyed cache either break them or add nothing.

* docs(ci): note the recorder command's OpenAI default upstream and prefix override

Addresses a review note: the shared start_openai_record_replay_proxy command
defaults the upstream to OpenAI, so a non-OpenAI model must carry the
/__recorder_upstream/<host>/ prefix on its api_base. Document that in the
command description so a future caller does not assume the default follows the
provider.
2026-06-06 14:33:42 -07:00
..
fixtures
realtime test: stabilize batch VCR coverage and stop live upload/network leaks (#29477) 2026-06-02 16:11:52 -07:00
reasoning_effort_grid fix(proxy): enforce allowed_passthrough_routes for auth=true pass-thr… (#29256) 2026-05-30 17:07:24 -07:00
test_llm_response_utils Litellm oss staging (#29492) 2026-06-02 08:48:10 -07:00
test_skills_data Remove Apache 2 license from SKILL.md (#22322) 2026-02-27 19:33:55 -08:00
test-skill
base_audio_transcription_unit_tests.py style: run black formatter on files from main merge 2026-04-17 13:02:59 -07:00
base_embedding_unit_tests.py
base_llm_unit_tests.py test(vcr): close out the remaining VCR live-call leaks (#29603) 2026-06-03 13:46:43 -07:00
base_rerank_unit_tests.py style: run black formatter on files from main merge 2026-04-17 13:02:59 -07:00
conftest.py test(vcr): close out the remaining VCR live-call leaks (#29603) 2026-06-03 13:46:43 -07:00
dog.wav
duck.png
gettysburg.wav
guinea.png
log.xt
Readme.md test: add 24hr Redis-backed VCR cache to additional test suites (#27159) 2026-05-05 15:13:31 -07:00
test_a2a.py style: run black formatter on files from main merge 2026-04-17 13:02:59 -07:00
test_anthropic_completion.py chore(ci): modernize model references in tests and configs (#27856) 2026-05-15 15:44:28 -07:00
test_aws_base_llm.py
test_azure_agents.py style: run black formatter on files from main merge 2026-04-17 13:02:59 -07:00
test_azure_ai.py test_completion_azure 2026-03-30 21:54:27 -07:00
test_azure_o_series.py [Fix] CI: Enable VCR replay for test_azure_o_series 2026-05-04 20:48:26 -07:00
test_azure_openai.py Litellm ishaan april15 2 (#25828) 2026-04-15 18:42:23 -07:00
test_bedrock_agentcore.py Revert "chore(tests): migrate Bedrock CI to AWS account 941277531214 (#28728)" (#29326) 2026-05-30 11:26:24 -07:00
test_bedrock_agents.py
test_bedrock_anthropic_regression.py fix(tests): replace deprecated Bedrock Claude 3.7 Sonnet model ID 2026-04-28 14:24:19 -07:00
test_bedrock_common_utils.py style: run black formatter on files from main merge 2026-04-17 13:02:59 -07:00
test_bedrock_completion.py test(vcr): close out the remaining VCR live-call leaks (#29603) 2026-06-03 13:46:43 -07:00
test_bedrock_dynamic_auth_params_unit_tests.py style: run black formatter on files from main merge 2026-04-17 13:02:59 -07:00
test_bedrock_embedding.py style: run black formatter on files from main merge 2026-04-17 13:02:59 -07:00
test_bedrock_govcloud.py style: run black formatter on files from main merge 2026-04-17 13:02:59 -07:00
test_bedrock_gpt_oss.py [Test] add request-body mock test for bedrock gpt-oss tool schema 2026-04-14 19:36:57 -07:00
test_bedrock_invoke_tests.py test(vcr): close out the remaining VCR live-call leaks (#29603) 2026-06-03 13:46:43 -07:00
test_bedrock_llama.py style: run black formatter on files from main merge 2026-04-17 13:02:59 -07:00
test_bedrock_mantle.py fix(bedrock-mantle): use /anthropic/v1/messages path for Mantle endpo… (#27976) 2026-05-15 13:31:59 -07:00
test_bedrock_moonshot.py [Test] Mock remaining live Bedrock Moonshot tests 2026-04-16 17:43:43 -07:00
test_bedrock_nova_embedding.py style: run black formatter on files from main merge 2026-04-17 13:02:59 -07:00
test_bedrock_nova_json.py style: run black formatter on files from main merge 2026-04-17 13:02:59 -07:00
test_cloudflare.py fix(cloudflare): support response_text in streaming chunk parser 2026-05-02 05:59:15 +00:00
test_cohere.py style: run black formatter on files from main merge 2026-04-17 13:02:59 -07:00
test_containers_api.py style: run black formatter on files from main merge 2026-04-17 13:02:59 -07:00
test_convert_dict_to_image.py style: run black formatter on files from main merge 2026-04-17 13:02:59 -07:00
test_crusoe.py fix(crusoe): remove trailing slashes from API base URLs and fix list indentation 2026-05-01 17:27:52 +05:30
test_databricks.py style: run black formatter on files from main merge 2026-04-17 13:02:59 -07:00
test_deepgram.py
test_deepseek_completion.py Litellm oss staging (#28161) 2026-05-18 16:27:44 -07:00
test_elevenlabs.py style: run black formatter on files from main merge 2026-04-17 13:02:59 -07:00
test_evals_api.py [Fix] Tests: Reduce VCR cassette bloat and fix multipart caching 2026-05-07 11:54:19 -07:00
test_fireworks_ai_translation.py Litellm oss staging 040626 (#29671) 2026-06-04 11:07:20 -07:00
test_gemini_image_usage.py style: run black formatter on files from main merge 2026-04-17 13:02:59 -07:00
test_gemini.py Litellm oss staging 030626 (#29578) 2026-06-03 11:01:51 -07:00
test_gigachat.py style: run black formatter on files from main merge 2026-04-17 13:02:59 -07:00
test_gpt4o_audio.py fix(tests): replace shut-down gpt-4o-audio-preview with gpt-audio-1.5 (#28281) 2026-05-19 14:48:30 -07:00
test_groq.py style: run black formatter on files from main merge 2026-04-17 13:02:59 -07:00
test_hosted_vllm_embedding_e2e.py style: run black formatter on files from main merge 2026-04-17 13:02:59 -07:00
test_huggingface_chat_completion.py
test_hyperbolic.py style: run black formatter on files from main merge 2026-04-17 13:02:59 -07:00
test_infinity.py style: run black formatter on files from main merge 2026-04-17 13:02:59 -07:00
test_jina_ai.py
test_lambda_ai.py style: run black formatter on files from main merge 2026-04-17 13:02:59 -07:00
test_langgraph.py style: run black formatter on files from main merge 2026-04-17 13:02:59 -07:00
test_litellm_proxy_provider.py fix(tests): replace deprecated Bedrock Claude 3.7 Sonnet model ID 2026-04-28 14:24:19 -07:00
test_minimax_tts.py style: run black formatter on files from main merge 2026-04-17 13:02:59 -07:00
test_mistral_api.py
test_model_cost_map_resilience.py style: run black formatter on files from main merge 2026-04-17 13:02:59 -07:00
test_morph.py style: run black formatter on files from main merge 2026-04-17 13:02:59 -07:00
test_nvidia_nim.py fix(tests): migrate realtime + rerank tests off shut-down upstream models (#28191) 2026-05-18 15:41:51 -07:00
test_openai_o1.py test(vcr): drop dead 'from respx import MockRouter' imports 2026-05-13 00:32:03 +00:00
test_openai_record_replay_proxy.py Extend the record/replay proxy to chat, embeddings, moderations, rerank, and Anthropic (#29847) 2026-06-06 14:33:42 -07:00
test_openai.py test(vcr): drop dead 'from respx import MockRouter' imports 2026-05-13 00:32:03 +00:00
test_openrouter.py Fix deprecated model test 2026-05-11 09:49:47 +05:30
test_optional_params.py chore(ci): modernize model references in tests and configs (#27856) 2026-05-15 15:44:28 -07:00
test_perplexity_reasoning.py style: run black formatter on files from main merge 2026-04-17 13:02:59 -07:00
test_prompt_caching.py test(vcr): drop dead 'from respx import MockRouter' imports 2026-05-13 00:32:03 +00:00
test_prompt_factory.py style: run black formatter on files from main merge 2026-04-17 13:02:59 -07:00
test_replicate.py style: run black formatter on files from main merge 2026-04-17 13:02:59 -07:00
test_rerank.py refactor: refactor testing 2026-03-28 18:39:32 -07:00
test_router_llm_translation_tests.py test: test 2026-03-28 19:17:38 -07:00
test_sambanova_chat_transformation.py style: run black formatter on files from main merge 2026-04-17 13:02:59 -07:00
test_skills_api.py style: run black formatter on files from main merge 2026-04-17 13:02:59 -07:00
test_skills_e2e.py style: run black formatter on files from main merge 2026-04-17 13:02:59 -07:00
test_snowflake.py Merge main and resolve Snowflake test conflict 2026-03-30 18:06:37 -07:00
test_text_completion_unit_tests.py style: run black formatter on files from main merge 2026-04-17 13:02:59 -07:00
test_text_completion.py
test_together_ai.py [Fix] TogetherAIConfig.get_supported_openai_params recursion 2026-04-16 17:20:58 -07:00
test_triton.py style: run black formatter on files from main merge 2026-04-17 13:02:59 -07:00
test_unit_test_bedrock_invoke.py style: run black formatter on files from main merge 2026-04-17 13:02:59 -07:00
test_v0.py style: run black formatter on files from main merge 2026-04-17 13:02:59 -07:00
test_vcr_classification.py test: stabilize batch VCR coverage and stop live upload/network leaks (#29477) 2026-06-02 16:11:52 -07:00
test_vcr_conftest_common_banner.py fix(tests/vcr): make Redis cassette cache replay deterministically (zero VCR misses on consecutive runs) (#28826) 2026-05-26 11:30:44 -07:00
test_vcr_filters.py fix(tests/vcr): mint Google OAuth tokens live to prevent stale-token replay (#29229) 2026-05-28 17:12:02 -07:00
test_vcr_redis_persister.py test(vcr): stop refreshing cassette TTL on read so cassettes lapse after 24h (#29784) 2026-06-05 10:22:41 -07:00
test_voyage_ai.py style: run black formatter on files from main merge 2026-04-17 13:02:59 -07:00
test_watsonx.py style: run black formatter on files from main merge 2026-04-17 13:02:59 -07:00
test_xai.py test(vcr): drop dead 'from respx import MockRouter' imports 2026-05-13 00:32:03 +00:00

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.

Redis-backed VCR cache

Every test in this directory is auto-decorated with @pytest.mark.vcr (via conftest.py). The first time a test runs we hit the live provider and record the HTTP exchange into Redis under litellm:vcr:cassette:<test_id>. Every subsequent run within 24h replays from Redis without touching the network. The 24h TTL means each new day's first run records again, so upstream API drift surfaces within a day.

The persister, header scrubbing, and 2xx-only filtering are defined in tests/_vcr_redis_persister.py. Files that already use respx (which patches the same httpx transport vcrpy does) are excluded from the auto-marker — see _RESPX_CONFLICTING_FILES in conftest.py.

The same VCR cache is used by other test directories that exercise live provider APIs. The reusable conftest plumbing lives in tests/_vcr_conftest_common.py and is wired into:

  • tests/llm_translation/
  • tests/llm_responses_api_testing/
  • tests/audio_tests/
  • tests/batches_tests/
  • tests/guardrails_tests/
  • tests/image_gen_tests/
  • tests/litellm_utils_tests/
  • tests/local_testing/ (covers local_testing_part1, local_testing_part2, litellm_router_testing, litellm_assistants_api_testing, langfuse_logging_unit_tests)
  • tests/logging_callback_tests/
  • tests/pass_through_unit_tests/
  • tests/router_unit_tests/
  • tests/unified_google_tests/

Test directories that run LiteLLM proxy in Docker (e.g. build_and_test, proxy_logging_guardrails_model_info_tests, proxy_store_model_in_db_tests) are intentionally not included: VCR.py patches the in-process httpx transport, so it cannot intercept the LLM calls that originate inside the Docker container.

Required environment

CASSETTE_REDIS_URL — separate Redis instance from the application Redis (REDIS_URL/REDIS_HOST) so test cassettes are not flushed by proxy tests. Provider credentials (ANTHROPIC_API_KEY, OPENAI_API_KEY, AWS_*, etc.) are needed only on cache-miss (the daily re-record), not on replay.

Flushing the cache

When you want the next run to re-record immediately instead of waiting for the 24h TTL:

make test-llm-translation-flush-vcr-cache

Disabling VCR

Skip the cache entirely (every call goes live, no recording):

LITELLM_VCR_DISABLE=1 uv run pytest tests/llm_translation/test_<file>.py