WIP: remove setApiKey, resolveApiKey
This commit is contained in:
@@ -9,6 +9,7 @@ import type {
|
||||
ChatCompletionToolMessageParam,
|
||||
} from "openai/resources/chat/completions.js";
|
||||
import { calculateCost } from "../models.js";
|
||||
import { getApiKeyFromEnv } from "../stream.js";
|
||||
import type {
|
||||
AssistantMessage,
|
||||
Context,
|
||||
@@ -98,7 +99,8 @@ export const streamOpenAICompletions: StreamFunction<"openai-completions"> = (
|
||||
};
|
||||
|
||||
try {
|
||||
const client = createClient(model, context, options?.apiKey);
|
||||
const apiKey = options?.apiKey || getApiKeyFromEnv(model.provider) || "";
|
||||
const client = createClient(model, context, apiKey);
|
||||
const params = buildParams(model, context, options);
|
||||
const openaiStream = await client.chat.completions.create(params, { signal: options?.signal });
|
||||
stream.push({ type: "start", partial: output });
|
||||
|
||||
Reference in New Issue
Block a user