litellm/tests/unit/litellm_core_utils
joshua-berri f94c79290c
feat(ui): show an optional currency estimate on the Usage spend card (#51979)
* feat(ui): show the usage spend total in another currency at ECB reference rates

Adds GET /get/reference_exchange_rates, which returns the current ECB
reference rates as USD per unit for every feed currency. It refreshes at
most once a day under a lock, keeps fresh rates when a refresh fails and
answers 503 instead of serving rates older than seven days.

The usage overview's spend card gets a Spend display selector. It asks for
rates only once opened and then shows an estimated amount with the rate date
under the unchanged USD total. Every other figure stays in USD.

* fix(ui): fall back to USD when spend display rates stop being usable

The selector now shows USD whenever no estimate can be shown, so a failed
refetch never leaves EUR selected beside a USD-only notice, and an opened
selector refreshes its rates hourly. The endpoint gets its HTTP client
inside the async fetch so the client belongs to the serving event loop.

* fix(proxy): import the ECB rates endpoint HTTP client helper at module level

Binds get_async_httpx_client at import so its type is known. The client is
still built inside the awaited fetch on the serving event loop.

* fix(proxy): fetch display rates with a short-lived handler closed after each refresh

Builds an AsyncHTTPHandler inside the refresh fetch and closes it when the
fetch ends, and drops the descriptive comment on the spend display component.

* chore(ui): regenerate API types for the reference exchange rates endpoint

* fix(proxy): use the cached async client factory for display rate refreshes

Direct AsyncHTTPHandler construction fails the async client check, so the
refresh fetch goes back to get_async_httpx_client, called inside the awaited
fetch, with a named type suppression for the factory's untyped params.

* fix(ui): tidy spend display helper, hook options and fallback test

Groups the rate snapshot into one estimatedSpend argument, names the rates
query options, names the missing-estimate condition, and waits for the
unavailable notice before asserting the USD fallback.

* chore(ui): drop a restating comment on the spend estimate helper

* test(proxy): prove concurrent first rate requests share one ECB fetch

* fix(proxy): wait a minute before retrying a failed display rate refresh

A failed ECB refresh left rates due, so every request after it waited on
the lock and fetched again, and N queued callers paid N timeouts during an
outage. The endpoint now skips refreshing for 60 seconds after a failed
attempt, serving held rates or a 503, and retries on the first request
after that. Concurrent waiters share the failed attempt. Also drops the
usd_rates docstring.

* fix(ui): retry unavailable currency estimates on reopen

* refactor(ui): name the currency selector open handler

* style(ui): format currency selector props

---------

Co-authored-by: Joshua Valluru <326636767+joshua-berri@users.noreply.github.com>
2026-11-16 16:00:20 -08:00
..
audio_utils feat(realtime)!: support latest OpenAI audio models (#35600) 2026-11-03 07:27:52 +00:00
llm_cost_calc fix(model-prices): drop Flex prices from Vertex AI Gemini 4 Argon and Hydrogen (#51735) 2026-11-13 23:18:03 +00:00
llm_response_utils feat(github_copilot): support GitHub App authentication with PEM upload (#51427) 2026-11-14 10:33:20 -05:00
prompt_templates fix(bedrock): send s3:// image, document and video URLs to Converse as S3 sources (#50577) 2026-11-13 21:33:21 -08:00
specialty_caches
__init__.py
attribute_forwarder.py refactor(typing): clear 1181 basedpyright Any errors across 431 files (#47789) 2026-10-24 11:31:09 -07:00
conftest.py
event_loop_lag.py perf(token_counter): memoize token counts of long texts per tokenizer (#51904) 2026-11-16 19:21:55 +00:00
fake_secret_vault.py
messages_with_counts.py
test_agentic_followup_kwargs.py
test_allowed_tools_tool_choice.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_anthropic_dedup_factory.py
test_api_route_to_call_types.py fix(proxy): serve /a2a/{agent_id}/message/stream routes (#49471) 2026-10-31 16:11:51 -07:00
test_app_crypto.py
test_audio_utils.py fix(transcription): stop billing a FLAC with no sample count as 576 trillion seconds (#50842) 2026-11-10 06:19:33 +00:00
test_aws_partition.py feat(s3-log): replace the python s3_v2 logger with a rust callback (#51539) 2026-11-14 23:03:58 +00:00
test_batch_utils.py fix(proxy): rewrite batch JSONL alias rows to the deployment model on model-routed uploads (#51843) 2026-11-16 15:12:52 -08:00
test_bedrock_converse_dedup_factory.py
test_bug_report.py fix(proxy): cooldown errors carry 429, Sentry starts at boot without request bodies, tracing failures log at ERROR, exporter counters exported (#46344) 2026-10-16 00:53:52 +00:00
test_chat_completion_agentic_loop.py fix(openai): cap and bill web search rounds on Responses-pinned chat completions (#51802) 2026-11-14 14:36:10 -05:00
test_classifier_logging.py
test_cli_token_utils.py fix(cli): end the local login when lite logout cannot check the OS keychain (#50098) 2026-11-08 11:17:59 +00:00
test_cloud_storage_security.py fix(bedrock): send s3:// image, document and video URLs to Converse as S3 sources (#50577) 2026-11-13 21:33:21 -08:00
test_codestral_provider_routing.py
test_core_helpers.py fix(messages): hand rust only the anthropic metadata user_id (#51355) 2026-11-12 19:39:53 +00:00
test_coroutine_checker.py
test_cost_discount.py
test_custom_logger_registry.py
test_dd_tracing.py refactor(typing): clear about 1,100 basedpyright Any errors across 303 files (#49986) 2026-11-06 13:31:15 -08:00
test_decisions_pricing.py feat(decisions): add Parallel AI web-grounded decisions (#49188) 2026-11-03 04:47:02 +00:00
test_decode_special_tokens.py
test_default_encoding.py
test_dot_notation_indexing.py fix(proxy): count tokens with the thinking, effort, and tool_choice that inference sends (#51079) 2026-11-14 02:29:16 +00:00
test_duration_parser.py fix(budgets): match window starts to stored millisecond precision (#51921) 2026-11-16 04:02:44 +08:00
test_ecb_reference_rates.py feat(ui): show an optional currency estimate on the Usage spend card (#51979) 2026-11-16 16:00:20 -08:00
test_env_utils.py fix(router): cap the default OTPM reservation and reconcile token counters after each call (#49054) 2026-10-29 20:32:04 -07:00
test_error_normalization.py fix(anthropic): answer an upstream Anthropic 529 as 529 overloaded_error on /v1/messages (#46063) 2026-11-03 17:37:09 -08:00
test_exception_mapping_utils.py fix(azure): drop the traceback from stream-cut errors sent to clients and alerts (#51760) 2026-11-14 08:00:58 +00:00
test_extract_base64_image.py
test_fallback_generalizations.py fix(minimax): forward reasoning_effort instead of dropping it (#49583) 2026-11-09 14:03:50 -08:00
test_fallback_utils.py fix(sdk): stop global model_fallbacks from recursing on every completion call (#51817) 2026-11-14 16:28:38 -05:00
test_get_litellm_params.py feat(openai): bill gov.api.openai.com FedRAMP endpoint with 1.1x uplift (#49951) 2026-11-04 08:57:42 -08:00
test_get_llm_provider_endpoint_match.py
test_get_llm_provider_logic.py refactor(rust_bridge): route every Rust-to-Python call through host modules (#50822) 2026-11-11 01:57:54 +00:00
test_get_model_cost_map.py fix(cost-map): restore backward compatibility after the Rust loader move (#51545) 2026-11-14 08:12:17 +09:00
test_get_supported_openai_params.py fix(bedrock): backfill published regional service tier prices (#49113) 2026-10-29 19:46:57 -07:00
test_health_check_helpers.py fix(proxy): stop returning stack traces in health check errors 2026-11-16 14:01:24 +01:00
test_hidden_params.py perf(streaming): stop raising caught AttributeErrors inside pydantic on every streamed chunk (#49166) 2026-10-30 10:01:44 -07:00
test_image_handling.py fix(anthropic): send an https PDF image_url to Claude as a document (#49708) 2026-11-03 07:05:15 +00:00
test_initialize_dynamic_callback_params.py
test_internal_call_metadata.py fix(responses): resume background response streams with stream and starting_after (#48819) 2026-10-29 02:31:22 -07:00
test_json_fragment_accumulator.py test: deflake the json accumulator drain test and the armed routing prefetch test (#49505) 2026-10-31 15:14:33 -07:00
test_json_schema_validation.py
test_litellm_logging.py fix(logging): send one async success log per sync bridged Responses stream (#51787) 2026-11-14 07:25:03 -05:00
test_llm_judge.py fix(guardrails): resolve decision models in caller team scope (#46085) 2026-10-15 11:43:36 -07:00
test_llm_request_utils.py fix(aiand)!: show ai&'s name and logo, and sync ai&'s model list (#49158) 2026-10-30 10:55:26 -07:00
test_logging_callback_manager.py feat(custom-logger-v2): add the contract for rust callbacks and bind the proxy request scope (#51526) 2026-11-14 02:33:27 +00:00
test_logging_utils.py perf(logging): skip the base64 regex on plain text and copy a few large strings inline (#49228) 2026-10-31 01:03:04 -07:00
test_logging_worker.py fix(proxy): persist tag spend and drain success callbacks within the shutdown budget (#48988) 2026-10-29 09:32:18 -07:00
test_max_streaming_duration.py fix(router): log each dropped /v1/messages attempt through its own logging copy and open the retry without its usage (#45194) 2026-10-20 21:46:45 -07:00
test_model_cost_table.py refactor(rust_bridge): route every Rust-to-Python call through host modules (#50822) 2026-11-11 01:57:54 +00:00
test_model_latest_aliases.py chore(cost-map): rolling registry audit 2026-11-12 (#51395) 2026-11-12 08:03:26 -08:00
test_model_param_helper.py feat(realtime)!: support latest OpenAI audio models (#35600) 2026-11-03 07:27:52 +00:00
test_model_response_utils.py
test_moderation_standard_logging.py
test_oauth_token_exchange.py
test_offline_mode.py feat(proxy): add LITELLM_OFFLINE_MODE, one switch for the fetches LiteLLM makes on its own (#48096) 2026-10-23 16:54:19 -07:00
test_optional_imports.py
test_path_utils.py
test_private_json.py
test_provider_affinity.py fix(headroom): forward tenant-scoped session affinity (#49255) 2026-10-30 12:32:03 -07:00
test_provider_specific_headers.py
test_ptu_pricing.py feat(proxy): split Azure PTU deployments across teams with per-team PTU ceilings and PTU-hour reporting (#43043) 2026-10-15 18:44:30 +00:00
test_realtime_errors.py
test_realtime_guardrails.py fix(bedrock): run realtime guardrails on Nova Sonic sessions (#49833) 2026-11-06 13:18:48 -08:00
test_realtime_streaming.py fix(bedrock): run realtime guardrails on Nova Sonic sessions (#49833) 2026-11-06 13:18:48 -08:00
test_redact_messages.py fix(guardrails): log requests that a guardrail blocks on /apply_guardrail (#51014) 2026-11-16 15:18:08 -08:00
test_request_timeout_resolver.py
test_retry_after_headers.py
test_safe_divide_seconds.py
test_safe_json_dumps.py feat(accounting)!: make the SpendLogs ledger the default accounting path (#49872) 2026-11-05 09:14:10 -08:00
test_sensitive_data_masker.py
test_sentry_scrubbing.py fix(proxy): cooldown errors carry 429, Sentry starts at boot without request bodies, tracing failures log at ERROR, exporter counters exported (#46344) 2026-10-16 00:53:52 +00:00
test_served_output_texts.py fix(guardrails): scan and rewrite streamed /v1/completions under post_call guardrails (#49035) 2026-10-29 08:46:49 -07:00
test_stream_usage_logging.py
test_streaming_chunk_builder_cursor.py
test_streaming_chunk_builder_server_tool_use.py
test_streaming_chunk_builder_utils.py perf(streaming): extract usage once per chunk when assembling stream usage (#51903) 2026-11-14 22:31:39 -08:00
test_streaming_handler.py perf(token_counter): memoize token counts of long texts per tokenizer (#51904) 2026-11-16 19:21:55 +00:00
test_streaming_overhead.py
test_text_completion_conversion.py refactor(types): replace Any with proven types in 14 files (#48928) 2026-10-29 07:26:07 -07:00
test_thread_pool_executor.py
test_token_counter.py perf(token_counter): memoize token counts of long texts per tokenizer (#51904) 2026-11-16 19:21:55 +00:00
test_token_counter_tool.py
test_token_counter_tool_data.py
test_tokenizer.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_tool_fields.py fix(mcp)!: answer 400 for a hosted MCP tool a translated route cannot run, drop it under drop_params (#48931) 2026-11-02 13:13:03 -08:00
test_tool_search_spend_logging.py
test_total_deadline.py feat(proxy): total_timeout bounds a whole non-streaming request (#50496) 2026-11-08 00:43:50 -08:00
test_url_utils.py feat(proxy): authenticate billing metrics with a cognito bearer token (#49852) 2026-11-04 14:08:40 -08:00
test_xai_oauth_routing.py
weakly_parked_logger.py fix(logging): retain streaming success logging tasks until they finish (#52067) 2026-11-16 11:21:05 -08:00