litellm/litellm/proxy
Ishaan Jaff 371cabfebd
Add MCP Security guardrail to block unregistered MCP servers (#21429)
* Add MCP_SECURITY enum to SupportedGuardrailIntegrations

* Add MCP security guardrail initializer

* Add MCPSecurityGuardrail implementation

* Add MCP Security policy template

* Add Type filter to policy templates UI

* Add unit tests for MCP security guardrail

* fix(lint): remove unused Dict import from mcp_security_guardrail

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

* Add French language support for EU AI Act Article 5 guardrail (#21427)

* Add French language support for EU AI Act Article 5 template

- Create eu_ai_act_article5_fr.yaml with comprehensive French keywords
- Includes identifier words: concevoir, créer, développer, noter, classer, etc.
- Includes block words: crédit social, comportement social, émotion des employés, etc.
- Includes always-block keywords for explicit prohibited practices
- Includes exceptions for research, compliance, and legitimate use cases
- Catches circumvention attempts with phrase variations

* Add comprehensive tests for French EU AI Act guardrail

- Test 3 critical scenarios: blocked query, circumvention attempt, safe query
- Test edge cases: case-insensitive, mixed language, research exceptions
- All 7 tests passing
- Validates both blocking and allowing behavior

* Fix content filter to support conditional matching without inherit_from

- Enable conditional matching when identifier_words + additional_block_words are present
- Previously required inherit_from, but EU AI Act templates are self-contained
- Fixes Greptile feedback: conditional matching now works as documented

* Add pure conditional matching test for French guardrail

- Test identifier + block word combinations not in always_block_keywords
- Verifies conditional matching works independently
- Addresses Greptile feedback about test coverage gap

* Fix exception word bypass risk in French template

- Replace short words (film, jeu, juste) with context-specific phrases
- Prevents substring matching bypasses (e.g., enjeu matching jeu)
- Add tests for bypass prevention and legitimate game context
- Addresses Greptile security feedback

* Make conditional match assertion more robust

- Use getattr to safely access exception detail field
- Check if detail is dict before calling .get()
- Addresses Greptile feedback about brittle string assertion

* Add French EU AI Act Article 5 policy template to registry

- Add eu-ai-act-article5-fr template for French language support
- Includes French description and guardrail info
- Matches structure of English template

* Address greptile review feedback (greploop iteration 1)

- Use status_code=400 instead of 403 to match guardrail logging convention
- Use prefix stripping instead of split('/')[-1] for robust server name extraction

* remove French EU AI Act template from policy_templates.json

---------

Co-authored-by: Julio Quinteros Pro <jquinter@gmail.com>
Co-authored-by: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-02-17 21:19:13 -08:00
..
_experimental Add GDPR Art. 32 EU PII Protection Policy Template (#21340) 2026-02-16 15:28:46 -08:00
agent_endpoints Merge remote-tracking branch 'origin' into litellm_access_groups_inte 2026-02-14 13:27:36 -08:00
analytics_endpoints
anthropic_endpoints [Fix] 404 Not Found on /api/event_logging/batch endpoint (#20504) 2026-02-05 10:58:08 -08:00
auth fixing linting 2026-02-14 15:58:42 -08:00
batches_endpoints fix: proxy/batches_endpoints/endpoints.py:309:11: PLR0915 Too many statements (54 > 50) 2026-02-16 18:41:06 +05:30
client
common_utils fix: remove unused asyncio imports (F401) 2026-02-17 18:54:18 -03:00
config_management_endpoints
container_endpoints
credential_endpoints
custom_hooks
db perf(spend): avoid duplicate daily agent transaction computation (#21187) 2026-02-16 18:28:34 +05:30
discovery_endpoints fix(azure): preserve content_policy_violation error details from Azure OpenAI (#20883) 2026-02-10 22:47:03 -08:00
example_config_yaml [Guardrails] Add guardrail pipeline support for conditional sequential execution (#21177) 2026-02-13 19:49:12 -08:00
fine_tuning_endpoints
google_endpoints
guardrails Add MCP Security guardrail to block unregistered MCP servers (#21429) 2026-02-17 21:19:13 -08:00
health_check_utils fix: shared health check serialization (#21119) 2026-02-13 09:15:43 -08:00
health_endpoints
hooks Add comments 2026-02-14 19:46:56 -05:00
image_endpoints fix(arize-phoenix): dynamic project naming from metadata + guardrails on image generation 2026-02-11 15:45:46 +05:30
management_endpoints Add compliance checker endpoints + UI panel (#21432) 2026-02-17 18:22:26 -08:00
management_helpers
middleware
ocr_endpoints
openai_evals_endpoints Fix mypy issues 2026-02-17 20:51:51 +05:30
openai_files_endpoints Addressed greptile comments to extract common helpers and return 404 2026-02-16 07:58:04 -05:00
pass_through_endpoints fix(ci): Fix mypy type errors across 6 files (#21179) 2026-02-13 18:14:43 -08:00
policy_engine Merge pull request #21202 from jquinter/fix-unused-variable-pipeline-executor 2026-02-14 14:36:01 -03:00
prompts
public_endpoints
rag_endpoints
rerank_endpoints
response_api_endpoints
response_polling
search_endpoints
spend_tracking fixes - showing content filter on failure 2026-02-17 17:57:52 -08:00
swagger
test_prompts
types_utils
ui_crud_endpoints Merge pull request #20444 from BerriAI/litellm_ui_config_req_auth_mh 2026-02-06 12:34:27 -08:00
vector_store_endpoints fix(ci): Fix mypy type errors across 6 files (#21179) 2026-02-13 18:14:43 -08:00
vector_store_files_endpoints Add support for managed file ids 2026-02-13 10:52:48 +05:30
vertex_ai_endpoints
video_endpoints
__init__.py
_logging.py
_new_new_secret_config.yaml
_new_secret_config.yaml Guardrails - new Policy Templates (pre-configured guardrail combinations for specific use-cases) (#21025) 2026-02-13 11:53:02 -08:00
_super_secret_config.yaml
_types.py Merge branch 'main' into litellm_fix-virtual-key-grace-period 2026-02-15 08:09:13 +05:30
.gitignore
cached_logo.jpg
caching_routes.py
common_request_processing.py Fix mypy issues 2026-02-17 20:51:51 +05:30
compliance_checks.py Add compliance checker endpoints + UI panel (#21432) 2026-02-17 18:22:26 -08:00
custom_auth_auto.py
custom_prompt_management.py
custom_sso.py Add support for extra fields in Generic SSO via GENERIC_USER_EXTRA_ATTRIBUTES (#20761) 2026-02-10 16:00:28 +05:30
custom_validate.py
enterprise
health_check.py
lambda.py
litellm_pre_call_utils.py docs: improve comment clarity per Greptile feedback 2026-02-14 14:43:20 -03:00
llamaguard_prompt.txt
logo.jpg
mcp_registry.json feat: MCP server discovery UI (#21079) 2026-02-12 17:59:21 -08:00
mcp_tools.py
model_config.yaml
openapi.json
post_call_rules.py
prisma_migration.py
proxy_cli.py fix(proxy): handle missing DATABASE_URL in append_query_params (#21239) 2026-02-16 09:03:10 -08:00
proxy_config.yaml [UI] M2M OAuth2 UI Flow (#20794) 2026-02-09 19:28:02 -08:00
proxy_server.py Add compliance checker endpoints + UI panel (#21432) 2026-02-17 18:22:26 -08:00
README.md
route_llm_request.py fix(lint): suppress PLR0915 in route_request function 2026-02-17 14:38:17 -03:00
schema.prisma Merge branch 'main' into litellm_fix-virtual-key-grace-period 2026-02-15 08:09:13 +05:30
start.sh
utils.py Merge branch 'main' into litellm_fix-virtual-key-grace-period 2026-02-15 08:09:13 +05:30

litellm-proxy

A local, fast, and lightweight OpenAI-compatible server to call 100+ LLM APIs.

usage

$ pip install litellm
$ litellm --model ollama/codellama 

#INFO: Ollama running on http://0.0.0.0:8000

replace openai base

import openai # openai v1.0.0+
client = openai.OpenAI(api_key="anything",base_url="http://0.0.0.0:8000") # set proxy to base_url
# request sent to model set on litellm proxy, `litellm --model`
response = client.chat.completions.create(model="gpt-3.5-turbo", messages = [
    {
        "role": "user",
        "content": "this is a test request, write a short poem"
    }
])

print(response)

See how to call Huggingface,Bedrock,TogetherAI,Anthropic, etc.


Folder Structure

Routes

  • proxy_server.py - all openai-compatible routes - /v1/chat/completion, /v1/embedding + model info routes - /v1/models, /v1/model/info, /v1/model_group_info routes.
  • health_endpoints/ - /health, /health/liveliness, /health/readiness
  • management_endpoints/key_management_endpoints.py - all /key/* routes
  • management_endpoints/team_endpoints.py - all /team/* routes
  • management_endpoints/internal_user_endpoints.py - all /user/* routes
  • management_endpoints/ui_sso.py - all /sso/* routes