Skip to main content
POST
/
v1
/
audio
/
speech
Python (OpenAI SDK)
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>"

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.

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.

First request

Start with three fields: 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.

Read the response

The response is binary audio, not JSON. In SDK examples, write the response to a file such as output.mp3. In direct HTTP clients, save the response body and set the file extension to match the requested response_format.

Next steps

Authorizations

Authorization
string
header
required

Bearer token authentication. Use your CometAPI key.

Body

application/json
model
string
default:tts-1
required

The TTS model to use. Choose a current speech model from the Models page.

input
string
required

The text to generate audio for. Maximum length is 4096 characters.

Maximum string length: 4096
voice
enum<string>
default:alloy
required

The voice to use for speech synthesis.

Available options:
alloy,
ash,
ballad,
coral,
echo,
fable,
onyx,
nova,
sage,
shimmer
response_format
enum<string>
default:mp3

The audio output format.

Available options:
mp3,
opus,
aac,
flac,
wav,
pcm
speed
number
default:1

The speed of the generated audio. Select a value between 0.25 and 4.0.

Required range: 0.25 <= x <= 4

Response

200 - audio/mpeg

The audio file content.

The response is of type file.