n8n-io/n8n · error · NodeOperationError
API Key is missing in the selected Azure OpenAI API credenti
Error message
API Key is missing in the selected Azure OpenAI API credential. Please configure the API Key or choose Entra ID authentication.
What it means
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.
Source
Thrown at packages/@n8n/nodes-langchain/nodes/llms/LmChatAzureOpenAi/credentials/api-key.ts:22
/**
* Handles API Key authentication setup for Azure OpenAI
*/
export async function setupApiKeyAuthentication(
this: ISupplyDataFunctions,
credentialName: string,
): Promise<AzureOpenAIApiKeyModelConfig> {
try {
// Get Azure OpenAI Config (Endpoint, Version, etc.)
const configCredentials = await this.getCredentials<{
apiKey?: string;
resourceName: string;
apiVersion: string;
endpoint?: string;
}>(credentialName);
if (!configCredentials.apiKey) {
throw new NodeOperationError(
this.getNode(),
'API Key is missing in the selected Azure OpenAI API credential. Please configure the API Key or choose Entra ID authentication.',
);
}
this.logger.info('Using API Key authentication for Azure OpenAI.');
return {
azureOpenAIApiKey: configCredentials.apiKey,
azureOpenAIApiInstanceName: configCredentials.resourceName,
azureOpenAIApiVersion: configCredentials.apiVersion,
azureOpenAIEndpoint: configCredentials.endpoint,
};
} catch (error) {
if (error instanceof OperationalError) {
throw error;
}
View on GitHub (pinned to 5ac6606e81)
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.
Example fix
// before
configCredentials = { apiKey: '', resourceName: 'my-aoai', apiVersion: '2024-10-21' }
// after
configCredentials = { apiKey: 'xxxx...', resourceName: 'my-aoai', apiVersion: '2024-10-21' } Defensive patterns
Strategy: validation
Validate before calling
if (!configCredentials.apiKey) {
throw new Error('Paste an API key in the Azure OpenAI credential, or switch to Entra ID auth.');
} Type guard
const hasApiKey = (c: any): boolean => typeof c?.apiKey === 'string' && c.apiKey.length > 0;
Try / catch
// Pre-validate at credential-save time.
Prevention
- 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.
When it happens
Trigger: 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.
Common situations: 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.
Understand the failure class
- Authentication and authorization failures — expired tokens, bad credentials, and missing scopes.
Related errors
- Invalid authentication method
- Failed to retrieve access token
- Failed to retrieve OAuth2 access token
- Failed to retrieve API Key
- No suspended run found for runId: ${this.runId}
AI-assisted analysis of n8n-io/n8n@5ac6606e81 (2026-08-12).
Data as JSON: /api/errors/a1d7c92e64ff7e1a.
Report an issue: GitHub.