litellm/tests/unit
Claude f5abac6e62
refactor(cost): delete the Python token breakdown, billed-rate and savings formulas
get_token_type_cost_breakdown, get_billed_token_rates and
calculate_prompt_caching_savings keep their signatures for SDK callers, the
savings writer and the tests, but each is now one Rust price() call on the row
it names, mapped back to the old return. Their formula helpers are deleted:
_cost_map_billed_rates, _custom_pricing_rates, _cache_token_counts,
_reasoning_token_count, BilledTokenRates.scaled, calculate_cache_writing_cost,
billed_cache_read_rate, call_context and the provider-specific geo and speed
multipliers, along with the NativePrices, NativeCallContext and NativeQuote
bindings only they used.

The tests of calculate_cache_writing_cost now check the same cache write
lifetimes through the stored breakdown, and the Fable 5.2 fast mode test checks
the doubled price through Anthropic's cost_per_token instead of the deleted
multiplier helper.
2026-11-19 18:01:44 +00:00
..
a2a_protocol perf(token_counter): memoize token counts of long texts per tokenizer (#51904) 2026-11-16 19:21:55 +00:00
accounting feat(customer-portal): show token usage and cache costs (#52601) 2026-11-18 18:49:08 -08:00
anthropic_interface feat(anthropic): forward message threads on native /v1/messages (#50976) 2026-11-10 18:33:54 -08:00
batch_completion
batches feat(cost): price batch output lines in Rust, a whole file per crossing 2026-11-19 18:01:37 +00:00
caching fix(responses): stop the background stream when a polling response is cancelled (#49384) 2026-11-18 14:33:39 +00:00
completion_extras fix(responses): scope cacheable system input to stateless requests (#52694) 2026-11-18 17:24:52 -08:00
compression
containers refactor(router): delete the python router core, the rust core is the only core (#50178) 2026-11-05 10:40:46 -08:00
db_scripts chore: move scripts and runtime sources under litellm (#51006) 2026-11-12 04:19:57 +00:00
decisions fix(decisions): match OpenAI format answers to questions by name (#52597) 2026-11-18 12:55:45 -08:00
endpoints
enterprise feat(auth): read projects, tags, access groups and object permissions through rust repositories (#52178) 2026-11-18 22:32:06 +00:00
expected_fine_tuning_api
expected_responses_api_request
experimental_mcp_client
extraction
files
fine_tuning
fixtures
gateway feat(gateway): serve one native app in both modes, answering a master key caller's /v1/messages with it in front of Python (#52229) 2026-11-19 12:06:49 +09:00
google_genai fix(google_genai): honor snake_case generation_config on generateContent (#51139) 2026-11-18 03:47:08 +00:00
harness feat(harness): add typed agent evaluations (#52143) (#52174) 2026-11-17 02:35:52 +00:00
images fix: keep LiteLLM-internal params out of provider request bodies (#46083) 2026-11-16 22:20:05 -08:00
integration_support fix(db): fail rust pool acquires at once on a refusing postgres, with #52532 integration follow-ups (#52617) 2026-11-19 07:23:54 +09:00
integrations test: stabilize the flaky prompt cache detector unit tests (#52671) 2026-11-18 14:47:18 -08:00
interactions fix(interactions): retain async stream success logging task so it survives GC and shutdown drain (#52300) 2026-11-17 09:43:45 -08:00
litellm_core_utils refactor(cost): delete the Python token breakdown, billed-rate and savings formulas 2026-11-19 18:01:44 +00:00
litellm_proxy_extras fix(auth): index restricted end-user registry refreshes (#51772) 2026-11-17 15:15:46 -08:00
llms feat(cost): price every token call, session and Model Router fee from one Rust receipt 2026-11-19 18:01:44 +00:00
mcp_client ci(unit): cut unit check time with cheaper per-test resets and fewer non-unit tests (#51864) 2026-11-14 15:41:30 -08:00
models feat(alerts): add email labels, bulk actions and threshold editing (#52139) 2026-11-16 15:32:19 -08:00
ocr
passthrough fix(bedrock): forward x-pass- headers on the /bedrock/model pass-through routes (#50728) 2026-11-10 21:28:49 +00:00
proxy refactor(cost): keep the lint gates flat for the Rust-priced Messages hand-off 2026-11-19 15:59:40 +00:00
rag
realtime_api refactor(typing): clear 1141 basedpyright Any errors across 182 files (#50711) 2026-11-11 22:11:47 +00:00
redis fix(proxy): keep a customer budget reset from being undone by a stale hierarchy cache entry (#51694) 2026-11-13 14:21:20 -08:00
repositories feat(customer portal): set budgets per customer and gateway app (#52477) 2026-11-18 17:31:03 +00:00
rerank_api
responses fix(responses): log the resolved provider on Responses API calls (#52622) 2026-11-18 22:34:16 +00:00
router_rust feat(redis): serve the health checks' deployment states from a native store (#50357) 2026-11-13 03:22:28 +00:00
router_strategy feat(tts)!: stream audio from the provider as it arrives on /v1/audio/speech (#46222) 2026-11-17 15:03:12 +00:00
router_utils refactor(router): delete router code nothing calls (#52516) 2026-11-19 06:11:10 +09:00
rust_bridge refactor(cost): keep the lint gates flat for the Rust-priced Messages hand-off 2026-11-19 15:59:40 +00:00
sandbox
search feat(cost): price search calls in Rust 2026-11-19 18:01:26 +00:00
secret_managers chore: move workspace packages under litellm (#51000) 2026-11-12 04:19:57 +00:00
skills
systemone
telemetry
test_router test: pin RPM override test to a fixed minute (#52746) 2026-11-18 18:52:48 -08:00
text_completions fix(proxy): name the deployment in stream error alerts on chat, completions, responses and messages (#51034) 2026-11-11 22:50:23 +00:00
tracing
types feat(customer portal): set budgets per customer and gateway app (#52477) 2026-11-18 17:31:03 +00:00
vector_stores feat(vector_stores): add YAML-configured unified search fallbacks (#52093) 2026-11-18 08:41:02 -08:00
videos refactor(typing): clear 1141 basedpyright Any errors across 182 files (#50711) 2026-11-11 22:11:47 +00:00
__init__.py
AGENTS.md
conftest.py refactor(rust_bridge): route every Rust-to-Python call through host modules (#50822) 2026-11-11 01:57:54 +00:00
create_mock_standard_logging_payload.py
test_a2a_registry_lookup.py
test_acompletion_session_reuse_e2e.py
test_add_deployment_no_master_key.py
test_aembedding_session_reuse_e2e.py
test_anthropic_beta_gated_fields.py
test_anthropic_beta_headers_filtering.py fix(bedrock): forward the compact-2026-09-04 compaction param on Invoke /v1/messages (#51223) 2026-11-11 15:10:32 -08:00
test_anthropic_skills_transformation.py
test_assert_ci_coverage.py ci(unit): split proxy-infra-root in two, isolate subprocess tests, make its file exclusions take effect (#51316) 2026-11-11 17:39:10 -08:00
test_assert_secret_absent.py
test_assert_workflow_dir_hygiene.py
test_audio_transcription_rust_bridge.py
test_azure_ad_token_credential_resolution.py feat(proxy)!: only let clients pick S3 buckets the admin allowed (#47496) 2026-11-06 02:50:15 +00:00
test_azure_ai_grok_4_3_model_metadata.py
test_azure_ai_grok_4_6_model_metadata.py
test_baseten_glm_5_3_model_metadata.py
test_batch_completion_models_all_responses.py
test_bedrock_marengo_embed_3_model_metadata.py
test_build_core_distribution.py chore: move workspace packages under litellm (#51000) 2026-11-12 04:19:57 +00:00
test_cerebras_llama_model_metadata.py chore(cost-map): remove the 52 rows whose provider retired them before 2026 (#49974) 2026-11-03 16:23:06 -08:00
test_chat_ui_responses_session.py
test_check_licenses.py
test_check_mcp_operation_boundary.py chore: move scripts and runtime sources under litellm (#51006) 2026-11-12 04:19:57 +00:00
test_check_migrations_lock_timeout.py
test_check_migrations_no_data_rewrites.py
test_check_openapi_docs.py feat(proxy): support Cursor CLI subscriptions (#52205) 2026-11-16 21:49:12 -08:00
test_check_py310_typing_imports.py
test_check_test_quality.py chore: move scripts and runtime sources under litellm (#51006) 2026-11-12 04:19:57 +00:00
test_check_type_discipline.py chore: move scripts and runtime sources under litellm (#51006) 2026-11-12 04:19:57 +00:00
test_check_unbounded_in_lists.py
test_check_windows_wheel_install.py
test_ci_path_filter.py Skip unit-core shards for test-only pull requests (#52720) 2026-11-19 02:00:05 +00:00
test_claude_fable_5_config.py refactor(cost): delete the Python token breakdown, billed-rate and savings formulas 2026-11-19 18:01:44 +00:00
test_claude_haiku_5_5_config.py
test_claude_opus_4_6_config.py
test_claude_opus_4_8_config.py
test_claude_opus_5_config.py
test_claude_sonnet_5_config.py
test_cli_package.py chore: move workspace packages under litellm (#51000) 2026-11-12 04:19:57 +00:00
test_cloudflare_workers_ai_model_metadata.py
test_completion_timeout_resolution.py
test_compression.py
test_conftest_isolation.py refactor(model-cost): move the cost map inputs, fetch and register_model overlay into Rust (#50501) 2026-11-10 02:37:35 +00:00
test_constants.py
test_container_router.py
test_cost_calculation_log_level.py
test_cost_calculator.py feat(cost): price every token call, session and Model Router fee from one Rust receipt 2026-11-19 18:01:44 +00:00
test_cost_map_guard.py chore: move scripts and runtime sources under litellm (#51006) 2026-11-12 04:19:57 +00:00
test_count_tokens_public_api.py feat(mistral): add native upstream token counting support (#50652) (#50653) 2026-11-14 03:19:57 -05:00
test_dashscope_image_generation.py
test_daybreak_model_metadata.py
test_deepseek_model_metadata.py
test_default_branch.py chore: move scripts and runtime sources under litellm (#51006) 2026-11-12 04:19:57 +00:00
test_detect_changes.py Skip unit-core shards for test-only pull requests (#52720) 2026-11-19 02:00:05 +00:00
test_docker_entrypoint.py chore: move scripts and runtime sources under litellm (#51006) 2026-11-12 04:19:57 +00:00
test_docker_no_network_on_deploy.py chore: move deployment sources under litellm/deploy (#50981) 2026-11-12 04:19:56 +00:00
test_dockerfile_apk_repository.py chore: move deployment sources under litellm/deploy (#50981) 2026-11-12 04:19:56 +00:00
test_dockerfile_bedrock_realtime_extra.py chore: move deployment sources under litellm/deploy (#50981) 2026-11-12 04:19:56 +00:00
test_dockerfile_non_root.py chore: move deployment sources under litellm/deploy (#50981) 2026-11-12 04:19:56 +00:00
test_e2e_egress_sentinel.py
test_elevenlabs_tts_pricing.py
test_empty_mock_response.py
test_env_key_doc_gate.py chore: move workspace packages under litellm (#51000) 2026-11-12 04:19:57 +00:00
test_exception_exports.py
test_exception_header_preservation.py
test_exception_mapping_request_attribute.py
test_fake_openai_endpoint.py
test_filter_out_litellm_params.py
test_fireworks_serverless_model_costs.py
test_gate_slot_lock.py chore: move scripts and runtime sources under litellm (#51006) 2026-11-12 04:19:57 +00:00
test_gemini_3_1_flash_lite_image_pricing.py
test_gemini_4_argon_model_metadata.py
test_gemini_tts_native_audio_pricing.py
test_get_blog_posts.py chore(blog): refresh the bundled blog posts backup with the latest 50 posts from the docs RSS feed (#49971) 2026-11-03 23:41:15 +00:00
test_git_hooks.py chore: move scripts and runtime sources under litellm (#51006) 2026-11-12 04:19:57 +00:00
test_gpt_5_4_model_metadata.py
test_gpt_5_5_model_metadata.py
test_gpt_image_cost_calculator.py fix(cost): bill SVG authoring usage on OpenAI image responses (#52571) 2026-11-18 13:04:49 -08:00
test_gpt_realtime_mode.py chore(cost-map): remove the 52 rows whose provider retired them before 2026 (#49974) 2026-11-03 16:23:06 -08:00
test_groq_streaming_encoding.py
test_guardrail_exception_status_codes.py
test_guardrails.py Add guardrails.apply SDK helper (#49217) (#49469) 2026-10-31 23:37:45 +00:00
test_integration_run.py
test_internal_context.py refactor(router): delete router code nothing calls (#52516) 2026-11-19 06:11:10 +09:00
test_lazy_imports.py ci(unit): cut unit check time with cheaper per-test resets and fewer non-unit tests (#51864) 2026-11-14 15:41:30 -08:00
test_lint_base_counts.py chore: move scripts and runtime sources under litellm (#51006) 2026-11-12 04:19:57 +00:00
test_lint_workflow_diff_gates.py ci: fit the pull request gate into five minutes (#52660) 2026-11-18 14:41:04 -08:00
test_litellm_cli.py ci(unit): cut unit check time with cheaper per-test resets and fewer non-unit tests (#51864) 2026-11-14 15:41:30 -08:00
test_litellm_overhead.py
test_litellm_params_reserved_keys.py
test_logging.py chore: move workspace packages under litellm (#51000) 2026-11-12 04:19:57 +00:00
test_lowest_latency_zero_tokens.py
test_main.py fix(azure_ai)!: call Responses natively for a model router on a Foundry project or resource base (#52474) 2026-11-18 16:36:46 +00:00
test_main_module_header.py
test_mistral_large_4_model_metadata.py chore(cost-map): fill Bedrock regional and Azure Government pricing gaps, rolling registry audit 2026-11-18 (#52458) 2026-11-18 07:02:05 -08:00
test_mistral_medium_3_5_model_metadata.py
test_mistral_small_4_0_model_metadata.py
test_mistral_zai_glm_5_2_model_metadata.py
test_model_block_unblock.py
test_model_cost_aliases.py fix(cost-map): restore backward compatibility after the Rust loader move (#51545) 2026-11-14 08:12:17 +09:00
test_model_param_helper.py
test_model_prices_and_context_window.py chore(cost-map): fill Bedrock regional and Azure Government pricing gaps, rolling registry audit 2026-11-18 (#52458) 2026-11-18 07:02:05 -08:00
test_model_response_normalization.py
test_muse_ember_1_0_model_metadata.py feat(cost-map): add meta/muse-ember-1.0 with long-context rates from the Meta pricing page (#50847) 2026-11-10 06:36:06 +00:00
test_muse_spark_1_1_model_metadata.py
test_muse_spark_1_2_model_metadata.py
test_muse_spark_1_3_model_metadata.py
test_mutation_report.py chore: move scripts and runtime sources under litellm (#51006) 2026-11-12 04:19:57 +00:00
test_nested_drop_params.py
test_no_top_level_test_invocations.py refactor(rust_bridge): route every Rust-to-Python call through host modules (#50822) 2026-11-11 01:57:54 +00:00
test_non_chat_routes_open_llm_spans.py
test_openai_embedding_encoding_format_default.py
test_openai_record_replay_proxy.py
test_openai_service_tier_long_context_pricing.py
test_openapi_docs_gate.py chore: move scripts and runtime sources under litellm (#51006) 2026-11-12 04:19:57 +00:00
test_package_layout.py
test_package_metadata.py fix(packaging): keep the litellm-proxy package version in step with litellm (#51807) 2026-11-14 18:16:47 -08:00
test_pre_commit_lint.py chore: move scripts and runtime sources under litellm (#51006) 2026-11-12 04:19:57 +00:00
test_prisma_generate_if_needed.py chore: move scripts and runtime sources under litellm (#51006) 2026-11-12 04:19:57 +00:00
test_private_usage_aliases.py feat(model_capacity): replace the python dynamic rate limiter v3 with a rust callback (#51540) 2026-11-17 22:20:54 +00:00
test_process_helpers.py
test_project_alias_tracking.py
test_project_tags_pydantic.py
test_proxy_auth.py
test_pydantic_namespaces.py refactor(rust_bridge): route every Rust-to-Python call through host modules (#50822) 2026-11-11 01:57:54 +00:00
test_rag_openai_ingestion.py
test_rate_limit_error_unification.py feat(model_capacity): replace the python dynamic rate limiter v3 with a rust callback (#51540) 2026-11-17 22:20:54 +00:00
test_rate_limit_error_unification_rust.py feat(callbacks-parallel-request-limiter): port parallel request limiter v3 to a rust callback (#51537) 2026-11-16 22:56:38 -08:00
test_read_rc_version.py
test_recursive_detector.py chore: move workspace packages under litellm (#51000) 2026-11-12 04:19:57 +00:00
test_redact_string_in_error_paths.py refactor(router): delete the python router core, the rust core is the only core (#50178) 2026-11-05 10:40:46 -08:00
test_redis.py fix(redis): drop ssl_ kwargs from the async pool when ssl is off (#52344) 2026-11-17 13:23:34 -08:00
test_redis_credential_provider.py
test_register_model_custom_pricing.py fix(cost-map): restore backward compatibility after the Rust loader move (#51545) 2026-11-14 08:12:17 +09:00
test_register_model_zero_cost_persistence.py
test_replicate_model_key_format.py
test_responses_api_bridge_non_stream.py
test_responses_id_security.py fix(responses)!: authorize and decode comparison response IDs (#49402) 2026-11-03 03:40:46 +00:00
test_responses_streaming_container_ownership.py refactor(router): delete the python router core, the rust core is the only core (#50178) 2026-11-05 10:40:46 -08:00
test_retrieve_batch_bedrock_dispatch.py
test_router_block_helpers.py refactor(router): delete the python router core, the rust core is the only core (#50178) 2026-11-05 10:40:46 -08:00
test_router_exception_redaction.py
test_router_get_settings.py
test_router_google_genai.py
test_router_model_cost_isolation.py refactor(rust_bridge): route every Rust-to-Python call through host modules (#50822) 2026-11-11 01:57:54 +00:00
test_router_order_fallback.py refactor(router): delete the python router core, the rust core is the only core (#50178) 2026-11-05 10:40:46 -08:00
test_router_per_deployment_num_retries.py refactor(router): delete the python router core, the rust core is the only core (#50178) 2026-11-05 10:40:46 -08:00
test_router_redis_init.py
test_router_retry_backoff_headers.py refactor(router): delete the python router core, the rust core is the only core (#50178) 2026-11-05 10:40:46 -08:00
test_router_retry_non_retryable_errors.py refactor(router): delete the python router core, the rust core is the only core (#50178) 2026-11-05 10:40:46 -08:00
test_router_retry_policy_update.py refactor(router): delete the python router core, the rust core is the only core (#50178) 2026-11-05 10:40:46 -08:00
test_router_silent_experiment.py fix(router)!: stop a client's metadata flag from turning off silent_model mirroring (#52083) 2026-11-16 15:45:56 -08:00
test_router_streaming_fallback_metadata.py refactor(router): delete the python router core, the rust core is the only core (#50178) 2026-11-05 10:40:46 -08:00
test_router_weighted_failover.py refactor(router): delete the python router core, the rust core is the only core (#50178) 2026-11-05 10:40:46 -08:00
test_ruff_strict_gate.py chore: move config and docs off the repo root (#50966) 2026-11-11 18:29:35 -08:00
test_sambanova_model_metadata.py
test_scaledown_model_prices.py
test_scheduler.py refactor(rust_bridge): route every Rust-to-Python call through host modules (#50822) 2026-11-11 01:57:54 +00:00
test_secret_redaction.py perf(logging): scan opt-in spend-log tokens natively (#51770) 2026-11-15 06:09:02 +08:00
test_seed_tracing_fixtures.py chore: move scripts and runtime sources under litellm (#51006) 2026-11-12 04:19:57 +00:00
test_select_changed_tests.py Skip unit-core shards for test-only pull requests (#52720) 2026-11-19 02:00:05 +00:00
test_select_ui_test_scope.py
test_service_logger.py
test_setup_wizard.py
test_shared_session_integration.py
test_snowflake_model_prices.py chore(cost-map): rolling registry update, fal_ai kling v4, azure gpt-6-luna flex, snowflake, bedrock/mantle claude 5.5 (#52299) 2026-11-17 19:36:09 +00:00
test_socket_policy.py
test_spend_logs_guard.py chore: move scripts and runtime sources under litellm (#51006) 2026-11-12 04:19:57 +00:00
test_ssl_verify_unit.py
test_stream_chunk_builder_annotations.py
test_stream_chunk_builder_citations.py
test_stream_chunk_builder_images.py
test_streaming_connection_cleanup.py fix(aiohttp): reset the upstream connection when a stream closes early, so aborted Bedrock Invoke streams stop (#50657) 2026-11-14 12:08:03 -05:00
test_system_message_format_bug.py
test_test_quality_gate.py chore: move scripts and runtime sources under litellm (#51006) 2026-11-12 04:19:57 +00:00
test_thinking_enabled.py
test_together_ai_model_metadata.py feat(moonshot): add Kimi K3 and Together AI Inkling model support (#33922) 2026-11-18 16:26:14 +00:00
test_tool_loop.py fix(tool_choice): accept the Responses API's flat allowed_tools layout on chat completions (#50467) 2026-11-10 13:04:06 -08:00
test_type_check_gate.py chore: move config and docs off the repo root (#50966) 2026-11-11 18:29:35 -08:00
test_type_discipline_gate.py chore: move scripts and runtime sources under litellm (#51006) 2026-11-12 04:19:57 +00:00
test_typesafe_model_metadata.py
test_unit_shard_missing_paths.py
test_unit_shard_per_test_timeout.py
test_utils.py fix(gemini): send minimal thinking to Nano and drop settings image models refuse (#52514) 2026-11-18 22:33:34 +00:00
test_utils_get_model_info.py feat(cost-map): price Claude on Bedrock Mantle under bedrock_mantle/ and bedrock/mantle/ (#52231) 2026-11-17 07:12:16 +00:00
test_utils_get_optional_params.py fix(cohere)!: map tool_choice, reasoning_effort and json_schema response_format on the v2 chat route (#50834) 2026-11-17 18:10:37 +00:00
test_utils_module_docstring.py
test_uuid_helper.py
test_vcr_classification.py
test_vcr_conftest_common_banner.py ci: remove CircleCI (#50950) 2026-11-11 15:38:27 -08:00
test_vcr_filters.py
test_vcr_leak_guard.py
test_vcr_redis_persister.py
test_vcr_safe_body_matcher.py
test_version.py
test_vertex_ai_xai_grok_prompt_caching_metadata.py
test_video_generation.py fix(cost): keep a deployment's per-second video price over the catalog row's flat price (#51688) 2026-11-15 12:04:41 -08:00
test_with_dashboard_node.py chore: move scripts and runtime sources under litellm (#51006) 2026-11-12 04:19:57 +00:00
test_ws_vcr.py
test_xai_grok_4_3_model_metadata.py
test_xai_responses_auto_routing.py
whitelisted_bedrock_models.txt chore(cost-map): fill Bedrock regional and Azure Government pricing gaps, rolling registry audit 2026-11-18 (#52458) 2026-11-18 07:02:05 -08:00