POST
/
v1
/
audio
/
speech
Text to Speech
curl --request POST \
  --url https://llm.ai-nebula.com/v1/audio/speech \
  --header 'Authorization: <authorization>' \
  --header 'Content-Type: application/json' \
  --data '
{
  "model": "<string>",
  "input": "<string>",
  "voice": "<string>",
  "response_format": "<string>",
  "speed": 123
}
'

Introduction

Convert text into natural-sounding speech audio. The endpoint is OpenAI-compatible, so you can use the OpenAI SDK or any compatible client directly.

Authentication

Authorization
string
required
Bearer Token, e.g. Bearer sk-xxxxxxxxxx

Request Parameters

model
string
required
Model name, e.g. gpt-4o-mini-tts
input
string
required
The text to convert to speech.
voice
string
required
Voice to synthesize with, e.g. alloy, echo, fable, onyx, nova, shimmer
response_format
string
default:"mp3"
Audio output format: mp3, opus, aac, flac, wav, or pcm
speed
number
default:"1.0"
Playback speed, from 0.25 to 4.0

cURL Example

curl https://llm.ai-nebula.com/v1/audio/speech \
  -H "Content-Type: application/json" \
  -H "Authorization: Bearer sk-XyLy**************************mIqSt" \
  -d '{
    "model": "gpt-4o-mini-tts",
    "input": "Hello from Nebula",
    "voice": "alloy"
  }' \
  --output speech.mp3

Python Example

from openai import OpenAI

client = OpenAI(
    api_key="sk-XyLy**************************mIqSt",
    base_url="https://llm.ai-nebula.com/v1"
)

response = client.audio.speech.create(
    model="gpt-4o-mini-tts",
    voice="alloy",
    input="Hello from Nebula"
)

response.stream_to_file("speech.mp3")

Supported Voices

VoiceDescription
alloyBalanced and neutral
echoCalm and clear
fableWarm and expressive
onyxDeep and authoritative
novaBright and energetic
shimmerSoft and gentle

Notes

  • The response body is raw binary audio — write it to a file (e.g. speech.mp3) rather than printing it
  • response_format defaults to mp3; use wav or pcm when you need lossless audio
  • Requires openai library: pip install openai