AI Audio (TTS) (/api/ai/audio)
Try it
AI Audio (Text-to-Speech)
Synthesize speech using Vercel AI Gateway (OpenAI-compatible). Returns audio bytes.
Endpoint
POST /api/ai/audioRequest Body
| Field | Type | Description | Required |
|---|---|---|---|
| text | string | Text to synthesize | Yes |
| provider | ’vercel’ | Provider to use | No (default: ‘vercel’) |
| voice | string | Voice name | No |
| format | ’mp3’ | ‘wav’ | ‘ogg’ | Output format | No (default: ‘mp3’) |
| model | string | Model id (OpenAI-compatible) | No |
Example
{
"text": "Hello from the AI audio API",
"provider": "vercel",
"voice": "alloy",
"format": "mp3"
}Response
Binary audio data. Content-Type depends on format.
Environment
- Vercel:
VERCEL_AI_GATEWAY_OPENAI,VERCEL_AI_GATEWAY_API_KEY
Last updated on