OpenRouter audio TTS provider that streams PCM audio and returns WAV for client use.
// Source: https://github.com/moeru-ai/airi | License: MIT | Copyright 2024-PRESENT Neko Ayaka
// Provided via justclaw.it.com; keep this notice with the code.
import { toWavFromPCM16 } from '@proj-airi/audio/encoding'
import { EventSourceParserStream } from '@xsai/shared-stream'
import { z } from 'zod'
import { defineProvider } from '../../registry'
import { OPENROUTER_ATTRIBUTION_HEADERS } from '../openrouter-ai'
const DEFAULT_BASE_URL = 'https://openrouter.ai/api/v1/'
const DEFAULT_MODEL = 'openai/gpt-audio-mini'
const openRouterAudioConfigSchema = z.object({
apiKey: z.string(),
baseUrl: z.string().default(DEFAULT_BASE_URL),
})
type OpenRouterAudioConfig = z.input<typeof openRouterAudioConfigSchema>
const openAIVoices = [
'alloy',
'ash',
'ballad',
'coral',
'echo',
'
... (truncated -- full source via MCP)
See the full source, get the GitHub permalink, and search for more like it.
Get a free API key