refactor(open-sse): B1 consolidate media endpoint URLs into registry
- image/embed/tts/search base URLs derive from media.*Config.baseUrl / searchViaChat.endpoint (single source); handlers read PROVIDER_MEDIA. - ~18 hardcoded endpoints moved: bfl/fal/stability/runway/hf/gemini/ cloudflare/recraft/sdwebui/comfyui/nanobanana image, voyage embed, gemini/openrouter tts, chatSearch endpoints. - Byte-identical: PROVIDERS 62 + alias 90 baselines, image buildUrl outputs. Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
@@ -1,10 +1,14 @@
|
||||
// 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 = "openai/gpt-4o-mini-tts";
|
||||
let ttsModel = TTS_CFG.defaultModel;
|
||||
let voice = "alloy";
|
||||
if (model && model.includes("/")) {
|
||||
const lastSlash = model.lastIndexOf("/");
|
||||
@@ -20,13 +24,12 @@ export default {
|
||||
voice = model;
|
||||
}
|
||||
|
||||
const res = await fetch("https://openrouter.ai/api/v1/chat/completions", {
|
||||
const res = await fetch(TTS_CFG.baseUrl, {
|
||||
method: "POST",
|
||||
headers: {
|
||||
"Content-Type": "application/json",
|
||||
"Authorization": `Bearer ${credentials.apiKey}`,
|
||||
"HTTP-Referer": "https://endpoint-proxy.local",
|
||||
"X-Title": "Endpoint Proxy",
|
||||
...(TTS_CFG.headers || {}),
|
||||
},
|
||||
body: JSON.stringify({
|
||||
model: ttsModel,
|
||||
|
||||
Reference in New Issue
Block a user