{"record":{"id":"a1d7c92e64ff7e1a","repo":"n8n-io/n8n","slug":"api-key-is-missing-in-the-selected-azure-openai-ap","errorCode":null,"errorMessage":"API Key is missing in the selected Azure OpenAI API credential. Please configure the API Key or choose Entra ID authentication.","messagePattern":"API Key is missing in the selected Azure OpenAI API credential\\. Please configure the API Key or choose Entra ID authentication\\.","errorType":"exception","errorClass":"NodeOperationError","httpStatus":null,"severity":"error","filePath":"packages/@n8n/nodes-langchain/nodes/llms/LmChatAzureOpenAi/credentials/api-key.ts","lineNumber":22,"sourceCode":"\n/**\n * Handles API Key authentication setup for Azure OpenAI\n */\nexport async function setupApiKeyAuthentication(\n\tthis: ISupplyDataFunctions,\n\tcredentialName: string,\n): Promise<AzureOpenAIApiKeyModelConfig> {\n\ttry {\n\t\t// Get Azure OpenAI Config (Endpoint, Version, etc.)\n\t\tconst configCredentials = await this.getCredentials<{\n\t\t\tapiKey?: string;\n\t\t\tresourceName: string;\n\t\t\tapiVersion: string;\n\t\t\tendpoint?: string;\n\t\t}>(credentialName);\n\n\t\tif (!configCredentials.apiKey) {\n\t\t\tthrow new NodeOperationError(\n\t\t\t\tthis.getNode(),\n\t\t\t\t'API Key is missing in the selected Azure OpenAI API credential. Please configure the API Key or choose Entra ID authentication.',\n\t\t\t);\n\t\t}\n\n\t\tthis.logger.info('Using API Key authentication for Azure OpenAI.');\n\n\t\treturn {\n\t\t\tazureOpenAIApiKey: configCredentials.apiKey,\n\t\t\tazureOpenAIApiInstanceName: configCredentials.resourceName,\n\t\t\tazureOpenAIApiVersion: configCredentials.apiVersion,\n\t\t\tazureOpenAIEndpoint: configCredentials.endpoint,\n\t\t};\n\t} catch (error) {\n\t\tif (error instanceof OperationalError) {\n\t\t\tthrow error;\n\t\t}\n","sourceCodeStart":4,"sourceCodeEnd":40,"githubUrl":"https://github.com/n8n-io/n8n/blob/5ac6606e81f67bb9534255570cd4e86fd8101eee/packages/@n8n/nodes-langchain/nodes/llms/LmChatAzureOpenAi/credentials/api-key.ts#L4-L40","documentation":"Thrown in setupApiKeyAuthentication() when the selected Azure OpenAI API credential has no apiKey field. The node needs the key to construct AzureOpenAI client configuration, so it halts with a message that also points the user at the Entra ID alternative. Logs precede the throw so the absence is traceable.","triggerScenarios":"User selects 'API Key' authentication but the referenced Azure OpenAI credential's apiKey is empty — credential saved without the key, key field cleared, or a templated credential value that returned empty.","commonSituations":"Credential created but key never pasted; key redacted/blanked by a migration; wrong credential selected; user intending Entra ID but left the selector on API Key.","solutions":["Open the Azure OpenAI API credential and paste the API key from the Azure portal (Keys and Endpoint).","Or switch the node authentication to 'Entra ID (OAuth2)' if API key is not available.","Verify the credential selected in the node is the one that holds the key."],"exampleFix":"// before\nconfigCredentials = { apiKey: '', resourceName: 'my-aoai', apiVersion: '2024-10-21' }\n// after\nconfigCredentials = { apiKey: 'xxxx...', resourceName: 'my-aoai', apiVersion: '2024-10-21' }","handlingStrategy":"validation","validationCode":"if (!configCredentials.apiKey) {\n  throw new Error('Paste an API key in the Azure OpenAI credential, or switch to Entra ID auth.');\n}","typeGuard":"const hasApiKey = (c: any): boolean => typeof c?.apiKey === 'string' && c.apiKey.length > 0;","tryCatchPattern":"// Pre-validate at credential-save time.","preventionTips":["Store the Azure OpenAI key right after creating the credential.","Switch to Entra ID when API key access is unavailable.","Validate the credential references the right Azure OpenAI resource."],"tags":["azure","openai","credentials","authentication","api-key"],"backgroundTag":null,"analyzedSha":"5ac6606e81f67bb9534255570cd4e86fd8101eee","analyzedAt":"2026-08-12T05:26:35.080Z","schemaVersion":2},"datasetVersion":"2026-08-13T04:17:16.726Z"}