litellm/litellm/proxy
Yuneng Jiang 151d7ab1bc
fix: isolate per-fetch HTTPException in centralized common_checks gate
The asyncio.gather in `_run_centralized_common_checks` ran with
`return_exceptions=False` and a single bare `except HTTPException`
arm, so an HTTPException from any one fetch (the realistic case is a
404 from `get_team_object` when a token references a deleted team)
zeroed out the user, end-user, project, and global-spend contexts in
addition to falling back the team object. That silently skipped the
user budget, end-user budget, and project enforcement passes inside
`common_checks` for the unrelated contexts that had actually fetched
fine.

Switch to `return_exceptions=True` and apply per-fetch fallback
(matches the pre-refactor per-fetch try/except pattern in the builder):

- ProxyException / BudgetExceededError still propagate as authz failures.
- HTTPException on the team fetch reconstructs from the token; on the
  other fetches it nulls only that one context.
- Successful fetches always reach `common_checks` intact.

Adds two unit tests covering the team-404 and user-404 cases to lock
the per-fetch isolation in. Drops the inaccurate `PROXY_ADMIN tokens
short-circuit` claim from the docstring — admin tokens still flow
through `common_checks`; admin status is only honored where the
underlying check exempts it.
2026-04-25 09:58:23 -07:00
..
_experimental Merge pull request #26274 from stuxf/fix/mcp-byok-oauth-auth 2026-04-24 13:05:44 -07:00
agent_endpoints feat(guardrails): LLM-as-a-Judge guardrail (#26360) 2026-04-24 17:15:32 -07:00
analytics_endpoints fix(spend): session-TZ-independent date filtering for spend/error log queries 2026-04-10 17:04:52 -07:00
anthropic_endpoints style: run black formatter on files from main merge 2026-04-17 13:02:59 -07:00
auth fix: isolate per-fetch HTTPException in centralized common_checks gate 2026-04-25 09:58:23 -07:00
batches_endpoints
client style: run black formatter on files from main merge 2026-04-17 13:02:59 -07:00
common_utils refactor(rbac): narrow org-admin restriction to key generation only 2026-04-24 19:36:31 -07:00
config_management_endpoints
container_endpoints style: run black formatter on files from main merge 2026-04-17 13:02:59 -07:00
credential_endpoints style: run black formatter on files from main merge 2026-04-17 13:02:59 -07:00
custom_hooks
db Merge pull request #26279 from stuxf/fix/post-auth-enforcement 2026-04-24 13:04:29 -07:00
discovery_endpoints
example_config_yaml fix(adaptive_router): 3 P1 review defects 2026-04-20 15:22:18 -07:00
fine_tuning_endpoints style: run black formatter on files from main merge 2026-04-17 13:02:59 -07:00
google_endpoints
guardrails Merge remote-tracking branch 'origin/litellm_internal_staging' into litellm_yj_apr23 2026-04-25 09:47:47 -07:00
health_check_utils Optimize database query which fetches latest model_id, model_name pairs and dedupes them in memory. 2026-04-15 00:54:37 +00:00
health_endpoints fix: /health/readiness 503 loop when DB is unreachable (#26134) 2026-04-20 15:29:43 -07:00
hooks fix: skip personal budget check in MaxBudgetLimiter for team-key requests 2026-04-21 10:38:08 -07:00
image_endpoints fix: tighten file input handling in image edit endpoints 2026-04-22 18:04:39 -07:00
management_endpoints Merge remote-tracking branch 'origin/litellm_internal_staging' into litellm_yj_apr23 2026-04-25 09:47:47 -07:00
management_helpers fix(team): surface budget_reset_at on /team/info and cloned member budgets 2026-04-22 18:27:36 -07:00
memory feat(proxy): add /v1/memory CRUD endpoints (#26218) 2026-04-24 18:38:07 -07:00
middleware style: run black formatter on files from main merge 2026-04-17 13:02:59 -07:00
ocr_endpoints
openai_evals_endpoints
openai_files_endpoints style: run black formatter on files from main merge 2026-04-17 13:02:59 -07:00
pass_through_endpoints fix: preserve trailing slash when joining pass-through paths 2026-04-24 18:23:59 -07:00
policy_engine style: run black formatter on files from main merge 2026-04-17 13:02:59 -07:00
prompts style: run black formatter on files from main merge 2026-04-17 13:02:59 -07:00
public_endpoints Merge remote-tracking branch 'origin/litellm_internal_staging' into litellm_/wonderful-bouman 2026-04-17 21:32:09 -07:00
rag_endpoints style: run black formatter on files from main merge 2026-04-17 13:02:59 -07:00
realtime_endpoints
rerank_endpoints
response_api_endpoints
response_polling style: run black formatter on files from main merge 2026-04-17 13:02:59 -07:00
search_endpoints style: run black formatter on files from main merge 2026-04-17 13:02:59 -07:00
spend_tracking Scope NULLS LAST to ttft_ms only 2026-04-24 22:52:04 -07:00
swagger
test_prompts
types_utils
ui_crud_endpoints Merge pull request #26442 from BerriAI/litellm_feat-restrict-org-admin-permissions 2026-04-25 08:50:26 -07:00
vector_store_endpoints fix(proxy): respect object-level permissions for managed vector store endpoints (#26351) 2026-04-24 09:21:13 -07:00
vector_store_files_endpoints
vertex_ai_endpoints style: run black formatter on files from main merge 2026-04-17 13:02:59 -07:00
video_endpoints
__init__.py
_logging.py
_new_new_secret_config.yaml
_new_secret_config.yaml Litellm krrish staging 04 20 2026 (#26138) 2026-04-20 16:22:12 -07:00
_super_secret_config.yaml
_types.py Merge pull request #26490 from BerriAI/litellm_restrict_global_spend_routes 2026-04-25 09:30:36 -07:00
.gitignore
cached_logo.jpg
caching_routes.py
common_request_processing.py style: run black formatter on files from main merge 2026-04-17 13:02:59 -07:00
compliance_checks.py
custom_auth_auto.py
custom_prompt_management.py
custom_sso.py
custom_validate.py
dd_span_tagger.py
enterprise
health_check.py style: apply black formatting 2026-04-20 16:02:21 -07:00
lambda.py
litellm_pre_call_utils.py Prompt Compression - add it to the proxy (#25729) 2026-04-20 15:08:00 -07:00
llamaguard_prompt.txt
logo.jpg
mcp_registry.json
mcp_tools.py
model_config.yaml
openapi_registry.json
openapi.json
post_call_rules.py
prisma_migration.py
prometheus_cleanup.py
proxy_cli.py [Feature] Proxy: opt-in v2 migration resolver (--use_v2_migration_resolver) 2026-04-21 14:20:35 -07:00
proxy_config.yaml
proxy_server.py feat(proxy): add /v1/memory CRUD endpoints (#26218) 2026-04-24 18:38:07 -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 fix: align agent endpoint and routing permission checks with existing pattern 2026-04-16 17:22:28 -07:00
schema.prisma feat(proxy): add /v1/memory CRUD endpoints (#26218) 2026-04-24 18:38:07 -07:00
start.sh
utils.py fix(proxy): guardrail header dedupe, mypy during_call, test mock kwargs 2026-04-22 23:22:35 +03: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