POST/audio/speech

Text-to-Speech

Convert text to natural-sounding speech. Supports multiple voices, languages, and audio formats.

OpenAI Compatible

This endpoint is fully compatible with OpenAI's text-to-speech API. Simply change the base URL and use your Selam API key.

Request

Request Body

1{
2  "model": "tts-1",
3  "input": "Hello! Welcome to SelamGPT text-to-speech.",
4  "voice": "alloy",
5  "response_format": "mp3",
6  "speed": 1.0
7}

Parameters

modelstringrequired

The TTS model to use. Options: "tts-1" (standard), "tts-1-hd" (high quality).

inputstringrequired

The text to convert to speech. Maximum length is 4096 characters.

voicestringrequired

The voice to use. Options: "alloy", "echo", "fable", "onyx", "nova", "shimmer". Use /audio/voices to see all available voices.

response_formatstringoptional

The audio format. Options: "mp3", "opus", "aac", "flac". Default is "mp3".

speednumberoptional

The speed of the generated audio. Range: 0.25 to 4.0. Default is 1.0.

Response

Returns the audio file as binary data with the appropriate Content-Type header.

Examples

1from openai import OpenAI
2
3client = OpenAI(
4    api_key="YOUR_API_KEY",
5    base_url="https://api.selamgpt.com/v1"
6)
7
8response = client.audio.speech.create(
9    model="tts-1",
10    voice="alloy",
11    input="Hello! Welcome to SelamGPT."
12)
13
14response.stream_to_file("speech.mp3")

Was this page helpful?