Skip to content

Audio

The Audio API provides text-to-speech and audio transcription capabilities.

  • Text-to-speech: convert text into audio
  • Transcription: convert audio into text

Text-to-speech

Convert input text into an audio file.

Endpoint

http
POST https://api.nexusmodels.cn/v1/audio/speech

Headers

http
Authorization: Bearer YOUR_NEXUSMODELS_API_KEY
Content-Type: application/json

Request parameters

ParameterTypeRequiredDescription
modelstringYesText-to-speech model name
inputstringYesText to convert into speech
voicestringYesVoice name supported by the model
response_formatstringNoOutput format, such as mp3 or wav
speednumberNoPlayback speed supported by the model

Example

bash
curl -sS -X POST \
  'https://api.nexusmodels.cn/v1/audio/speech' \
  -H 'Authorization: Bearer YOUR_NEXUSMODELS_API_KEY' \
  -H 'Content-Type: application/json' \
  -d '{
    "model": "YOUR_TTS_MODEL",
    "input": "Welcome to the NexusModels API.",
    "voice": "alloy",
    "response_format": "mp3"
  }' \
  --output nexusmodels-speech.mp3

Verify the output file

bash
ls -lh nexusmodels-speech.mp3
file nexusmodels-speech.mp3

Transcription

Convert an audio file into text.

Endpoint

http
POST https://api.nexusmodels.cn/v1/audio/transcriptions

Headers

http
Authorization: Bearer YOUR_NEXUSMODELS_API_KEY
Content-Type: multipart/form-data

When using curl -F, do not manually set Content-Type. Curl automatically generates the correct boundary.

Request parameters

ParameterTypeRequiredDescription
modelstringYesAudio transcription model name
filefileYesAudio file to transcribe
languagestringNoAudio language, such as zh or en
promptstringNoOptional context to improve recognition
response_formatstringNoResponse format, such as json or text
temperaturenumberNoControls transcription randomness

Example

bash
curl -sS -X POST \
  'https://api.nexusmodels.cn/v1/audio/transcriptions' \
  -H 'Authorization: Bearer YOUR_NEXUSMODELS_API_KEY' \
  -F 'model=YOUR_TRANSCRIPTION_MODEL' \
  -F 'file=@audio.mp3' \
  -F 'language=en' \
  -F 'response_format=json'

Response example

json
{
  "text": "Welcome to the NexusModels API."
}