import { OpenRouterCore } from "@openrouter/sdk/core.js";import { ttsCreateSpeech } from "@openrouter/sdk/funcs/ttsCreateSpeech.js";// Use `OpenRouterCore` for best tree-shaking performance.// You can create one instance of it to use across an application.const openRouter = new OpenRouterCore({ httpReferer: "<value>", appTitle: "<value>", appCategories: "<value>", apiKey: process.env["OPENROUTER_API_KEY"] ?? "",});async function run() { const res = await ttsCreateSpeech(openRouter, { speechRequest: { input: "Hello world", model: "mistralai/voxtral-mini-tts-2603", speed: 1, voice: "en_paul_neutral", }, }); if (res.ok) { const { value: result } = res; console.log(result); } else { console.log("ttsCreateSpeech failed:", res.error); }}run();
Options that are passed to the underlying HTTP request. This can be used to inject extra headers for examples. All Request options, except method and body, are allowed.
Lists every text-to-speech model with the inputs it accepts and its speech output parameters, merged across its endpoints, plus each endpoint with its own.
Example Usage
import { OpenRouter } from "@openrouter/sdk";const openRouter = new OpenRouter({ httpReferer: "<value>", appTitle: "<value>", appCategories: "<value>",});async function run() { const result = await openRouter.tts.listModels(); console.log(result);}run();
Standalone function
The standalone function version of this method:
import { OpenRouterCore } from "@openrouter/sdk/core.js";import { ttsListModels } from "@openrouter/sdk/funcs/ttsListModels.js";// Use `OpenRouterCore` for best tree-shaking performance.// You can create one instance of it to use across an application.const openRouter = new OpenRouterCore({ httpReferer: "<value>", appTitle: "<value>", appCategories: "<value>",});async function run() { const res = await ttsListModels(openRouter); if (res.ok) { const { value: result } = res; console.log(result); } else { console.log("ttsListModels failed:", res.error); }}run();
Options that are passed to the underlying HTTP request. This can be used to inject extra headers for examples. All Request options, except method and body, are allowed.
Returns a text-to-speech model with each endpoint’s own inputs and speech output parameters.
Example Usage
import { OpenRouter } from "@openrouter/sdk";const openRouter = new OpenRouter({ httpReferer: "<value>", appTitle: "<value>", appCategories: "<value>",});async function run() { const result = await openRouter.tts.getModel({ author: "openai", slug: "gpt-4o-mini-tts", }); console.log(result);}run();
Standalone function
The standalone function version of this method:
import { OpenRouterCore } from "@openrouter/sdk/core.js";import { ttsGetModel } from "@openrouter/sdk/funcs/ttsGetModel.js";// Use `OpenRouterCore` for best tree-shaking performance.// You can create one instance of it to use across an application.const openRouter = new OpenRouterCore({ httpReferer: "<value>", appTitle: "<value>", appCategories: "<value>",});async function run() { const res = await ttsGetModel(openRouter, { author: "openai", slug: "gpt-4o-mini-tts", }); if (res.ok) { const { value: result } = res; console.log(result); } else { console.log("ttsGetModel failed:", res.error); }}run();
Options that are passed to the underlying HTTP request. This can be used to inject extra headers for examples. All Request options, except method and body, are allowed.