Skip to main content
API Reference: POST /audio/speech

Provider capabilities

The table below summarizes gateway support for this endpoint by provider.
Legend:
  • Supported by provider and TrueFoundry
  • Provided by provider, but not by TrueFoundry
  • Provider does not support this feature
For every gateway endpoint and provider, see Supported APIs. Text to speech (TTS) turns written text into audio. The AI Gateway supports two ways to call it:

Add models to the AI Gateway

Before you can call the Text to Speech API, add your TTS models to TrueFoundry through a model account. When adding a model, select Text to Speech as the model type.
You can also call TTS through a virtual model to load-balance or fail over across multiple TTS providers. Create a virtual model with the Text to Speech model type and use its name as model in your request.

Code snippets

Before you start: Replace {GATEWAY_BASE_URL} with your gateway base URL and your-tfy-api-key with your TrueFoundry API key. For the native SDK, replace {providerAccountName} with the display name of your model account on TrueFoundry.
Model names: For audio (STT/TTS), the model ID in code must match the display name of the model on your TrueFoundry model account.
Which SDK to use: For OpenAI, Azure OpenAI, Azure AI Foundry, and Groq, use the OpenAI SDK (same API). For Deepgram, Cartesia, ElevenLabs, Gemini, and Vertex, use each provider’s native SDK with the AI Gateway URL above. For Smallest AI, call the Waves HTTP API directly.

Response

TTS responses are audio bytes. Each snippet above writes the audio to a file and prints the output path.