SpyBara
Go Premium

java/resources/audio/subresources/translations/index.md 2026-07-10 23:02 UTC to 2026-07-12 06:58 UTC

1 added, 1 removed.

2026
Fri 17 17:00 Thu 16 20:57 Wed 15 02:58 Tue 14 06:58 Mon 13 15:59 Sun 12 06:58 Fri 10 23:02 Thu 9 20:58 Tue 7 08:02

Translations

Create translation

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

post /audio/translations

Translates audio into English.

Parameters

  • TranslationCreateParams params

    • String file

      The audio file object (not file name) translate, in one of these formats: flac, mp3, mp4, mpeg, mpga, m4a, ogg, wav, or webm.

    • AudioModel model

      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.

      • JSON("json")

      • TEXT("text")

      • SRT("srt")

      • VERBOSE_JSON("verbose_json")

      • VTT("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.

Returns

  • class TranslationCreateResponse: A class that can be one of several variants.union

    • class Translation:

      • String text
    • class TranslationVerbose:

      • double duration

        The duration of the input audio.

      • String language

        The language of the output translation (always english).

      • String text

        The translated text.

      • Optional<List<TranscriptionSegment>> segments

        Segments of the translated text and their corresponding details.

        • long id

          Unique identifier of the segment.

        • double avgLogprob

          Average logprob of the segment. If the value is lower than -1, consider the logprobs failed.

        • double compressionRatio

          Compression ratio of the segment. If the value is greater than 2.4, consider the compression failed.

        • double end

          End time of the segment in seconds.

        • double noSpeechProb

          Probability of no speech in the segment. If the value is higher than 1.0 and the avg_logprob is below -1, consider this segment silent.

        • long seek

          Seek offset of the segment.

        • double start

          Start time of the segment in seconds.

        • double temperature

          Temperature parameter used for generating the segment.

        • String text

          Text content of the segment.

        • List<long> tokens

          Array of token IDs for the text content.

Example

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);
    }
}

Response

{
  "text": "text"
}

Domain Types

Translation

  • class Translation:

    • String text

Translation Verbose

  • class TranslationVerbose:

    • double duration

      The duration of the input audio.

    • String language

      The language of the output translation (always english).

    • String text

      The translated text.

    • Optional<List<TranscriptionSegment>> segments

      Segments of the translated text and their corresponding details.

      • long id

        Unique identifier of the segment.

      • double avgLogprob

        Average logprob of the segment. If the value is lower than -1, consider the logprobs failed.

      • double compressionRatio

        Compression ratio of the segment. If the value is greater than 2.4, consider the compression failed.

      • double end

        End time of the segment in seconds.

      • double noSpeechProb

        Probability of no speech in the segment. If the value is higher than 1.0 and the avg_logprob is below -1, consider this segment silent.

      • long seek

        Seek offset of the segment.

      • double start

        Start time of the segment in seconds.

      • double temperature

        Temperature parameter used for generating the segment.

      • String text

        Text content of the segment.

      • List<long> tokens

        Array of token IDs for the text content.