Add GET list of providers endpoint (#16432)

This commit is contained in:
Sameer Kankute
2025-11-10 18:38:09 -08:00
committed by GitHub
parent af68763f5d
commit be3c09e6d5
3 changed files with 53 additions and 0 deletions
+14
View File
@@ -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
```
@@ -8,6 +8,7 @@ from litellm.types.proxy.management_endpoints.model_management_endpoints import
ModelGroupInfoProxy,
)
from litellm.types.proxy.public_endpoints.public_endpoints import PublicModelHubInfo
from litellm.types.utils import LlmProviders
router = APIRouter()
@@ -60,3 +61,16 @@ async def public_model_hub_info():
litellm_version=version,
useful_links=litellm.public_model_groups_links,
)
@router.get(
"/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)
@@ -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