nsarrazin HF Staff commited on
Commit
8a9d27a
·
unverified ·
1 Parent(s): 1fcfcd5

fix(endpoint): fallback to hf token for openai endpoint type

Browse files
src/lib/server/endpoints/openai/endpointOai.ts CHANGED
@@ -86,7 +86,7 @@ export const endpointOAIParametersSchema = z.object({
86
  model: z.any(),
87
  type: z.literal("openai"),
88
  baseURL: z.string().url().default("https://api.openai.com/v1"),
89
- apiKey: z.string().default(env.OPENAI_API_KEY ?? "sk-"),
90
  completion: z
91
  .union([z.literal("completions"), z.literal("chat_completions")])
92
  .default("chat_completions"),
@@ -135,7 +135,7 @@ export async function endpointOai(
135
  }
136
 
137
  const openai = new OpenAI({
138
- apiKey: apiKey ?? "sk-",
139
  baseURL,
140
  defaultHeaders,
141
  defaultQuery,
 
86
  model: z.any(),
87
  type: z.literal("openai"),
88
  baseURL: z.string().url().default("https://api.openai.com/v1"),
89
+ apiKey: z.string().default(env.OPENAI_API_KEY || env.HF_TOKEN || "sk-"),
90
  completion: z
91
  .union([z.literal("completions"), z.literal("chat_completions")])
92
  .default("chat_completions"),
 
135
  }
136
 
137
  const openai = new OpenAI({
138
+ apiKey: apiKey || "sk-",
139
  baseURL,
140
  defaultHeaders,
141
  defaultQuery,