litellm-mirror/litellm/proxy
Krish Dholakia ed8c63b51e Allow team admins to add/update/delete models on UI + show api base and model id on request logs (#9572)
* feat(view_logs.tsx): show model id + api base in request logs

easier debugging

* fix(index.tsx): fix length of api base

easier viewing

* refactor(leftnav.tsx): show models tab to team admin

* feat(model_dashboard.tsx): add explainer for what the 'models' page is for team admin

helps them understand how they can use it

* feat(model_management_endpoints.py): restrict model add by team to just team admin

allow team admin to add models via non-team keys (e.g. ui token)

* test(test_add_update_models.py): update unit testing for new behaviour

* fix(model_dashboard.tsx): show user the models

* feat(proxy_server.py): add new query param 'user_models_only' to `/v2/model/info`

Allows user to retrieve just the models they've added

Used in UI to show internal users just the models they've added

* feat(model_dashboard.tsx): allow team admins to view their own models

* fix: allow ui user to fetch model cost map

* feat(add_model_tab.tsx): require team admins to specify team when onboarding models

* fix(_types.py): add `/v1/model/info` to info route

`/model/info` was already there

* fix(model_info_view.tsx): allow user to edit a model they created

* fix(model_management_endpoints.py): allow team admin to update team model

* feat(model_managament_endpoints.py): allow team admin to delete team models

* fix(model_management_endpoints.py): don't require team id to be set when adding a model

* fix(proxy_server.py): fix linting error

* fix: fix ui linting error

* fix(model_management_endpoints.py): ensure consistent auth checks on all model calls

* test: remove old test - function no longer exists in same form

* test: add updated mock testing
2025-03-27 12:06:31 -07:00
..
_experimental fix import mcp router 2025-03-24 21:08:24 -07:00
analytics_endpoints (code quality) run ruff rule to ban unused imports (#7313) 2024-12-19 12:33:42 -08:00
anthropic_endpoints get_custom_headers 2025-03-12 18:57:41 -07:00
auth refactor PrismaDBExceptionHandler 2025-03-26 19:22:24 -07:00
batches_endpoints use correct get custom headers 2025-03-12 17:16:51 -07:00
common_utils fix _reset_budget_for_team 2025-03-17 19:34:44 -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 fix: fix linting error 2025-03-14 14:17:28 -07:00
db fix order of _setup_prisma_client 2025-03-26 20:42:01 -07:00
example_config_yaml fix user_api_key_auth example config 2025-03-26 08:36:11 -07:00
fine_tuning_endpoints use correct get custom headers 2025-03-12 17:16:51 -07:00
guardrails fix: fix linting errors 2025-03-13 19:40:18 -07:00
health_endpoints allow proxy to startup on DB unavailable 2025-03-26 19:50:57 -07:00
hooks fix ProxyUpdateSpend 2025-03-17 22:17:56 -07:00
management_endpoints Allow team admins to add/update/delete models on UI + show api base and model id on request logs (#9572) 2025-03-27 12:06:31 -07:00
management_helpers feat(model_management_endpoints.py): emit audit logs on model delete 2025-03-13 18:48:38 -07:00
openai_files_endpoints use correct get custom headers 2025-03-12 17:16:51 -07:00
pass_through_endpoints fix(llm_passthrough_endpoints.py): fix raising helpful debug error message 2025-03-22 15:06:16 -07:00
rerank_endpoints use correct get custom headers 2025-03-12 17:16:51 -07:00
response_api_endpoints Add stubbed routes to pass initial auth tests 2025-03-13 16:43:25 -07:00
spend_tracking Fix batches api cost tracking + Log batch models in spend logs / standard logging payload (#9077) 2025-03-08 11:47:25 -08:00
types_utils build: merge commit 1b15568af7 2025-02-17 21:56:00 -08:00
ui_crud_endpoints fix settings endpoints code qa 2025-03-17 21:32:05 -07:00
vertex_ai_endpoints build: cleanup unused files 2025-03-22 12:54:11 -07:00
.gitignore
__init__.py
_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 Add OpenAI gpt-4o-transcribe support (#9517) 2025-03-26 23:10:25 -07:00
_super_secret_config.yaml docs(enterprise.md): cleanup docs 2024-07-15 14:52:08 -07:00
_types.py Allow team admins to add/update/delete models on UI + show api base and model id on request logs (#9572) 2025-03-27 12:06:31 -07:00
cached_logo.jpg Litellm dev 01 23 2025 p2 (#7962) 2025-01-23 21:02:15 -08:00
caching_routes.py (Bug fix) - Cache Health not working when configured with prometheus service logger (#8687) 2025-02-20 13:41:56 -08:00
common_request_processing.py feat(pass_through_endpoints.py): support returning api-base on pass-through endpoints 2025-03-20 20:11:49 -07:00
custom_prompt_management.py example X42PromptManagement 2025-03-19 16:24:41 -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
health_check.py fix endpoint_data 2025-03-14 17:21:01 -07:00
lambda.py
litellm_pre_call_utils.py LITELLM_METADATA_ROUTES 2025-03-12 18:20:07 -07:00
llamaguard_prompt.txt
logo.jpg
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
post_call_rules.py
prisma_migration.py LiteLLM Contributor PRs (02/18/2025). (#8643) 2025-02-19 21:52:46 -08:00
proxy_cli.py feat(prisma_client.py): initial commit add prisma migration support to proxy 2025-03-19 14:26:59 -07:00
proxy_config.yaml add test config 2025-03-25 19:21:51 -07:00
proxy_server.py Allow team admins to add/update/delete models on UI + show api base and model id on request logs (#9572) 2025-03-27 12:06:31 -07:00
README.md [Feat-Proxy] Allow using custom sso handler (#5809) 2024-09-20 19:14:33 -07:00
route_llm_request.py undo changes to route llm request 2025-03-14 21:05:51 -07:00
schema.prisma Add Daily User Spend Aggregate view - allows UI Usage tab to work > 1m rows (#9538) 2025-03-26 16:36:36 -07:00
start.sh
utils.py Add Daily User Spend Aggregate view - allows UI Usage tab to work > 1m rows (#9538) 2025-03-26 16:36:36 -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