Passer directement au contenu principal

Ce navigateur n’est plus pris en charge.

Effectuez une mise à niveau vers Microsoft Edge pour tirer parti des dernières fonctionnalités, des mises à jour de sécurité et du support technique.

Télécharger Microsoft Edge Plus d’informations sur Internet Explorer et Microsoft Edge
microsoft-foundry.rest.security.o-auth2-auth

Audio

Create a translation

POST /openai/v1/audio/translations

Creates a translation from the supplied request.

Corps de la demande

The multipart request body.

Content-Type: multipart/form-data
file OpenAI.CreateTranslationRequest obligatoire

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.

model string | enum obligatoire

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

Un des éléments suivants :
string
enum
whisper-1
prompt string

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

response_format enum

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

jsontextsrtverbose_jsonvtt
temperature OpenAI.CreateTranslationRequest

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.

Réponses

The request has succeeded.

Corps

Content-Type: application/json
Un des éléments suivants :
text string obligatoire
language string obligatoire

The language of the output translation (always english).

duration integer obligatoire

The duration of the input audio.

text string obligatoire

The translated text.

segments OpenAI.TranscriptionSegment[]

Segments of the translated text and their corresponding details.

Client error

Corps

Content-Type: application/json
error OpenAI.Error obligatoire
code string | null obligatoire
message string obligatoire
param string | null
type string
misalignment OpenAI.MisalignmentErrorDetailsResource
review_target string | null
error_type string | enum
Un des éléments suivants :
string
enum
potentially_unintended_data_transferpotentially_unintended_data_accesspotentially_unintended_destructive_activityother
detailed_explanation string

The public explanation for this block.

steer OpenAI._MisalignmentSteer
message string obligatoire

The public continuation instruction.

details OpenAI.Error[]
additionalInfo object
debugInfo object

Server error

Corps

Content-Type: application/json
error OpenAI.Error obligatoire
code string | null obligatoire
message string obligatoire
param string | null
type string
misalignment OpenAI.MisalignmentErrorDetailsResource
review_target string | null
error_type string | enum
Un des éléments suivants :
string
enum
potentially_unintended_data_transferpotentially_unintended_data_accesspotentially_unintended_destructive_activityother
detailed_explanation string

The public explanation for this block.

steer OpenAI._MisalignmentSteer
message string obligatoire

The public continuation instruction.

details OpenAI.Error[]
additionalInfo object
debugInfo object

Requête

curl https://api.openai.com/v1/audio/translations \
  -H "Authorization: Bearer $OPENAI_API_KEY" \
  -H "Content-Type: multipart/form-data" \
  -F file="@/path/to/file/german.m4a" \
  -F model="whisper-1"
import os
from openai import OpenAI

client = OpenAI(
    api_key=os.environ.get("OPENAI_API_KEY"),  # This is the default and can be omitted
)
translation = client.audio.translations.create(
    file=b"Example data",
    model="whisper-1",
)
print(translation)
import fs from "fs";
import OpenAI from "openai";

const openai = new OpenAI();

async function main() {
    const translation = await openai.audio.translations.create({
        file: fs.createReadStream("speech.mp3"),
        model: "whisper-1",
    });

    console.log(translation.text);
}
main();
using System;

using OpenAI.Audio;

string audioFilePath = "audio.mp3";

AudioClient client = new(
    model: "whisper-1",
    apiKey: Environment.GetEnvironmentVariable("OPENAI_API_KEY")
);

AudioTranscription transcription = client.TranscribeAudio(audioFilePath);

Console.WriteLine($"{transcription.Text}");
import fs from 'fs';
import OpenAI from 'openai';

const client = new OpenAI({
  apiKey: process.env['OPENAI_API_KEY'], // This is the default and can be omitted
});

const translation = await client.audio.translations.create({
  file: fs.createReadStream('speech.mp3'),
  model: 'whisper-1',
});

console.log(translation);
package main

import (
    "bytes"
    "context"
    "fmt"
    "io"

    "github.com/openai/openai-go"
    "github.com/openai/openai-go/option"
)

func main() {
    client := openai.NewClient(
        option.WithAPIKey("My API Key"),
    )
    translation, err := client.Audio.Translations.New(context.TODO(), openai.AudioTranslationNewParams{
        File:  io.Reader(bytes.NewBuffer([]byte("Example data"))),
        Model: openai.AudioModelWhisper1,
    })
    if err != nil {
        panic(err.Error())
    }
    fmt.Printf("%+v
", 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);
    }
}
require "openai"

openai = OpenAI::Client.new(api_key: "My API Key")

translation = openai.audio.translations.create(file: StringIO.new("Example data"), model: :"whisper-1")

puts(translation)

Response

{
  "text": "Hello, my name is Wolfgang and I come from Germany. Where are you heading today?"
}
fr-fr
Vos choix en matière de confidentialité
  • Clause d’exclusion de responsabilité sur l’IA
  • Versions antérieures
  • Blog
  • Collaboration
  • Confidentialité
  • Confidentialité de la santé des consommateurs
  • Conditions d’utilisation
  • Accessibilité
  • Marques
  • © Microsoft 2026