decolua/9router · error · Error

No OpenRouter API key configured

Error message

No OpenRouter API key configured

What it means

The OpenRouter TTS provider requires credentials.apiKey; it throws locally before any network call when absent. OpenRouter proxies TTS to underlying models, so its key is mandatory. This is a pure configuration guard.

Source

Thrown at open-sse/handlers/ttsProviders/openrouter.js:8

// OpenRouter TTS — via chat completions + audio modality (SSE stream)
import { PROVIDER_MEDIA } from "../../providers/index.js";

const TTS_CFG = PROVIDER_MEDIA["openrouter"]?.ttsConfig || {};

export default {
  async synthesize(text, model, credentials) {
    if (!credentials?.apiKey) throw new Error("No OpenRouter API key configured");

    // model format: "tts-model/voice" e.g. "openai/gpt-4o-mini-tts/alloy"
    let ttsModel = TTS_CFG.defaultModel;
    let voice = "alloy";
    if (model && model.includes("/")) {
      const lastSlash = model.lastIndexOf("/");
      const maybVoice = model.slice(lastSlash + 1);
      const maybeModel = model.slice(0, lastSlash);
      if (maybeModel.includes("/")) {
        ttsModel = maybeModel;
        voice = maybVoice;
      } else {
        voice = model;
      }
    } else if (model) {
      voice = model;
    }

View on GitHub (pinned to 90b52e06ff)

Solutions

  1. Add an OpenRouter API key in the 9Router provider credentials
  2. Ensure the key is active on openrouter.ai/keys
  3. Restart/reload the gateway so credentials are re-read
  4. Or switch the TTS model to a provider whose credentials exist
Defensive patterns

Strategy: validation

Validate before calling

if (!credentials?.apiKey) throw new Error("Configure an OpenRouter API key before using OpenRouter TTS");

Type guard

function hasOpenRouterKey(c) {
  return typeof c?.apiKey === "string" && c.apiKey.trim().length > 0;
}

Try / catch

try {
  await openrouterTts.synthesize(text, model, creds);
} catch (e) {
  if (e.message === "No OpenRouter API key configured") {
    notifyUser("Add an OpenRouter API key in provider settings");
  } else throw e;
}

Prevention

When it happens

Trigger: Invoking TTS routed to OpenRouter without an OpenRouter API key stored in 9Router credentials, or with an empty apiKey string in the credentials object.

Common situations: OpenRouter added as a chat provider but no key saved for TTS use; key rotated/removed; wrong account object passed to the TTS handler.

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


AI-assisted analysis of decolua/9router@90b52e06ff (2026-08-30). Data as JSON: /api/errors/b2aef5a554eac251. Report an issue: GitHub.