{"record":{"id":"9f66ffa2a5e039b0","repo":"Mintplex-Labs/anything-llm","slug":"no-openai-api-key-was-set","errorCode":null,"errorMessage":"No OpenAI API key was set.","messagePattern":"No OpenAI API key was set\\.","errorType":"validation","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"collector/utils/WhisperProviders/OpenAiWhisper.js","lineNumber":6,"sourceCode":"const fs = require(\"fs\");\n\nclass OpenAiWhisper {\n  constructor({ options }) {\n    const { OpenAI: OpenAIApi } = require(\"openai\");\n    if (!options.openAiKey) throw new Error(\"No OpenAI API key was set.\");\n\n    this.openai = new OpenAIApi({\n      apiKey: options.openAiKey,\n    });\n    this.model = \"whisper-1\";\n    this.temperature = 0;\n    this.#log(\"Initialized.\");\n  }\n\n  #log(text, ...args) {\n    console.log(`\\x1b[32m[OpenAiWhisper]\\x1b[0m ${text}`, ...args);\n  }\n\n  async processFile(fullFilePath) {\n    return await this.openai.audio.transcriptions\n      .create({\n        file: fs.createReadStream(fullFilePath),\n        model: this.model,","sourceCodeStart":1,"sourceCodeEnd":24,"githubUrl":"https://github.com/Mintplex-Labs/anything-llm/blob/526360e320da9d1b36074be5ed64fe76e5bbfbbd/collector/utils/WhisperProviders/OpenAiWhisper.js#L1-L24","documentation":"Thrown synchronously by the OpenAiWhisper constructor in collector/utils/WhisperProviders/OpenAiWhisper.js:6 when options.openAiKey is falsy. This provider calls the official OpenAI /audio/transcriptions endpoint, so an API key is mandatory. Constructing the class during the transcription pipeline bootstrap will throw and propagate up.","triggerScenarios":"Instantiating new OpenAiWhisper({ options }) when the user picked WhisperProvider=\"OpenAiWhisper\" but openAiKey is empty/undefined — most commonly OPEN_AI_API_KEY (or the equivalent setting feeding options.openAiKey) is not set in the environment / system prompt preferences.","commonSituations":"Fresh deployment without OPEN_AI_API_KEY set; env var present in shell but not passed into the Docker container; key cleared from settings UI; typo in the env var name; user switched LLM provider away from OpenAI but left Whisper on OpenAI.","solutions":["Set options.openAiKey to a valid OpenAI API key (starts with sk-).","If using env, ensure OPEN_AI_API_KEY is exported AND mounted into the collector container, then restart it.","In the UI, fill the OpenAI API key field under transcription/audio settings.","If you have no OpenAI key, switch WhisperProvider to a Generic OpenAI-compatible or local provider."],"exampleFix":"// before\nnew OpenAiWhisper({ options: {} });\n\n// after\nnew OpenAiWhisper({ options: { openAiKey: process.env.OPEN_AI_API_KEY } });\n// and ensure process.env.OPEN_AI_API_KEY is set in the collector process","handlingStrategy":"validation","validationCode":"function canBuildOpenAiWhisper(options) {\n  return !!(options && typeof options.openAiKey === \"string\" && options.openAiKey.length > 0);\n}\nif (!canBuildOpenAiWhisper(options)) {\n  throw new Error(\"OpenAiWhisper requires options.openAiKey (set OPEN_AI_API_KEY)\");\n}\nnew OpenAiWhisper({ options });","typeGuard":"/** @param {unknown} o */\nfunction isOpenAiWhisperConfig(o) {\n  return o != null && typeof o === \"object\"\n    && typeof o.openAiKey === \"string\" && o.openAiKey.length > 0;\n}","tryCatchPattern":"let provider;\ntry {\n  provider = new OpenAiWhisper({ options });\n} catch (e) {\n  if (/No OpenAI API key was set/.test(e.message)) {\n    return surfaceConfigError(\"Set an OpenAI API key, or switch the Whisper provider.\");\n  }\n  throw e;\n}","preventionTips":["Set OPEN_AI_API_KEY in the collector process env (and mount it into the container), then restart.","Validate options.openAiKey presence before constructing the provider — constructors throw.","If no OpenAI key is available, switch the Whisper provider rather than relying on OpenAiWhisper."],"tags":["config","whisper","openai","api-key","audio"],"backgroundTag":null,"analyzedSha":"526360e320da9d1b36074be5ed64fe76e5bbfbbd","analyzedAt":"2026-08-13T01:45:47.170Z","schemaVersion":2},"datasetVersion":"2026-08-13T04:17:16.726Z"}