Commit graph

48834 commits

Author SHA1 Message Date
mateo-berri
d594b9385e fix(drop_params): warn when a deployment or env drop_params value is not a flag
A deployment drop_params string that is not a flag value (a typo like ture) stayed silently off. The router now logs one warning per deployment. LITELLM_DROP_PARAMS and litellm_settings.drop_params share the same helper, so a non-flag value there warns as well instead of flipping silently from on to off
2026-09-07 21:05:01 -07:00
mateo-berri
91391c1360 fix(files): page every provider listing, answer deleted true for managed ids, and skip S3 walks for purposes Bedrock never stores
GET /v1/files through a provider config now returns the OpenAI page shape
(object list, data, first_id, last_id, has_more) instead of a bare array, and
DELETE /v1/files/{id} on a managed id answers the OpenAI FileDeleted shape with
deleted true instead of an empty body

Bedrock listing asks S3 for max-keys=0 when the purpose is one Bedrock never
stores under LiteLLM's prefixes, and batch_output listing no longer requires an
input bucket when only s3_output_bucket_name is configured. The mock request
behind the 400 for a foreign file id uses the same https://litellm.ai URL the
exception module uses
2026-09-07 20:48:38 -07:00
mateo-berri
415bdbfd8f fix(azure_ai): charge the Model Router fee once and correct catalog limits
The router fee was folded into azure_ai.cost_per_token and then added again
by the additional_costs hook, so every routed request paid it twice. The hook
now owns the fee, the entry named by the deployment supplies the price, and a
response priced as the router entry itself is not charged again

model-router, gpt-chat-latest and cohere-command-a carry the limits from the
Foundry models page, and model-router and grok-4-20-* carry their retirement
dates. The router tests now run at the completion_cost level with a Logging
object, which is the path the proxy takes, and fail at the merge base
2026-09-07 20:46:39 -07:00
Mateo Wang
9dbfb060bd
Merge pull request #39668 from BerriAI/litellm_lit6899_vertex_batch_tuned_endpoints
fix(vertex_ai): support fine-tuned Gemini endpoints in managed batches
2026-09-07 20:28:02 -07:00
Mateo Wang
ecd8bab0a6
Merge pull request #40195 from BerriAI/litellm_remove_static_cost_map_tests 2026-09-07 19:56:04 -07:00
mateo
adcfe8cb7f test: pin redirected xai slugs to the target's tier field set
Co-Authored-By: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com>
2026-09-08 02:44:52 +00:00
mateo
dc035cba62 test: preserve live xai pricing invariant
Co-Authored-By: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com>
2026-09-08 02:33:04 +00:00
mateo
5cfe20a68d test: collapse blank lines left by removed tests
Co-Authored-By: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com>
2026-09-08 02:21:55 +00:00
mateo
ac573fd66e test: remove remaining static cost assertions
Co-Authored-By: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com>
2026-09-08 02:20:39 +00:00
mateo
3023497590 test: drop static cost-map value assertions
Co-Authored-By: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com>
2026-09-08 02:19:32 +00:00
mateo-berri
dcd38ab9f0 fix(proxy): count failure and rate-limit input tokens off the event loop
The failure hook's usage estimate and the project ITPM reservation both
called litellm.token_counter inline on the event loop, so a large request
that failed or hit the limiter stalled the gateway the same way the
count_tokens endpoints did. Both now run through asyncify. The loop-lag
probe the existing tests used moves into a shared helper that warms the
tokenizer first, and two new tests fail when either count runs inline
2026-09-07 19:15:36 -07:00
mateo-berri
02b18b4fc6 fix(passthrough): match image URL schemes case-insensitively when counting relayed prompt tokens 2026-09-07 19:10:06 -07:00
mateo-berri
0c6d4c5399 feat(cost_map): say on the card that Last run is deployment-wide while provenance is per worker 2026-09-07 19:06:30 -07:00
mateo-berri
b7c2decb7d fix(drop_params): honor string values in litellm_params and the LITELLM_DROP_PARAMS env var
get_litellm_params normalizes drop_params once, so a client-body string and
router_settings.default_litellm_params reach the anthropic, bedrock, and
azure_ai gates as a bool. LITELLM_DROP_PARAMS=false now means off. A value
that is neither a flag nor a string logs one warning and counts as unset,
both in the deployment validator and in litellm_settings.
2026-09-07 19:00:47 -07:00
mateo-berri
6076e9f611 chore(cost_calc): drop the query count section label comment 2026-09-07 18:54:31 -07:00
mateo-berri
a601c00afd fix(bedrock): pass litellm_params into the Bedrock embedding call so drop_params reaches Marengo 3.0 2026-09-07 18:47:25 -07:00
yujonglee
13df85cceb
test: add Rust extension pytest contract (#40181)
* test: add Rust extension pytest contract

* test: prove native OCR execution

* test: isolate Rust extension pytest collection

* ci: register Rust extension test coverage

* test: prove native OCR at wire boundary
2026-09-07 18:46:29 -07:00
mateo-berri
9c980b96d6 fix(budget_reservation): exempt vertex and bedrock count-tokens routes from budget reservation
Some checks failed
LiteLLM Rust / rust-lint (push) Has been cancelled
LiteLLM Rust / rust-test (push) Has been cancelled
Terraform Modules / fmt, validate, test (aws) (push) Has been cancelled
Terraform Modules / fmt, validate, test (gcp) (push) Has been cancelled
Terraform Provider / gofmt, vet, build, test (push) Has been cancelled
Terraform Provider / Provider endpoints vs proxy OpenAPI schema (push) Has been cancelled
2026-09-07 18:44:04 -07:00
mateo-berri
80fea089b6 fix(bedrock): reject Marengo 2.7-only and misplaced media params on 3.0 unless drop_params
Marengo 3.0 requests now get a 400 naming any textTruncate, lengthSec,
useFixedLengthSec, or minClipSec parameter, and any video or audio option
sent with a text, image, text_image, or multi_input request, instead of
silently dropping them. drop_params (global, per deployment, or per
request) drops them instead. Pydantic validation errors name the field
and the reason, and the 3.0 marker is the exact "marengo-embed-3-" model
id segment.
2026-09-07 18:40:31 -07:00
mateo-berri
d238e60220 fix(bedrock): answer 400 for a file id outside the configured bucket and keep S3 error bodies 2026-09-07 18:38:25 -07:00
ryan-crabbe-berri
ba91588b15 fix(proxy): price one cost estimate at one moment
The totals, the per-token-type lines and the reported rates each resolved off-peak pricing on their own clock read, so a quote taken as a window opened could bill on one side of the boundary and report rates from the other. /cost/estimate now pins a billing moment for the whole quote, and every rate lookup answers for the pinned moment instead of reading the clock again

Claude-Session: https://claude.ai/code/session_011Tn3657NkV6ojLqewL64Kb
2026-09-07 18:38:12 -07:00
mateo-berri
12d9413860 refactor(passthrough): share the relay shape table and price FLUX 2 provider relays 2026-09-07 18:37:58 -07:00
mateo-berri
95402ccb71 test(azure_ai): move the Foundry catalog metadata test into the mapped azure_ai directory
The new metadata test sat at the top of tests/test_litellm. The azure_ai metadata tests live in tests/test_litellm/llms/azure_ai next to the cost calculator test, so this moves it there and bumps its repo-root lookup by the two extra directory levels. No test changes.
2026-09-07 18:36:40 -07:00
mateo-berri
0d89873daf test(token_counter): type the parametrized cap test arguments 2026-09-07 18:36:09 -07:00
mateo-berri
3829ebdce5 fix(token_counter): estimate over-cap strings from evenly spaced samples instead of the prefix
A string above TOKEN_COUNTER_MAX_EXACT_CHARS was counted from its first cap characters and scaled, so a string whose start tokenizes unlike its end got a skewed count, and that count reaches fallback billing when the provider sends no usage. The estimate now tokenizes 16 evenly spaced samples that together total the cap and scales their sum by the string's length, keeping the same bound on work while tracking the whole string
2026-09-07 18:26:23 -07:00
mateo-berri
bb52fd44fa fix(cost_map): label the card's loaded_at as per-worker and cover the integrity-failure fallback 2026-09-07 18:20:41 -07:00
mateo-berri
86790a7723 fix(bedrock): bill Marengo embeddings per request instead of per estimated token
AWS prices Marengo 2.7 and 3.0 text and image embeddings per request, never per
token, and their responses carry no token count. The old transform estimated
prompt tokens from the vector length, which billed a text request at 128 tokens
times the per-token rate (0.00896 instead of 0.00007). Marengo responses now
report zero tokens with query_count and image_count derived from the request
batch, and all six Marengo cost-map entries price per request (with the video
and audio per-second and per-image rates on the base entries). query_count is a
new prompt_tokens_details field wired to input_cost_per_query in the cost
calculator.
2026-09-07 18:20:28 -07:00
yucheng-berri
9bc9104102
fix(proxy): log budget reservation notice once at config load (#40167)
* fix(proxy): log disable_budget_reservation notice once at config load

The disabled-budget-reservation reminder fired as a WARNING inside request
authentication, so every authenticated request on a proxy that deliberately
set the flag produced one warning line. The notice now runs once per worker
when general_settings loads, at INFO, and the request path only skips the
reservation. Reservation skipping and read-time budget checks are unchanged

* fix(proxy): keep budget notice sentinel with constants

* fix(proxy): expose shared budget notice state
2026-09-07 18:18:28 -07:00
tin-berri
1761fe236f
feat(complexity_router): add declarative custom dimensions to the heuristic scorer (#40156)
Co-authored-by: Claude Code <noreply@anthropic.com>
2026-09-07 18:17:30 -07:00
mateo-berri
3b199cd3da fix(azure_ai): price seven Foundry catalog names and charge the model router fee once
Add cost map entries for azure_ai/gpt-chat-latest, codex-mini, whisper,
model-router, cohere-command-a, grok-4-20-reasoning, and
grok-4-20-non-reasoning, priced from the live Azure AI Foundry and Azure
OpenAI pricing pages and the Azure Retail Prices API.

Skip the model router flat fee when the response model is the router
entry itself, since the generic cost already priced that fee. Before,
azure_ai/model_router charged it twice.

Resolves LIT-3157
2026-09-07 18:11:58 -07:00
mateo-berri
486af36963 Merge remote-tracking branch 'origin/litellm_internal_staging' into litellm_lit_5546_count_tokens_offload 2026-09-07 18:11:29 -07:00
mateo-berri
17b7003592 fix(azure_ai): cost embeddings, responses, images, and rerank relays instead of logging zero 2026-09-07 18:11:17 -07:00
mateo-berri
170fece7db fix(token_counter): release the GIL for HuggingFace counts and cap exact counting per string
Both proxy token counting endpoints already count in a worker thread, but the
HuggingFace tokenizer's encode holds the GIL for the whole call, so a 600k-token
count on a Claude model still froze the event loop for up to 0.8 s and every
other request with it. Count through encode_batch_fast, which releases the GIL,
and tokenize at most TOKEN_COUNTER_MAX_EXACT_CHARS characters of any one string
(default 4,000,000), scaling the exact count of that prefix by the string's
length above it so the largest payloads stay bounded.
2026-09-07 18:08:25 -07:00
mateo-berri
2f397fa128 fix(drop_params): honor string flags in litellm_settings and responses, and fail open on non-flag values 2026-09-07 18:06:29 -07:00
tin-berri
7da6fe54b5
fix: skip one-shot Claude Code cache injection (#40175) 2026-09-07 18:03:43 -07:00
Mateo Wang
26d589cd28
Merge pull request #39234 from BerriAI/litellm_fix_agent_mcp_grants
fix(mcp): clear error when an agent-bound key is denied a scoped MCP server + agent MCP grants in the UI
2026-09-07 18:02:16 -07:00
mateo-berri
c698ddeacb fix(azure): let the caller's api-version win over the deployment's on passthrough relays 2026-09-07 18:00:48 -07:00
mateo-berri
69608a29db Merge remote-tracking branch 'origin/litellm_internal_staging' into litellm_lit_6975_bedrock_files_delete_list
# Conflicts:
#	litellm/proxy/openai_files_endpoints/common_utils.py
2026-09-07 17:58:02 -07:00
mateo-berri
6f99917b33 fix(router): rewrite multi-segment model groups as whole passthrough path segments 2026-09-07 17:57:54 -07:00
mateo-berri
192ea9ec80 fix(policy_engine): fail open on streaming shapes post_call pipelines cannot govern yet
A post_call pipeline now releases the original stream instead of refusing the
request on every shape it has no handler for: a background request, a pipeline
guardrail without the unified apply_guardrail interface, a route with no
endpoint translation, a buffered stream no translation resolves, and a rewrite
the translation cannot write back (tool-call edits, text edits on translations
without write-back, n>1 chat, an unended Anthropic stream, a Responses dump
with no event envelope). Each case logs a warning naming the policy and
guardrail. Real blocks and writable text masks are unchanged.
2026-09-07 17:55:37 -07:00
mateo-berri
e256039077 fix(bedrock): import assert_never from typing_extensions for Python 3.10 2026-09-07 17:49:03 -07:00
mateo-berri
9041768fb4 feat(cost_map): derive source_revision from the loaded bytes instead of a _metadata stamp
The revision an operator checks is now the git blob id of the exact bytes the process
loaded, the same id git rev-parse <commit>:model_prices_and_context_window.json prints,
so it is always present, never goes stale between bot writes, and needs no stamp in the
JSON that every PR touching the file would have to regenerate. The _metadata block, the
generated_at field, the schema and guard changes, and the bot stamping are dropped
2026-09-07 17:47:51 -07:00
mateo-berri
1d7e81cf5d fix(streaming): guard empty choices and missing role when assembling stream chunks 2026-09-07 17:47:06 -07:00
mateo-berri
fb7d06da4b test(budget_reservation): type the tiny-budget reservation helper 2026-09-07 17:45:53 -07:00
mateo-berri
22d7616fe7 Merge remote-tracking branch 'origin/litellm_internal_staging' into litellm_lit_7022_azure_ai_passthrough_config
# Conflicts:
#	tests/test_litellm/proxy/pass_through_endpoints/test_llm_pass_through_endpoints.py
2026-09-07 17:44:44 -07:00
mateo-berri
aa1c76bc3b test(cost_map): skip every reserved top-level key in the price map schema test 2026-09-07 17:28:59 -07:00
mateo-berri
6c1bba54c2 fix(ui): show a malformed generated_at stamp as-is on the Price Data Reload card 2026-09-07 17:28:58 -07:00
mateo-berri
6e93d23e1e Merge remote-tracking branch 'origin/litellm_internal_staging' into litellm_lit6552_fix_build_base_response_empty_choices 2026-09-07 17:28:18 -07:00
mateo-berri
dc09d9e7cf feat(bedrock): add TwelveLabs Marengo Embed 3.0 embeddings 2026-09-07 17:24:17 -07:00
mateo-berri
0d5ea553da Merge remote-tracking branch 'origin/litellm_internal_staging' into litellm_fix_post_call_policy_pipeline 2026-09-07 17:24:10 -07:00