mirror of
https://github.com/Dokploy/dokploy.git
synced 2026-06-21 15:15:30 +02:00
feat(ai): send Gemini API key as query param when listing models packages/server/src/utils/ai/select-ai-provider.ts: add "gemini" case using createOpenAICompatible with queryParams: { key: config.apiKey } and empty headers. apps/dokploy/server/api/routers/ai.ts: update "gemini" models fetch to call ${input.apiUrl}/models?key=${encodeURIComponent(input.apiKey)} with empty headers.
This commit is contained in:
@@ -62,6 +62,12 @@ export const aiRouter = createTRPCRouter({
|
||||
case "ollama":
|
||||
response = await fetch(`${input.apiUrl}/api/tags`, { headers });
|
||||
break;
|
||||
case "gemini":
|
||||
response = await fetch(
|
||||
`${input.apiUrl}/models?key=${encodeURIComponent(input.apiKey)}`,
|
||||
{ headers: {} }
|
||||
);
|
||||
break;
|
||||
default:
|
||||
if (!input.apiKey)
|
||||
throw new TRPCError({
|
||||
|
||||
@@ -16,6 +16,7 @@ export function getProviderName(apiUrl: string) {
|
||||
if (apiUrl.includes("api.mistral.ai")) return "mistral";
|
||||
if (apiUrl.includes(":11434") || apiUrl.includes("ollama")) return "ollama";
|
||||
if (apiUrl.includes("api.deepinfra.com")) return "deepinfra";
|
||||
if (apiUrl.includes("generativelanguage.googleapis.com")) return "gemini";
|
||||
return "custom";
|
||||
}
|
||||
|
||||
@@ -66,6 +67,13 @@ export function selectAIProvider(config: { apiUrl: string; apiKey: string }) {
|
||||
baseURL: config.apiUrl,
|
||||
apiKey: config.apiKey,
|
||||
});
|
||||
case "gemini":
|
||||
return createOpenAICompatible({
|
||||
name:"gemini",
|
||||
baseURL:config.apiUrl,
|
||||
queryParams:{ key: config.apiKey},
|
||||
headers:{}
|
||||
})
|
||||
case "custom":
|
||||
return createOpenAICompatible({
|
||||
name: "custom",
|
||||
|
||||
Reference in New Issue
Block a user