litellm/litellm/proxy
Thibault Serot aa48016d91 fix(responses): surface MCP gateway initial-call failures instead of emitting a broken stream
When the initial LLM call inside MCPEnhancedStreamingIterator fails (e.g.
an invalid previous_response_id -> provider 400 'No tool output found for
function call ...'), the proxy returned HTTP 200 and the stream emitted the
pre-generated mcp_list_tools discovery events with no response.created
before them. That violates the Responses API streaming contract and crashes
SDK stream accumulators (openai-node: "expected 'response.created' event,
got response.mcp_list_tools.in_progress").

- aresponses_api_with_mcp now makes the initial call eagerly, before any
  SSE bytes are written, and re-raises the stashed failure so the client
  gets a real 4xx/5xx with the provider error body.
- If a creation failure still surfaces during iteration, the stream emits a
  single terminal 'error' event instead of discovery events.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
2026-07-09 14:43:14 +10:00
..
_experimental fix(mcp): roll up MCP tool spend to user counters and usage UI (#31576) 2026-07-02 08:16:39 -07:00
a2a feat(a2a): support a2a-sdk 1.x proxy routing for 0.3 and 1.0 agents (#30950) 2026-06-29 09:32:39 +05:30
agent_endpoints feat(a2a): support a2a-sdk 1.x proxy routing for 0.3 and 1.0 agents (#30950) 2026-06-29 09:32:39 +05:30
analytics_endpoints style: unify ruff format width on 120 (#31518) 2026-06-27 12:39:29 -07:00
anthropic_endpoints fix: report real usage on streaming blocks, disable buffered mode for content-rewriting guardrails 2026-07-02 21:22:15 +05:30
auth fix(proxy): extend banned-params + admin-clear lists for NVIDIA Riva (VERIA-493) (#31742) 2026-06-30 15:30:08 -07:00
batches_endpoints test(e2e): add live batches suite across providers and routing scenarios (#30958) 2026-07-02 08:05:23 -07:00
client feat(proxy): add AES-256-GCM at-rest credential encryption with versioned format and re-encryption migration (#31215) 2026-06-29 20:14:22 +02:00
common_utils fix(proxy): tighten role gating on /get/config/callbacks response (#31745) 2026-07-01 17:58:31 -07:00
config_management_endpoints build(deps-dev): bump black to 26.3.1 and apply formatting (#28525) 2026-05-21 17:24:18 -07:00
container_endpoints style: unify ruff format width on 120 (#31518) 2026-06-27 12:39:29 -07:00
credential_endpoints style: unify ruff format width on 120 (#31518) 2026-06-27 12:39:29 -07:00
custom_hooks style: run black formatter on entire codebase 2026-03-11 17:07:57 -03:00
db fix(proxy): isolate poison spend-log rows so one bad record can't drop the whole batch (#31705) 2026-06-30 12:21:14 -07:00
discovery_endpoints style: unify ruff format width on 120 (#31518) 2026-06-27 12:39:29 -07:00
example_config_yaml style: unify ruff format width on 120 (#31518) 2026-06-27 12:39:29 -07:00
fine_tuning_endpoints style: unify ruff format width on 120 (#31518) 2026-06-27 12:39:29 -07:00
google_endpoints style: unify ruff format width on 120 (#31518) 2026-06-27 12:39:29 -07:00
guardrails fix: handle Anthropic streaming guardrail blocks 2026-07-02 16:13:51 +00:00
health_check_utils style: unify ruff format width on 120 (#31518) 2026-06-27 12:39:29 -07:00
health_endpoints fix(proxy): authorize /health/test_connection against loaded deployment's team_id (VERIA-441) (#31767) 2026-07-01 17:05:49 -07:00
hooks fix(mcp): roll up MCP tool spend to user counters and usage UI (#31576) 2026-07-02 08:16:39 -07:00
image_endpoints style: unify ruff format width on 120 (#31518) 2026-06-27 12:39:29 -07:00
logging_endpoints style: unify ruff format width on 120 (#31518) 2026-06-27 12:39:29 -07:00
management_endpoints fix(mcp): byom visibility, preview UX, and admin settings gating (#31809) 2026-07-02 01:04:22 -07:00
management_helpers refactor(proxy): type object_permission dict with ObjectPermissionDict 2026-06-27 19:47:14 -07:00
memory style: unify ruff format width on 120 (#31518) 2026-06-27 12:39:29 -07:00
middleware style: unify ruff format width on 120 (#31518) 2026-06-27 12:39:29 -07:00
ocr_endpoints style: unify ruff format width on 120 (#31518) 2026-06-27 12:39:29 -07:00
openai_evals_endpoints style: unify ruff format width on 120 (#31518) 2026-06-27 12:39:29 -07:00
openai_files_endpoints style: unify ruff format width on 120 (#31518) 2026-06-27 12:39:29 -07:00
pass_through_endpoints style: unify ruff format width on 120 (#31518) 2026-06-27 12:39:29 -07:00
policy_engine style: unify ruff format width on 120 (#31518) 2026-06-27 12:39:29 -07:00
prompts style: unify ruff format width on 120 (#31518) 2026-06-27 12:39:29 -07:00
public_endpoints feat(a2a): support a2a-sdk 1.x proxy routing for 0.3 and 1.0 agents (#30950) 2026-06-29 09:32:39 +05:30
rag_endpoints style: unify ruff format width on 120 (#31518) 2026-06-27 12:39:29 -07:00
realtime_endpoints style: unify ruff format width on 120 (#31518) 2026-06-27 12:39:29 -07:00
rerank_endpoints style: unify ruff format width on 120 (#31518) 2026-06-27 12:39:29 -07:00
response_api_endpoints style: unify ruff format width on 120 (#31518) 2026-06-27 12:39:29 -07:00
response_polling style: unify ruff format width on 120 (#31518) 2026-06-27 12:39:29 -07:00
search_endpoints style: unify ruff format width on 120 (#31518) 2026-06-27 12:39:29 -07:00
shutdown feat(proxy): native /health/drain preStop hook for graceful shutdown (#29439) 2026-06-02 16:30:44 -07:00
spend_tracking fix(mcp): roll up MCP tool spend to user counters and usage UI (#31576) 2026-07-02 08:16:39 -07:00
swagger Change favicon (#16837) 2025-11-19 20:38:22 -08:00
test_prompts
types_utils style: unify ruff format width on 120 (#31518) 2026-06-27 12:39:29 -07:00
ui_crud_endpoints fix(mcp): byom visibility, preview UX, and admin settings gating (#31809) 2026-07-02 01:04:22 -07:00
vector_store_endpoints style: unify ruff format width on 120 (#31518) 2026-06-27 12:39:29 -07:00
vector_store_files_endpoints style: unify ruff format width on 120 (#31518) 2026-06-27 12:39:29 -07:00
vertex_ai_endpoints style: unify ruff format width on 120 (#31518) 2026-06-27 12:39:29 -07:00
video_endpoints style: unify ruff format width on 120 (#31518) 2026-06-27 12:39:29 -07:00
workflows feat(proxy): durable agent workflow run tracking via /v1/workflows/runs (#26793) 2026-04-29 17:12:18 -07:00
.gitignore
__init__.py
_lazy_features.py style: unify ruff format width on 120 (#31518) 2026-06-27 12:39:29 -07:00
_lazy_openapi_snapshot.json Litellm oss staging 1 (#28337) 2026-05-20 17:27:03 -07:00
_lazy_openapi_snapshot.py style: unify ruff format width on 120 (#31518) 2026-06-27 12:39:29 -07:00
_logging.py
_new_new_secret_config.yaml Revert "chore: remove _experimental/out (#31546)" 2026-07-01 13:25:47 -07:00
_new_secret_config.yaml Revert "chore: remove _experimental/out (#31546)" 2026-07-01 13:25:47 -07:00
_super_secret_config.yaml Revert "chore: remove _experimental/out (#31546)" 2026-07-01 13:25:47 -07:00
_types.py feat(mcp): add mcp_tool_search virtual tools for large tool catalogs (#31777) 2026-06-30 20:03:59 -07:00
cached_logo.jpg fix: prompt registry 2026-02-18 00:34:54 +05:30
caching_routes.py style: unify ruff format width on 120 (#31518) 2026-06-27 12:39:29 -07:00
common_request_processing.py fix(proxy): emit x-litellm-response-cost header on /messages and /generateContent (LIT-4076) (#31675) 2026-06-29 20:29:49 -07:00
compliance_checks.py style: unify ruff format width on 120 (#31518) 2026-06-27 12:39:29 -07:00
custom_auth_auto.py style: unify ruff format width on 120 (#31518) 2026-06-27 12:39:29 -07:00
custom_prompt_management.py fix: prompt registry 2026-02-18 00:34:54 +05:30
custom_sso.py style: unify ruff format width on 120 (#31518) 2026-06-27 12:39:29 -07:00
custom_validate.py
dd_span_tagger.py style: unify ruff format width on 120 (#31518) 2026-06-27 12:39:29 -07:00
dev_config.yaml fix(responses): surface MCP gateway initial-call failures instead of emitting a broken stream 2026-07-09 14:43:14 +10:00
enterprise
health_check.py fix: skip health check for semantic auto_router deployments (#31668) 2026-06-29 19:47:20 -07:00
lambda.py
litellm_pre_call_utils.py feat(sandbox): reuse e2b container across requests when metadata.session_id is set (#31688) 2026-06-30 18:58:09 -07:00
llamaguard_prompt.txt
logo.jpg
mcp_registry.json fix(mcp): default Linear MCP registry entry to streamable HTTP (#30396) 2026-06-13 14:45:47 -07:00
mcp_tools.py
model_config.yaml
openapi.json
openapi_registry.json feat(ui): OpenAPI MCP server support with popular API quick-picker (#23200) 2026-03-10 13:59:52 -07:00
plugin_routes.py style: unify ruff format width on 120 (#31518) 2026-06-27 12:39:29 -07:00
post_call_rules.py ci(lint): add blanket-noqa, dataclass-default, and unused-noqa Ruff rules (#30516) 2026-06-16 12:07:22 -07:00
prisma_migration.py style: unify ruff format width on 120 (#31518) 2026-06-27 12:39:29 -07:00
prometheus_cleanup.py style: unify ruff format width on 120 (#31518) 2026-06-27 12:39:29 -07:00
proxy_cli.py style: unify ruff format width on 120 (#31518) 2026-06-27 12:39:29 -07:00
proxy_config.yaml fix: prompt registry 2026-02-18 00:34:54 +05:30
proxy_server.py fix: report the blocked LLM response's real token usage (#31217) 2026-07-02 21:22:15 +05:30
read_model_list.py feat: add minimal rust router + axum ai-gateway calling router.realtime (2/2) (#31135) 2026-06-23 19:16:34 -07:00
README.md build: migrate packaging, CI, and Docker from Poetry to uv (#25007) 2026-04-09 11:46:23 -07:00
route_llm_request.py style: unify ruff format width on 120 (#31518) 2026-06-27 12:39:29 -07:00
schema.prisma feat(mcp): add mcp_tool_search virtual tools for large tool catalogs (#31777) 2026-06-30 20:03:59 -07:00
start.sh
utils.py fix(proxy): isolate poison spend-log rows so one bad record can't drop the whole batch (#31705) 2026-06-30 12:21:14 -07:00
wildcard_config.yaml feat: add dev and wildcard proxy configs for local testing (#30556) 2026-06-17 06:47:11 -07:00

litellm-proxy

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

usage

$ uv tool 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