{"record":{"id":"b2aef5a554eac251","repo":"decolua/9router","slug":"no-openrouter-api-key-configured","errorCode":null,"errorMessage":"No OpenRouter API key configured","messagePattern":"No OpenRouter API key configured","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"open-sse/handlers/ttsProviders/openrouter.js","lineNumber":8,"sourceCode":"// OpenRouter TTS — via chat completions + audio modality (SSE stream)\nimport { PROVIDER_MEDIA } from \"../../providers/index.js\";\n\nconst TTS_CFG = PROVIDER_MEDIA[\"openrouter\"]?.ttsConfig || {};\n\nexport default {\n  async synthesize(text, model, credentials) {\n    if (!credentials?.apiKey) throw new Error(\"No OpenRouter API key configured\");\n\n    // model format: \"tts-model/voice\" e.g. \"openai/gpt-4o-mini-tts/alloy\"\n    let ttsModel = TTS_CFG.defaultModel;\n    let voice = \"alloy\";\n    if (model && model.includes(\"/\")) {\n      const lastSlash = model.lastIndexOf(\"/\");\n      const maybVoice = model.slice(lastSlash + 1);\n      const maybeModel = model.slice(0, lastSlash);\n      if (maybeModel.includes(\"/\")) {\n        ttsModel = maybeModel;\n        voice = maybVoice;\n      } else {\n        voice = model;\n      }\n    } else if (model) {\n      voice = model;\n    }\n","sourceCodeStart":1,"sourceCodeEnd":26,"githubUrl":"https://github.com/decolua/9router/blob/90b52e06ffd666b7929554211474d01588f6b1f8/open-sse/handlers/ttsProviders/openrouter.js#L1-L26","documentation":"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.","triggerScenarios":"Invoking TTS routed to OpenRouter without an OpenRouter API key stored in 9Router credentials, or with an empty apiKey string in the credentials object.","commonSituations":"OpenRouter added as a chat provider but no key saved for TTS use; key rotated/removed; wrong account object passed to the TTS handler.","solutions":["Add an OpenRouter API key in the 9Router provider credentials","Ensure the key is active on openrouter.ai/keys","Restart/reload the gateway so credentials are re-read","Or switch the TTS model to a provider whose credentials exist"],"exampleFix":null,"handlingStrategy":"validation","validationCode":"if (!credentials?.apiKey) throw new Error(\"Configure an OpenRouter API key before using OpenRouter TTS\");","typeGuard":"function hasOpenRouterKey(c) {\n  return typeof c?.apiKey === \"string\" && c.apiKey.trim().length > 0;\n}","tryCatchPattern":"try {\n  await openrouterTts.synthesize(text, model, creds);\n} catch (e) {\n  if (e.message === \"No OpenRouter API key configured\") {\n    notifyUser(\"Add an OpenRouter API key in provider settings\");\n  } else throw e;\n}","preventionTips":["Preflight-check that every TTS-enabled provider has a non-empty key","Rotate keys on schedule and update the credential store","Don't reuse chat-provider account objects for TTS without verifying fields","Add startup health checks per enabled provider"],"tags":["tts","openrouter","api-key","missing-credentials"],"backgroundTag":"missing-api-key","analyzedSha":"90b52e06ffd666b7929554211474d01588f6b1f8","analyzedAt":"2026-08-30T21:05:45.952Z","schemaVersion":2},"datasetVersion":"2026-08-30T23:17:21.991Z"}