Create Translation
Brief: Translate audio into target text using OpenAI Whisper family models.
Overview
- Method:
POST - Path:
/v1/audio/translations - Content-Type:
multipart/form-data
Authentication
- Header:
Authorization: Bearer <token> - Supports bearer token authentication
Request Body Parameters
| Parameter | Type | Required | Description |
|---|---|---|---|
| file | file | Yes | Audio file object, supporting flac, mp3, mp4, mpeg, mpga, m4a, ogg, wav, or webm |
| model | string | Yes | Model name, typically whisper-1 |
| prompt | string | No | Optional prompt text to guide translation style. Should be written in English |
| response_format | string | No | Output format. Supported values: json, text, srt, verbose_json, vtt. Default: json |
| temperature | number | No | Sampling temperature, range 0 to 1. Higher values produce more random output, lower values produce more stable output |
| timestamp_granularities | array | No | Timestamp granularity. Options: response_format, verbose_json, word, segment |
| language | string | No | Audio language. Use ISO-639-1 codes to improve translation accuracy |
curl Example
bash
curl -X POST "https://api.gpt.ge/v1/audio/translations" \
-H "Authorization: Bearer sk-xxxx" \
-F "file=@./audio.wav" \
-F "model=whisper-1" \
-F "response_format=json" \
-F "language=zh"JavaScript (fetch) Example
javascript
const formData = new FormData();
formData.append('file', audioFile);
formData.append('model', 'whisper-1');
formData.append('response_format', 'json');
formData.append('language', 'zh');
fetch('https://api.gpt.ge/v1/audio/translations', {
method: 'POST',
headers: {
'Authorization': 'Bearer sk-xxxx'
},
body: formData
}).then(r => r.json()).then(console.log);Python (requests) Example
python
import requests
with open('audio.wav', 'rb') as f:
files = {'file': f}
data = {
'model': 'whisper-1',
'response_format': 'json',
'language': 'zh'
}
response = requests.post(
'https://api.gpt.ge/v1/audio/translations',
headers={'Authorization': 'Bearer sk-xxxx'},
files=files,
data=data
)
print(response.json())Response Example (200)
json
{
"text": "Hello, my name is Wolfgang and I come from Germany. Where are you heading today?"
}Note: The translation endpoint returns translated text. Selecting
response_formatassrt,vtt, orverbose_jsonwill also include timestamp or subtitle information.