Skip to content

Commit fa82dff

Browse files
committed
Fix JSON parse error
1 parent 2c9a790 commit fa82dff

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

src/api/providers/gemini.ts

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,11 @@ import {
55
type GenerateContentParameters,
66
type Content,
77
} from "@google/genai"
8+
import type { JWTInput } from "google-auth-library"
89
import NodeCache from "node-cache"
910

1011
import { ApiHandlerOptions, ModelInfo, GeminiModelId, geminiDefaultModelId, geminiModels } from "../../shared/api"
12+
import { safeJsonParse } from "../../shared/safeJsonParse"
1113

1214
import { SingleCompletionHandler } from "../index"
1315
import {
@@ -52,7 +54,9 @@ export class GeminiHandler extends BaseProvider implements SingleCompletionHandl
5254
vertexai: true,
5355
project,
5456
location,
55-
googleAuthOptions: { credentials: JSON.parse(this.options.vertexJsonCredentials) },
57+
googleAuthOptions: {
58+
credentials: safeJsonParse<JWTInput>(this.options.vertexJsonCredentials, undefined),
59+
},
5660
})
5761
: this.options.vertexKeyFile
5862
? new GoogleGenAI({

0 commit comments

Comments
 (0)