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

  1. In Credentials, create/recreate an OpenAI credential with a non-empty `openAIApiKey`.
  2. Open the Assistant record and ensure its Credential field points to that credential.
  3. Verify the key value is non-empty and is a valid `sk-...` token.
  4. Test the key with a direct `curl https://api.openai.com/v1/models -H "Authorization: Bearer $KEY"`.
  5. 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

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


AI-assisted analysis of FlowiseAI/Flowise@abe4a8601a (2026-08-12). Data as JSON: /api/errors/eb1a8e26b0c40781. Report an issue: GitHub.