The fastest, litest AI Gateway. Rust core with Python SDK. Call 100+ LLM APIs in OpenAI (or native) format with cost tracking, guardrails, load balancing, and logging [Bedrock, Azure, OpenAI, Anthropic, OpenAI, VertexAI, vLLM, Nvidia NIM]
Python ai-gatewayanthropicazure-openaibedrockgatewaylangchainlitellmllmllm-gatewayllmopsmcp-gatewayopenaiopenai-proxyrustrust-aivertex-ai
Add GET list of providers endpoint (#16432)
Sameer Kankutebe3c09e6d5ed
diff --git a/docs/my-website/docs/proxy/model_hub.md b/docs/my-website/docs/proxy/model_hub.mdindex bf361f7deb8..6c12194d751 100644--- a/docs/my-website/docs/proxy/model_hub.md+++ b/docs/my-website/docs/proxy/model_hub.md@@ -37,3 +37,17 @@ Click on `Make Public` and select the models you want to expose.Go to the public url (`PROXY_BASE_URL/ui/model_hub_table`) and see available models.<Image img={require('../../img/final_public_model_hub_view.png')} />++## API Endpoints++LiteLLM also exposes REST endpoints:++- `GET /public/model_hub` – returns the list of public model groups. Requires a valid user API key.+- `GET /public/model_hub/info` – returns metadata (docs title, version, useful links) for the public model hub.+- `GET /public/providers` – returns a sorted list of all providers supported by LiteLLM. No authentication required.++Example:++```bash+curl -s PROXY_BASE_URL/public/providers | jq+```diff --git a/litellm/proxy/public_endpoints/public_endpoints.py b/litellm/proxy/public_endpoints/public_endpoints.pyindex 4910f71429e..2cc3dd0ed43 100644--- a/litellm/proxy/public_endpoints/public_endpoints.py+++ b/litellm/proxy/public_endpoints/public_endpoints.py@@ -8,6 +8,7 @@ from litellm.types.proxy.management_endpoints.model_management_endpoints importModelGroupInfoProxy,)from litellm.types.proxy.public_endpoints.public_endpoints import PublicModelHubInfo+from litellm.types.utils import LlmProvidersrouter = APIRouter()@@ -60,3 +61,16 @@ async def public_model_hub_info():litellm_version=version,useful_links=litellm.public_model_groups_links,)+++ "/public/providers",+ tags=["public", "providers"],+ response_model=List[str],+)+async def get_supported_providers() -> List[str]:+ """+ Return a sorted list of all providers supported by LiteLLM.+ """++ return sorted(provider.value for provider in LlmProviders)diff --git a/tests/test_litellm/proxy/public_endpoints/test_public_endpoints.py b/tests/test_litellm/proxy/public_endpoints/test_public_endpoints.pynew file mode 100644index 00000000000..89f9dd09871--- /dev/null+++ b/tests/test_litellm/proxy/public_endpoints/test_public_endpoints.py@@ -0,0 +1,25 @@+import os+import sys++sys.path.insert(+ 0, os.path.abspath("../../..")+)++from fastapi import FastAPI+from fastapi.testclient import TestClient++from litellm.proxy.public_endpoints import router+from litellm.types.utils import LlmProviders+++def test_get_supported_providers_returns_enum_values():+ app = FastAPI()+ app.include_router(router)+ client = TestClient(app)++ response = client.get("/public/providers")++ assert response.status_code == 200+ expected_providers = sorted(provider.value for provider in LlmProviders)+ assert response.json() == expected_providers+