Mintplex-Labs/anything-llm · error · Error
No OpenAI API key was set.
Error message
No OpenAI API key was set.
What it means
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.
Source
Thrown at collector/utils/WhisperProviders/OpenAiWhisper.js:6
const fs = require("fs");
class OpenAiWhisper {
constructor({ options }) {
const { OpenAI: OpenAIApi } = require("openai");
if (!options.openAiKey) throw new Error("No OpenAI API key was set.");
this.openai = new OpenAIApi({
apiKey: options.openAiKey,
});
this.model = "whisper-1";
this.temperature = 0;
this.#log("Initialized.");
}
#log(text, ...args) {
console.log(`\x1b[32m[OpenAiWhisper]\x1b[0m ${text}`, ...args);
}
async processFile(fullFilePath) {
return await this.openai.audio.transcriptions
.create({
file: fs.createReadStream(fullFilePath),
model: this.model,View on GitHub (pinned to 526360e320)
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.
Example fix
// before
new OpenAiWhisper({ options: {} });
// after
new OpenAiWhisper({ options: { openAiKey: process.env.OPEN_AI_API_KEY } });
// and ensure process.env.OPEN_AI_API_KEY is set in the collector process Defensive patterns
Strategy: validation
Validate before calling
function canBuildOpenAiWhisper(options) {
return !!(options && typeof options.openAiKey === "string" && options.openAiKey.length > 0);
}
if (!canBuildOpenAiWhisper(options)) {
throw new Error("OpenAiWhisper requires options.openAiKey (set OPEN_AI_API_KEY)");
}
new OpenAiWhisper({ options }); Type guard
/** @param {unknown} o */
function isOpenAiWhisperConfig(o) {
return o != null && typeof o === "object"
&& typeof o.openAiKey === "string" && o.openAiKey.length > 0;
} Try / catch
let provider;
try {
provider = new OpenAiWhisper({ options });
} catch (e) {
if (/No OpenAI API key was set/.test(e.message)) {
return surfaceConfigError("Set an OpenAI API key, or switch the Whisper provider.");
}
throw e;
} Prevention
- 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.
When it happens
Trigger: 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.
Common situations: 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.
Related errors
- No base URL was set.
- Audio file sample rate is too low for accurate transcription
- Audio file duration exceeds maximum limit of 4 hours.
- Audio file exceeds maximum allowed length.
- [Conversion Failed]: Could not convert file to .wav format!
AI-assisted analysis of Mintplex-Labs/anything-llm@526360e320 (2026-08-13).
Data as JSON: /api/errors/9f66ffa2a5e039b0.
Report an issue: GitHub.