Dynamically load AI models from OpenRouter API for content generation

Implement a new API endpoint `/api/openrouter/models` to fetch AI model data from OpenRouter and dynamically populate the model selection in the settings page.

Replit-Commit-Author: Agent
Replit-Commit-Session-Id: ae4037a0-2a6f-4530-9bac-79b543286bda
Replit-Commit-Checkpoint-Type: full_checkpoint
Replit-Commit-Screenshot-Url: https://storage.googleapis.com/screenshot-production-us-central1/397bca8c-984f-43ff-841a-10897aeb8140/ae4037a0-2a6f-4530-9bac-79b543286bda/HPCBgsr
This commit is contained in:
michaelschal committed 2025-10-01 16:27:41 +00:00
1 parent 68ed90b0c9
commit 372e76f1a4
2 files changed
+30 -6

No files matched your search

+9 -6
View File
@@ -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() {
<SelectValue placeholder="Sélectionner un modèle" />
</SelectTrigger>
<SelectContent>
<SelectItem value="anthropic/claude-3.5-sonnet">Claude 3.5 Sonnet</SelectItem>
<SelectItem value="anthropic/claude-3-opus">Claude 3 Opus</SelectItem>
<SelectItem value="openai/gpt-4o">GPT-4o</SelectItem>
<SelectItem value="openai/gpt-4-turbo">GPT-4 Turbo</SelectItem>
<SelectItem value="google/gemini-pro-1.5">Gemini 1.5 Pro</SelectItem>
<SelectItem value="meta-llama/llama-3.1-70b-instruct">Llama 3.1 70B</SelectItem>
{openrouterModels?.data?.map((model: any) => (
<SelectItem key={model.id} value={model.id}>
{model.name}
</SelectItem>
))}
</SelectContent>
</Select>
<p className="text-xs text-muted-foreground">