Commit graph

33248 commits

Author SHA1 Message Date
Sameer Kankute
32bfbbfbe1 Add method support for passthrough endpoints 2026-02-19 11:58:25 +05:30
yuneng-jiang
70d5281b52
Merge pull request #21537 from BerriAI/litellm_team_member_usage_permission
[Feature] Allow team members to view entire team usage
2026-02-18 22:01:13 -08:00
Sameer Kankute
44a68cf1c6 Fix: add stop param as supported for openai and azure 2026-02-19 11:26:38 +05:30
Harshit Jain
31752c7b78
fix: mypy issues from auth_checks 2026-02-19 11:11:52 +05:30
Ishaan Jaff
1a5133f229
Competitor guardrails: streaming discovery, variations, pre/post split (#21533)
* fix aviation safety topic filter: remove overly broad exceptions, add cockpit access block words

* fix airline brand protection filter: add identifier words, competitor/ops block words, tighten exceptions

* update policy templates with competitor pre/post guardrails and streaming enrichment

* sync policy_templates_backup.json with policy_templates.json

* add streaming enrichment endpoint, competitor variations, and model selection

* add streaming enrichPolicyTemplate networking function

* rewrite template parameter modal with streaming tags, AI/manual toggle, model selector

* update policies panel to pass enrichment options and show discovered competitors

* show discovered competitors as tags in guardrail selection modal

* use llm_router instead of litellm.acompletion, extract helpers, move constants

* validate competitors list size, cap variation prompt input

* add refinement instruction support for competitor discovery

* add instruction and existingCompetitors params to streaming enrichment

* add refinement input for iterating on competitor list with AI

* emit status events during variation generation so UI shows progress

* add onStatus callback to streaming enrichment

* show status spinner during variation generation, widen modal to 700px

* add tests for competitor enrichment helper functions
2026-02-18 21:39:19 -08:00
yuneng-jiang
528b21ad1d [Feature] Allow team members to view entire team usage
Add a new team member permission `/team/daily/activity` that allows
non-admin team members to see all team usage data, not just their own.

## Changes
- Add `TEAM_DAILY_ACTIVITY` to `KeyManagementRoutes` enum and available
  team member permissions
- Add `_team_member_has_permission` helper in `common_utils.py`
- Modify `/team/daily/activity` endpoint to skip API key filtering when
  the member has this permission
- Add permission description and method detection in the UI
- Add backend and frontend tests

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-02-18 21:38:40 -08:00
jquinter
1e372ebc82
Merge pull request #20909 from jquinter/fix/ui-tagsSpendLogsCall-double-url
fix(ui): remove duplicate URL in tagsSpendLogsCall query string
2026-02-19 02:22:33 -03:00
jquinter
abc4603675
Merge pull request #21476 from BerriAI/fix/test-log-record-message-attr
fix(tests): use record.getMessage() instead of record.message for LogRecord
2026-02-19 02:21:54 -03:00
jquinter
2c1d2fa948
Merge pull request #21439 from BerriAI/fix/restore-default-internal-user-params
fix(test): restore default_internal_user_params to None instead of delattr
2026-02-19 02:19:10 -03:00
jquinter
ed79d435a4
Merge pull request #21535 from BerriAI/fix/mypy-mcp-user-permissions-type-errors
fix(mypy): resolve type errors from MCP user permissions commit
2026-02-19 02:18:58 -03:00
jquinter
53cfb93a06
Merge pull request #21536 from BerriAI/fix/mcp-test-failures-from-user-permissions
fix(tests): update MCP tests broken by user permissions commit (#21462)
2026-02-19 02:17:49 -03:00
Julio Quinteros Pro
a9d3c49572 fix(tests): update MCP tests broken by user permissions commit (#21462)
Four tests were broken by commit e00c181f0c (Mcp user permissions #21462):

1. test_list_tools_single_server_unprefixed_names: The commit changed
   _get_tools_from_mcp_servers to always add server prefixes (add_prefix=True),
   removing the conditional that skipped prefixing for single servers.
   Updated assertion from "toolA" → "zapier-toolA".

2. test_mcp_get_prompt_success: mcp_get_prompt now extracts the server name
   from a prefixed prompt name via split_server_prefix_from_name(). Passing
   unprefixed "hello" returns server_name="" which matches no server → 403.
   Updated call to use "server_a-hello" so the server lookup succeeds.

3. test_e2e_jwt_team_mcp_permissions_enforced &
4. test_e2e_jwt_team_mcp_key_intersection:
   The commit replaced `from typing import List` with
   `from litellm.proxy.proxy_server import general_settings` in
   MCPRequestHandler.get_allowed_mcp_servers(). Both tests mock
   litellm.proxy.proxy_server with a types.ModuleType that lacked
   general_settings, causing ImportError. Added general_settings={} to
   both mock modules.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-02-19 02:09:11 -03:00
jquinter
d106393394
Merge pull request #21505 from BerriAI/fix/spend-test-model-cost-contamination
fix(tests): restore litellm.model_cost after TestPriceDataReloadIntegration tests
2026-02-19 02:06:13 -03:00
yuneng-jiang
a717f3624d
Merge pull request #21516 from BerriAI/litellm_model_settings_modal
[Feature] UI - Models & Endpoints: Add Model Settings Modal
2026-02-18 21:02:31 -08:00
Julio Quinteros Pro
fdcb2ca37d fix(mypy): resolve type errors introduced by MCP user permissions (#21462)
- Cast `guardrail` to `Dict[str, Any]` in `mcp_end_user_permission/__init__.py`
  to fix "No overload variant of 'get' matches argument type 'str'" — the
  `Guardrail` TypedDict's `.get()` overloads resolve the key type to `Never`
  when chained with a `{}` default, making further `.get()` calls fail.
- Cast `fn` to `Dict[str, Any]` in `transformation.py`
  `transform_chat_completion_tool_params_to_responses_api_tools` to fix
  '"object" has no attribute "get"' — `tool.get("function")` on
  `Union[ChatCompletionFunctionToolParam, OpenAIMcpServerTool]` returns
  `object` because `"function"` is not a key in `OpenAIMcpServerTool`.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-02-19 02:02:17 -03:00
jquinter
803a1f003e
Merge pull request #21500 from BerriAI/fix/managed-file-table-optional-defaults
fix(types): add = None defaults to Optional[str] fields in managed table models
2026-02-19 01:47:33 -03:00
jquinter
01ff53822c
Merge pull request #21440 from BerriAI/fix/langfuse-test-sys-modules-mock
fix: prevent sys.modules["langfuse"] import failures in langfuse unit tests
2026-02-19 01:47:07 -03:00
Julio Quinteros Pro
063238a789 chore: resolve merge conflict with main
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-02-19 01:46:13 -03:00
Julio Quinteros Pro
68b83b1376 fix(tests): restore litellm.model_cost after TestPriceDataReloadIntegration tests
test_complete_reload_flow and test_distributed_reload_check_function both
trigger code paths that assign a minimal stub dict to litellm.model_cost
(via the /reload/model_cost_map endpoint and _check_and_reload_model_cost_map).
Without restoring, subsequent tests in the same worker can't find gpt-4o
pricing and calculate spend=0.0 instead of the expected value.

Added try/finally save-and-restore of litellm.model_cost in both tests,
matching the pattern used in test_reload_model_cost_map_admin_access.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-02-19 01:42:48 -03:00
Sameer Kankute
155b79e53f
Merge pull request #21534 from BerriAI/litellm_context-1m-2025-08-07_converse2
Add supoort for context-1m-2025-08-07
2026-02-19 09:53:13 +05:30
Sameer Kankute
b452f98a6c Add supoort for context-1m-2025-08-07 2026-02-19 09:52:23 +05:30
Harshit Jain
c1fce02b21
fix: mypy issues 2026-02-19 09:26:51 +05:30
Sameer Kankute
4773838561
Merge pull request #21531 from BerriAI/litellm_cicd_190226
Litellm cicd 190226
2026-02-19 09:07:25 +05:30
Ishaan Jaff
0486161bea
feat(ui): add CSV dataset upload to compliance playground (#21526) 2026-02-19 03:33:18 +00:00
Sameer Kankute
0664604fda Fix:test_standard_logging_payload_stream_usage 2026-02-19 08:47:09 +05:30
Harshit Jain
66ce7513f6
Merge branch 'main' into litellm_project_management_apis 2026-02-19 08:40:12 +05:30
Sameer Kankute
51146c4c94 Fix:test_anthropic_messages_with_all_beta_headers 2026-02-19 08:35:38 +05:30
Krish Dholakia
e00c181f0c
Mcp user permissions (#21462)
* feat(schema.prisma): add object permissions for end users

allows controlling if end user can call specific mcp servers

* feat: cleanup for customer_endpoints support of object permission id

* fix: cleanup str

* feat(customers/): enforce end user can only call allowed mcps - if configured

* docs: document customer/end user object permission usage

* feat: enforce end user permissions on MCP tool calls

This commit implements end user permission enforcement for MCP servers:

1. Always add server prefixes to MCP tool names
   - Removed conditional logic that only added prefixes when multiple servers existed
   - Now always adds server prefix for consistent tool naming across all scenarios
   - Updated 5 locations in server.py (list_tools, get_prompts, get_resources,
     get_resource_templates, get_prompt)

2. Created MCP End User Permission Guardrail Hook
   - New guardrail hook: litellm/proxy/guardrails/guardrail_hooks/mcp_end_user_permission.py
   - Runs on post_call to validate tool calls in LLM responses
   - Extracts MCP server name from tool names (splits on first '-')
   - Checks if end_user_id has permissions for the MCP server
   - Raises GuardrailRaisedException if end user lacks permission
   - Supports both streaming and non-streaming responses

3. Added comprehensive tests
   - Test file: tests/test_litellm/proxy/guardrails/guardrail_hooks/test_mcp_end_user_permission.py
   - Tests cover: authorized/unauthorized tools, non-MCP tools, no end_user scenarios
   - Tests permission checking logic and exception raising

The hook integrates with the existing MCPRequestHandler._get_allowed_mcp_servers_for_end_user
to fetch end user permissions and enforce access control at the response level.

Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>

* refactor: remove redundant add_prefix variable assignments

Simplified the code by removing intermediate `add_prefix` variable
assignments and passing `True` directly to function calls since
we now always add server prefixes.

Changes:
- Removed `add_prefix = True` variable assignments in 5 locations
- Changed `add_prefix=add_prefix` to `add_prefix=True` in function calls
- Added inline comments to clarify the behavior

This makes the code more concise and clearer in intent.

Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>

* feat(auth_utils.py): support safety_identifier as a valid way of passing the end user id for responses api

* feat(llms): ensure 'tools' is correctly updated for responses api

* fix: fix greptile feedback

* feat: transformation.py

proper responses api tool handling for guardrail translation layer

---------

Co-authored-by: Claude Sonnet 4.5 <noreply@anthropic.com>
2026-02-18 18:53:59 -08:00
Ishaan Jaffer
936e04e0e1 fix: add missing Field import in policy_endpoints.py
Co-Authored-By: Warp <agent@warp.dev>
2026-02-18 18:28:31 -08:00
Ishaan Jaff
91fd2b4621
Add aviation and UAE policy templates with tag-based filtering (#21518)
* add aviation and UAE regex patterns (PNR, Skywards, Emirates ID, UAE phone, flight number)

* add aviation safety topics category yaml

* add airline brand protection category yaml

* add UAE cultural sensitivity category yaml

* add UAE anti-discrimination category yaml

* add aviation, UAE, and competitor policy templates + migrate region/type to tags

* sync policy_templates_backup.json

* add /policy/templates/enrich endpoint for LLM competitor discovery

* add enrichPolicyTemplate networking call

* add TemplateParameterModal component

* handle parameterized templates and LLM enrichment in policies index

* replace region/type radio filters with tag sidebar checkboxes
2026-02-18 18:26:24 -08:00
Krish Dholakia
a385126a7c Litellm dev compliance UI (#21457)
* feat(ui/): initial commit adding a compliance testing playground

allow proxy admins to test policies and guardrails against datasets

* feat(ui/): make score more friendly

* feat(policy_endpoints.py): new helper function for testing policies

* feat(policy_endpoints.py): expose new endpoint for testing policies and guardrails

enables compliance playground to work as expected

* feat(complianceui.tsx): show returned text
2026-02-18 18:22:43 -08:00
Ishaan Jaff
323aed7211
fix: CI failures - missing env key doc + streaming test (#21510)
* docs: add DATABRICKS_API_KEY to environment settings reference

* fix: streaming test usage check on Pydantic model

* fix: mock litellm.proxy.proxy_server in test_skip_server_startup
2026-02-18 18:20:32 -08:00
yuneng-jiang
f1cbaac124 Add unit tests for ModelSettingsModal and useStoreModelInDB hook
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-02-18 18:11:07 -08:00
yuneng-jiang
876c4cfd0f adjusting hook to use /config/field/update 2026-02-18 18:06:02 -08:00
yuneng-jiang
b0973b3ac8 Add model setting modal 2026-02-18 18:01:09 -08:00
yuneng-jiang
2c6095bdf2
Merge pull request #21511 from BerriAI/litellm_store_model_in_db_from_database
[Feature] Allow store_model_in_db to be set via database
2026-02-18 17:43:56 -08:00
yuneng-jiang
64fe3a502e
Merge pull request #21503 from BerriAI/litellm_sso_role_map
fix(sso): preserve SSO role regardless of role_mappings config
2026-02-18 17:31:49 -08:00
yuneng-jiang
6356db560d [Feature] Allow store_model_in_db to be set via database
Users had to set store_model_in_db in the config YAML and restart the proxy,
causing service downtime. This change allows the value to be written to the
LiteLLM_Config table and read from the database at runtime, with DB values
overriding config file values.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-02-18 17:25:39 -08:00
Shivam Rawat
9ceaa2cbb0
tests and route permissions (#21508) 2026-02-18 16:58:38 -08:00
jquinter
d75bb10c5f
Merge pull request #21506 from BerriAI/fix/enterprise-install-wrong-venv
fix(ci): install enterprise package into main project venv, not enterprise's own venv
2026-02-18 21:31:48 -03:00
Julio Quinteros Pro
24ead9b4e1 fix(ci): install enterprise package into main project venv, not enterprise's own venv
Running `cd enterprise && poetry run pip install -e .` causes poetry to
create a separate venv in `enterprise/.venv` (since enterprise/ has its
own pyproject.toml). The main project's tests run with `.venv/bin/python`,
so the enterprise package installed in `enterprise/.venv` is never seen.

Fix: run `poetry run pip install -e enterprise/` from the repo root so
poetry uses the main project's venv. This ensures litellm_enterprise is
importable when tests run.

This explains why enterprise tests kept failing with:
  AttributeError: '_PROXY_LiteLLMManagedFiles' object has no attribute
  '_check_file_deletion_allowed'
even after --force-reinstall was added — the reinstall was going to the
wrong virtual environment.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-02-18 21:24:06 -03:00
Ishaan Jaff
6486db3646
fix: improve streaming proxy throughput by fixing middleware and logging bottlenecks (#21501)
* fix(middleware): replace BaseHTTPMiddleware with pure ASGI middleware

BaseHTTPMiddleware wraps streaming responses with receive_or_disconnect
per chunk, blocking the event loop and causing severe throughput
degradation under concurrent streaming load (53% of CPU in profiling).

Converts PrometheusAuthMiddleware to a pure ASGI middleware using the
__call__(scope, receive, send) protocol.

* fix(streaming): remove expensive debug logging and optimize usage stripping

- Remove print_verbose calls that format chunk/response Pydantic objects,
  triggering millions of __repr__ calls (8% of CPU in profiling)
- Guard remaining verbose_logger.debug with isEnabledFor(DEBUG) and use
  lazy %s formatting instead of f-strings
- Replace usage stripping round-trip (model_dump + delete + reconstruct)
  with a _usage_stripped flag, deferring exclusion to serialization time

* fix(proxy): remove per-chunk debug log and use _usage_stripped flag

- Remove verbose_proxy_logger.debug that formatted every streaming chunk
- Honor _usage_stripped flag from streaming handler to exclude usage
  during model_dump_json serialization instead of reconstructing objects

* fix(proxy): remove per-chunk debug log in async_data_generator

Remove verbose_proxy_logger.debug that formatted every streaming chunk,
which triggered expensive Pydantic serialization on the hot path.

* fix indentation and add clarifying comment for usage stripping

* fix: guard calculate_total_usage against None usage in chunks

* fix: store chunk copy to preserve usage for calculate_total_usage
2026-02-18 16:16:49 -08:00
Ryan Crabbe
28c7cc6efe style: move anyio import to module level per Greptile review 2026-02-18 15:51:04 -08:00
yuneng-jiang
e445694a40 fix(sso): preserve SSO role regardless of role_mappings configuration
When `default_internal_user_params` was set, `insert_sso_user()` only
preserved SSO-provided roles if `role_mappings` was explicitly configured.
Roles from other valid SSO sources (Microsoft app_roles,
GENERIC_USER_ROLE_ATTRIBUTE, custom SSO handlers) were silently
overwritten with the default "internal_user" role, causing admin users
to be downgraded on first login or after user deletion.

Replace the `role_mappings_configured` gate with `_should_use_role_from_sso_response()`
which validates the role is a recognized LitellmUserRoles value regardless
of origin. Also removes an unnecessary DB round-trip to litellm_ssoconfig
on every new SSO user creation.

Fixes: admin users seeing internal-user UI after SSO login
Fixes: test_get_redirect_url_for_sso flaking due to local env vars

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-02-18 15:24:18 -08:00
Milan
b601d8855b fix(router): resolve litellm_credential_name in get_deployment_credentials_with_provider
When models are created via UI with pre-existing credentials, they use
litellm_credential_name to reference credentials stored separately.

The batch file upload endpoint uses get_deployment_credentials_with_provider()
to retrieve model credentials, but this method was returning the credential
reference name instead of resolving it to actual API keys and endpoints.

This fix adds credential resolution using CredentialAccessor.get_credential_values()
to ensure UI-created models work the same as YAML-configured models for batch
file uploads and other passthrough endpoints.

Fixes: Batch file uploads failing with 'Missing credentials' error for UI models
2026-02-19 01:03:19 +02:00
ryan-crabbe
de8552d92c
Update litellm/proxy/proxy_server.py
Co-authored-by: greptile-apps[bot] <165735046+greptile-apps[bot]@users.noreply.github.com>
2026-02-18 15:00:10 -08:00
Ryan Crabbe
97bc998943 fix: add cancellation shielding to async_data_generator cleanup per Greptile review 2026-02-18 14:51:06 -08:00
Julio Quinteros Pro
40b0f72dae fix(types): add = None defaults to Optional[str] fields in managed table models
In Pydantic v2, `Optional[str]` without a default value is a required field
(callers must explicitly pass `None`). This caused `ValidationError` when
constructing `LiteLLM_ManagedFileTable` and `LiteLLM_ManagedVectorStoreTable`
without providing `created_by`/`updated_by`.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-02-18 19:24:18 -03:00
Ryan Crabbe
988e43662e fix: cap uvicorn version to <1.0.0 per Greptile review 2026-02-18 14:19:21 -08:00
Julio Quinteros Pro
db615cd721 chore: resolve merge conflict with main
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-02-18 19:10:36 -03:00