Skip to content

Commit 0635f4e

Browse files
github-actions[bot]zuisong
authored andcommitted
list models
1 parent bcdec73 commit 0635f4e

File tree

1 file changed

+6
-3
lines changed

1 file changed

+6
-3
lines changed

src/gemini-api-client/gemini-api-client.ts

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -22,9 +22,10 @@ interface Task {
2222
}
2323

2424
export async function listModels(apiParam: ApiParam | null) {
25-
const url = new URL(`${BASE_URL}/v1beta/models`)
26-
url.searchParams.append("key", apiParam?.apikey ?? "")
27-
const resp = await makeRequest(url, undefined, undefined, "GET")
25+
const url = new URL(`${BASE_URL}/v1beta/openai/models`)
26+
const resp = await makeRequest(url, undefined, undefined, "GET", {
27+
Authorization: `Bearer ${apiParam?.apikey ?? ""}`,
28+
})
2829
return (await resp.json()) as components["schemas"]["ListModelsResponse"]
2930
}
3031
export async function* streamGenerateContent(
@@ -74,6 +75,7 @@ async function makeRequest(
7475
body: string | undefined,
7576
requestOptions?: RequestOptions,
7677
requestMethod = "POST",
78+
headers: Record<string, string> = {},
7779
): Promise<Response> {
7880
let response: Response
7981
try {
@@ -82,6 +84,7 @@ async function makeRequest(
8284
method: requestMethod,
8385
headers: {
8486
"Content-Type": "application/json",
87+
...headers,
8588
},
8689
body,
8790
})

0 commit comments

Comments
 (0)