Skip to content

Commit 8c0db75

Browse files
authored
Merge pull request #2795 from Harikrishnan1367709/Support-query-parameter-auth-(-key=)-for-Gemini-API-in-AI-Providers-#2775
feat(ai):Support Gemini query-param auth for model listing-#2775
2 parents b3c6645 + 8de5001 commit 8c0db75

File tree

2 files changed

+14
-0
lines changed

2 files changed

+14
-0
lines changed

apps/dokploy/server/api/routers/ai.ts

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,12 @@ export const aiRouter = createTRPCRouter({
6262
case "ollama":
6363
response = await fetch(`${input.apiUrl}/api/tags`, { headers });
6464
break;
65+
case "gemini":
66+
response = await fetch(
67+
`${input.apiUrl}/models?key=${encodeURIComponent(input.apiKey)}`,
68+
{ headers: {} },
69+
);
70+
break;
6571
default:
6672
if (!input.apiKey)
6773
throw new TRPCError({

packages/server/src/utils/ai/select-ai-provider.ts

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ export function getProviderName(apiUrl: string) {
1616
if (apiUrl.includes("api.mistral.ai")) return "mistral";
1717
if (apiUrl.includes(":11434") || apiUrl.includes("ollama")) return "ollama";
1818
if (apiUrl.includes("api.deepinfra.com")) return "deepinfra";
19+
if (apiUrl.includes("generativelanguage.googleapis.com")) return "gemini";
1920
return "custom";
2021
}
2122

@@ -66,6 +67,13 @@ export function selectAIProvider(config: { apiUrl: string; apiKey: string }) {
6667
baseURL: config.apiUrl,
6768
apiKey: config.apiKey,
6869
});
70+
case "gemini":
71+
return createOpenAICompatible({
72+
name: "gemini",
73+
baseURL: config.apiUrl,
74+
queryParams: { key: config.apiKey },
75+
headers: {},
76+
});
6977
case "custom":
7078
return createOpenAICompatible({
7179
name: "custom",

0 commit comments

Comments
 (0)