Commit graph

6414 commits

Author SHA1 Message Date
Mateo Wang
12593788a2
Merge pull request #41949 from BerriAI/litellm_bulk_update_keys_keep_unset_fields
fix(proxy): /key/bulk_update writes only the fields each item carries
2026-09-19 06:08:54 -07:00
Mateo Wang
f15dba2e2f
Merge pull request #41943 from BerriAI/litellm_unknown_model_spend_logs_outside_router
fix(proxy): keep the raw client model out of spend logs for rejections outside the router
2026-09-19 05:15:26 -07:00
mateo-berri
dc02e5f5fb test(proxy): stub the existing key's team in the bulk item policy tests 2026-09-19 05:12:12 -07:00
mateo-berri
df6a222cb8 fix(proxy): validate bulk object_permission against the key's team as /key/update does 2026-09-19 04:59:26 -07:00
mateo-berri
aadadc647d Merge remote-tracking branch 'origin/main' into litellm_unknown_model_spend_logs_outside_router
# Conflicts:
#	litellm/proxy/openai_files_endpoints/common_utils.py
2026-09-19 04:43:19 -07:00
Mateo Wang
dad8c32d23
Merge pull request #41940 from BerriAI/litellm_rag_ingest_registry_store
fix(rag): resolve registry stores on /v1/rag/ingest and reject providers without ingestion
2026-09-19 04:42:54 -07:00
mateo-berri
e74a5e0c21 test(rag): drop the docstrings from the registered-store ingest tests 2026-09-19 04:10:49 -07:00
Mateo Wang
43e835c3ca
Merge pull request #41950 from BerriAI/litellm_cost_callback_bounded_error_msg
fix(proxy): keep request metadata out of the cost tracking failure alert
2026-09-19 04:08:14 -07:00
mateo-berri
d437cd662b fix(proxy): placeholder the metadata copied into a placeholdered row's stored request body 2026-09-19 03:56:44 -07:00
Mateo Wang
db04e7909e
Merge pull request #41934 from BerriAI/litellm_mistral_ocr_batches
feat(batches): support Mistral files/batches and per-page OCR batch cost tracking (internal copy of #40484)
2026-09-19 03:51:27 -07:00
Mateo Wang
aa3e6df086
Merge pull request #41926 from BerriAI/litellm_fix_41515
fix(proxy): register transcribe as a known provider for model grants
2026-09-19 03:47:36 -07:00
mateo-berri
b746ac4456 fix(proxy): accept object_permission on /key/bulk_update items instead of 422 2026-09-19 03:44:07 -07:00
mateo-berri
e2d118aaf8 fix(rag): read a registered S3 Vectors store's bucket and index from its id
A registered S3 Vectors store usually carries only its "bucket:index" id,
and the previous commit stopped forwarding the caller's bucket and index for
a managed store, so ingesting into one raised KeyError 'vector_bucket_name'.
The ingestion now derives both from vector_store_id with the rule the search
side already uses, explicit keys still winning. The caller's
litellm_credential_name is dropped for a managed store too, since it expands
into api_key and api_base, and max_embedding_requests_per_min joins the
per-upload options a caller may still set.
2026-09-19 03:38:20 -07:00
mateo-berri
ad4da0f8e6 chore(proxy): regenerate the lazy OpenAPI snapshot on Python 3.12 and drop a test helper docstring 2026-09-19 03:28:42 -07:00
mateo-berri
9e8a847c5b fix(proxy): keep request metadata out of the cost tracking failure alert
The cost tracking callback f-stringed chosen_metadata, litellm_metadata,
and old_metadata into the failed_tracking_spend alert on every failure,
at every log level, so one 250-byte request produced a 23 KB alert
carrying the client's metadata, headers, and key-auth reprs four times
over. The alert now carries the exception, the traceback, the model, and
the call type; the metadata keys are logged once at debug level through
lazy formatting, so nothing is built at warning level
2026-09-19 03:21:28 -07:00
mateo-berri
a49fbc6272 fix(proxy): keep the raw client model out of the stored request body when a spend row is placeholdered
With store_prompts_in_spend_logs on, the persisted request body kept the client's model string even when the row's model, model_group, and error text had been replaced by the unknown-model placeholder. The body's model now takes the same placeholder on those rows. Also annotates the new test locals with Final and wraps the four test lines that ran past 120 characters.
2026-09-19 03:20:31 -07:00
mateo-berri
bdbe265c70 fix(proxy): /key/bulk_update writes only the fields each item carries
A bulk item that carried only tags reached the DB with max_budget, team_id,
and budget_id as explicit nulls, wiping the key's budget and detaching it
from its team. The per-key update is now built from the fields the item
actually set, so a field left out keeps its value and an explicit null still
clears it, the same as /key/update. Items carrying a field the bulk path
cannot apply (object_permission and the like) are rejected with 422 instead
of being silently dropped.
2026-09-19 03:14:39 -07:00
mateo-berri
e327a6ae76 test(guardrails): drop regression docstrings from the api_version tests 2026-09-19 02:52:42 -07:00
mateo-berri
df3a37857c fix(proxy): keep a configured model group in spend logs when it fails before a deployment is picked 2026-09-19 02:48:30 -07:00
mateo-berri
24064e3b31 fix(guardrails): treat the stored Javelin api_version default as unset for Azure Content Safety
Guardrails created through POST /guardrails on older releases have api_version "v1" saved in the database, because the writer persists every default. Azure Content Safety never accepts that value, so those guardrails kept answering 404 after the default moved to None. The Azure base now resolves "v1" to 2024-09-01 the same way it resolves a missing value. Also restores the OpenAPI snapshot line that a Python 3.14 regeneration had dedented
2026-09-19 02:29:43 -07:00
mateo-berri
a98c48f933 fix(rag): keep only per-upload caller options when ingesting into a registered store 2026-09-19 02:22:34 -07:00
mateo-berri
2e3667b270 fix(proxy): keep the raw client model out of spend logs for rejections outside the router 2026-09-19 02:01:28 -07:00
mateo-berri
6f4d1c5911 fix(guardrails): stop the Javelin api_version default leaking into Azure Content Safety
LitellmParams mixes every provider config model into one class, so the
Javelin api_version default of "v1" reached the Azure Content Safety
guardrails whenever config.yaml omitted api_version and Azure answered 404.
The shared field now defaults to None, Javelin keeps filling in "v1" itself,
and the Azure guardrails fall back to the documented 2024-09-01 at request
time so a DB update that omits api_version stays on the default too.
2026-09-19 01:41:35 -07:00
mateo-berri
b60b513f6a fix(rag): resolve registry stores on /v1/rag/ingest and reject providers without ingestion
POST /v1/rag/ingest authorized the managed vector store the request
named but then handed the raw request options to the ingestion
pipeline, which defaults to OpenAI. A request naming only a registered
store id uploaded the document to OpenAI Files, got an OpenAI 400, and
answered HTTP 200 with status "failed"; naming azure_ai explicitly
escaped as a 500.

The store's provider and litellm_params now merge into the request the
way /v1/rag/query already does (store wins, None values dropped), the
merged provider is checked against the ingestion registry before any
upload so unsupported providers get a 400 naming the supported ones, and
persistence keeps reading the caller's original options so registry
credentials never reach the database. A registry store with no database
row is no longer written as a new row.
2026-09-19 01:37:50 -07:00
mateo-berri
7133baa777 fix(vector_stores): run the full model grant check on caller-supplied model hints
The vector-store file routes accept a model hint through the ?model= query
param and the x-litellm-model header. That hint was authorized with a hand
rolled check that covered only the key allowlist and the team allowlist, so
a key restricted by its project's model grant, a team-member restriction, or a
key config still routed through the hinted deployment. Greptile flagged the
gap as a P1 on the replacement PR.

The hint now goes through the same authorize_model_for_key path the batches
and files routes use, which runs can_key_call_resolved_model with every rule
the proxy enforces elsewhere. Keys those extra rules deny now get a 403 on
these routes. The two remaining behavioral differences are edge cases the
old check tolerated: a key whose team_models is set without a team_id no
longer runs the team allowlist, and a key with a config set skips the key
allowlist, both matching the rest of the proxy.

The regression test caches a project whose grant excludes the hinted model
and asserts the request is refused before any deployment lookup. The two
patch() calls on litellm.proxy.proxy_server carry a test-quality-ok reason
because can_key_call_resolved_model reads prisma_client and
user_api_key_cache through a lazy module import with no injection seam.
2026-09-19 00:54:41 -07:00
mateo-berri
0feca8641f fix(batches): price model-encoded batch retrievals by their deployment
A batch retrieved by its model-encoded id takes the direct (non-router) path,
which resolved credentials without stamping the deployment's model_info, so a
completed batch on a deployment with its own per-page pricing was billed at
the published rate with an empty model_id on the spend row.

Extract the router's credential lookup into get_credential_deployment and
stamp the resolved deployment's model_info onto the retrieve call the way the
router does for routed calls.
2026-09-19 00:30:15 -07:00
Mateo Wang
5f1268c056
Merge pull request #41933 from BerriAI/litellm_deliver_multi_choice_stream_rewrites
fix(policy_engine): deliver guardrail text rewrites on multi-choice, unfinished, and envelope-less streams
2026-09-19 00:22:02 -07:00
yucheng-berri
8afbc51cb7
Merge pull request #41685 from BerriAI/litellm_prompt_injection_llm_api_check_dispatch
* fix(proxy): dispatch llm_api_check moderation through during_call_hook

ProxyLogging.during_call_hook only ran async_moderation_hook for CustomGuardrail callbacks, so a
CustomLogger such as the prompt injection detector with llm_api_check enabled never called the
configured moderation model. Dispatch any CustomLogger that overrides async_moderation_hook and hand
the proxy router to every registered prompt injection detector at startup so that call can route

Co-Authored-By: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com>

* fix(enterprise): resolve openai_moderations model at call time and default to omni-moderation-latest

Co-Authored-By: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com>

* fix(proxy): keep queued moderation running past a V1 pre_call guardrail

A V1 CustomGuardrail with moderation_check pre_call returned out of
during_call_hook before asyncio.gather, abandoning already-queued
CustomLogger moderation coroutines and skipping every later callback.
Skip only that guardrail instead.

Co-Authored-By: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com>

* fix(utils): skip null tool_calls when formatting prompts for moderation hooks

Co-Authored-By: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com>

---------

Co-authored-by: yucheng <yucheng@berri.ai>
Co-authored-by: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com>
2026-09-18 23:53:14 -07:00
mateo-berri
4fe1549432 fix(policy_engine): keep the per-choice rebuilt response's choices a list so legacy hook rewrites survive the model_dump round-trip 2026-09-18 23:53:02 -07:00
Mateo Wang
56116079c8
Merge pull request #41930 from BerriAI/litellm_mat602_upstream_500_error_type
fix(exceptions): keep internal_server_error as the public type of an upstream 500
2026-09-18 23:19:52 -07:00
mateo-berri
b3d9ba9e7b fix(policy_engine): deliver guardrail text rewrites on multi-choice, unfinished, and envelope-less streams
Post-call pipeline rewrites on buffered streams failed open on three shapes:
chat streams with n > 1 (the rebuilt response collapsed every choice into
index 0), streams that ended without a finish marker, and Responses streams
whose final event carried no response envelope.

The chat handler now rebuilds the ended stream one choice index at a time and
writes each choice's rewrite back to that choice's buffered deltas. The
Anthropic handler writes an unended stream's rewrite across its text deltas.
The Responses handler spreads an envelope-less rewrite over the buffered
output_text events, still failing open when a scanned event cannot be placed.

Tool-call rewrites on n > 1 chat streams keep failing open.
2026-09-18 22:59:52 -07:00
Mateo Wang
4eb13a0b2a
Merge pull request #41843 from BerriAI/litellm_lit8064_unpin_derived_pricing
fix(proxy): unpin cost-map pricing copied into model_info and report pricing overrides
2026-09-18 22:58:04 -07:00
mateo-berri
5f6ffdc333 test: drop the docstring that restated the payload test's name 2026-09-18 22:48:42 -07:00
mateo-berri
5783a38e27 fix(proxy): enforce the unified batch model grant before the DB shortcut and skip it for registry-routed vector store models
retrieve_batch returned a terminal batch from the DB before checking that the key may use the model encoded in a unified batch id; the grant check now runs right after pre-call processing. The vector store file list helper authorized data["model"] through handle_model_based_routing even when the vector store registry set it server-side and even with no caller, which crashed on a None key; it now authorizes only a caller-supplied hint and resolves credentials directly.
2026-09-18 22:30:07 -07:00
mateo-berri
ddac683ec6 fix(exceptions): keep internal_server_error as the public type of an upstream 500
PR #40243 started carrying the upstream error body on InternalServerError so the Responses response.failed event can report the provider's code and message, and openai's APIError.__init__ took the body's type along with it. The proxy then answered an OpenAI-compatible upstream 500 with type server_error while a 502 and a 503 kept internal_server_error, and the integration contract in test_observed_routing.py went red. Pin the type the way RateLimitError pins throttling_error, keeping the body.
2026-09-18 22:28:58 -07:00
yuneng-jiang
12ddb35aad
Merge pull request #41924 from BerriAI/litellm_role_permissions_normalization
fix(proxy): parse role_permissions where it is read
2026-09-18 22:15:20 -07:00
mateo-berri
fb76b67e78 Merge remote-tracking branch 'origin/main' into litellm_mistral_ocr_batches
# Conflicts:
#	litellm/batches/batch_utils.py
2026-09-18 21:51:33 -07:00
Mateo Wang
078a60478f
Merge pull request #41485 from BerriAI/litellm_jwt_token_exchange_grant
feat(proxy): add RFC 8693 token exchange for IdP JWTs on the gateway token endpoint
2026-09-18 21:27:20 -07:00
Mateo Wang
b46612cfeb
Merge pull request #41893 from BerriAI/litellm_fix_responses_ws_encrypted_content_affinity
fix(responses): restore encrypted_content and apply affinity on the native WebSocket relay
2026-09-18 21:09:17 -07:00
Yuneng Jiang
044f88ee91
fix(proxy): register transcribe as a known provider for model grants
#41515 added the cost map entry transcribe/StartTranscriptionJob under a
new litellm_provider value "transcribe" without registering that provider
anywhere else, so litellm.models_by_provider had no "transcribe" key.

test_models_by_provider derives its provider set from the cost map itself,
so it went red on main. The user-visible half is that get_provider_models
returned None for the provider, which get_known_models_from_wildcard turns
into an empty list, leaving a transcribe/* key or team grant resolving to
no models.

Mirror the aws_polly registration: an enum member, a model set, an
ingestion branch, and a models_by_provider entry. Amazon Transcribe is
reached through the pass-through route rather than the Add Model form, so
it joins the frozen unlisted set the Add Model drift test tracks.
2026-09-18 21:04:25 -07:00
Yuneng Jiang
800b09ba41
Merge remote-tracking branch 'origin/main' into litellm_role_permissions_normalization 2026-09-18 21:00:23 -07:00
Yuneng Jiang
ef34e44d8b
fix(proxy): parse role_permissions where it is read
load_config used to return a local general_settings dict that it had
normalized in place, turning the configured role_permissions entries into
RoleBasedPermissions objects. It now returns the SettingsStore, which never
saw that write, so JWT auth received raw dicts and every request failed with
"'dict' object has no attribute 'role'" whenever role_permissions was set.

Convert the entries in the consumer instead, with a TypeAdapter, so the value
is parsed wherever it comes from. load_config keeps validating at boot, so a
malformed entry still fails startup rather than the first request.
2026-09-18 21:00:18 -07:00
Mateo Wang
c1de8665ff
Merge pull request #34267 from BerriAI/litellm_claude_code_gateway_protocol
feat(proxy): serve the Claude Code gateway protocol under /claude_code_gateway
2026-09-18 20:49:48 -07:00
kerry-berri
a1f3124e18
Merge pull request #41891 from BerriAI/litellm_overhead_window_from_proxy_receive
fix(timing): anchor response duration and overhead at proxy receive time
2026-09-18 20:01:31 -07:00
mateo-berri
9662b2a35c refactor(responses): type the websocket test parameters and suppress the error-frame send explicitly 2026-09-18 18:35:48 -07:00
ryan-crabbe-berri
4b4042c5d1
Merge pull request #41916 from BerriAI/litellm_team_admin_projects_permission
feat(proxy): let team admins manage projects via team_admin_editable_team_fields
2026-09-18 18:26:25 -07:00
mateo-berri
06a5594bb6 fix(claude_code_gateway): mint the bearer before consuming the device code so a signing failure never spends the login 2026-09-18 18:25:55 -07:00
mateo-berri
fcc7efa4db fix(responses): forward the routed input and report routing rejections on the websocket 2026-09-18 18:10:26 -07:00
mateo-berri
ca8062e506 fix(claude_code_gateway): keep the device secret out of the browser URL and validate the login before claiming it 2026-09-18 18:07:21 -07:00
kerry
a1560936f7 fix(timing): use epoch math for detailed pre-processing and drop client-supplied timing windows
Co-Authored-By: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com>
2026-09-19 01:06:53 +00:00