Add /v1/models endpoint (no per-user auth) for LibreChat model discovery

This commit is contained in:
inference-bot committed 2026-09-04 17:33:01 -06:00
1 parent ee265ee18f
commit d6605992bc
1 file changed
+15
+15
View File
@@ -241,6 +241,21 @@ async def opencollective_webhook(request: Request):
# --- B. Key injector (proxy) ---
@app.get("/v1/models")
async def list_models():
"""List models (same for everyone — no per-user auth needed)."""
async with httpx.AsyncClient() as client:
r = await client.get(
f"{LITELLM_BASE}/v1/models",
headers={"Authorization": f"Bearer {LITELLM_MASTER_KEY}"},
)
return Response(
content=r.content,
status_code=r.status_code,
headers={"content-type": r.headers.get("content-type", "application/json")},
)
@app.api_route("/v1/{path:path}", methods=["GET", "POST", "PUT", "DELETE", "PATCH"])
async def inject_key(request: Request, path: str):
"""Read the member's email from a header, inject their key, forward to LiteLLM."""