decolua/9router · error · Error
No OpenAI API key configured
Error message
No OpenAI API key configured
What it means
The OpenAI TTS provider requires an apiKey in the credentials object passed to synthesize(). If credentials are missing or credentials.apiKey is falsy, it fails fast before making any HTTP call. This is a local configuration check, not an upstream error.
Source
Thrown at open-sse/handlers/ttsProviders/openai.js:9
// OpenAI TTS — model format: "tts-model/voice"
import { Buffer } from "node:buffer";
import { PROVIDER_MEDIA } from "../../providers/index.js";
const DEFAULT_TTS_MODEL = PROVIDER_MEDIA["openai"]?.ttsConfig?.defaultModel;
export default {
async synthesize(text, model, credentials) {
if (!credentials?.apiKey) throw new Error("No OpenAI API key configured");
let ttsModel = DEFAULT_TTS_MODEL;
let voice = "alloy";
if (model && model.includes("/")) {
const parts = model.split("/");
if (parts.length === 2) [ttsModel, voice] = parts;
} else if (model) {
voice = model;
}
const baseUrl = (credentials.baseUrl || "https://api.openai.com").replace(/\/+$/, "");
const res = await fetch(`${baseUrl}/v1/audio/speech`, {
method: "POST",
headers: { "Content-Type": "application/json", "Authorization": `Bearer ${credentials.apiKey}` },
body: JSON.stringify({ model: ttsModel, voice, input: text }),
});
if (!res.ok) {
const err = await res.json().catch(() => ({}));View on GitHub (pinned to 90b52e06ff)
Solutions
- Add an OpenAI API key in the 9Router dashboard (provider credential settings)
- Verify the credential record persisted and its apiKey field is non-empty
- Restart the gateway after adding credentials so the account cache refreshes
- Select a TTS provider that does have credentials configured
Defensive patterns
Strategy: validation
Validate before calling
if (!credentials?.apiKey) throw new Error("Configure an OpenAI API key before using OpenAI TTS"); Type guard
function hasOpenAiKey(c) {
return typeof c?.apiKey === "string" && c.apiKey.trim().length > 0;
} Try / catch
try {
await openaiTts.synthesize(text, model, creds);
} catch (e) {
if (e.message === "No OpenAI API key configured") {
notifyUser("Add an OpenAI API key in provider settings");
} else throw e;
} Prevention
- Run a credential preflight check at gateway startup for enabled TTS providers
- Never pass provider credentials objects between providers
- Keep keys in the credential store, not ad-hoc env lookups
- Add a dashboard health check that flags providers with missing keys
When it happens
Trigger: Calling the OpenAI TTS synthesize flow without configuring an OpenAI API key in 9Router's account/credential store, or with a credential entry whose apiKey field is empty/undefined.
Common situations: Fresh installs where the OpenAI provider was selected for TTS but no key was added; keys deleted from the dashboard; passing the wrong provider's credentials object; env var not loaded.
Understand the failure class
Background: "API key is required" / "API key not found" / "No API key was set": the missing-api-key error family across 16 libraries — this error's family across 16 libraries.
Related errors
- ElevenLabs API key required
- No Gemini API key configured
- No OpenRouter API key configured
- xiaomi-mimo API key required
- Upstream error (${res.status})
AI-assisted analysis of decolua/9router@90b52e06ff (2026-08-30).
Data as JSON: /api/errors/66813e84d7504ad8.
Report an issue: GitHub.