mirror of
https://github.com/BerriAI/litellm.git
synced 2026-11-25 22:20:43 +00:00
* fix(proxy): size the budget hold for Gemini native generateContent bodies A Gemini contents body got no input-token count, so the pre-call budget hold fell back to the model's whole max_input_tokens window and an overlapping call on a budget-limited key got 422. The hold now counts text, function calls and declarations, responseSchema and inline audio by duration, reads the Gemini config output cap and candidateCount, and holds cachedContent at the cache-read rate. Images, PDF, video, fileData and server tools keep the whole-window hold. * fix(proxy): hold cached Gemini context at the deployment cache-read rate A model group behind a router has no cache_read_input_token_cost of its own, so the cachedContent hold fell back to the input rate and still exceeded small budgets. Read each deployment's cache-read rate and hold at the highest one * fix(proxy): count every field of a Gemini part and hold inline audio at its audio price A part that carries text beside a function call, a function response or inline audio now counts each field. A body with inline audio holds its input at the higher of the text and audio prices, counted at the audio rate of the Gemini model routing serves the name from. A cachedContent name only changes the hold on Gemini contents bodies, so chat and Responses holds stay as they were. * fix(proxy): hold Gemini thought signatures, long-prompt rates and extra_body overrides Count a returned thoughtSignature at its decoded size, since Gemini bills it as the earlier turn's thinking tokens Price a Gemini contents prompt at the _above_<n>_tokens rates its size reaches, and hold a cache that may hold audio at the audio cache-read rate Size the hold and the cancel floor from the body extra_body sends, and count a named cachedContent's window at the cache-read rate in the cancel floor too * fix(proxy): read above-threshold Gemini prices from each deployment A router model group's prices leave out the _above_<n>_tokens keys, so a cachedContent hold on a routed gemini-2.5-pro used the base cache-read rate. Read those keys from each deployment's prices too * fix(proxy): hold uncounted Gemini prompts at base prices and read every config name A Gemini body the proxy cannot count (media, file URIs, server tools) keeps main's base prices for its whole-window hold. The hold reads the output cap, candidate count and cachedContent from every config name the body sends and takes the largest, and an extra_body config replaces one sent under any name. The audio cache-read price is read from each deployment like the text one. * fix(proxy): hold the larger Gemini body when extra_body may be dropped A generateContent request with extra_body now holds the larger of the body with extra_body merged in and the body without it. A Gemini deployment merges it, while the completion adapter other providers use drops it, so a smaller extra_body can no longer shrink the hold of a request the provider gets in full. * fix(proxy): keep the uncapped hold when a Gemini config name sets no output cap * fix(proxy): keep a larger Gemini output cap when another config name sets none * fix(proxy): count a Gemini response schema under any config name in the budget hold * fix(proxy): count a Gemini body routed to a non-Gemini deployment as the chat request it becomes Size the config fields too, so a large response schema is counted off the event loop. * fix(proxy): let a Gemini body's deployments, not its counted name, pick the token count A mixed group holds the larger of the native and chat counts, media the chat counter cannot size keeps the whole window on the adapter route, and an inline PDF adds the chat route's per-file tokens * fix(proxy): keep an unsized Gemini count when the group's name points at another provider A contents body whose context-aware count is unknown (a server tool such as urlContext) was recounted by the group's name alone. For a group named gpt-4o or claude-sonnet-5-5 that Gemini serves, that recount went through the completion adapter, dropped the tool, and held a few tokens instead of the whole window. The precomputed counts now keep an unknown count as None, and the estimators only recount a model that has no precomputed entry. --------- Co-authored-by: mateo-berri <277851410+mateo-berri@users.noreply.github.com> |
||
|---|---|---|
| .. | ||
| native_budgets_golden | ||
| __init__.py | ||
| native_budgets_replica.py | ||
| test_background_interaction_settlement.py | ||
| test_baseline_accounting.py | ||
| test_budget_reservation.py | ||
| test_budget_reservation_redis_failure.py | ||
| test_budget_reservation_redis_failure_ledger.py | ||
| test_budget_reservation_rust.py | ||
| test_budget_reservation_rust_ledger.py | ||
| test_carried_budget_state.py | ||
| test_cloudzero_endpoints.py | ||
| test_committed_spend.py | ||
| test_compression_savings.py | ||
| test_cost_finalization.py | ||
| test_customer_budget_alerts.py | ||
| test_customer_cost_margin.py | ||
| test_customer_window_accounting.py | ||
| test_customer_window_accounting_rust.py | ||
| test_input_tokens.py | ||
| test_key_metadata_recovery.py | ||
| test_native_budget_checks.py | ||
| test_native_budgets.py | ||
| test_native_budgets_ledger.py | ||
| test_native_budgets_proxy_path.py | ||
| test_native_budgets_proxy_path_ledger.py | ||
| test_native_spend_log_row_type.py | ||
| test_performance_alerts.py | ||
| test_ptu_feature_flag.py | ||
| test_ptu_flat_cost_rollup.py | ||
| test_rust_spend_counters.py | ||
| test_savings.py | ||
| test_search_api_logging.py | ||
| test_session_page.py | ||
| test_session_spend_total.py | ||
| test_spend_capture_rate.py | ||
| test_spend_counter_batch.py | ||
| test_spend_counter_batch_ledger.py | ||
| test_spend_event.py | ||
| test_spend_event_producer.py | ||
| test_spend_log_error_logger.py | ||
| test_spend_logs_ledger_setting.py | ||
| test_spend_management_endpoints.py | ||
| test_spend_query_optimization.py | ||
| test_spend_tracking_utils.py | ||
| test_subscription_billing_periods.py | ||