Audio
Generate speech or transcribe audio through Runtoken.
Choose an operation#
Speech generation accepts JSON; transcription accepts a multipart file upload. Select a model for the operation you need.
- Speech:
POST /v1/audio/speech. - Transcription:
POST /v1/audio/transcriptions.
Both use your platform key in the Authorization header on https://api.runtoken.net.
Generate speech#
This example saves the MP3 response to a local file.
curl 'https://api.runtoken.net/v1/audio/speech' \
-H 'Authorization: Bearer YOUR_PLATFORM_KEY' \
-H 'Content-Type: application/json' \
-d '{
"model": "YOUR_MODEL_ID",
"input": "Hello!",
"voice": "alloy",
"response_format": "mp3"
}' --output YOUR_OUTPUT_AUDIO.mp3Replace these placeholders before running the example.
| Placeholder | Replace with |
|---|---|
YOUR_PLATFORM_KEY | Your platform API key from the console. |
YOUR_MODEL_ID | A speech model ID. |
YOUR_OUTPUT_AUDIO.mp3 | Local path for the generated audio. |
Set the voice and output format with these parameters.
| Parameter | Example value | Description |
|---|---|---|
voice | alloy | Voice name; confirm support for the selected model. |
response_format | mp3 | Output audio format; confirm support for the selected model. |
Inspect the HTTP status and content type before treating a downloaded response as playable audio.
Transcribe audio#
Submit a local audio file using a multipart request.
curl 'https://api.runtoken.net/v1/audio/transcriptions' \
-H 'Authorization: Bearer YOUR_PLATFORM_KEY' \
-F 'model=YOUR_MODEL_ID' \
-F 'file=@YOUR_INPUT_AUDIO.wav' \
-F 'response_format=verbose_json'Replace these placeholders before running the example.
| Placeholder | Replace with |
|---|---|
YOUR_PLATFORM_KEY | Your platform API key from the console. |
YOUR_MODEL_ID | A transcription model ID. |
YOUR_INPUT_AUDIO.wav | Path to the local audio file. |
The transcription example sets response_format to verbose_json. Use it only if the selected model supports that format.
curl constructs the multipart body for the file upload.
Usage and duration#
Transcription response formats vary by model. Where supported, verbose_json can provide duration; a JSON response may instead carry native token usage.
Media billing uses explicit evidence. Missing usage enters review, and file size is never used to infer audio duration.
Supported formats and limits#
Confirm the accepted voice names, output formats and upload limits before you build a voice selector or accept audio uploads.
Next steps#
For asynchronous generation, see Video Tasks. Common routing and billing behavior is covered in the integration guide.