Sample - OpenAI API
POST/audio/translations

Create an audio translation

Translates an uploaded audio file into English. Supply file and model, then optionally control prompting, output format, and sampling temperature. The response contains translated text or a verbose translation object.

  • RetriesRetries up to 2×, 500ms backoff, 30s timeout.

5 body fields

Multipart form data containing the audio file, translation model, and optional output and sampling settings.

filestringrequired
The audio file object (not file name) translate, in one of these formats: flac, mp3, mp4, mpeg, mpga, m4a, ogg, wav, or webm. The request must include enough format metadata for the file to be identified. We recommend an extension-bearing filename and an appropriate content type.
modelstringrequired
ID of the model to use. Only `whisper-1` (which is powered by our open source Whisper V2 model) is currently available.
promptstringoptional
An optional text to guide the model's style or continue a previous audio segment. The [prompt](https://developers.openai.com/api/docs/guides/speech-to-text#prompting) should be in English.
response_formatstringoptional
The format of the output, in one of these options: `json`, `text`, `srt`, `verbose_json`, or `vtt`.
Allowed:jsontextsrtverbose_jsonvttDefault:json
temperaturenumberoptional
The sampling temperature, between 0 and 1. Higher values like 0.8 will make the output more random, while lower values like 0.2 will make it more focused and deterministic. If set to 0, the model will use [log probability](https://en.wikipedia.org/wiki/Log_probability) to automatically increase the temperature until certain thresholds are hit.
Default:0

3 status codes
200Returns the translated text, or a verbose translation object containing language, duration, text, and segments.
textstringrequired
429Returned when the request was rejected because the rate limit was exceeded; reduce the request rate if a `slow_down` error is reported.

One documented failure

  • slow_down

    Your request rate increased too quickly. Please reduce the request rate and gradually increase it again.

    Traffic increased too quickly

errorobjectrequired
503Returned when the service is temporarily unavailable or the requested model is overloaded; retry after a brief delay.

One documented failure

  • server_is_overloaded

    The model is temporarily overloaded. Please retry your request after a brief delay.

    The requested model is temporarily overloaded

errorobjectrequired

Error handling

A 429 is returned when the request exceeds the rate limit, and a 503 is returned when the service or requested model is temporarily unavailable. file and model are required, model must be whisper-1, response_format must be one of the listed formats, and temperature must be between 0 and 1.