litellm/litellm/proxy
Krish Dholakia cf439c269c
Agents - add max budget + tpm/rpm limiting per agent AND per agent session (#22849)
* feat: enforce x-litellm-trace-id in header, if required

* feat: update spend for agent

* refactor: update agent table to follow similar format as other entities - also add a spend column - allows us to see spend of an agent

* fix: cleanup ui

* feat: return spend on agent endpoints

* feat: scope pr

* feat(agents/): support budgets + rate limiting on agents + agent sessions

* fix: address PR review feedback

- Add missing tpm_limit, rpm_limit, session_tpm_limit, session_rpm_limit
  columns to root schema.prisma to match proxy and extras schemas
- Add backwards-compatible fallback to key metadata for max_iterations
  so existing users don't silently lose enforcement

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

* fix: qa'ed RPM limiting on agents

---------

Co-authored-by: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-07 19:12:42 -08:00
..
_experimental CircleCI test stability (#23055) 2026-03-07 15:19:39 -08:00
agent_endpoints Agents - add max budget + tpm/rpm limiting per agent AND per agent session (#22849) 2026-03-07 19:12:42 -08:00
analytics_endpoints
anthropic_endpoints fix(count_tokens): include system and tools in token counting API requests 2026-02-27 15:39:35 -03:00
auth Agents - add max budget + tpm/rpm limiting per agent AND per agent session (#22849) 2026-03-07 19:12:42 -08:00
batches_endpoints Merge pull request #22728 from BerriAI/litellm_batch_expiry_validation_followup 2026-03-04 10:16:02 -08:00
client
common_utils Merge pull request #20688 from BerriAI/litellm_budget_tier_enforcement_for_keys 2026-03-06 20:44:58 -08:00
config_management_endpoints
container_endpoints
credential_endpoints
custom_hooks
db Agents - add max budget + tpm/rpm limiting per agent AND per agent session (#22849) 2026-03-07 19:12:42 -08:00
discovery_endpoints
example_config_yaml
fine_tuning_endpoints
google_endpoints fix: Metadata / Trace ID Missing in S3 Streaming Callbacks 2026-02-25 14:16:21 +05:30
guardrails Agents - add max budget + tpm/rpm limiting per agent AND per agent session (#22849) 2026-03-07 19:12:42 -08:00
health_check_utils
health_endpoints Prisma DB Failure Detection and Self-Healing (#21059) 2026-03-05 13:44:49 -08:00
hooks Agents - add max budget + tpm/rpm limiting per agent AND per agent session (#22849) 2026-03-07 19:12:42 -08:00
image_endpoints
management_endpoints Merge pull request #23065 from BerriAI/litellm_fix_team_scoped_virtual_keys 2026-03-07 17:43:25 -08:00
management_helpers
middleware Fix inflight mypy 2026-03-02 19:41:32 +05:30
ocr_endpoints Enable local file support for OCR (#22133) 2026-02-27 10:50:02 -08:00
openai_evals_endpoints
openai_files_endpoints Merge pull request #22728 from BerriAI/litellm_batch_expiry_validation_followup 2026-03-04 10:16:02 -08:00
pass_through_endpoints fix(pass_through): inject cost into Anthropic streaming chunks + fix SSE parsing in tests (#23078) 2026-03-07 17:27:51 -08:00
policy_engine
prompts
public_endpoints Development environment setup (#22432) 2026-02-28 14:50:06 -08:00
rag_endpoints
rerank_endpoints
response_api_endpoints feat(proxy): add WebSocket endpoint for responses API and route_llm_request support 2026-03-02 17:22:44 +05:30
response_polling
search_endpoints
spend_tracking feat(spend-logs): add truncation note when error logs are truncated for DB storage (#22936) 2026-03-05 16:58:46 -08:00
swagger
test_prompts
types_utils
ui_crud_endpoints [Fix] PATCH /update/ui_settings now merges with existing record instead of overwriting 2026-03-05 15:49:40 -08:00
vector_store_endpoints [Feature] RBAC for Vector Stores and Agents 2026-03-04 20:13:14 -08:00
vector_store_files_endpoints
vertex_ai_endpoints
video_endpoints
__init__.py
_logging.py
_new_new_secret_config.yaml
_new_secret_config.yaml [Feat] Add Tool Policies for AI Gateway (#22732) 2026-03-03 20:22:20 -08:00
_super_secret_config.yaml
_types.py Agents - add max budget + tpm/rpm limiting per agent AND per agent session (#22849) 2026-03-07 19:12:42 -08:00
.gitignore
cached_logo.jpg
caching_routes.py
common_request_processing.py Merge pull request #22559 from BerriAI/litellm_responses_websocket 2026-03-04 17:57:34 +05:30
compliance_checks.py
custom_auth_auto.py
custom_prompt_management.py
custom_sso.py chore: remove debug print statements from custom_sso.py 2026-03-07 12:27:16 +02:00
custom_validate.py
dd_span_tagger.py feat(proxy): add key_alias, key_hash, requested_model DD APM span tags (#22710) 2026-03-03 20:22:59 -08:00
enterprise
health_check.py add docs and formatting 2026-02-28 14:08:09 +05:30
lambda.py
litellm_pre_call_utils.py Agents - add max budget + tpm/rpm limiting per agent AND per agent session (#22849) 2026-03-07 19:12:42 -08:00
llamaguard_prompt.txt
logo.jpg
mcp_registry.json
mcp_tools.py
model_config.yaml
openapi.json
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 Add Prometheus child_exit cleanup for gunicorn workers 2026-02-27 16:11:15 -08:00
proxy_config.yaml
proxy_server.py Agents - add max budget + tpm/rpm limiting per agent AND per agent session (#22849) 2026-03-07 19:12:42 -08:00
README.md
route_llm_request.py feat(proxy): add WebSocket endpoint for responses API and route_llm_request support 2026-03-02 17:22:44 +05:30
schema.prisma Agents - add max budget + tpm/rpm limiting per agent AND per agent session (#22849) 2026-03-07 19:12:42 -08:00
start.sh
utils.py Agents - add max budget + tpm/rpm limiting per agent AND per agent session (#22849) 2026-03-07 19:12:42 -08:00

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