diff --git a/client/src/pages/settings.tsx b/client/src/pages/settings.tsx index e50c98a..dc72205 100644 --- a/client/src/pages/settings.tsx +++ b/client/src/pages/settings.tsx @@ -33,6 +33,10 @@ export default function Settings() { queryKey: ['/api/openrouter/config'], }); + const { data: openrouterModels } = useQuery({ + queryKey: ['/api/openrouter/models'], + }); + useEffect(() => { if (cloudinaryConfig) { setCloudName((cloudinaryConfig as any).cloudName || ""); @@ -200,12 +204,11 @@ export default function Settings() { - Claude 3.5 Sonnet - Claude 3 Opus - GPT-4o - GPT-4 Turbo - Gemini 1.5 Pro - Llama 3.1 70B + {openrouterModels?.data?.map((model: any) => ( + + {model.name} + + ))}

diff --git a/server/routes.ts b/server/routes.ts index bc69862..9fdf8ab 100644 --- a/server/routes.ts +++ b/server/routes.ts @@ -283,6 +283,27 @@ export async function registerRoutes(app: Express): Promise { } }); + // OpenRouter models list + app.get("/api/openrouter/models", async (req, res) => { + try { + const response = await fetch("https://openrouter.ai/api/v1/models", { + headers: { + "Content-Type": "application/json", + } + }); + + if (!response.ok) { + throw new Error(`OpenRouter API error: ${response.status}`); + } + + const data = await response.json(); + res.json(data); + } catch (error) { + console.error("Error fetching OpenRouter models:", error); + res.status(500).json({ error: "Failed to fetch OpenRouter models" }); + } + }); + // OpenRouter configuration app.get("/api/openrouter/config", async (req, res) => { try {