litellm/litellm/proxy
Alexsander Hamir a4eec173bc
fix: reduce get_deployment cost to O(1) (#14967)
* fix: reduce get_deployment cost to O(1)

* fix: add unit test

* fix: cleaner

* fix: reference errors

* fix: add missing unit tests
2025-09-27 13:44:10 -07:00
..
_experimental calculate_mcp_tool_call_cost 2025-09-27 12:11:00 -07:00
analytics_endpoints (code quality) run ruff rule to ban unused imports (#7313) 2024-12-19 12:33:42 -08:00
anthropic_endpoints [Fix] Remove INFO level log from /messages endpoint (#14377) 2025-09-09 12:51:03 -07:00
auth mypy lint fixes 2025-09-27 12:09:46 -07:00
batches_endpoints Batches - support batch retrieve with target model Query Param + Anthropic - completion bridge, yield content_block_stop chunk (#12228) 2025-07-01 22:13:48 -07:00
client fix: use fastuuid helper (#14903) 2025-09-25 15:47:01 -07:00
common_utils [Feat] UI - Allow scheduling key rotations when creating virtual keys (#14960) 2025-09-26 16:24:40 -07:00
config_management_endpoints (code quality) run ruff rule to ban unused imports (#7313) 2024-12-19 12:33:42 -08:00
credential_endpoints added support to credential delete to support slashes in the curl (#10987) 2025-05-20 19:08:48 -07:00
custom_hooks [Feat] SSO - Allow users to run a custom sso login handler (#12465) 2025-07-09 16:36:30 -07:00
db fix: use fastuuid helper (#14903) 2025-09-25 15:47:01 -07:00
discovery_endpoints fix code qa check 2025-07-11 22:35:27 -07:00
example_config_yaml Merge pull request #14519 from uc4w6c/feat/add_tools_permission_guardrail 2025-09-13 23:22:31 -07:00
fine_tuning_endpoints Litellm managed file updates combined (#11040) 2025-05-22 17:20:41 -07:00
google_endpoints format 2025-09-02 09:52:50 +08:00
guardrails make_bedrock_api_request 2025-09-27 12:12:30 -07:00
health_endpoints fix(_health_endpoints.py): protect /health/test_connection - only allow users who are allowed to create models, to call this endpoint 2025-09-17 18:00:59 -07:00
hooks _group_keys_by_hash_tag fix mypy 2025-09-27 12:10:28 -07:00
image_endpoints Feat: add add azure endpoint for image endpoints (#11482) 2025-06-06 10:38:37 -07:00
management_endpoints [Feat] UI - Allow scheduling key rotations when creating virtual keys (#14960) 2025-09-26 16:24:40 -07:00
management_helpers fix: use fastuuid helper (#14903) 2025-09-25 15:47:01 -07:00
middleware PrometheusAuthMiddleware 2025-04-04 20:37:53 -07:00
openai_files_endpoints fix: ci/cd tests + lint errors (#14646) 2025-09-17 18:00:59 -07:00
pass_through_endpoints fix: use fastuuid helper (#14903) 2025-09-25 15:47:01 -07:00
prompts Prompt Management - add prompts on UI (#13240) 2025-08-02 22:33:37 -07:00
public_endpoints build(ui/): UI - Public Model Hub v2 (#12532) 2025-07-11 22:24:31 -07:00
rerank_endpoints use correct get custom headers 2025-03-12 17:16:51 -07:00
response_api_endpoints [Feat]Add cancel endpoint support for openai and azure (#14561) 2025-09-15 07:08:56 -07:00
spend_tracking fix: use fastuuid helper (#14903) 2025-09-25 15:47:01 -07:00
swagger Swagger - bump DOMPurify version + add back Support local swagger bundle (good for airgapped environments) + support local swagger on custom root paths (#12911) 2025-07-23 11:22:56 -07:00
test_prompts Prompt Management (2/2) - New /prompt/list endpoint + key-based access to prompt templates (#13218) 2025-08-02 10:36:38 -07:00
types_utils [Feat] Allow reading custom logger python scripts from s3 (#12623) 2025-07-16 15:07:01 -07:00
ui_crud_endpoints fix: use fastuuid helper (#14903) 2025-09-25 15:47:01 -07:00
vector_store_endpoints [Feat] LLM API Endpoint - Expose OpenAI Compatible /vector_stores/{vector_store_id}/search endpoint (#12749) 2025-07-18 18:18:53 -07:00
vertex_ai_endpoints build(pyproject.toml): add new dev dependencies - for type checking (#9631) 2025-03-29 11:02:13 -07:00
.gitignore fix(gitmodules): remapping to new proxy 2023-10-12 21:23:53 -07:00
__init__.py refactor: add black formatting 2023-12-25 14:11:20 +05:30
_logging.py fix(_logging.py): fix timestamp format for json logs 2024-06-20 15:20:21 -07:00
_new_new_secret_config.yaml Ollama ssl verify = False + Spend Logs reliability fixes (#7931) 2025-01-23 23:05:41 -08:00
_new_secret_config.yaml feat: initial commit for v2 oauth flow 2025-09-26 15:25:42 -07:00
_super_secret_config.yaml docs(enterprise.md): cleanup docs 2024-07-15 14:52:08 -07:00
_types.py [Feat] UI - Allow scheduling key rotations when creating virtual keys (#14960) 2025-09-26 16:24:40 -07:00
cached_logo.jpg Litellm dev 01 23 2025 p2 (#7962) 2025-01-23 21:02:15 -08:00
caching_routes.py fix install on python 2025-06-14 15:42:06 -07:00
common_request_processing.py isort 2025-09-24 01:41:36 +09:00
custom_auth_auto.py Custom Auth - bubble up custom exceptions (#13093) 2025-07-29 16:28:25 -07:00
custom_prompt_management.py Litellm dev 07 03 2025 p2 (#12301) 2025-07-03 22:40:21 -07:00
custom_sso.py (code quality) run ruff rule to ban unused imports (#7313) 2024-12-19 12:33:42 -08:00
custom_validate.py build: merge commit 1b15568af7 2025-02-17 21:56:00 -08:00
enterprise feat(llama_guard.py): add llama guard support for content moderation + new async_moderation_hook endpoint 2024-02-17 19:13:04 -08:00
health_check.py feat: add a health_check_voice param 2025-05-19 13:02:06 +02:00
lambda.py Add mangum. 2023-11-23 00:04:47 -05:00
litellm_pre_call_utils.py feat(langsmith.py): add langsmith sampling rate 2025-09-17 18:02:33 -07:00
llamaguard_prompt.txt feat(llama_guard.py): allow user to define custom unsafe content categories 2024-02-17 17:42:47 -08:00
logo.jpg (feat) admin ui custom branding 2024-02-21 17:34:42 -08:00
mcp_tools.py example mcp tools 2025-03-20 17:53:20 -07:00
model_config.yaml Revert "Revert "(feat) Allow using include to include external YAML files in a config.yaml (#6922)"" 2024-11-27 16:08:59 -08:00
openapi.json (feat) add swagger.json for litellm proxy 2023-10-13 20:41:04 -07:00
post_call_rules.py (docs) add example post call rules to proxy 2024-01-15 20:58:50 -08:00
prisma_migration.py LiteLLM SDK <-> Proxy: support user param + Prisma - remove use_prisma_migrate flag - redundant as this is now default (#13555) 2025-08-12 22:03:39 -07:00
proxy_cli.py test fix 2025-09-20 16:55:23 -07:00
proxy_config.yaml [Fix] Parallel Request Limiter v3 - ensure Lua scripts can execute on redis cluster (#14968) 2025-09-26 18:15:57 -07:00
proxy_server.py fix: reduce get_deployment cost to O(1) (#14967) 2025-09-27 13:44:10 -07:00
README.md [Feat-Proxy] Allow using custom sso handler (#5809) 2024-09-20 19:14:33 -07:00
route_llm_request.py [Feat]Add cancel endpoint support for openai and azure (#14561) 2025-09-15 07:08:56 -07:00
schema.prisma [Feat] UI - Allow scheduling key rotations when creating virtual keys (#14960) 2025-09-26 16:24:40 -07:00
start.sh fix(factory.py): fixing llama-2 non-chat models prompt templating 2023-11-07 21:33:54 -08:00
utils.py fix: prisma client state retries (#14925) 2025-09-25 21:54:00 -07: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