Model APIs
Audio transcription, translation and speech
Use audio/transcriptions, audio/translations and audio/speech with multipart uploads and binary output.
Updated
/v1/audio/transcriptions/v1/audio/translations/v1/audio/speechTranscribe and translate
POST /v1/audio/transcriptions converts audio to text; POST /v1/audio/translations requests audio translation. Both require a model supporting the task and audio.create permission. A typical request is multipart/form-data with model and a nonempty file. Let the HTTP client create the boundary rather than setting Content-Type manually.
| Optional parameter | Meaning |
|---|---|
| language | Transcription language hint, e.g. en; not a universal target-language selector |
| prompt | Text hint for terminology and names |
| response_format | json / text / verbose_json / srt / vtt |
| temperature | 0–1 |
curl --fail-with-body https://api.token4ai.cloud/v1/audio/transcriptions \
-H "Authorization: Bearer $TOKEN4AI_API_KEY" \
-F "model=$TOKEN4AI_MODEL" \
-F "file=@./recording.mp3" \
-F "response_format=json"Generate speech
POST /v1/audio/speech accepts JSON containing model, input and voice. Success generally returns audio bytes rather than JSON. Check HTTP status and Content-Type before saving the output. voice and response_format must be supported by the selected model.
curl --fail-with-body https://api.token4ai.cloud/v1/audio/speech \
-H "Authorization: Bearer $TOKEN4AI_API_KEY" \
-H "Content-Type: application/json" \
--data '{"model":"YOUR_MODEL_ID","input":"Welcome to Token4AI Cloud.","voice":"YOUR_VOICE_ID","response_format":"mp3"}' \
--output speech.mp3Large files and errors
Validate with a short recording before scaling file size. Split long recordings when appropriate and retain time offsets for merging transcripts. A 413 indicates an oversized payload. Correct model or capability errors instead of retrying; re-uploading after a disconnect can cause additional processing and usage.