WIP: remove setApiKey, resolveApiKey

This commit is contained in:
Mario Zechner 2025-12-24 23:34:23 +01:00
parent 385e7aff62
commit d93cbf8c32
6 changed files with 21 additions and 61 deletions

View file

@ -5,7 +5,7 @@ import type {
MessageParam,
} from "@anthropic-ai/sdk/resources/messages.js";
import { calculateCost } from "../models.js";
import { getApiKey } from "../stream.js";
import { getApiKeyFromEnv } from "../stream.js";
import type {
Api,
AssistantMessage,
@ -114,7 +114,7 @@ export const streamAnthropic: StreamFunction<"anthropic-messages"> = (
};
try {
const apiKey = options?.apiKey ?? getApiKey(model.provider) ?? "";
const apiKey = options?.apiKey ?? getApiKeyFromEnv(model.provider) ?? "";
const { client, isOAuthToken } = createClient(model, apiKey, options?.interleavedThinking ?? true);
const params = buildParams(model, context, isOAuthToken, options);
const anthropicStream = client.messages.stream({ ...params, stream: true }, { signal: options?.signal });