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/speechHeaders
http
Authorization: Bearer YOUR_NEXUSMODELS_API_KEY
Content-Type: application/jsonRequest parameters
| Parameter | Type | Required | Description |
|---|---|---|---|
model | string | Yes | Text-to-speech model name |
input | string | Yes | Text to convert into speech |
voice | string | Yes | Voice name supported by the model |
response_format | string | No | Output format, such as mp3 or wav |
speed | number | No | Playback 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.mp3Verify the output file
bash
ls -lh nexusmodels-speech.mp3
file nexusmodels-speech.mp3Transcription
Convert an audio file into text.
Endpoint
http
POST https://api.nexusmodels.cn/v1/audio/transcriptionsHeaders
http
Authorization: Bearer YOUR_NEXUSMODELS_API_KEY
Content-Type: multipart/form-dataWhen using curl -F, do not manually set Content-Type. Curl automatically generates the correct boundary.
Request parameters
| Parameter | Type | Required | Description |
|---|---|---|---|
model | string | Yes | Audio transcription model name |
file | file | Yes | Audio file to transcribe |
language | string | No | Audio language, such as zh or en |
prompt | string | No | Optional context to improve recognition |
response_format | string | No | Response format, such as json or text |
temperature | number | No | Controls 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."
}