{"record":{"id":"eb1a8e26b0c40781","repo":"FlowiseAI/Flowise","slug":"openai-apikey-not-found","errorCode":null,"errorMessage":"OpenAI ApiKey not found","messagePattern":"OpenAI ApiKey not found","errorType":"validation","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"packages/components/nodes/agents/OpenAIAssistant/OpenAIAssistant.ts","lineNumber":242,"sourceCode":"        }\n\n        let tools = nodeData.inputs?.tools\n        tools = flatten(tools)\n        const formattedTools = tools?.map((tool: any) => formatToOpenAIAssistantTool(tool)) ?? []\n\n        const usedTools: IUsedTool[] = []\n        const fileAnnotations = []\n        const artifacts = []\n\n        const assistant = await appDataSource.getRepository(databaseEntities['Assistant']).findOneBy({\n            id: selectedAssistantId\n        })\n\n        if (!assistant) throw new Error(`Assistant ${selectedAssistantId} not found`)\n\n        const credentialData = await getCredentialData(assistant.credential ?? '', options)\n        const openAIApiKey = getCredentialParam('openAIApiKey', credentialData, nodeData)\n        if (!openAIApiKey) throw new Error(`OpenAI ApiKey not found`)\n\n        const openai = new OpenAI({ apiKey: openAIApiKey })\n\n        // Start analytics\n        const analyticHandlers = AnalyticHandler.getInstance(nodeData, options)\n        await analyticHandlers.init()\n        const parentIds = await analyticHandlers.onChainStart('OpenAIAssistant', input)\n\n        try {\n            const assistantDetails = JSON.parse(assistant.details)\n            const openAIAssistantId = assistantDetails.id\n\n            // Retrieve assistant\n            const retrievedAssistant = await openai.beta.assistants.retrieve(openAIAssistantId)\n\n            if (formattedTools.length) {\n                let filteredTools = []\n                for (const tool of retrievedAssistant.tools) {","sourceCodeStart":224,"sourceCodeEnd":260,"githubUrl":"https://github.com/FlowiseAI/Flowise/blob/abe4a8601a058047b350c260676826e21dd14101/packages/components/nodes/agents/OpenAIAssistant/OpenAIAssistant.ts#L224-L260","documentation":"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`.","triggerScenarios":"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.","commonSituations":"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.","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."],"exampleFix":null,"handlingStrategy":"validation","validationCode":"const cred = await getCredentialData(assistant.credential ?? '', options)\nconst key = getCredentialParam('openAIApiKey', cred, nodeData)\nif (!key) throw new Error('Assistant credential must contain a non-empty openAIApiKey')","typeGuard":null,"tryCatchPattern":"try {\n  await assistantNode.run(nodeData, input, options)\n} catch (e) {\n  if ((e as Error).message === 'OpenAI ApiKey not found') configureCredential()\n  throw e\n}","preventionTips":["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."],"tags":["agent","openai-assistant","credentials","missing-api-key","config"],"backgroundTag":null,"analyzedSha":"abe4a8601a058047b350c260676826e21dd14101","analyzedAt":"2026-08-12T16:04:40.823Z","schemaVersion":2},"datasetVersion":"2026-08-12T23:17:12.415Z"}