{"record":{"id":"47d4e277f046ad28","repo":"microsoft/vscode","slug":"api-key-not-found-for-the-model","errorCode":null,"errorMessage":"API key not found for the model","messagePattern":"API key not found for the model","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"extensions/copilot/src/extension/byok/vscode-node/anthropicProvider.ts","lineNumber":112,"sourceCode":"\n\tasync provideLanguageModelChatResponse(model: ExtendedLanguageModelChatInformation<LanguageModelChatConfiguration>, messages: Array<LanguageModelChatMessage | LanguageModelChatMessage2>, options: ProvideLanguageModelChatResponseOptions, progress: Progress<LanguageModelResponsePart2>, token: CancellationToken): Promise<void> {\n\t\t// Restore CapturingToken context if correlation ID was passed through modelOptions.\n\t\t// This handles the case where AsyncLocalStorage context was lost crossing VS Code IPC.\n\t\tconst correlationId = (options as { modelOptions?: OTelModelOptions }).modelOptions?._capturingTokenCorrelationId;\n\t\tconst capturingToken = correlationId ? retrieveCapturingTokenByCorrelation(correlationId) : undefined;\n\t\tconst telemetryTurn = (options as { modelOptions?: OTelModelOptions }).modelOptions?._telemetryTurn;\n\n\t\t// Restore OTel trace context to link spans back to the agent trace\n\t\tconst parentTraceContext = (options as { modelOptions?: OTelModelOptions }).modelOptions?._otelTraceContext ?? undefined;\n\n\t\t// OTel span handle — created outside doRequest, enriched inside with usage data\n\t\tlet otelSpan: ReturnType<typeof this._otelService.startSpan> | undefined;\n\n\t\tconst doRequest = async () => {\n\t\t\tconst issuedTime = Date.now();\n\t\t\tconst apiKey = model.configuration?.apiKey;\n\t\t\tif (!apiKey) {\n\t\t\t\tthrow new Error('API key not found for the model');\n\t\t\t}\n\n\t\t\tconst anthropicClient = new Anthropic({ apiKey });\n\n\t\t\t// Convert the messages from the API format into messages that we can use against anthropic\n\t\t\tconst { system, messages: convertedMessages } = apiMessageToAnthropicMessage(messages as LanguageModelChatMessage[]);\n\n\t\t\tconst requestId = generateUuid();\n\t\t\tconst pendingLoggedChatRequest = this._requestLogger.logChatRequest(\n\t\t\t\t'AnthropicBYOK',\n\t\t\t\t{\n\t\t\t\t\tmodel: model.id,\n\t\t\t\t\tmodelMaxPromptTokens: model.maxInputTokens,\n\t\t\t\t\turlOrRequestMetadata: anthropicClient.baseURL,\n\t\t\t\t},\n\t\t\t\t{\n\t\t\t\t\tmodel: model.id,\n\t\t\t\t\tmessages: anthropicMessagesToRawMessagesForLogging(convertedMessages, system),","sourceCodeStart":94,"sourceCodeEnd":130,"githubUrl":"https://github.com/microsoft/vscode/blob/a94b963a32aa9749d69504576791fa29700ae46d/extensions/copilot/src/extension/byok/vscode-node/anthropicProvider.ts#L94-L130","documentation":"Error \"API key not found for the model\" thrown in microsoft/vscode.","triggerScenarios":"Thrown at extensions/copilot/src/extension/byok/vscode-node/anthropicProvider.ts:112 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":[],"exampleFix":null,"handlingStrategy":null,"validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"analyzedSha":"a94b963a32aa9749d69504576791fa29700ae46d","analyzedAt":"2026-08-12T01:08:56.794Z","schemaVersion":2},"datasetVersion":"2026-08-12T06:17:24.410Z"}