Skip to main content

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
ProviderText To Speech
OpenAI
Azure OpenAI
Azure AI Foundry
Anthropic
Bedrock
Vertex
Cohere
Gemini
Groq
Together-AI
xAI
DeepInfra
DeepGram
Cartesia
ElevenLabs
For every gateway endpoint and provider, see Supported APIs. Text to speech (TTS) turns written text into audio. The gateway supports two ways to call it:
ApproachUse forBase path
OpenAI-compatible APIOpenAI, Azure OpenAI, Azure AI Foundry, Groq{GATEWAY_BASE_URL}
Native SDKDeepgram, Cartesia, ElevenLabs, Gemini, Vertex{GATEWAY_BASE_URL}/tts/{providerAccountName}

Add models to the gateway

Before you can call the Text to Speech API, add your TTS models to TrueFoundry through a provider account. When adding a model, select Text to Speech as the model type.
ProviderSetup guide
OpenAIOpenAI
Azure OpenAIAzure OpenAI
Azure AI FoundryAzure AI Foundry
GroqGroq
DeepgramDeepgram
CartesiaCartesia
ElevenLabsElevenLabs
GeminiGoogle Gemini
VertexGoogle Vertex

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 provider 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 provider 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 gateway URL above.
from pathlib import Path
from openai import OpenAI

BASE_URL = "{GATEWAY_BASE_URL}"
API_KEY = "your-tfy-api-key"

client = OpenAI(api_key=API_KEY, base_url=BASE_URL)

output_path = Path(__file__).parent / "output.mp3"
with client.audio.speech.with_streaming_response.create(
    model="openai-main/gpt-4o-mini-tts",  # truefoundry model name
    voice="alloy",
    input="Hello, how are you?",
) as response:
    response.stream_to_file(output_path)

print(output_path)

Response

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