microsoft/vscode · error · Error
API key not found for the model
Error message
API key not found for the model
What it means
Error "API key not found for the model" thrown in microsoft/vscode.
Source
Thrown at extensions/copilot/src/extension/byok/vscode-node/geminiNativeProvider.ts:98
async provideLanguageModelChatResponse(model: ExtendedLanguageModelChatInformation<LanguageModelChatConfiguration>, messages: Array<LanguageModelChatMessage | LanguageModelChatMessage2>, options: ProvideLanguageModelChatResponseOptions, progress: Progress<LanguageModelResponsePart2>, token: CancellationToken): Promise<any> {
// Restore CapturingToken context if correlation ID was passed through modelOptions.
// This handles the case where AsyncLocalStorage context was lost crossing VS Code IPC.
const correlationId = (options as { modelOptions?: OTelModelOptions }).modelOptions?._capturingTokenCorrelationId;
const capturingToken = correlationId ? retrieveCapturingTokenByCorrelation(correlationId) : undefined;
const telemetryTurn = (options as { modelOptions?: OTelModelOptions }).modelOptions?._telemetryTurn;
// Restore OTel trace context to link spans back to the agent trace
const parentTraceContext = (options as { modelOptions?: OTelModelOptions }).modelOptions?._otelTraceContext ?? undefined;
// OTel span handle — created outside doRequest, enriched inside with usage data
let otelSpan: ReturnType<typeof this._otelService.startSpan> | undefined;
const doRequest = async () => {
const issuedTime = Date.now();
const apiKey = model.configuration?.apiKey;
if (!apiKey) {
throw new Error('API key not found for the model');
}
const client = new GoogleGenAI({ apiKey });
// Convert the messages from the API format into messages that we can use against Gemini
const { contents, systemInstruction } = apiMessageToGeminiMessage(messages as LanguageModelChatMessage[]);
const requestId = generateUuid();
const pendingLoggedChatRequest = this._requestLogger.logChatRequest(
'GeminiNativeBYOK',
{
model: model.id,
modelMaxPromptTokens: model.maxInputTokens,
urlOrRequestMetadata: 'https://generativelanguage.googleapis.com',
},
{
model: model.id,
messages: geminiMessagesToRawMessagesForLogging(contents, systemInstruction),
ourRequestId: requestId,View on GitHub (pinned to a94b963a32)
When it happens
Trigger: Thrown at extensions/copilot/src/extension/byok/vscode-node/geminiNativeProvider.ts:98 when the library encounters an invalid state.
Common situations: See trigger scenarios.
AI-assisted analysis of microsoft/vscode@a94b963a32 (2026-08-12).
Data as JSON: /api/errors/afaf182e7b102d17.
Report an issue: GitHub.