mirror of
https://github.com/getcompanion-ai/co-mono.git
synced 2026-04-21 20:04:55 +00:00
WIP: remove setApiKey, resolveApiKey
This commit is contained in:
parent
385e7aff62
commit
d93cbf8c32
6 changed files with 21 additions and 61 deletions
|
|
@ -11,6 +11,7 @@ import type {
|
|||
ResponseReasoningItem,
|
||||
} from "openai/resources/responses/responses.js";
|
||||
import { calculateCost } from "../models.js";
|
||||
import { getApiKeyFromEnv } from "../stream.js";
|
||||
import type {
|
||||
Api,
|
||||
AssistantMessage,
|
||||
|
|
@ -27,7 +28,6 @@ import type {
|
|||
import { AssistantMessageEventStream } from "../utils/event-stream.js";
|
||||
import { parseStreamingJson } from "../utils/json-parse.js";
|
||||
import { sanitizeSurrogates } from "../utils/sanitize-unicode.js";
|
||||
|
||||
import { transformMessages } from "./transorm-messages.js";
|
||||
|
||||
/** Fast deterministic hash to shorten long strings */
|
||||
|
|
@ -82,7 +82,8 @@ export const streamOpenAIResponses: StreamFunction<"openai-responses"> = (
|
|||
|
||||
try {
|
||||
// Create OpenAI client
|
||||
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.responses.create(params, { signal: options?.signal });
|
||||
stream.push({ type: "start", partial: output });
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue