TTS-1
Text-to-Speech • OpenAI • ProxiedOpenAI's text-to-speech model optimized for real-time use with low latency.
| Model Info | |
|---|---|
| Terms and License | link ↗ |
| More information | link ↗ |
| Pricing | View pricing in the Cloudflare dashboard ↗ |
Usage
const response = await env.AI.run( 'openai/tts-1', { text: 'Hello! Welcome to Cloudflare AI Gateway. Let me show you what we can do.', voice: 'alloy', response_format: 'mp3', speed: 1, }, { gateway: { id: 'default' }, })console.log(response){ "state": "Completed", "result": { "audio": "https://pub-04a6d208d361438ea01b797e6973bd19.r2.dev/catalog/openai__tts-1/simple-speech.mp3" }, "gatewayMetadata": { "keySource": "Unified" }}Examples
Different Voice — Use the Nova voice for a different tone
const response = await env.AI.run( 'openai/tts-1', { text: 'The weather today is sunny with a high of 72 degrees. Perfect for a walk in the park.', voice: 'nova', response_format: 'mp3', speed: 1, }, { gateway: { id: 'default' }, })console.log(response){ "state": "Completed", "result": { "audio": "https://pub-04a6d208d361438ea01b797e6973bd19.r2.dev/catalog/openai__tts-1/different-voice.mp3" }, "gatewayMetadata": { "keySource": "Unified" }}Narration — Slower narration style with the Onyx voice
const response = await env.AI.run( 'openai/tts-1', { text: 'In the beginning, the universe was a singularity of infinite density. Then, in a fraction of a second, it expanded into everything we know today.', voice: 'onyx', response_format: 'mp3', speed: 0.85, }, { gateway: { id: 'default' }, })console.log(response){ "state": "Completed", "result": { "audio": "https://pub-04a6d208d361438ea01b797e6973bd19.r2.dev/catalog/openai__tts-1/narration.mp3" }, "gatewayMetadata": { "keySource": "Unified" }}Echo Voice — Use the Echo voice for a deeper tone
const response = await env.AI.run( 'openai/tts-1', { text: 'Welcome back to the podcast. Today we are going to talk about the future of artificial intelligence and its impact on creative work.', voice: 'echo', response_format: 'mp3', speed: 1, }, { gateway: { id: 'default' }, })console.log(response){ "state": "Completed", "result": { "audio": "https://pub-04a6d208d361438ea01b797e6973bd19.r2.dev/catalog/openai__tts-1/echo-voice.mp3" }, "gatewayMetadata": { "keySource": "Unified" }}Fast Playback — Speed up speech for quick listening
const response = await env.AI.run( 'openai/tts-1', { text: 'This is a fast-paced summary of the key findings from the quarterly report. Revenue is up fifteen percent, user growth exceeded expectations, and infrastructure costs remain stable.', voice: 'shimmer', response_format: 'mp3', speed: 1.5, }, { gateway: { id: 'default' }, })console.log(response){ "state": "Completed", "result": { "audio": "https://pub-04a6d208d361438ea01b797e6973bd19.r2.dev/catalog/openai__tts-1/fast-playback.mp3" }, "gatewayMetadata": { "keySource": "Unified" }}Parameters
stringrequiredmaxLength: 4096The text to generate audio for. Maximum length is 4096 characters.stringrequireddefault: alloyenum: alloy, echo, fable, onyx, nova, shimmerThe voice to use when generating the audio. Defaults to alloy.stringrequireddefault: mp3enum: mp3, opus, wav, aac, flacThe output format for the audio. Supported formats are mp3, opus, wav, aac and flac.numberrequireddefault: 1minimum: 0.25maximum: 4The speed of the generated audio. Select a value from 0.25 to 4.0. 1.0 is the default.stringURL to the generated audio file