From be3c09e6d5edebaec25260b11a129a5ba5f030b7 Mon Sep 17 00:00:00 2001 From: Sameer Kankute Date: Tue, 11 Nov 2025 08:08:09 +0530 Subject: [PATCH] Add GET list of providers endpoint (#16432) --- docs/my-website/docs/proxy/model_hub.md | 14 +++++++++++ .../public_endpoints/public_endpoints.py | 14 +++++++++++ .../public_endpoints/test_public_endpoints.py | 25 +++++++++++++++++++ 3 files changed, 53 insertions(+) create mode 100644 tests/test_litellm/proxy/public_endpoints/test_public_endpoints.py diff --git a/docs/my-website/docs/proxy/model_hub.md b/docs/my-website/docs/proxy/model_hub.md index bf361f7deb..6c12194d75 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. + +## 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.py index 4910f71429..2cc3dd0ed4 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 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) diff --git a/tests/test_litellm/proxy/public_endpoints/test_public_endpoints.py b/tests/test_litellm/proxy/public_endpoints/test_public_endpoints.py new file mode 100644 index 0000000000..89f9dd0987 --- /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 +