litellm/tests/proxy_unit_tests
Darien Kindlund 17e145a083
fix(proxy): use model_group for model_max_budget spend tracking cache key (#25549)
The model_max_budget limiter tracks spend in one code path
(async_log_success_event) and enforces budget limits in another
(is_key_within_model_budget via user_api_key_auth). These two paths
used different model name formats to build cache keys:

- Tracking used standard_logging_payload["model"], which is the
  deployment-level model name (e.g. "vertex_ai/claude-opus-4-6@default")
- Enforcement used request_data["model"], which is the model group
  alias (e.g. "claude-opus-4-6")

Because the cache keys never matched, the enforcement path always read
None for current spend, silently allowing all requests through even
after the budget was exceeded. This affected any provider that decorates
model names with provider prefixes or version suffixes (Vertex AI,
Bedrock, etc.).

Fix: use model_group (the user-facing alias) from StandardLoggingPayload
for spend tracking, falling back to model when model_group is None.
This aligns the tracking cache key with the enforcement cache key.

Fixes the same root cause reported in #15223 and #10052.

Co-authored-by: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-04-11 19:37:58 -07:00
..
example_config_yaml test: test 2026-03-28 19:17:38 -07:00
test_configs test: test 2026-03-28 19:17:38 -07:00
test_model_response_typing
azure_fine_tune.jsonl
batch_job_results_furniture.jsonl
conftest copy.py
conftest.py
data_map.txt
eagle.wav
gettysburg.wav
large_text.py
messages_with_counts.py
model_cost.json
openai_batch_completions_router.jsonl
openai_batch_completions.jsonl
speech_vertex.mp3
test_aproxy_startup.py
test_audit_logs_proxy.py fix(tests): skip prisma DB test and sync root schema.prisma with spec_path field 2026-02-20 12:29:53 -03:00
test_auth_checks.py Fix: Anthropic model wildcard access issue 2026-02-23 17:12:55 +05:30
test_banned_keyword_list.py
test_blog_posts_endpoint.py fix: log fallback warning in blog posts endpoint and tighten test 2026-02-21 17:34:08 -08:00
test_check_batch_cost.py Fix flaky e2e batch test: set batch_processed=True on completion in retrieve_batch 2026-03-15 18:18:32 -07:00
test_check_responses_cost.py fix(test): update check_responses_cost tests for _expire_stale_rows 2026-04-07 10:09:11 -07:00
test_custom_callback_input.py
test_custom_logger_s3_gcs.py
test_custom_tokenizer_bug.py [Release Fix] (#22411) 2026-02-28 09:46:35 -08:00
test_db_schema_changes.py
test_db_schema_migration.py [Release Fix] (#22411) 2026-02-28 09:46:35 -08:00
test_default_end_user_budget_simple.py
test_deployed_proxy_keygen.py
test_e2e_pod_lock_manager.py fix(tests): skip more CI tests requiring external DB/Redis connections 2026-02-20 11:49:38 -03:00
test_get_favicon.py feat(proxy): add custom favicon support\n\nAdd ability to configure a custom favicon for the litellm proxy UI.\n\n- Add favicon_url field to UIThemeConfig model\n- Add LITELLM_FAVICON_URL env var support\n- Add /get_favicon endpoint to serve custom favicons\n- Update ThemeContext to dynamically set favicon\n- Add favicon URL input to UI theme settings page\n- Add comprehensive tests\n\nCloses #8323 (#21653) 2026-02-21 00:46:51 -08:00
test_get_image.py
test_google_endpoint_routing.py
test_google_gemini_proxy_request.py Revert "QA: improve gpt-5.4 code/bugs" 2026-03-13 10:15:47 -07:00
test_jwt_key_mapping.py fix: fix ci/cd + handle oidc jwt tokens 2026-03-30 16:12:58 -07:00
test_jwt.py retain ui_routes enum alias for JWT config backwards compatibility 2026-04-10 08:55:32 -07:00
test_key_generate_dynamodb.py
test_key_generate_prisma.py [Fix] /key/aliases: Add pagination and search to prevent OOMs 2026-02-25 17:55:26 -08:00
test_models_fallback_endpoint.py
test_prisma_client_backoff_retry.py
test_project_endpoints_prisma.py [Fix] Include created_at and updated_at in /project/list response 2026-02-27 15:41:03 -08:00
test_prompt_test_endpoint.py
test_proxy_config_unit_test.py
test_proxy_custom_auth.py
test_proxy_custom_logger.py
test_proxy_encrypt_decrypt.py
test_proxy_exception_mapping.py
test_proxy_gunicorn.py
test_proxy_pass_user_config.py test: test 2026-03-28 19:17:38 -07:00
test_proxy_reject_logging.py
test_proxy_routes.py tests and route permissions (#21508) 2026-02-18 16:58:38 -08:00
test_proxy_server_caching.py
test_proxy_server_keys.py
test_proxy_server_langfuse.py
test_proxy_server_spend.py
test_proxy_server.py Litellm ishaan april4 2 (#25150) 2026-04-04 23:09:42 +00:00
test_proxy_setting_guardrails.py
test_proxy_token_counter.py fix(tests): use unconditional skip for vertex/gemini token counting test 2026-02-20 11:36:54 -03:00
test_proxy_utils.py Litellm oss staging 04 02 2026 p1 (#25055) 2026-04-08 21:37:10 -07:00
test_realtime_cache.py
test_response_polling_handler.py Add incomplete response error propagation test 2026-03-17 11:39:12 -07:00
test_response_polling_pre_call_checks.py fix(test): rewrite polling pre-call guard test to call responses_api() directly 2026-03-19 14:30:29 +05:30
test_search_api_logging.py fix(tests): skip test_search_api_logging_and_cost_tracking - requires Prisma DB 2026-02-20 13:19:01 -03:00
test_server_root_path.py
test_skills_db.py fix(tests): skip CI tests requiring external services (DB, API keys) 2026-02-20 11:28:42 -03:00
test_ui_path_detection.py
test_unit_test_max_model_budget_limiter.py fix(proxy): use model_group for model_max_budget spend tracking cache key (#25549) 2026-04-11 19:37:58 -07:00
test_unit_test_proxy_hooks.py
test_update_daily_tag_spend.py cherry-pick: tag query fix + MCP metadata support (#25145) 2026-04-04 16:44:02 -07:00
test_update_spend.py
test_user_api_key_auth.py refactor: consolidate route auth for UI and API tokens 2026-04-09 21:36:35 -07:00
test_zero_cost_model_budget_bypass.py
vertex_key.json test: update to new vertex ai keys 2026-03-28 20:19:05 -07:00