Skip to content

Commit

Permalink
fix(endpoint): fallback to hf token for openai endpoint type
Browse files Browse the repository at this point in the history
  • Loading branch information
nsarrazin committed Oct 25, 2024
1 parent ec83e81 commit c83861a
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions src/lib/server/endpoints/openai/endpointOai.ts
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ export const endpointOAIParametersSchema = z.object({
model: z.any(),
type: z.literal("openai"),
baseURL: z.string().url().default("https://api.openai.com/v1"),
apiKey: z.string().default(env.OPENAI_API_KEY ?? "sk-"),
apiKey: z.string().default(env.OPENAI_API_KEY || env.HF_TOKEN || "sk-"),
completion: z
.union([z.literal("completions"), z.literal("chat_completions")])
.default("chat_completions"),
Expand Down Expand Up @@ -135,7 +135,7 @@ export async function endpointOai(
}

const openai = new OpenAI({
apiKey: apiKey ?? "sk-",
apiKey: apiKey || "sk-",
baseURL,
defaultHeaders,
defaultQuery,
Expand Down

0 comments on commit c83861a

Please sign in to comment.