Implementation:Openai Openai node Translations Create
Appearance
| Knowledge Sources | |
|---|---|
| Domains | Audio, Translation |
| Last Updated | 2026-02-15 00:00 GMT |
Overview
Concrete tool for translating audio to English text provided by the openai-node SDK.
Description
The Translations.create() method has 4 overloads for different response formats. It uploads an audio file via multipart form to /audio/translations and returns the English translation.
Usage
Use this method to translate non-English audio files to English text.
Code Reference
Source Location
- Repository: openai-node
- File: src/resources/audio/translations.ts
- Lines: L11-42 (class with overloads), L72-109 (TranslationCreateParams)
Signature
class Translations extends APIResource {
create(
body: TranslationCreateParams & { response_format?: 'json' },
options?: RequestOptions,
): APIPromise<Translation>;
create(
body: TranslationCreateParams & { response_format: 'verbose_json' },
options?: RequestOptions,
): APIPromise<TranslationVerbose>;
create(
body: TranslationCreateParams & { response_format: 'text' | 'srt' | 'vtt' },
options?: RequestOptions,
): APIPromise<string>;
}
interface TranslationCreateParams {
file: Uploadable;
model: string | AudioModel;
prompt?: string;
response_format?: 'json' | 'text' | 'srt' | 'verbose_json' | 'vtt';
temperature?: number;
}
Import
import OpenAI from 'openai';
// Access via: client.audio.translations.create(...)
I/O Contract
Inputs
| Name | Type | Required | Description |
|---|---|---|---|
| file | Uploadable | Yes | Non-English audio file to translate |
| model | AudioModel | Yes | Model ('whisper-1') |
| prompt | string | No | English context hint |
| response_format | string | No (default 'json') | Output format |
| temperature | number | No | Sampling temperature |
Outputs
| Name | Type | Description |
|---|---|---|
| (json) | Translation | { text: string } — English translation |
| (verbose_json) | TranslationVerbose | { text, language, duration, segments } |
| (text/srt/vtt) | string | Plain English text or subtitle format |
Usage Examples
import OpenAI from 'openai';
import fs from 'fs';
const client = new OpenAI();
// Translate French audio to English
const translation = await client.audio.translations.create({
file: fs.createReadStream('french_audio.mp3'),
model: 'whisper-1',
});
console.log('English translation:', translation.text);
// With verbose output
const verbose = await client.audio.translations.create({
file: fs.createReadStream('german_audio.mp3'),
model: 'whisper-1',
response_format: 'verbose_json',
});
console.log('Duration:', verbose.duration);
console.log('Detected language:', verbose.language);
console.log('Translation:', verbose.text);
Related Pages
Implements Principle
Requires Environment
Page Connections
Double-click a node to navigate. Hold to expand connections.
Principle
Implementation
Heuristic
Environment