Commit graph

8121 commits

Author SHA1 Message Date
Sameer Kankute
4523f6af3d
fix(embeddings): allow omitting encoding_format via env sentinel none
Greptile: LITELLM_DEFAULT_EMBEDDING_ENCODING_FORMAT=none (case-insensitive)
strips encoding_format so OpenAI-compatible backends can use provider defaults.
Preserves optional_params passthrough when env is unset.

Co-authored-by: Cursor <cursoragent@cursor.com>
2026-05-01 23:03:13 +05:30
Cursor Agent
7deac91a92
Fix Vertex batch custom id labels 2026-05-01 17:29:50 +00:00
Sameer Kankute
8300657af9
fix(mcp): preserve oauth2 m2m auth for tools routes (#26871)
* Fix tool/list M2M creds issue

* Fix tool call creds issue

* Fix greptile review

* Fix lint

* Fix lint

* Fix lint

* Fix lint
2026-05-01 10:26:10 -07:00
Cursor Agent
97cfb4f6fd
Unify secret redaction patterns 2026-05-01 17:24:21 +00:00
Mateo Wang
a155ea1e8a
Merge pull request #26076 from BerriAI/litellm_vertex_model_garden_xai_openapi
feat(vertex_ai): Model Garden OpenAPI for publisher model ids
2026-05-01 10:15:58 -07:00
harish-berri
32ab390e7e
Merge pull request #26202 from BerriAI/litellm_token_verification_query_opt
Litellm token verification query optimization
2026-05-01 10:10:07 -07:00
Mateo Wang
026ee8839c
Merge pull request #25270 from BerriAI/litellm_oss_staging_04_06_2026 2026-05-01 08:04:25 -07:00
Cursor Agent
fca21a979c
Fix org MCP permission ceiling escalation 2026-05-01 14:54:29 +00:00
Mateo Wang
6552e3c5c0
Merge pull request #26402 from BerriAI/litellm_azure-container-file-routing-fix 2026-05-01 07:50:37 -07:00
Mateo Wang
dddbfd54a1
Merge pull request #26950 from BerriAI/litellm_batch_model_id_mapping 2026-05-01 07:47:47 -07:00
Sameer Kankute
8b85deb1df
Merge pull request #26985 from BerriAI/litellm_internal_staging
merge main
2026-05-01 19:07:11 +05:30
Sameer Kankute
a94ae62706
Merge pull request #26984 from BerriAI/litellm_internal_staging
merge main
2026-05-01 19:03:59 +05:30
Sameer Kankute
0a9c076e8b
Fix greptile review 2026-05-01 18:28:24 +05:30
Sameer Kankute
19813527fa
feat(vertex_ai): Model Garden OpenAPI for publisher model ids
- Route publisher/model ids (e.g. xai/grok) to .../endpoints/openapi; keep model in JSON body
- Add model_prices keys for vertex_ai/openai/xai/grok-*
- Document xAI Grok on vertex_partner (aligned with GPT-OSS)
- Add tests for create_vertex_url and body-model heuristic

Made-with: Cursor
2026-05-01 18:05:08 +05:30
Sameer Kankute
5feb6008d8
Fix greptile review 2026-05-01 17:56:37 +05:30
Emmanuel Acheampong
6e1e6244cf
fix(crusoe): remove trailing slashes from API base URLs and fix list indentation
Trailing slashes on custom API base examples cause double-slash in
get_complete_url. Also fixes inconsistent list indentation in
test_crusoe_models_configuration.
2026-05-01 17:27:52 +05:30
Emmanuel Acheampong
2805572e9b
fix(crusoe): add param_mappings for max_completion_tokens → max_tokens
Crusoe's vLLM-based endpoint accepts max_tokens, not max_completion_tokens.
Without this mapping, callers using the OpenAI-standard param would get errors.
2026-05-01 17:27:52 +05:30
Emmanuel Acheampong
9039eb1898
fix(crusoe): fix docs trailing slash, test state pollution, missing __init__.py
- Remove trailing slash from docs Base URL to match providers.json
- Wrap model_cost mutations in try/finally to prevent test state leakage
- Add missing __init__.py to crusoe test package
2026-05-01 17:27:52 +05:30
Emmanuel Acheampong
d7313496f3
fix: remove trailing slash from CRUSOE_API_BASE and unused sys import 2026-05-01 17:27:52 +05:30
Emmanuel Acheampong
6ae7929d7c
Apply suggestion from @greptile-apps[bot]
Co-authored-by: greptile-apps[bot] <165735046+greptile-apps[bot]@users.noreply.github.com>
2026-05-01 17:27:52 +05:30
Emmanuel Acheampong
d492d8fe82
refactor(crusoe): simplify to JSON-based provider registration
Replace hand-written CrusoeChatConfig class and manual registrations
across constants.py, __init__.py, get_llm_provider_logic.py, and
_lazy_imports_registry.py with a single entry in
litellm/llms/openai_like/providers.json, consistent with the
recommended pattern for OpenAI-compatible providers.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-05-01 17:27:52 +05:30
Sameer Kankute
ed853e138f
Fix code qa 2026-05-01 17:26:46 +05:30
d 🔹
9d6983c4c0
fix(gemini): handle Gemini Files API URIs without fetching (#24922)
* fix(gemini): handle Gemini Files API URIs without fetching

Fixes #24907

When a file is uploaded via the Gemini Files API, the returned URI
(https://generativelanguage.googleapis.com/v1beta/files/...) starts
with 'https://' and hits the generic HTTPS handler in
_process_gemini_media(). That handler calls
_get_image_mime_type_from_url() which tries to fetch the URL — but
Gemini Files API URLs return 403 when accessed directly, causing:
  'Unable to determine mime type for file_id: ...'

Fix: add an early elif that matches Gemini Files API URLs and passes
them through as file_data without trying to fetch the URL. When an
explicit format is provided it's included; otherwise the Gemini API
infers the MIME type from its stored metadata.

Exactly matches the fix direction suggested by the issue reporter
(rodriciru).

* fix: anchor Gemini Files API URL check with startswith

Address greptile P2: replace `in` substring check with `startswith`
to prevent query-string injection bypass (e.g.
`https://evil.com/?ref=https://generativelanguage...`).

Also adds trailing slash to match only valid file URIs.

---------

Co-authored-by: voidborne-d <voidborne-d@users.noreply.github.com>
2026-05-01 17:26:45 +05:30
milan-berri
7e58c7139a
fix(proxy): include team membership budget in combined_view for RPM/TPM (#24925)
Join LiteLLM_BudgetTable as b_tm on team membership budget_id and select
team_member_tpm_limit / team_member_rpm_limit so virtual key auth populates
limits for parallel_request_limiter_v3.

Add test_team_member_rate_limits_v3_raises_429_when_over_limit mirroring
existing key-level OVER_LIMIT / HTTP 429 coverage.

Made-with: Cursor
2026-05-01 17:26:45 +05:30
michelligabriele
1b6914d44c
fix(cost): pass service_tier through azure and azure_ai cost calculation (#24926)
service_tier (priority/flex) was not forwarded to generic_cost_per_token
for azure and azure_ai providers, so tier-specific pricing was ignored
and standard pricing was always returned. Other providers (openai,
bedrock, gemini, vertex_ai) already pass it correctly.
2026-05-01 17:26:45 +05:30
Mathieu St-Vincent
49ec6aba80
feat: add Qohash Nexus guardrail hook (#24927)
* feat: added Qohash Nexus guardrail hook

* fix: ui_friendly_name of Qostodian Nexus

* Update litellm/proxy/guardrails/guardrail_hooks/qohash/qohash.py

Co-authored-by: greptile-apps[bot] <165735046+greptile-apps[bot]@users.noreply.github.com>

* Update litellm/proxy/guardrails/guardrail_hooks/qohash/qohash.py

Co-authored-by: greptile-apps[bot] <165735046+greptile-apps[bot]@users.noreply.github.com>

---------

Co-authored-by: greptile-apps[bot] <165735046+greptile-apps[bot]@users.noreply.github.com>
2026-05-01 17:26:32 +05:30
Vedanshu Joshi
f46074664e
fix(llm translation): redact Gemini API key from URL query params in error traces (#24943)
* fix(proxy): use actual request start_time for failed spend logs

async_post_call_failure_hook was calling datetime.now() for both
start_time and end_time, making every failed request show Duration: 0.000s.

litellm_logging_obj (already fetched in the same method for trace ID
propagation) carries the real request start_time — use it as
actual_start_time with a datetime.now() fallback when absent.

Add two regression tests covering the fix and the fallback path.

Fixes #24888

* fix(llm translation): redact Gemini API key from URL query params in error traces

Gemini API requests authenticate via a ?key=<api_key> URL query param.
When a provider call fails, httpx.Response.raise_for_status() embeds the full
URL in the error message, leaking the key in exception traces and logs.

Changes:
- Extract secret-redaction logic from litellm/_logging.py into a new public
  utility module litellm/litellm_core_utils/secret_redaction.py, exposing
  redact_string() as a proper public API instead of a private helper
- Add (?<=[?&])key=[^\s&'"]{8,} pattern to _SECRET_RE so ?key=VALUE and
  &key=VALUE fragments are caught by the existing SecretRedactionFilter
- Apply redact_string() to error_str in exception_mapping_utils.py so the
  key is also stripped from the mapped exception message surfaced to callers
- Add 5 regression tests covering: ?key=, &key=, short-value no-op, httpx
  raise_for_status path, and end-to-end logger output
- Keep _redact_string = redact_string alias in _logging.py for backward compat

Fixes #24902

* revert: undo start_time fix for failed spend logs

* fix: gate exception redaction on _ENABLE_SECRET_REDACTION opt-out flag

- Apply redact_string() conditionally in exception_mapping_utils.py,
  matching the same _ENABLE_SECRET_REDACTION guard used by SecretRedactionFilter
  so that LITELLM_DISABLE_REDACT_SECRETS=true is honoured for exception messages
- Rewrite test_redact_string_applied_to_httpx_error_message to use pytest.raises
  so assertions cannot be silently skipped if raise_for_status() doesn't raise
- Add test_exception_mapping_respects_redaction_opt_out to verify the flag is
  respected end-to-end through exception_type()
2026-05-01 17:24:43 +05:30
Sameer Kankute
5c72a95289
Fix code 2026-05-01 16:35:19 +05:30
Sameer Kankute
8473b70dd8
feat(embedding): default OpenAI-path encoding_format to float
Made-with: Cursor
2026-05-01 16:26:17 +05:30
Sameer Kankute
900ef454c8
test: fix Bedrock PDF tool-result bytes assertion in factory test
The test supplies a minimal PDF base64 payload but expected the wrong
constant (base64 for "test"). Assert against the same pdf_b64 value
and drop the unused import.

Made-with: Cursor
2026-05-01 15:35:30 +05:30
user
a03d24076b Merge remote-tracking branch 'origin/litellm_internal_staging' into codex/resolve-team-callback-conflicts
# Conflicts:
#	litellm/proxy/management_endpoints/team_callback_endpoints.py
#	tests/test_litellm/proxy/management_endpoints/test_team_callback_endpoints.py
2026-05-01 01:35:07 -07:00
user
8538193bd3 chore(proxy): stabilize lazy openapi snapshot 2026-05-01 01:10:44 -07:00
user
e60a72ee1d
fix(proxy): hardcode mock-testing strip list to avoid cyclic import
CodeQL flagged the previous ``from litellm.types.router import
MockRouterTestingParams`` at module top-level — ``litellm.types.router``
indirectly imports back into proxy modules, so the dataclass may not
exist yet when ``route_llm_request`` is being imported.

Hardcode the three flag names instead, with a guard test
(``test_mock_testing_kwarg_names_matches_dataclass``) that asserts the
hardcoded list matches ``MockRouterTestingParams.fields`` so drift is
caught at test time rather than missed in production.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
2026-05-01 08:06:10 +00:00
user
cc9700f1da
Merge remote-tracking branch 'upstream/main' into fix/router-override-trust
# Conflicts:
#	tests/test_litellm/proxy/test_route_llm_request.py
2026-05-01 07:55:44 +00:00
user
150a34f2b0 chore(guardrails): tighten tool permission checks 2026-05-01 00:55:04 -07:00
user
a5b7eeebdc
chore(proxy): close router-settings-override fallback smuggling path
Two changes that together prevent a caller from smuggling unauthorized
models past the API key's allowlist via per-request router overrides.

1. ``_enforce_key_and_fallback_model_access``: also walk fallback models
   nested inside ``router_settings_override.fallbacks`` /
   ``context_window_fallbacks`` / ``content_policy_fallbacks``.
   ``route_llm_request.py`` promotes those to per-request kwargs after
   auth, so without this they bypassed the model allowlist entirely.
   New ``iter_router_fallback_model_names`` helper extracts leaf names
   from both the simple top-level shape (str | {"model": str}) and the
   nested router-config shape ({primary: [fallbacks]}). The two fallback
   validation loops are unified — every name (top-level + override) is
   deduplicated and validated once via ``can_key_call_model`` +
   ``is_valid_fallback_model``.

2. ``route_request``: strip router-internal ``mock_testing_*`` flags
   from user-supplied data. These are testing-only flags that
   deterministically force the router into fallback logic by raising a
   synthetic ``InternalServerError`` etc. Combined with override
   fallbacks they made the smuggling path trivially exploitable. Test
   code that calls the router directly bypasses the strip and is
   unaffected. The strip list is derived from ``MockRouterTestingParams``
   so a new ``mock_testing_*`` flag added to that dataclass is
   automatically covered.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
2026-05-01 07:49:32 +00:00
user
83ed317c50 track reservation entry before counter write 2026-05-01 00:09:51 -07:00
yuneng-jiang
eab0075353
Merge pull request #26805 from BerriAI/litellm_auth_bypass_tag_based_routing
add test(tag-routing): prevent header regex bypass for strict plain t…
2026-05-01 00:08:57 -07:00
user
403bbc3b88 degrade budget reservation cache failures 2026-04-30 23:53:36 -07:00
Baqiao
ec38f2b17b
feat(xai): add parallel_tool_calls to supported params (#25106) 2026-05-01 12:06:56 +05:30
shubham-arora-clear
f49c91ea92
fix(bedrock): handle document content blocks in Converse API message conversion (#24644)
* fix(bedrock): handle document content blocks in Converse API message conversion

Document content blocks (used for PDF support) were silently dropped
during message conversion for Bedrock's Converse API. The content block
processing loop only handled text, image_url, and file types — document
blocks were skipped without warning, causing the model to respond as if
no document was provided.

Adds document block handling in three locations:
- Sync user message processing (_bedrock_converse_messages_pt)
- Async user message processing (_bedrock_converse_messages_pt_async)
- Tool result conversion (_convert_to_bedrock_tool_call_result)

Fixes #24641

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>

* fix: use _validate_format for proper MIME type to Bedrock format mapping

Address Greptile review: naive media_type.split("/")[1] produced invalid
Bedrock format names for complex MIME types (e.g. OOXML → docx, text/plain
→ txt, text/markdown → md). Now reuses BedrockImageProcessor._validate_format
which handles all MIME types correctly via mimetypes + fallback.

Also fixes test assertions to expect correct Bedrock format values and adds
text/plain and text/markdown test cases.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>

* fix: reject non-base64 document sources with a clear error

URL-type document sources (e.g. {"type": "url", "url": "..."}) would
crash with an opaque KeyError on missing 'media_type'. Guard at the top
of _process_document_message and raise a clear ValueError since Bedrock
Converse only supports base64-encoded document sources.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>

---------

Co-authored-by: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-05-01 12:06:53 +05:30
Gowtham Raj
262782f5b2
fix: resolve access group names in _filter_models_by_team_id (#25224)
The /v2/model/info endpoint (used by the UI's Models + Endpoints page)
was not resolving access group names when filtering models by team.

When a team has models: ["Group-A"] where "Group-A" is an access group,
_filter_models_by_team_id() passed it as a literal model name to
get_model_list(), which found no deployments with that name. This caused
the UI to show all models instead of only team-accessible ones.

The request-time auth path (model_in_access_group in auth_checks.py)
correctly resolves access groups via get_model_access_groups(). This
fix applies the same resolution in _filter_models_by_team_id() for both
the in-memory router lookup and the database fallback query.

Tests added:
- test_filter_resolves_access_group_names
- test_filter_resolves_mix_of_access_groups_and_literal_names
- test_filter_excludes_models_from_other_access_group
- test_filter_db_fallback_receives_resolved_model_names
2026-05-01 11:55:36 +05:30
user
f51dd68ff0 test(proxy): cover lazy openapi operation ids 2026-04-30 23:00:25 -07:00
user
66c0fe23da handle bad reservation counters after spend write 2026-04-30 22:55:26 -07:00
user
6ef26945fa test(proxy): narrow media resource decoding 2026-04-30 22:55:00 -07:00
user
0704f672c5 test(proxy): cover resource model extraction fallbacks 2026-04-30 22:21:57 -07:00
user
336fe8276f chore(proxy): align resource model auth checks 2026-04-30 21:59:56 -07:00
user
0b1ea9eb8f harden budget reservation edge cases 2026-04-30 21:49:31 -07:00
user
5397ac4562
fix(guardrails): redact `data["input"]` for Responses-API mask paths
Greptile P1: Aim's ``_anonymize_request`` and Lakera v2's mask-PII path
both wrote redacted content only to ``data["messages"]``. The Responses
API backend reads ``data["input"]``, so when a request arrived via
``/v1/responses`` with a plain string ``input`` the hook would update
``messages`` (which the backend ignores) and leave ``input`` carrying
the original unredacted text. Net effect: anonymize/mask silently passed
PII through to the LLM.

Add ``apply_redacted_messages_back`` to ``_content_utils`` — it writes
the redacted messages back to ``data["messages"]`` AND, when present,
re-flattens the redacted content into ``data["input"]``. Aim and
Lakera v2 now route their mask writeback through this helper. List
``input`` (multimodal) is still handled by the upstream
block-on-multimodal guard.

Adds unit tests for the helper and regression tests asserting
``data["input"]`` is redacted for both hooks on Responses-API string
input.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
2026-05-01 04:41:57 +00:00
Sameer Kankute
b540a71e47
feat(mcp): enforce org-level MCP server and toolset permissions
Apply organization object_permission as a ceiling on allowed MCP servers
and tool permissions, consistent with vector store org checks.

Includes unit tests for org ceiling, intersection, and tool filtering.

Made-with: Cursor
2026-05-01 10:10:38 +05:30