Commit Graph
498 Commits
Author SHA1 Message Date
YutaSaitoandGitHub f487f4e3a9 feat: add dynamic OAuth2 metadata discovery for MCP servers (#16676)
* feat: add dynamic OAuth2 metadata discovery for MCP servers

* fix: lint error
2025-11-14 18:14:43 -08:00
Ishaan JaffandGitHub b360cc957e [Feat] Model Management API - Add API Endpoint for creating model access group (#16663)
* add NewModelGroupRequest

* add endpoint for create_model_group

* fix model_access_group_management_router

* add UpdateModelGroupRequest, info and delete

* fix model management tag

* fix validate_models_exist

* fix get_all_access_groups_from_db

* test_create_duplicate_access_group_fails

* test fixes

* fix working create access groups

* fix access group management endpoints

* add is db model checks for model access groups
2025-11-14 16:40:43 -08:00
yuneng-jiangandGitHub f1ff195bd8 Add Model uses endpoint info (#16664) 2025-11-14 16:08:27 -08:00
Alexsander HamirandGitHub c7847125c2 [Perf] Embeddings: Use router's O(1) lookup and shared sessions (#16344)
* Refactor proxy embeddings to use shared processor

- allow ProxyBaseLLMRequestProcessing to accept the aembedding route so embeddings requests reuse the base pipeline hooks

- route embeddings requests through base_process_llm_request, sharing logging, hook execution, retries, and header handling with chat/responses

- tighten token array decoding logic by using router deployment lookups and the unified error handler

* Fix: Correctly process embedding requests with token arrays

The `test_embedding_input_array_of_tokens` test was failing due to a regression that caused embedding requests with token arrays to be processed incorrectly. This prevented the `aembedding` function from being called as expected.

This was caused by a combination of three distinct issues:

1.  In `litellm/proxy/common_request_processing.py`, the `function_setup` utility was called with `aembedding` as the `original_function` for embedding routes. This has been corrected to `embedding` to ensure proper request setup.

2.  In `litellm/proxy/proxy_server.py`, a `TypeError` occurred because the `get_deployment` method was called with the `model_name` keyword argument instead of the expected `model_id`. This has been corrected. Additionally, the check for token arrays was improved to validate that all elements in the input subarray are integers.

3.  In `litellm/proxy/litellm_pre_call_utils.py`, the check for the `enforced_params` enterprise feature was too strict. It blocked valid requests even when the `enforced_params` list was empty. The condition has been adjusted to trigger the check only for non-empty lists.

Finally, the `test_embedding_input_array_of_tokens` assertion was updated to be more robust. The previous `assert_called_once_with` was overly strict, causing failures when unrelated internal parameters were added to the function call. The test now first asserts that `aembedding` is called and then separately verifies the `model` and `input` arguments. This makes the test more resilient to future changes without sacrificing its ability to catch regressions.

* test: align proxy embedding assertions

Update the embedding proxy test to match the new request pipeline: keep the data the proxy builds, expect the extra control kwargs, let the post-call hook return the actual response, and assert the normalized 'embeddings' hook type. This proves the refactor still forwards metadata and returns the mocked payload.

* Update proxy exception test

The proxy now forwards additional kwargs (request_timeout, litellm_call_id, litellm_logging_obj) to llm_router.aembedding. The test needs to accept these to match the real call signature and keep validating the error path instead of the kwargs list.

* testing: unsure of this change

I don't remember why I changed this, will revert and see if any tests fail since the manual test isn't failing without it.

* fix: remove unrelated change

This change was not related to the embeddings refactor and actually belonged to a different branch.
2025-11-14 09:21:45 -08:00
yuneng-jiangandGitHub 379aa7b79a Pagination for /spend/logs/session/ui endpoint (#16603) 2025-11-13 22:03:00 -08:00
YutaSaitoandGitHub 331be4f57b fix: avoid crashing when MCP server record lacks credentials (#16601) 2025-11-13 22:01:11 -08:00
yuneng-jiangandGitHub 792339200a Migrate Add Model Fields to backend (#16620) 2025-11-13 21:48:57 -08:00
yuneng-jiangandGitHub 8bf491c939 [Fix] /spend/logs/ui Access Control (#16446)
* RBAC for /spend/logs/ui

* Addressing comments
2025-11-12 18:44:21 -08:00
yuneng-jiangandGitHub cb27d6c456 [Fix] UI - Delete Callbacks Failing (#16473)
* Temp commit for branch switching

* Created normalize callback name util function and tests
2025-11-12 18:43:37 -08:00
yuneng-jiangandGitHub 898f15c33c Add Langfuse OTEL and SQS to health check (#16514) 2025-11-12 18:25:30 -08:00
YutaSaitoandGitHub 2843dab7fe fix: allow tool call even when server name prefix is missing (#16425)
* fix: allow tool call even when server name prefix is missing

* fix: test

* fix: test

* fix: test
2025-11-12 13:50:52 -08:00
Mubashir OsmaniandGitHub e6bbf3ce81 fix: app_roles missing from jwt payload (#16448)
* fix: jwt app_roles missing

* add test
2025-11-12 12:07:04 -08:00
yuneng-jiangandGitHub ba674f241c [Fix] Use user budget instead of key budget when creating new team (#16074)
* Use end user budget instead of key budget when creating new team

* Fixed implementation to use user's max budget from the UserTable instead of EndUserTable
2025-11-11 18:55:05 -08:00
yuneng-jiangandGitHub 67478a9074 [Fix] Litellm tags usage add request_id (#16111)
* Add request_id into tag spend

* Linting
2025-11-11 18:53:48 -08:00
Alan PonnachanandGitHub df33f36c06 Correctly handle date filters in /spend/logs endpoint (#16443) 2025-11-10 19:26:55 -08:00
Sameer KankuteandGitHub be3c09e6d5 Add GET list of providers endpoint (#16432) 2025-11-10 18:38:09 -08:00
Ishaan JaffandGitHub 8140d85d28 [Bug Fix] - LiteLLM Usage shows key_hash- (#16471)
* test_get_logging_payload_api_key_preserved_when_standard_logging_payload_is_none

* fix get_logging_payload

* test_api_key_preserved_through_failure_hook_to_database
2025-11-10 18:15:52 -08:00
912be308b2 fix: allow internal users to access video generation routes (#16472)
Fixes #16470

Video generation endpoints (/v1/videos, /videos/{video_id}, etc.) were
incorrectly restricted to proxy_admin role only. These routes are now
added to openai_routes list, making them accessible to internal_user
role as they should be - video generation is a legitimate user feature,
not a management/admin operation.

Changes:
- Added 8 video route patterns to LiteLLMRoutes.openai_routes in _types.py
- Added comprehensive tests verifying internal_user and virtual key access
- All existing route permission tests continue to pass

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-authored-by: Claude <noreply@anthropic.com>
2025-11-10 17:44:16 -08:00
Ishaan JaffandGitHub dc76b6c76e [Fix] Management Endpoints - Fixes inconsistent error responses in customer management endpoints. Non-existent user errors now return proper 404 status codes with consistent error schema format across all endpoints. (#16450)
* fix: ensure end user endpoints use "handle_exception_on_proxy" correctly

* test 404 on info and update for non-existent user

* test 404 for no customer found

* fix 404 handling for customer endpoints

* test_error_schema_consistency

* test_customer_endpoints_error_schema_consistency
2025-11-10 17:16:53 -08:00
Ishaan Jaffer 1bf284abca test_delete_callbacks_in_db 2025-11-08 14:05:44 -08:00
Ishaan Jaffer 45323dd537 test_patch_guardrail_endpoint 2025-11-07 22:09:52 -08:00
YutaSaitoandGitHub 6eb74bd62a Feat/persist mcp credentials in db (#16308)
* feat: persist mcp credentials in db

* feat: remove Auth Value field from MCP Tool Testing Playground

* fix: test
2025-11-07 19:22:49 -08:00
Ishaan JaffandGitHub 674d4b4cab [Feat] Guardrails - LiteLLM Content Filter, Allow Viewing/Editing Content Filter Settings (#16383)
* fix safe dumps

* add patterns.json

* add PrebuiltPattern

* add test patterns

* fix edit and view

* fix backend handling

* fix CF ui edit

* fix init
2025-11-07 18:15:09 -08:00
Ishaan JaffandGitHub ca229fe030 [Feat] LiteLLM Guardrail - UI Fix, ensure you can see UI Friendly name for PII Patterns (#16382)
* fix safe dumps

* add patterns.json

* add PrebuiltPattern

* add test patterns
2025-11-07 18:14:58 -08:00
Jason RobertsandGitHub 5733f711fd feat(guardrails): panw prisma airs guardrail deduplication and enhanced session tracking (#16273)
* feat(guardrails): Add deduplication and session tracking

- Implement deduplication logic to prevent duplicate scans (via call_id; add _check_and_mark_scanned) caused by LiteLLM callback system
- Add session tracking using litellm_trace_id as AI Session ID for Prisma AIRS SCM logging
- Extract helper methods _extract_prompt_from_request maintainability
- Use httpxSpecialProvider import (LoggingCallback -> GuardrailCallback)
- Add comprehensive tests for deduplication and session tracking (7 new tests)
- Update documentation with multi-turn conversation tracking examples

* docs: update PANW Prisma AIRS multi-turn conversation example to use industry-standard terminology

- Clearer example for conversation tracking
- Updated terminology from 'AI Session ID' to 'Prisma AIRS AI Session ID' for clarity

* fix: remove unused asyncio import

* fix: correct mypy type ignore comment
2025-11-06 19:34:37 -08:00
Ishaan Jaffer 5157078e0a test_delete_callbacks_in_db 2025-11-06 18:37:36 -08:00
Ishaan Jaffer 8a9fe7b056 fix delete callbacks 2025-11-06 17:06:34 -08:00
Ishaan Jaffer c727a2ad63 test noma, presidio 2025-11-06 17:06:03 -08:00
Ishaan Jaffer 0a4e2a88e3 TestIsAllowedToCallVectorStoreEndpoint 2025-11-06 17:02:59 -08:00
Ishaan JaffGitHubCopilot Autofix powered by AI <62310815+github-advanced-security[bot]@users.noreply.github.com>
18a5c4f75a [Feat] Add LiteLLM Gateway built in guardrail (#16338)
* add ContentFilterAction

* store pre-built regex patterns

* add v0 of content filter guard

* add _filter_messages

* test content filter guard

* init ContentFilterGuardrail

* fix ContentFilterGuardrail enums

* rename folder

* fix litellm_content_filter

* refactor content filter guard

* test content filter

* add streaming for ContentFilterGuardrail

* test_streaming_hook_mask

* add litellm_content_filter

* docs show litellm content filter

* docs litellm content filter

* fix lnting

* Potential fix for code scanning alert no. 3675: Clear-text logging of sensitive information

Co-authored-by: Copilot Autofix powered by AI <62310815+github-advanced-security[bot]@users.noreply.github.com>

---------

Co-authored-by: Copilot Autofix powered by AI <62310815+github-advanced-security[bot]@users.noreply.github.com>
2025-11-06 16:02:28 -08:00
yuneng-jiangandGitHub 812c8b88e9 Fixed /model_group/info returning entire model list for SSO users (#16296) 2025-11-05 18:30:30 -08:00
dean-zavadandGitHub f19356db60 Litellm noma guardrail support images (#16199)
* noma support v2 api and images with during call

* supporting streams and images with texts

* Supporting text now

* annonymization works

* removing function

* fixing noma.py

* all old tests pass

* adding new tests

* removing changes

* Fixing application id headers

* fix whitespace

* deleting unused imports
2025-11-05 11:23:39 -08:00
YutaSaitoandGitHub 8e27b6c0b4 [MCP] configure static mcp header (#16179)
* feat: configure extra mcp headers in ui

* doc: static header

* build: add new migration file

* chore: add missing image file

* fix: test
2025-11-03 21:06:36 -08:00
Krish DholakiaandGitHub 07d2a27f14 Milvus - Passthrough API support - adds create + read vector store support via passthrough API's (#16170)
* feat(llm_passthrough_endpoints.py): support milvus passthrough api

* fix(llm_passthrough_endpoints.py): move streaming request value to the top of the function

* docs: document new milvus vector store passthrough flow
2025-11-02 09:47:58 -08:00
Krish DholakiaandGitHub 3f40613c56 fix(ui_sso.py): support dot notation on ui sso (#16135) 2025-11-02 09:35:52 -08:00
Ishaan JaffandGitHub 579843b4bc UI - Fix regression where Guardrail Entity Could not be selected and entity was not displayed (#16165)
* fix PiiEntityCategoryMap

* fix OpenAIChatCompletionsHandler

* fix lint
2025-11-01 18:00:54 -07:00
Krish DholakiaandGitHub 43aacf2dc0 (feat) Azure AI Vector Stores - support "virtual" indexes + create vector store on passthrough API (#16160)
* feat(vector_store_endpoints/endpoints.py): add new index_create endpoint

allows admin to create a virtual index, to do permission management for

* feat(key_management_endpoints.py): enable setting allowed_vector_store_indexes on keys

proxy admin can enable dev to create an index on a vector stor

* feat: initial commit adding vector store index passthrough logic to litellm

* feat: add vector store table

* fix(azure_ai/transformation.py): fix headers

* feat: track read/write endpoints by vector store integration

enables permissions by index to work

* fix: azure_ai/vector_stores/search

document the vector store endpoints correctly

 ensures permission management works as expected

* fix(proxy/utils.py): improve error message

* docs(azure_ai_vector_stores_passthrough.md): document azure ai passthrough vector store support

* docs(create.md): document azure ai support via passthrough for vector store create

* fix: fix code qa errors

* fix: document new allowed_vector_store_indexes endpoint
2025-11-01 12:01:32 -07:00
Krish DholakiaandGitHub b02be1ba70 (feat) Milvus - search vector store support + (fix) Passthrough Endpoints - support multi-part form data on passthrough (#16035)
* feat(milvus/): initial commit adding milvus vector store support to LiteLLM

allows querying milvus vector store through litellm

* feat(bedrock/vector_stores): support translating openai filters param to aws kb

adds filtering to aws kb

* feat(milvus/): add milvus vector store unified search support

allows calling milvus vector store in through chat completions

* docs(milvus_vector_stores.md): document new milvus vector search integration

* feat(pass_through_endpoints.py): support passing form data through to a passthrough endpoint

Closes LIT-1147

* fix: fix linting errors
2025-11-01 12:00:29 -07:00
Ishaan Jaffer f2b5a5f832 test google endpoints 2025-10-31 20:50:31 -07:00
Ishaan JaffandGitHub c59a0c9681 [Feat] UI - Allow setting cache settings on UI (#16143)
* add LiteLLM_CacheConfig

* add CacheSettingsField

* add UI cache saver

* feat add cache_settings_router

* fix schema

* fix ssl_check_hostname

* refactor into utils

* add groups for field names

* add test_connection in base cache

* add test_connection inredis and redis cluster

* feat _decrypt_db_variables

* add cache settings endpoints

* test_test_cache_connection_calls_cache_test_connection_with_params

* fix: add switch_on_llm_response_caching

* feat use CacheSettingsManager

* feat use CacheSettingsManager

* TestCacheSettingsManager

* fix update_config

* Cache Field test
2025-10-31 17:43:59 -07:00
yuneng-jiangandGitHub 725671395a [Feature] UI - Config Guardrails should not be editable and guardrail info fix (#16142)
* UI Config Guardrails should not be editable and guardrails info definition location fix

* Remove unused import

* Added literals for guardrail definition location
2025-10-31 16:29:24 -07:00
Nicholas CoutureandGitHub f747a4a38a fix: Handle multiple rate limit types per descriptor and prevent IndexError (#16039)
* improve descriptor_key handling for multiple and missing rate limit descriptors in parallel request limiter v3

* Add tests for parallel request limiter v3 in proxy hooks
2025-10-30 20:12:54 -07:00
yuneng-jiangandGitHub 720ba865fb [Infra] Litellm Backend SSO Changes (#16029)
* SSO Backend changes

* Encrypt and Decrypt, load into os env

* Linting and addressing comments
2025-10-30 14:32:08 -07:00
5e10ea4136 Improve(mcp): respect X-Forwarded- headers in OAuth endpoints (#16036)
* fix(mcp): respect X-Forwarded-Proto header in OAuth endpoints

When LiteLLM proxy is deployed behind a reverse proxy (like nginx or a load balancer) that terminates SSL/TLS, the proxy receives HTTP requests internally but should expose HTTPS URLs externally. This change detects the X-Forwarded-Proto header and uses it to construct correct redirect URIs and endpoint URLs.

Changes:
- Added X-Forwarded-Proto detection to authorize, token, oauth_protected_resource_mcp, oauth_authorization_server_mcp, and register_client endpoints
- Added comprehensive tests for X-Forwarded-Proto header support across all affected endpoints
- Fixed existing tests to properly mock request.headers

🤖 Generated with [Claude Code](https://claude.com/claude-code)

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

* fix formatting

* feat(mcp): support X-Forwarded-Host for proxy base URL reconstruction

Extended X-Forwarded-Proto support to also handle X-Forwarded-Host and X-Forwarded-Port headers. This allows LiteLLM to correctly construct redirect URIs and endpoint URLs when deployed behind a reverse proxy that changes the host/port.

Example scenario:
- Internal URL: http://localhost:8888/github/mcp
- External URL: https://proxy.abc.com/github/mcp
- Proxy sets: X-Forwarded-Proto: https, X-Forwarded-Host: proxy.abc.com

Changes:
- Added get_request_base_url() helper function to centralize X-Forwarded-* header handling
- Replaced all inline X-Forwarded-Proto checks with calls to the helper function
- Helper handles X-Forwarded-Proto, X-Forwarded-Host, and X-Forwarded-Port
- Added tests for X-Forwarded-Host scenarios in authorize and token endpoints

Fixes issue where protected resource URL mismatch occurred:
  Error: Protected resource http://proxy.abc.com:8888/github/mcp
  does not match expected https://proxy.abc.com/github/mcp

🤖 Generated with [Claude Code](https://claude.com/claude-code)

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

* chore: replace Yelp-specific hostnames with generic examples

Changed all references from chatproxy.yelpcorp.com to proxy.example.com in:
- test_proxy_forwarding.py (default host parameter)
- TEST_PROXY_FORWARDING.md (documentation examples)
- discoverable_endpoints.py (docstring example)
- test_discoverable_endpoints.py (test mock data)

This makes the code more generic and suitable for open source.
All 13 tests still passing.

* remove accidentally added files

* fix formatting

* add new test for get_base_url

---------

Co-authored-by: Claude <noreply@anthropic.com>
2025-10-29 19:11:32 -07:00
Jason RobertsandGitHub 6672250769 feat(guardrails): Add per-request profile overrides to PANW Prisma AIRS (#16069)
- Per-request metadata: profile_name, profile_id, user_ip, app_name
- Full litellm_call_id for traceability
- Optional profile_name (supports API keys with linked profiles)
- Backward compatible
2025-10-29 19:05:59 -07:00
Ishaan JaffandGitHub 95dd216150 [UI] Feature - Add Apply Guardrail Testing Playground (#16030)
* add applyGuardrail endpoints

* v0 testing apply guard

* fix: use tabs

* move apply guardrails endpoint

* fix apply_guardrail

* fix applyGuardrail

* fix apply guardrail for bedrock

* test guard endpoints

* add tooltip for enter button

* refactor

* add guardrail test

* tests guardrails selector

* TestNomaApplyGuardrail
2025-10-28 16:41:17 -07:00
Ishaan JaffandGitHub 5c375b23ae [Fix] Guardrails - Ensure Key Guardrails are applied (#16025)
* _add_guardrails_from_key_or_team_metadata

* test_team_guardrails_append_to_key_guardrails

* fix move_guardrails_to_metadata

* fix _add_guardrails_from_key_or_team_metadata
2025-10-28 16:40:49 -07:00
ArielandGitHub 647f2f5d86 [feat]: graceful degradation for pillar service when using litellm (#15857)
* graceful degradation for pillar service when using litellm

* remove unnecessary mode

* simplify docs

* final fixes

* lint fixes

* fix linting
2025-10-27 19:51:29 -07:00
YutaSaitoandGitHub 8b33328cc1 Perf speed up pytest (#15951)
* perf: Skip sleep delays in base_mail.py during tests to improve test speed

* perf: Mock datetime.now in parallel_request_limiter_v3.py to improve test speed

* pref: Mock urllib system calls in test_aiohttp_transport.py to improve test speed

* chore: add --durations=50 to visualize slowest tests

* pref: reduce setup phase overhead by widening fixture scope in conftest.py

* test: stabilize flaky tests

* fix: minor issue
2025-10-27 19:43:40 -07:00
Ishaan JaffandGitHub 4cef208c5f [Fix] - Responses API - add /openai routes for responses API. (Azure OpenAI SDK Compatibility) (#15988)
* add /openai routes for responses API

* TestResponsesAPIEndpoints
2025-10-27 19:12:13 -07:00