Use CometAPI POST /v1/audio/speech to convert text into lifelike audio with TTS models. Choose from 10 voices, adjust speed, and output in MP3, OPUS, AAC, FLAC, WAV, or PCM.
from openai import OpenAI
client = OpenAI(
api_key="<COMETAPI_KEY>",
base_url="https://api.cometapi.com/v1"
)
response = client.audio.speech.create(
model="tts-1",
voice="alloy",
input="The quick brown fox jumped over the lazy dog."
)
response.stream_to_file("output.mp3")"<string>"Use this endpoint to turn text into an audio file through the OpenAI-compatible audio API. It fits narration, short voice prompts, read-aloud features, and other workflows where your app already has text and needs speech output.Documentation Index
Fetch the complete documentation index at: https://apidoc.cometapi.com/llms.txt
Use this file to discover all available pages before exploring further.
model, input, and voice. Keep the first request short so you can verify authentication, audio format, and file handling before you tune speed or output format.
output.mp3. In direct HTTP clients, save the response body and set the file extension to match the requested response_format.
Bearer token authentication. Use your CometAPI key.
The TTS model to use. Choose a current speech model from the Models page.
The text to generate audio for. Maximum length is 4096 characters.
4096The voice to use for speech synthesis.
alloy, ash, ballad, coral, echo, fable, onyx, nova, sage, shimmer The audio output format.
mp3, opus, aac, flac, wav, pcm The speed of the generated audio. Select a value between 0.25 and 4.0.
0.25 <= x <= 4The audio file content.
The response is of type file.
from openai import OpenAI
client = OpenAI(
api_key="<COMETAPI_KEY>",
base_url="https://api.cometapi.com/v1"
)
response = client.audio.speech.create(
model="tts-1",
voice="alloy",
input="The quick brown fox jumped over the lazy dog."
)
response.stream_to_file("output.mp3")"<string>"