Audio API

Text-to-speech (TTS) and voice list queries

The Audio API provides text-to-speech (TTS) and voice listing capabilities.

Endpoints

MethodPathDescription
GET/v1/audio/voice/{model}List voices for a TTS model
POST/v1/audio/speechText-to-speech (TTS)

Recommended call order: First call the voice list endpoint to get data[].code, then pass it as the voice field in the TTS request.


GET /v1/audio/voice/{model}

List available voices for a TTS model.

Auth: Bearer Token

Path parameter: model — TTS model name, e.g. tts-1, cosyvoice-v3-flash

Request: No request body

Request example (curl)

curl https://www.guid.ai/v1/audio/voice/cosyvoice-v3-flash \
  -H "Authorization: Bearer sk-xxx"

Response body

HTTP 200

{
  "success": true,
  "object": "list",
  "data": [
    {
      "name": "龙小淳",
      "code": "longxiaochun"
    },
    {
      "name": "Cherry",
      "code": "Cherry"
    }
  ]
}

Response fields

FieldTypeDescription
successbooleanWhether the call succeeded
objectstringAlways list
dataarrayVoice list
data[].namestringVoice display name
data[].codestringVoice code; pass as voice in TTS requests

When no voices are available:

{
  "success": true,
  "object": "list",
  "data": []
}

Failure response

HTTP 400

{
  "success": false,
  "message": "model is required"
}
FieldTypeDescription
successbooleanAlways false
messagestringFailure reason

Notes:

  • Channel voices: name equals code; comes from channel configuration
  • Platform voice library: name is the display name; code is voice_key. If the model supports private user voices, they are included as well

POST /v1/audio/speech

Text-to-speech (TTS).

Auth: Bearer Token

Content-Type: application/json

Request body

{
  "model": "tts-1",
  "input": "Hello, welcome to Guid AI text-to-speech service.",
  "voice": "alloy",
  "response_format": "mp3",
  "speed": 1.0
}

Request fields

FieldTypeRequiredDescription
modelstringYesTTS model, e.g. tts-1, cosyvoice-v3-flash
inputstringYesText to synthesize
voicestringYesVoice code (see voice list above)
response_formatstringNoOutput format: mp3 (default), opus, aac, flac, wav, pcm
speednumberNoSpeech rate, 0.25–4.0; default 1.0

CosyVoice model example:

{
  "model": "cosyvoice-v3-flash",
  "input": "你好,欢迎使用语音合成服务。",
  "voice": "longxiaochun",
  "response_format": "mp3",
  "speed": 1.0
}

Request example (curl)

curl https://www.guid.ai/v1/audio/speech \
  -H "Authorization: Bearer sk-xxx" \
  -H "Content-Type: application/json" \
  -d '{
    "model": "tts-1",
    "input": "Hello, welcome to Guid AI text-to-speech service.",
    "voice": "alloy",
    "response_format": "mp3",
    "speed": 1.0
  }' \
  -o speech.mp3

CosyVoice model:

curl https://www.guid.ai/v1/audio/speech \
  -H "Authorization: Bearer sk-xxx" \
  -H "Content-Type: application/json" \
  -d '{
    "model": "cosyvoice-v3-flash",
    "input": "你好,欢迎使用语音合成服务。",
    "voice": "longxiaochun",
    "response_format": "mp3",
    "speed": 1.0
  }' \
  -o speech.mp3

Response body

HTTP 200

  • Content-Type: audio/mpeg (mp3) or the MIME type for the chosen format
  • Body: Audio binary stream (not JSON)

Example response headers:

HTTP/1.1 200 OK
Content-Type: audio/mpeg
Content-Length: 45632

Response notes

ItemDescription
HTTP status200
Content-TypeDetermined by response_format; see table below
BodyAudio binary stream, not JSON

response_format and Content-Type mapping

response_formatContent-Type
mp3 (default)audio/mpeg
opusaudio/opus
aacaudio/aac
flacaudio/flac
wavaudio/wav
pcmaudio/pcm

Failure response

HTTP 400. Format: Standard errors.

{
  "error": {
    "message": "voice is required",
    "type": "invalid_request_error",
    "code": "invalid_request"
  }
}