FlowiseAI/Flowise · error · Error
OpenAI ApiKey not found
Error message
OpenAI ApiKey not found
What it means
After the assistant record is found, the node resolves its credential and reads `openAIApiKey` via getCredentialParam. If the key is empty/falsy it throws immediately — the credential is missing, misnamed, or the assistant record's `credential` field does not point at a valid credential containing `openAIApiKey`.
Source
Thrown at packages/components/nodes/agents/OpenAIAssistant/OpenAIAssistant.ts:242
}
let tools = nodeData.inputs?.tools
tools = flatten(tools)
const formattedTools = tools?.map((tool: any) => formatToOpenAIAssistantTool(tool)) ?? []
const usedTools: IUsedTool[] = []
const fileAnnotations = []
const artifacts = []
const assistant = await appDataSource.getRepository(databaseEntities['Assistant']).findOneBy({
id: selectedAssistantId
})
if (!assistant) throw new Error(`Assistant ${selectedAssistantId} not found`)
const credentialData = await getCredentialData(assistant.credential ?? '', options)
const openAIApiKey = getCredentialParam('openAIApiKey', credentialData, nodeData)
if (!openAIApiKey) throw new Error(`OpenAI ApiKey not found`)
const openai = new OpenAI({ apiKey: openAIApiKey })
// Start analytics
const analyticHandlers = AnalyticHandler.getInstance(nodeData, options)
await analyticHandlers.init()
const parentIds = await analyticHandlers.onChainStart('OpenAIAssistant', input)
try {
const assistantDetails = JSON.parse(assistant.details)
const openAIAssistantId = assistantDetails.id
// Retrieve assistant
const retrievedAssistant = await openai.beta.assistants.retrieve(openAIAssistantId)
if (formattedTools.length) {
let filteredTools = []
for (const tool of retrievedAssistant.tools) {View on GitHub (pinned to abe4a8601a)
Solutions
- In Credentials, create/recreate an OpenAI credential with a non-empty `openAIApiKey`.
- Open the Assistant record and ensure its Credential field points to that credential.
- Verify the key value is non-empty and is a valid `sk-...` token.
- Test the key with a direct `curl https://api.openai.com/v1/models -H "Authorization: Bearer $KEY"`.
- If using a secret manager, confirm the env var it reads is populated in this process.
Defensive patterns
Strategy: validation
Validate before calling
const cred = await getCredentialData(assistant.credential ?? '', options)
const key = getCredentialParam('openAIApiKey', cred, nodeData)
if (!key) throw new Error('Assistant credential must contain a non-empty openAIApiKey') Try / catch
try {
await assistantNode.run(nodeData, input, options)
} catch (e) {
if ((e as Error).message === 'OpenAI ApiKey not found') configureCredential()
throw e
} Prevention
- Create the OpenAI credential before binding it to the assistant.
- Use the canonical field name `openAIApiKey`.
- Rotate and re-verify keys regularly.
- Confirm the key works with a direct OpenAI call before runtime.
When it happens
Trigger: assistant.credential is empty so getCredentialData returns nothing; the referenced credential was deleted; the credential exists but lacks the `openAIApiKey` field; the key value is an empty string.
Common situations: Credential never created or deleted after assistant setup; assistant's credential dropdown cleared; key entered in wrong field name; secret resolved to empty due to a vault/env issue.
Related errors
- Assistant ${selectedAssistantId} not found
- Error executing tool. Tool: ${tool.name}. Thread ID: ${threa
- Error submitting tool outputs. Thread ID: ${threadId}. Run I
- Error processing thread: ${state}, Thread ID: ${threadId}
- ${error}
AI-assisted analysis of FlowiseAI/Flowise@abe4a8601a (2026-08-12).
Data as JSON: /api/errors/eb1a8e26b0c40781.
Report an issue: GitHub.