Skip to content
For the complete documentation index, see llms.txt. Markdown versions of documentation pages are available by appending .md to the page URL.
Primary navigation

Create translation

TranslationCreateResponse audio().translations().create(TranslationCreateParamsparams, RequestOptionsrequestOptions = RequestOptions.none())
POST/audio/translations

Translates audio into English.

ParametersExpand Collapse
TranslationCreateParams params
InputStream file

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.

ID of the model to use. Only whisper-1 (which is powered by our open source Whisper V2 model) is currently available.

Optional<String> prompt

An optional text to guide the model’s style or continue a previous audio segment. The prompt should be in English.

Optional<ResponseFormat> responseFormat

The format of the output, in one of these options: json, text, srt, verbose_json, or vtt.

Optional<Double> temperature

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 to automatically increase the temperature until certain thresholds are hit.

ReturnsExpand Collapse
class TranslationCreateResponse: A class that can be one of several variants.union
class Translation:
class TranslationVerbose:

Create translation

package com.openai.example;

import com.openai.client.OpenAIClient;
import com.openai.client.okhttp.OpenAIOkHttpClient;
import com.openai.models.audio.AudioModel;
import com.openai.models.audio.translations.TranslationCreateParams;
import com.openai.models.audio.translations.TranslationCreateResponse;
import java.io.ByteArrayInputStream;

public final class Main {
    private Main() {}

    public static void main(String[] args) {
        OpenAIClient client = OpenAIOkHttpClient.fromEnv();

        TranslationCreateParams params = TranslationCreateParams.builder()
            .file(new ByteArrayInputStream("Example data".getBytes()))
            .model(AudioModel.WHISPER_1)
            .build();
        TranslationCreateResponse translation = client.audio().translations().create(params);
    }
}
{
  "text": "Hello, my name is Wolfgang and I come from Germany. Where are you heading today?"
}
Returns Examples
{
  "text": "Hello, my name is Wolfgang and I come from Germany. Where are you heading today?"
}