Help on API translation script


I use the script below but i have an error :
Échec de la requête : 404
*** “error”: {***
*** “message”: “Invalid URL (POST /v1/audio/translations)”,***
*** “type”: “invalid_request_error”,***
*** “param”: null,***
*** “code”: null***
*** }***

what is wrong please?

import requests
import json

# Remplacez 'your-api-key' par votre clé API OpenAI
api_key = 'MY KEY'

# Endpoint de l'API OpenAI pour les traductions audio
endpoint = ''

# Données de la requête
data = {
    "model": "text-davinci-003",
    "data": {
        "audio": {
            "url": "https://your-audio-file-url.mp3",  # Remplacez par l'URL de votre fichier audio
        "target_language": "fr",  # Remplacez par la langue cible de la traduction

# En-têtes de la requête
headers = {
    'Content-Type': 'application/json',
    'Authorization': f'Bearer {api_key}',

# Envoi de la requête POST à l'API OpenAI
response =, data=json.dumps(data), headers=headers)

# Vérification de la réponse
if response.status_code == 200:
    result = response.json()
    print("Traduction audio réussie :")
    print(f"Échec de la requête : {response.status_code}")

I believe you’re using the wrong model

Should be whisper-1 instead of text-davinci-003

But i have a new error:
Échec de la requête : 400
“error”: {
“message”: “1 validation error for Request\nbody → file\n field required (type=value_error.missing)”,
“type”: “invalid_request_error”,
“param”: null,
“code”: null

Where did you find this parameter? target_language

I don’t seem to find it in the OpenAI documentation - and it seems only translating to English is currently supported (althought I may be mistaken).

I don’t see target_language

Another thing you could so is convert audio to text using Whisper and then use ChatCompletions to convert from English text to French text

The only way you would get code like that is by asking an AI.

  • The only model supported is whisper-1, not “text-davinci-003”;
  • The parameter for the audio contents is "file":;
  • You must use http multipart/form, with a mime-encoded audio file;
  • The translation endpoint is only for translation TO English.