litellm/litellm/proxy
oss-agent-shin c8e47dcb43
Fix early proxy request size enforcement (#27311)
* Add early proxy request size guard

Co-authored-by: ishaan-berri <ishaan-berri@users.noreply.github.com>

* Address request size review feedback

Co-authored-by: ishaan-berri <ishaan-berri@users.noreply.github.com>

---------

Co-authored-by: oss-agent-shin <279349115+oss-agent-shin@users.noreply.github.com>
Co-authored-by: ishaan-berri <ishaan-berri@users.noreply.github.com>
2026-05-06 12:29:11 -07:00
..
_experimental fix(anthropic, mcp): sanitize tool names to match Anthropic's [a-zA-Z0-9_-]{1,128} pattern (#26788) 2026-05-06 00:00:36 +00:00
agent_endpoints fix(proxy): use set lookup for permitted agent filters 2026-05-01 21:47:18 -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/member access group team (#27317) 2026-05-06 12:05:22 -07:00
batches_endpoints fix(proxy/batches): forward model to retrieve_batch for bedrock 2026-04-29 22:48:03 +02:00
client fix: scope CLI stored token to base_url to prevent cross-domain credential leakage (#26945) 2026-05-01 12:11:32 -07:00
common_utils Merge remote-tracking branch 'upstream/litellm_internal_staging' into codex/skills-containers-tenant-guard 2026-05-05 01:41:25 +00:00
config_management_endpoints
container_endpoints chore(container): use delete_cache, json-encode scope key, clean test 2026-05-05 00:43:47 +00:00
credential_endpoints style: run black formatter on files from main merge 2026-04-17 13:02:59 -07:00
custom_hooks style: run black formatter on entire codebase 2026-03-11 17:07:57 -03:00
db fix(proxy): keep spend log cleanup running after batch failures and surface DB errors (#27303) 2026-05-06 18:39:15 +00:00
discovery_endpoints feat: add control plane for multi-proxy worker management 2026-03-19 22:50:19 -07:00
example_config_yaml [Fix] Tests: Restore /metrics access for prometheus test suite 2026-05-04 20:54:54 -07:00
fine_tuning_endpoints style: run black formatter on files from main merge 2026-04-17 13:02:59 -07:00
google_endpoints run pre_call_hook on Google generateContent endpoints 2026-04-30 16:43:42 -07:00
guardrails Merge pull request #26957 from stuxf/chore/guardrail-coverage 2026-05-04 18:01:27 -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(proxy): preserve low-detail readiness status 2026-05-01 19:09:37 -07:00
hooks Include model name + configured TPM/RPM in priority rate-limit 429 er… (#27216) 2026-05-05 19:05:22 -07:00
image_endpoints fix: tighten file input handling in image edit endpoints 2026-04-22 18:04:39 -07:00
management_endpoints Fix SCIM user lookup filters (#27308) 2026-05-06 11:58:47 -07:00
management_helpers Merge branch 'litellm_internal_staging' into litellm_token_verification_query_opt 2026-04-30 17:25:12 -07:00
memory Litellm memory improvements v2 (#26541) 2026-04-25 19:03:43 -07:00
middleware Fix early proxy request size enforcement (#27311) 2026-05-06 12:29:11 -07:00
ocr_endpoints style: run black formatter on entire codebase 2026-03-11 17:07:57 -03:00
openai_evals_endpoints style: run black formatter on entire codebase 2026-03-11 17:07:57 -03:00
openai_files_endpoints harden cloud file compatibility path 2026-05-01 18:14:36 -07:00
pass_through_endpoints Merge branch 'litellm_yj_may1' into codex/budget-race-enforcement 2026-05-01 14:32:18 -07:00
policy_engine Fix runtime policy attachment initialization 2026-05-01 17:11:57 -07:00
prompts style: run black formatter on files from main merge 2026-04-17 13:02:59 -07:00
public_endpoints chore(proxy): keep public AI hub unauthenticated 2026-05-01 19:07:21 -07:00
rag_endpoints test(vector stores): allow primitive rag depth boundary 2026-04-30 17:28:02 -07:00
realtime_endpoints [Fix] Use type:ignore instead of Union return type for realtime endpoint 2026-03-13 11:42:26 -07:00
rerank_endpoints
response_api_endpoints fix: address Greptile review comments 2026-03-19 14:10:58 +05:30
response_polling style: run black formatter on files from main merge 2026-04-17 13:02:59 -07:00
search_endpoints feat(proxy): move search tool access to object permissions 2026-04-29 12:29:20 +05:30
spend_tracking fix(security): prevent secret_fields from leaking into spend logs 2026-05-05 02:01:41 +00:00
swagger
test_prompts
types_utils style: run black formatter on entire codebase 2026-03-11 17:07:57 -03:00
ui_crud_endpoints fix(proxy): preserve public ai hub ui setting 2026-05-01 19:46:27 -07:00
vector_store_endpoints fix(vector_store): cache use-time embedding-config resolution 2026-05-03 10:27:53 +00:00
vector_store_files_endpoints chore(vector stores): address access review followups 2026-04-30 16:09:26 -07:00
vertex_ai_endpoints chore(callbacks): guard dynamic integration hosts 2026-04-30 14:27:19 -07:00
video_endpoints [Staging] - Ishaan March 17th (#23903) 2026-03-18 15:09:01 -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 fix ruff: APIRouter type-checking import, replace print with sys.std* writes 2026-04-29 17:23:10 -07:00
_lazy_openapi_snapshot.json Merge upstream/litellm_internal_staging into HEAD 2026-05-02 02:24:39 +00:00
_lazy_openapi_snapshot.py [Fix] Proxy: Repair Stale HTTP_METHODS Reference In Lazy OpenAPI Snapshot 2026-05-01 15:11:56 -07:00
_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 [Fix] Proxy: Address Greptile feedback on hook-cycle PR 2026-05-04 20:13:31 -07:00
cached_logo.jpg
caching_routes.py
common_request_processing.py Merge pull request #27024 from BerriAI/litellm_yj_may1 2026-05-01 16:36:24 -07:00
compliance_checks.py
custom_auth_auto.py
custom_prompt_management.py
custom_sso.py style: run black formatter on entire codebase 2026-03-11 17:07:57 -03:00
custom_validate.py
dd_span_tagger.py style: run black formatter on entire codebase 2026-03-11 17:07:57 -03:00
enterprise
health_check.py feat(proxy): add health_check_reasoning_effort for model health checks 2026-05-04 17:13:01 +05:30
lambda.py
litellm_pre_call_utils.py union x-litellm-tags with static team/key tags (#27247) 2026-05-05 17:46:42 -07:00
llamaguard_prompt.txt
logo.jpg
mcp_registry.json feat(ui): group MCP tools by CRUD risk category in allowlist panels (#23403) 2026-03-11 21:15:25 -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
post_call_rules.py
prisma_migration.py
prometheus_cleanup.py Add Prometheus child_exit cleanup for gunicorn workers 2026-02-27 16:11:15 -08:00
proxy_cli.py proxy: hot-reload config YAML when --reload is set (#27274) 2026-05-06 16:06:58 +00:00
proxy_config.yaml
proxy_server.py Fix early proxy request size enforcement (#27311) 2026-05-06 12:29:11 -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(proxy): hardcode mock-testing strip list to avoid cyclic import 2026-05-01 08:06:10 +00:00
schema.prisma fix(proxy): normalize managed resource team owner field 2026-05-04 17:05:50 -07:00
start.sh
utils.py fix(spend-logs): preserve no-traceback behavior for update_daily_tag_spend 2026-05-02 00:44:35 +00: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