OpenAI API Audio 接口参考
Audio 音频资源
资源类型
音频模型
AudioModel = "whisper-1" or "gpt-transcribe" or "gpt-4o-transcribe" or 3 more
"whisper-1"
"gpt-transcribe"
"gpt-4o-transcribe"
"gpt-4o-mini-transcribe"
"gpt-4o-mini-transcribe-2025-12-15"
"gpt-4o-transcribe-diarize"
音频响应格式
AudioResponseFormat = "json" or "text" or "srt" or 3 more
输出格式,可选 json、text、srt、verbose_json、vtt 或 diarized_json。gpt-4o-transcribe 和 gpt-4o-mini-transcribe 仅支持 json。gpt-4o-transcribe-diarize 支持 json、text 和 diarized_json;如需说话人标注,须使用 diarized_json。
"json"
"text"
"srt"
"verbose_json"
"vtt"
"diarized_json"
Speech 语音合成
创建语音
post /audio/speech
根据输入文本生成音频。
返回音频文件内容或音频事件流。
tts-1、tts-1-hd、gpt-4o-mini-tts、gpt-4o-mini-tts-2025-03-20 和
gpt-4o-mini-tts-2025-12-15 模型均已弃用,计划
于 2027 年 1 月 6 日停用。以下示例使用现有 Speech API;新的
集成应通过
Realtime API迁移到 gpt-realtime-2.1-mini。迁移详情请参阅
弃用时间表。
请求体参数
内容类型为 application/json。
input: string
要合成为音频的文本,最多 4096 个字符。
maxLength: 4096
model: string or SpeechModel
可用的 TTS 模型之一,可选 tts-1、tts-1-hd、gpt-4o-mini-tts 或 gpt-4o-mini-tts-2025-12-15。
string
SpeechModel = "tts-1" or "tts-1-hd" or "gpt-4o-mini-tts" or "gpt-4o-mini-tts-2025-12-15"
"tts-1"
"tts-1-hd"
"gpt-4o-mini-tts"
"gpt-4o-mini-tts-2025-12-15"
voice: string or "alloy" or "ash" or "ballad" or 10 more or ID { id }
生成音频所用的音色。支持的内置音色包括 alloy、ash、ballad、coral、echo、fable、onyx、nova、sage、shimmer、verse、marin 和 cedar。也可提供包含 id 的自定义音色对象,例如 { "id": "voice_1234" }。可在文本转语音指南试听。自定义音色须由音频样本创建,基于文本提示词创建的音色仅适用于 Live。
string
"alloy" or "ash" or "ballad" or 10 more
生成音频所用的音色。支持的内置音色包括 alloy、ash、ballad、coral、echo、fable、onyx、nova、sage、shimmer、verse、marin 和 cedar。也可提供包含 id 的自定义音色对象,例如 { "id": "voice_1234" }。可在文本转语音指南试听。自定义音色须由音频样本创建,基于文本提示词创建的音色仅适用于 Live。
"alloy"
"ash"
"ballad"
"coral"
"echo"
"sage"
"shimmer"
"verse"
"marin"
"cedar"
"fable"
"onyx"
"nova"
ID object { id }
自定义音色引用。
id: string
自定义音色 ID,例如 voice_1234。
instructions: optional string
通过额外指令控制生成音频的声音表现。tts-1 和 tts-1-hd 不支持此参数。
maxLength: 4096
response_format: optional "mp3" or "opus" or "aac" or 3 more (default: "mp3")
音频输出格式,支持 mp3、opus、aac、flac、wav 和 pcm。
"mp3"
"opus"
"aac"
"flac"
"wav"
"pcm"
speed: optional number (default: 1)
生成音频的语速,可选范围为 0.25–4.0,默认为 1.0。
minimum: 0.25, maximum: 4
stream_format: optional "sse" or "audio" (default: "audio")
音频流的格式,可选 sse 或 audio。tts-1 和 tts-1-hd 不支持 sse。
"sse"
"audio"
返回值
file
内容类型为 application/octet-stream。
示例
## 设置 OPENAI_API_KEY,并按示例替换音频文件、音色或授权录音 ID。
curl https://api.openai.com/v1/audio/speech \
-H 'Content-Type: application/json' \
-H "Authorization: Bearer $OPENAI_API_KEY" \
-d '{
"input": "input",
"model": "tts-1",
"voice": "ash"
}'
示例
## 设置 OPENAI_API_KEY,并按示例替换音频文件、音色或授权录音 ID。
curl https://api.openai.com/v1/audio/speech \
-H "Authorization: Bearer $OPENAI_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"model": "gpt-4o-mini-tts",
"input": "敏捷的棕色狐狸跃过了懒狗。",
"voice": "alloy"
}' \
--output speech.mp3
SSE 流格式示例
## 设置 OPENAI_API_KEY,并按示例替换音频文件、音色或授权录音 ID。
curl https://api.openai.com/v1/audio/speech \
-H "Authorization: Bearer $OPENAI_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"model": "gpt-4o-mini-tts",
"input": "敏捷的棕色狐狸跃过了懒狗。",
"voice": "alloy",
"stream_format": "sse"
}'
资源类型
语音合成模型
SpeechModel = "tts-1" or "tts-1-hd" or "gpt-4o-mini-tts" or "gpt-4o-mini-tts-2025-12-15"
"tts-1"
"tts-1-hd"
"gpt-4o-mini-tts"
"gpt-4o-mini-tts-2025-12-15"
Transcriptions 转录资源
创建音频转录
post /audio/transcriptions
将音频转录为其原始语言的文本。
返回 json、diarized_json 或 verbose_json 格式的转录对象,
或 text、srt、vtt 格式的纯文本,也可返回
转录事件流。支持的格式取决于模型。
请求体参数
内容类型为 multipart/form-data。
file: string
待转录的音频文件对象,须提供文件内容。支持 flac、mp3、mp4、mpeg、mpga、m4a、ogg、wav 或 webm。 请求须提供足够的格式元数据以识别文件,建议使用带扩展名的文件名和合适的内容类型。
model: string or AudioModel
要使用的模型 ID,可选 gpt-transcribe、gpt-4o-transcribe、gpt-4o-mini-transcribe、gpt-4o-mini-transcribe-2025-12-15、基于开源 Whisper V2 的 whisper-1,以及 gpt-4o-transcribe-diarize。
string
AudioModel = "whisper-1" or "gpt-transcribe" or "gpt-4o-transcribe" or 3 more
"whisper-1"
"gpt-transcribe"
"gpt-4o-transcribe"
"gpt-4o-mini-transcribe"
"gpt-4o-mini-transcribe-2025-12-15"
"gpt-4o-transcribe-diarize"
chunking_strategy: optional "auto" or VadConfig { type, prefix_padding_ms, silence_duration_ms, threshold } or null
控制音频分块方式。设为 "auto" 时,服务器先归一化响度,再用语音活动检测(VAD)确定边界。可提供 server_vad 对象手动调整 VAD 参数。未设置时,将整段音频作为单个块转录。使用 gpt-4o-transcribe-diarize 处理超过 30 秒的输入时,此项为必填。
"auto"
根据音频自动设置分块参数,值必须为 "auto"。
"auto"
VadConfig object { type, prefix_padding_ms, silence_duration_ms, threshold }
type: "server_vad"
须设为 server_vad 才能通过服务端 VAD 手动配置分块。
"server_vad"
prefix_padding_ms: optional integer (default: 300)
在 VAD 检测到语音之前一并保留的音频时长,单位为 毫秒。
silence_duration_ms: optional integer (default: 200)
用于判断语音结束的静音时长,单位为毫秒。 较短的时长能使模型更快响应, 但可能在用户短暂停顿时提前插入响应。
threshold: optional number (default: 0.5)
语音活动检测的敏感度阈值,范围为 0.0–1.0。 较高阈值要求更大的音量才能激活模型, 因此可能更适合嘈杂环境。
include: optional array of TranscriptionInclude
转录响应中需要包含的额外信息。
logprobs 会返回响应中各词元的对数概率,
以便了解模型对转录结果的置信程度。
logprobs 仅在 response_format 设为 json 时有效,且仅支持
gpt-4o-transcribe、gpt-4o-mini-transcribe 和 gpt-4o-mini-transcribe-2025-12-15。使用 gpt-4o-transcribe-diarize 时不支持此字段。
"logprobs"
keywords: optional array of string
用于引导输入音频转录的词语或短语,gpt-transcribe 支持。
known_speaker_names: optional array of string
可选的说话人名称列表,与 known_speaker_references[] 中的音频样本对应。每项应为简短标识,例如 customer 或 agent。最多支持 4 位说话人。
maxItems: 4
known_speaker_references: optional array of string
可选的已知说话人音频样本列表,采用 data URL 形式,与 known_speaker_names[] 对应。每个样本须为 2–10 秒,可使用 file 支持的任一输入音频格式。
maxItems: 4
language: optional string
输入音频的语言。以 ISO-639-1 格式(例如 en)提供语言,有助于改善准确率和延迟。
languages: optional array of string
输入音频可能使用的语言,采用 ISO-639-1 格式。gpt-transcribe 支持。
minItems: 1
prompt: optional string
可选文本,用于引导模型的表达风格或续接此前音频片段。提示词应与音频语言一致。使用 gpt-4o-transcribe-diarize 时不支持此字段。
response_format: optional AudioResponseFormat (default: "json")
输出格式,可选 json、text、srt、verbose_json、vtt 或 diarized_json。gpt-4o-transcribe 和 gpt-4o-mini-transcribe 仅支持 json。gpt-4o-transcribe-diarize 支持 json、text 和 diarized_json;如需说话人标注,须使用 diarized_json。
"json"
"text"
"srt"
"verbose_json"
"vtt"
"diarized_json"
stream: optional boolean or null (default: false)
设为 true 时,模型响应数据会在生成过程中通过 服务器发送事件(SSE)流式发送给客户端。 更多信息请参阅语音转文字指南的流式传输章节 中的说明。
注意:whisper-1 不支持流式传输,将忽略此参数。
temperature: optional number (default: 0)
采样温度,范围为 0–1。较高值(如 0.8)使输出更随机,较低值(如 0.2)使输出更集中、更确定。设为 0 时,模型根据对数概率自动提高温度,直到满足相应阈值。
timestamp_granularities: optional array of "word" or "segment" (default: ["segment"])
此次转录所需的时间戳粒度。使用时须将 response_format 设为 verbose_json。可选择 word、segment,也可同时选择。分段时间戳不会增加额外延迟,逐词时间戳会增加延迟。
gpt-4o-transcribe-diarize 不支持此选项。
"word"
"segment"
返回值
Transcription object { text, languages, logprobs, usage }
表示模型根据输入返回的转录响应。
text: string
转录文本。
languages: optional array of TranscriptionLanguage
音频中检测到的语言,由 gpt-transcribe 返回。空数组表示未能可靠识别语言。
code: string
音频中检测到的语言代码。
logprobs: optional array of object { token, bytes, logprob }
转录词元的对数概率。仅在将 logprobs 加入 include 数组并使用 gpt-4o-transcribe 或 gpt-4o-mini-transcribe 时返回。
token: optional string
转录中的词元。
bytes: optional array of number
词元的字节。
logprob: optional number
词元的对数概率。
usage: optional Tokens { input_tokens, output_tokens, total_tokens, 2 more } or Duration { seconds, type }
请求的词元用量统计。
Tokens object { input_tokens, output_tokens, total_tokens, 2 more }
按词元计费的模型用量统计。
input_tokens: integer
此请求计费的输入词元数量。
output_tokens: integer
生成的输出词元数量。
total_tokens: integer
使用的词元总数,为输入与输出之和。
type: "tokens"
用量对象的类型,此变体固定为 tokens。
"tokens"
input_token_details: optional object { audio_tokens, text_tokens }
此请求计费输入词元的明细。
audio_tokens: optional integer
此请求计费的音频词元数量。
text_tokens: optional integer
此请求计费的文本词元数量。
Duration object { seconds, type }
按音频输入时长计费的模型用量统计。
seconds: number
输入音频时长,单位为秒。
format: double
type: "duration"
用量对象的类型,此变体固定为 duration。
"duration"
TranscriptionDiarized object { duration, segments, task, 2 more }
表示模型返回的说话人分离转录响应,包含合并文本及带有说话人标注的分段。
duration: number
输入音频时长,单位为秒。
format: double
segments: array of TranscriptionDiarizedSegment
带时间戳和说话人标签的转录分段。
id: string
分段的唯一标识。
end: number
分段结束时间戳,单位为秒。
format: double
speaker: string
分段的说话人标签。提供已知说话人时,标签与 known_speaker_names[] 对应;否则按顺序使用大写字母标记,例如 A、B 等。
start: number
分段开始时间戳,单位为秒。
format: double
text: string
此分段的转录文本。
type: "transcript.text.segment"
分段类型,固定为 transcript.text.segment。
"transcript.text.segment"
task: "transcribe"
执行的任务类型,固定为 transcribe。
"transcribe"
text: string
整段输入音频的拼接转录文本。
usage: optional Tokens { input_tokens, output_tokens, total_tokens, 2 more } or Duration { seconds, type }
请求的词元或时长用量统计。
Tokens object { input_tokens, output_tokens, total_tokens, 2 more }
按词元计费的模型用量统计。
input_tokens: integer
此请求计费的输入词元数量。
output_tokens: integer
生成的输出词元数量。
total_tokens: integer
使用的词元总数,为输入与输出之和。
type: "tokens"
用量对象的类型,此变体固定为 tokens。
"tokens"
input_token_details: optional object { audio_tokens, text_tokens }
此请求计费输入词元的明细。
audio_tokens: optional integer
此请求计费的音频词元数量。
text_tokens: optional integer
此请求计费的文本词元数量。
Duration object { seconds, type }
按音频输入时长计费的模型用量统计。
seconds: number
输入音频时长,单位为秒。
format: double
type: "duration"
用量对象的类型,此变体固定为 duration。
"duration"
TranscriptionVerbose object { duration, language, text, 3 more }
表示模型根据输入返回的详细 JSON 转录响应。
duration: number
输入音频的时长。
format: double
language: string
输入音频的语言。
text: string
转录文本。
segments: optional array of TranscriptionSegment
转录文本的分段及其详情。
id: integer
分段的唯一标识。
avg_logprob: number
分段的平均对数概率。小于 -1 时,可判定未通过对数概率检查。
format: float
compression_ratio: number
分段压缩率,大于 2.4 时可判定未通过压缩率检查。
format: float
end: number
分段结束时间,单位为秒。
format: double
no_speech_prob: number
分段不含语音的概率。官方原文给出的判定条件为此值大于 1.0 且 avg_logprob 小于 -1 时,将分段视为静音。
format: float
seek: integer
分段的查找偏移量。
start: number
分段开始时间,单位为秒。
format: double
temperature: number
生成分段所用的温度参数。
format: float
text: string
分段文本内容。
tokens: array of number
文本内容的词元 ID 数组。
usage: optional object { seconds, type }
按音频输入时长计费的模型用量统计。
seconds: number
输入音频时长,单位为秒。
format: double
type: "duration"
用量对象的类型,此变体固定为 duration。
"duration"
words: optional array of TranscriptionWord
提取出的词语及相应时间戳。
end: number
词语结束时间,单位为秒。
format: double
start: number
词语开始时间,单位为秒。
format: double
word: string
词语的文本内容。
示例
## 设置 OPENAI_API_KEY,并按示例替换音频文件、音色或授权录音 ID。
curl https://api.openai.com/v1/audio/transcriptions \
-H 'Content-Type: multipart/form-data' \
-H "Authorization: Bearer $OPENAI_API_KEY" \
-F 'file=@/path/to/file' \
-F model=gpt-4o-transcribe
200 响应示例
{
"text": "text",
"languages": [
{
"code": "code"
}
],
"logprobs": [
{
"token": "token",
"bytes": [
0
],
"logprob": 0
}
],
"usage": {
"input_tokens": 0,
"output_tokens": 0,
"total_tokens": 0,
"type": "tokens",
"input_token_details": {
"audio_tokens": 0,
"text_tokens": 0
}
}
}
示例
## 设置 OPENAI_API_KEY,并按示例替换音频文件、音色或授权录音 ID。
curl https://api.openai.com/v1/audio/transcriptions \
-H "Authorization: Bearer $OPENAI_API_KEY" \
-H "Content-Type: multipart/form-data" \
-F file="@/path/to/file/audio.mp3" \
-F model="gpt-4o-transcribe"
响应示例
{
"text": "Imagine the wildest idea that you've ever had, and you're curious about how it might scale to something that's a 100, a 1,000 times bigger. This is a place where you can get to do that.",
"usage": {
"type": "tokens",
"input_tokens": 14,
"input_token_details": {
"text_tokens": 0,
"audio_tokens": 14
},
"output_tokens": 45,
"total_tokens": 59
}
}
说话人分离示例
## 设置 OPENAI_API_KEY,并按示例替换音频文件、音色或授权录音 ID。
curl https://api.openai.com/v1/audio/transcriptions \
-H "Authorization: Bearer $OPENAI_API_KEY" \
-H "Content-Type: multipart/form-data" \
-F file="@/path/to/file/meeting.wav" \
-F model="gpt-4o-transcribe-diarize" \
-F response_format="diarized_json" \
-F chunking_strategy=auto \
-F 'known_speaker_names[]=agent' \
-F 'known_speaker_references[]=data:audio/wav;base64,AAA...'
响应示例
{
"task": "transcribe",
"duration": 27.4,
"text": "Agent: Thanks for calling OpenAI support.\nA: Hi, I'm trying to enable diarization.\nAgent: Happy to walk you through the steps.",
"segments": [
{
"type": "transcript.text.segment",
"id": "seg_001",
"start": 0.0,
"end": 4.7,
"text": "Thanks for calling OpenAI support.",
"speaker": "agent"
},
{
"type": "transcript.text.segment",
"id": "seg_002",
"start": 4.7,
"end": 11.8,
"text": "Hi, I'm trying to enable diarization.",
"speaker": "A"
},
{
"type": "transcript.text.segment",
"id": "seg_003",
"start": 12.1,
"end": 18.5,
"text": "Happy to walk you through the steps.",
"speaker": "agent"
}
],
"usage": {
"type": "duration",
"seconds": 27
}
}
对数概率示例
## 设置 OPENAI_API_KEY,并按示例替换音频文件、音色或授权录音 ID。
curl https://api.openai.com/v1/audio/transcriptions \
-H "Authorization: Bearer $OPENAI_API_KEY" \
-H "Content-Type: multipart/form-data" \
-F file="@/path/to/file/audio.mp3" \
-F "include[]=logprobs" \
-F model="gpt-4o-transcribe" \
-F response_format="json"
响应示例
{
"text": "Hey, my knee is hurting and I want to see the doctor tomorrow ideally.",
"logprobs": [
{ "token": "Hey", "logprob": -1.0415299, "bytes": [72, 101, 121] },
{ "token": ",", "logprob": -9.805982e-5, "bytes": [44] },
{ "token": " my", "logprob": -0.00229799, "bytes": [32, 109, 121] },
{
"token": " knee",
"logprob": -4.7159858e-5,
"bytes": [32, 107, 110, 101, 101]
},
{ "token": " is", "logprob": -0.043909557, "bytes": [32, 105, 115] },
{
"token": " hurting",
"logprob": -1.1041146e-5,
"bytes": [32, 104, 117, 114, 116, 105, 110, 103]
},
{ "token": " and", "logprob": -0.011076359, "bytes": [32, 97, 110, 100] },
{ "token": " I", "logprob": -5.3193703e-6, "bytes": [32, 73] },
{
"token": " want",
"logprob": -0.0017156356,
"bytes": [32, 119, 97, 110, 116]
},
{ "token": " to", "logprob": -7.89631e-7, "bytes": [32, 116, 111] },
{ "token": " see", "logprob": -5.5122365e-7, "bytes": [32, 115, 101, 101] },
{ "token": " the", "logprob": -0.0040786397, "bytes": [32, 116, 104, 101] },
{
"token": " doctor",
"logprob": -2.3392786e-6,
"bytes": [32, 100, 111, 99, 116, 111, 114]
},
{
"token": " tomorrow",
"logprob": -7.89631e-7,
"bytes": [32, 116, 111, 109, 111, 114, 114, 111, 119]
},
{
"token": " ideally",
"logprob": -0.5800861,
"bytes": [32, 105, 100, 101, 97, 108, 108, 121]
},
{ "token": ".", "logprob": -0.00011093382, "bytes": [46] }
],
"usage": {
"type": "tokens",
"input_tokens": 14,
"input_token_details": {
"text_tokens": 0,
"audio_tokens": 14
},
"output_tokens": 45,
"total_tokens": 59
}
}
分段时间戳示例
## 设置 OPENAI_API_KEY,并按示例替换音频文件、音色或授权录音 ID。
curl https://api.openai.com/v1/audio/transcriptions \
-H "Authorization: Bearer $OPENAI_API_KEY" \
-H "Content-Type: multipart/form-data" \
-F file="@/path/to/file/audio.mp3" \
-F "timestamp_granularities[]=segment" \
-F model="whisper-1" \
-F response_format="verbose_json"
响应示例
{
"task": "transcribe",
"language": "english",
"duration": 3.32,
"text": "The beach was a popular spot on a hot summer day.",
"segments": [
{
"id": 0,
"seek": 0,
"start": 0.0,
"end": 3.319999933242798,
"text": " The beach was a popular spot on a hot summer day.",
"tokens": [
50364, 440, 7534, 390, 257, 3743, 4008, 322, 257, 2368, 4266, 786, 13, 50530
],
"temperature": 0.0,
"avg_logprob": -0.2860786020755768,
"compression_ratio": 1.2363636493682861,
"no_speech_prob": 0.00985979475080967
}
],
"usage": {
"type": "duration",
"seconds": 4
}
}
流式传输示例
## 设置 OPENAI_API_KEY,并按示例替换音频文件、音色或授权录音 ID。
curl https://api.openai.com/v1/audio/transcriptions \
-H "Authorization: Bearer $OPENAI_API_KEY" \
-H "Content-Type: multipart/form-data" \
-F file="@/path/to/file/audio.mp3" \
-F model="gpt-4o-mini-transcribe" \
-F stream=true
响应示例
data: {"type":"transcript.text.delta","delta":"I","logprobs":[{"token":"I","logprob":-0.00007588794,"bytes":[73]}]}
data: {"type":"transcript.text.delta","delta":" see","logprobs":[{"token":" see","logprob":-3.1281633e-7,"bytes":[32,115,101,101]}]}
data: {"type":"transcript.text.delta","delta":" skies","logprobs":[{"token":" skies","logprob":-2.3392786e-6,"bytes":[32,115,107,105,101,115]}]}
data: {"type":"transcript.text.delta","delta":" of","logprobs":[{"token":" of","logprob":-3.1281633e-7,"bytes":[32,111,102]}]}
data: {"type":"transcript.text.delta","delta":" blue","logprobs":[{"token":" blue","logprob":-1.0280384e-6,"bytes":[32,98,108,117,101]}]}
data: {"type":"transcript.text.delta","delta":" and","logprobs":[{"token":" and","logprob":-0.0005108566,"bytes":[32,97,110,100]}]}
data: {"type":"transcript.text.delta","delta":" clouds","logprobs":[{"token":" clouds","logprob":-1.9361265e-7,"bytes":[32,99,108,111,117,100,115]}]}
data: {"type":"transcript.text.delta","delta":" of","logprobs":[{"token":" of","logprob":-1.9361265e-7,"bytes":[32,111,102]}]}
data: {"type":"transcript.text.delta","delta":" white","logprobs":[{"token":" white","logprob":-7.89631e-7,"bytes":[32,119,104,105,116,101]}]}
data: {"type":"transcript.text.delta","delta":",","logprobs":[{"token":",","logprob":-0.0014890312,"bytes":[44]}]}
data: {"type":"transcript.text.delta","delta":" the","logprobs":[{"token":" the","logprob":-0.0110956915,"bytes":[32,116,104,101]}]}
data: {"type":"transcript.text.delta","delta":" bright","logprobs":[{"token":" bright","logprob":0.0,"bytes":[32,98,114,105,103,104,116]}]}
data: {"type":"transcript.text.delta","delta":" blessed","logprobs":[{"token":" blessed","logprob":-0.000045848617,"bytes":[32,98,108,101,115,115,101,100]}]}
data: {"type":"transcript.text.delta","delta":" days","logprobs":[{"token":" days","logprob":-0.000010802739,"bytes":[32,100,97,121,115]}]}
data: {"type":"transcript.text.delta","delta":",","logprobs":[{"token":",","logprob":-0.00001700133,"bytes":[44]}]}
data: {"type":"transcript.text.delta","delta":" the","logprobs":[{"token":" the","logprob":-0.0000118755715,"bytes":[32,116,104,101]}]}
data: {"type":"transcript.text.delta","delta":" dark","logprobs":[{"token":" dark","logprob":-5.5122365e-7,"bytes":[32,100,97,114,107]}]}
data: {"type":"transcript.text.delta","delta":" sacred","logprobs":[{"token":" sacred","logprob":-5.4385737e-6,"bytes":[32,115,97,99,114,101,100]}]}
data: {"type":"transcript.text.delta","delta":" nights","logprobs":[{"token":" nights","logprob":-4.00813e-6,"bytes":[32,110,105,103,104,116,115]}]}
data: {"type":"transcript.text.delta","delta":",","logprobs":[{"token":",","logprob":-0.0036910512,"bytes":[44]}]}
data: {"type":"transcript.text.delta","delta":" and","logprobs":[{"token":" and","logprob":-0.0031903093,"bytes":[32,97,110,100]}]}
data: {"type":"transcript.text.delta","delta":" I","logprobs":[{"token":" I","logprob":-1.504853e-6,"bytes":[32,73]}]}
data: {"type":"transcript.text.delta","delta":" think","logprobs":[{"token":" think","logprob":-4.3202e-7,"bytes":[32,116,104,105,110,107]}]}
data: {"type":"transcript.text.delta","delta":" to","logprobs":[{"token":" to","logprob":-1.9361265e-7,"bytes":[32,116,111]}]}
data: {"type":"transcript.text.delta","delta":" myself","logprobs":[{"token":" myself","logprob":-1.7432603e-6,"bytes":[32,109,121,115,101,108,102]}]}
data: {"type":"transcript.text.delta","delta":",","logprobs":[{"token":",","logprob":-0.29254505,"bytes":[44]}]}
data: {"type":"transcript.text.delta","delta":" what","logprobs":[{"token":" what","logprob":-0.016815351,"bytes":[32,119,104,97,116]}]}
data: {"type":"transcript.text.delta","delta":" a","logprobs":[{"token":" a","logprob":-3.1281633e-7,"bytes":[32,97]}]}
data: {"type":"transcript.text.delta","delta":" wonderful","logprobs":[{"token":" wonderful","logprob":-2.1008714e-6,"bytes":[32,119,111,110,100,101,114,102,117,108]}]}
data: {"type":"transcript.text.delta","delta":" world","logprobs":[{"token":" world","logprob":-8.180258e-6,"bytes":[32,119,111,114,108,100]}]}
data: {"type":"transcript.text.delta","delta":".","logprobs":[{"token":".","logprob":-0.014231676,"bytes":[46]}]}
data: {"type":"transcript.text.done","text":"I see skies of blue and clouds of white, the bright blessed days, the dark sacred nights, and I think to myself, what a wonderful world.","logprobs":[{"token":"I","logprob":-0.00007588794,"bytes":[73]},{"token":" see","logprob":-3.1281633e-7,"bytes":[32,115,101,101]},{"token":" skies","logprob":-2.3392786e-6,"bytes":[32,115,107,105,101,115]},{"token":" of","logprob":-3.1281633e-7,"bytes":[32,111,102]},{"token":" blue","logprob":-1.0280384e-6,"bytes":[32,98,108,117,101]},{"token":" and","logprob":-0.0005108566,"bytes":[32,97,110,100]},{"token":" clouds","logprob":-1.9361265e-7,"bytes":[32,99,108,111,117,100,115]},{"token":" of","logprob":-1.9361265e-7,"bytes":[32,111,102]},{"token":" white","logprob":-7.89631e-7,"bytes":[32,119,104,105,116,101]},{"token":",","logprob":-0.0014890312,"bytes":[44]},{"token":" the","logprob":-0.0110956915,"bytes":[32,116,104,101]},{"token":" bright","logprob":0.0,"bytes":[32,98,114,105,103,104,116]},{"token":" blessed","logprob":-0.000045848617,"bytes":[32,98,108,101,115,115,101,100]},{"token":" days","logprob":-0.000010802739,"bytes":[32,100,97,121,115]},{"token":",","logprob":-0.00001700133,"bytes":[44]},{"token":" the","logprob":-0.0000118755715,"bytes":[32,116,104,101]},{"token":" dark","logprob":-5.5122365e-7,"bytes":[32,100,97,114,107]},{"token":" sacred","logprob":-5.4385737e-6,"bytes":[32,115,97,99,114,101,100]},{"token":" nights","logprob":-4.00813e-6,"bytes":[32,110,105,103,104,116,115]},{"token":",","logprob":-0.0036910512,"bytes":[44]},{"token":" and","logprob":-0.0031903093,"bytes":[32,97,110,100]},{"token":" I","logprob":-1.504853e-6,"bytes":[32,73]},{"token":" think","logprob":-4.3202e-7,"bytes":[32,116,104,105,110,107]},{"token":" to","logprob":-1.9361265e-7,"bytes":[32,116,111]},{"token":" myself","logprob":-1.7432603e-6,"bytes":[32,109,121,115,101,108,102]},{"token":",","logprob":-0.29254505,"bytes":[44]},{"token":" what","logprob":-0.016815351,"bytes":[32,119,104,97,116]},{"token":" a","logprob":-3.1281633e-7,"bytes":[32,97]},{"token":" wonderful","logprob":-2.1008714e-6,"bytes":[32,119,111,110,100,101,114,102,117,108]},{"token":" world","logprob":-8.180258e-6,"bytes":[32,119,111,114,108,100]},{"token":".","logprob":-0.014231676,"bytes":[46]}],"usage":{"input_tokens":14,"input_token_details":{"text_tokens":0,"audio_tokens":14},"output_tokens":45,"total_tokens":59}}
逐词时间戳示例
## 设置 OPENAI_API_KEY,并按示例替换音频文件、音色或授权录音 ID。
curl https://api.openai.com/v1/audio/transcriptions \
-H "Authorization: Bearer $OPENAI_API_KEY" \
-H "Content-Type: multipart/form-data" \
-F file="@/path/to/file/audio.mp3" \
-F "timestamp_granularities[]=word" \
-F model="whisper-1" \
-F response_format="verbose_json"
响应示例
{
"task": "transcribe",
"language": "english",
"duration": 0.5,
"text": "Hello.",
"words": [
{
"word": "Hello",
"start": 0.0,
"end": 0.5
}
],
"usage": {
"type": "duration",
"seconds": 1
}
}
资源类型
转录对象
Transcription object { text, languages, logprobs, usage }
表示模型根据输入返回的转录响应。
text: string
转录文本。
languages: optional array of TranscriptionLanguage
音频中检测到的语言,由 gpt-transcribe 返回。空数组表示未能可靠识别语言。
code: string
音频中检测到的语言代码。
logprobs: optional array of object { token, bytes, logprob }
转录词元的对数概率。仅在将 logprobs 加入 include 数组并使用 gpt-4o-transcribe 或 gpt-4o-mini-transcribe 时返回。
token: optional string
转录中的词元。
bytes: optional array of number
词元的字节。
logprob: optional number
词元的对数概率。
usage: optional Tokens { input_tokens, output_tokens, total_tokens, 2 more } or Duration { seconds, type }
请求的词元用量统计。
Tokens object { input_tokens, output_tokens, total_tokens, 2 more }
按词元计费的模型用量统计。
input_tokens: integer
此请求计费的输入词元数量。
output_tokens: integer
生成的输出词元数量。
total_tokens: integer
使用的词元总数,为输入与输出之和。
type: "tokens"
用量对象的类型,此变体固定为 tokens。
"tokens"
input_token_details: optional object { audio_tokens, text_tokens }
此请求计费输入词元的明细。
audio_tokens: optional integer
此请求计费的音频词元数量。
text_tokens: optional integer
此请求计费的文本词元数量。
Duration object { seconds, type }
按音频输入时长计费的模型用量统计。
seconds: number
输入音频时长,单位为秒。
format: double
type: "duration"
用量对象的类型,此变体固定为 duration。
"duration"
创建转录的响应对象
TranscriptionCreateResponse = Transcription or TranscriptionDiarized or TranscriptionVerbose
表示模型根据输入返回的转录响应。
Transcription object { text, languages, logprobs, usage }
表示模型根据输入返回的转录响应。
text: string
转录文本。
languages: optional array of TranscriptionLanguage
音频中检测到的语言,由 gpt-transcribe 返回。空数组表示未能可靠识别语言。
code: string
音频中检测到的语言代码。
logprobs: optional array of object { token, bytes, logprob }
转录词元的对数概率。仅在将 logprobs 加入 include 数组并使用 gpt-4o-transcribe 或 gpt-4o-mini-transcribe 时返回。
token: optional string
转录中的词元。
bytes: optional array of number
词元的字节。
logprob: optional number
词元的对数概率。
usage: optional Tokens { input_tokens, output_tokens, total_tokens, 2 more } or Duration { seconds, type }
请求的词元用量统计。
Tokens object { input_tokens, output_tokens, total_tokens, 2 more }
按词元计费的模型用量统计。
input_tokens: integer
此请求计费的输入词元数量。
output_tokens: integer
生成的输出词元数量。
total_tokens: integer
使用的词元总数,为输入与输出之和。
type: "tokens"
用量对象的类型,此变体固定为 tokens。
"tokens"
input_token_details: optional object { audio_tokens, text_tokens }
此请求计费输入词元的明细。
audio_tokens: optional integer
此请求计费的音频词元数量。
text_tokens: optional integer
此请求计费的文本词元数量。
Duration object { seconds, type }
按音频输入时长计费的模型用量统计。
seconds: number
输入音频时长,单位为秒。
format: double
type: "duration"
用量对象的类型,此变体固定为 duration。
"duration"
TranscriptionDiarized object { duration, segments, task, 2 more }
表示模型返回的说话人分离转录响应,包含合并文本及带有说话人标注的分段。
duration: number
输入音频时长,单位为秒。
format: double
segments: array of TranscriptionDiarizedSegment
带时间戳和说话人标签的转录分段。
id: string
分段的唯一标识。
end: number
分段结束时间戳,单位为秒。
format: double
speaker: string
分段的说话人标签。提供已知说话人时,标签与 known_speaker_names[] 对应;否则按顺序使用大写字母标记,例如 A、B 等。
start: number
分段开始时间戳,单位为秒。
format: double
text: string
此分段的转录文本。
type: "transcript.text.segment"
分段类型,固定为 transcript.text.segment。
"transcript.text.segment"
task: "transcribe"
执行的任务类型,固定为 transcribe。
"transcribe"
text: string
整段输入音频的拼接转录文本。
usage: optional Tokens { input_tokens, output_tokens, total_tokens, 2 more } or Duration { seconds, type }
请求的词元或时长用量统计。
Tokens object { input_tokens, output_tokens, total_tokens, 2 more }
按词元计费的模型用量统计。
input_tokens: integer
此请求计费的输入词元数量。
output_tokens: integer
生成的输出词元数量。
total_tokens: integer
使用的词元总数,为输入与输出之和。
type: "tokens"
用量对象的类型,此变体固定为 tokens。
"tokens"
input_token_details: optional object { audio_tokens, text_tokens }
此请求计费输入词元的明细。
audio_tokens: optional integer
此请求计费的音频词元数量。
text_tokens: optional integer
此请求计费的文本词元数量。
Duration object { seconds, type }
按音频输入时长计费的模型用量统计。
seconds: number
输入音频时长,单位为秒。
format: double
type: "duration"
用量对象的类型,此变体固定为 duration。
"duration"
TranscriptionVerbose object { duration, language, text, 3 more }
表示模型根据输入返回的详细 JSON 转录响应。
duration: number
输入音频的时长。
format: double
language: string
输入音频的语言。
text: string
转录文本。
segments: optional array of TranscriptionSegment
转录文本的分段及其详情。
id: integer
分段的唯一标识。
avg_logprob: number
分段的平均对数概率。小于 -1 时,可判定未通过对数概率检查。
format: float
compression_ratio: number
分段压缩率,大于 2.4 时可判定未通过压缩率检查。
format: float
end: number
分段结束时间,单位为秒。
format: double
no_speech_prob: number
分段不含语音的概率。官方原文给出的判定条件为此值大于 1.0 且 avg_logprob 小于 -1 时,将分段视为静音。
format: float
seek: integer
分段的查找偏移量。
start: number
分段开始时间,单位为秒。
format: double
temperature: number
生成分段所用的温度参数。
format: float
text: string
分段文本内容。
tokens: array of number
文本内容的词元 ID 数组。
usage: optional object { seconds, type }
按音频输入时长计费的模型用量统计。
seconds: number
输入音频时长,单位为秒。
format: double
type: "duration"
用量对象的类型,此变体固定为 duration。
"duration"
words: optional array of TranscriptionWord
提取出的词语及相应时间戳。
end: number
词语结束时间,单位为秒。
format: double
start: number
词语开始时间,单位为秒。
format: double
word: string
词语的文本内容。
说话人分离转录对象
TranscriptionDiarized object { duration, segments, task, 2 more }
表示模型返回的说话人分离转录响应,包含合并文本及带有说话人标注的分段。
duration: number
输入音频时长,单位为秒。
format: double
segments: array of TranscriptionDiarizedSegment
带时间戳和说话人标签的转录分段。
id: string
分段的唯一标识。
end: number
分段结束时间戳,单位为秒。
format: double
speaker: string
分段的说话人标签。提供已知说话人时,标签与 known_speaker_names[] 对应;否则按顺序使用大写字母标记,例如 A、B 等。
start: number
分段开始时间戳,单位为秒。
format: double
text: string
此分段的转录文本。
type: "transcript.text.segment"
分段类型,固定为 transcript.text.segment。
"transcript.text.segment"
task: "transcribe"
执行的任务类型,固定为 transcribe。
"transcribe"
text: string
整段输入音频的拼接转录文本。
usage: optional Tokens { input_tokens, output_tokens, total_tokens, 2 more } or Duration { seconds, type }
请求的词元或时长用量统计。
Tokens object { input_tokens, output_tokens, total_tokens, 2 more }
按词元计费的模型用量统计。
input_tokens: integer
此请求计费的输入词元数量。
output_tokens: integer
生成的输出词元数量。
total_tokens: integer
使用的词元总数,为输入与输出之和。
type: "tokens"
用量对象的类型,此变体固定为 tokens。
"tokens"
input_token_details: optional object { audio_tokens, text_tokens }
此请求计费输入词元的明细。
audio_tokens: optional integer
此请求计费的音频词元数量。
text_tokens: optional integer
此请求计费的文本词元数量。
Duration object { seconds, type }
按音频输入时长计费的模型用量统计。
seconds: number
输入音频时长,单位为秒。
format: double
type: "duration"
用量对象的类型,此变体固定为 duration。
"duration"
说话人分离转录分段
TranscriptionDiarizedSegment object { id, end, speaker, 3 more }
包含说话人元数据的转录文本分段。
id: string
分段的唯一标识。
end: number
分段结束时间戳,单位为秒。
format: double
speaker: string
分段的说话人标签。提供已知说话人时,标签与 known_speaker_names[] 对应;否则按顺序使用大写字母标记,例如 A、B 等。
start: number
分段开始时间戳,单位为秒。
format: double
text: string
此分段的转录文本。
type: "transcript.text.segment"
分段类型,固定为 transcript.text.segment。
"transcript.text.segment"
转录额外返回项目
TranscriptionInclude = "logprobs"
"logprobs"
转录语言
TranscriptionLanguage object { code }
转录音频中检测到的语言。
code: string
音频中检测到的语言代码。
转录分段
TranscriptionSegment object { id, avg_logprob, compression_ratio, 7 more }
id: integer
分段的唯一标识。
avg_logprob: number
分段的平均对数概率。小于 -1 时,可判定未通过对数概率检查。
format: float
compression_ratio: number
分段压缩率,大于 2.4 时可判定未通过压缩率检查。
format: float
end: number
分段结束时间,单位为秒。
format: double
no_speech_prob: number
分段不含语音的概率。官方原文给出的判定条件为此值大于 1.0 且 avg_logprob 小于 -1 时,将分段视为静音。
format: float
seek: integer
分段的查找偏移量。
start: number
分段开始时间,单位为秒。
format: double
temperature: number
生成分段所用的温度参数。
format: float
text: string
分段文本内容。
tokens: array of number
文本内容的词元 ID 数组。
转录流式事件
TranscriptionStreamEvent = TranscriptionTextSegmentEvent or TranscriptionTextDeltaEvent or TranscriptionTextDoneEvent
说话人分离转录返回包含说话人信息的完整分段时发出。仅在创建转录时将 stream 设为 true、response_format 设为 diarized_json 才会发出。
TranscriptionTextSegmentEvent object { id, end, speaker, 3 more }
说话人分离转录返回包含说话人信息的完整分段时发出。仅在创建转录时将 stream 设为 true、response_format 设为 diarized_json 才会发出。
id: string
分段的唯一标识。
end: number
分段结束时间戳,单位为秒。
format: double
speaker: string
此分段的说话人标签。
start: number
分段开始时间戳,单位为秒。
format: double
text: string
此分段的转录文本。
type: "transcript.text.segment"
事件类型,固定为 transcript.text.segment。
"transcript.text.segment"
TranscriptionTextDeltaEvent object { delta, type, logprobs, segment_id }
有新增文本增量时发出,也是转录开始时的第一个事件。仅在创建转录时将 stream 参数设为 true 才会发出。
delta: string
新增的转录文本增量。
type: "transcript.text.delta"
事件类型,固定为 transcript.text.delta。
"transcript.text.delta"
logprobs: optional array of object { token, bytes, logprob }
增量的对数概率。仅在创建转录时将 include[] 设为 logprobs 才会包含此字段。
token: optional string
用于生成对数概率的词元。
bytes: optional array of number
用于生成对数概率的字节。
logprob: optional number
词元的对数概率。
segment_id: optional string
此增量所属的说话人分离分段标识,仅在使用 gpt-4o-transcribe-diarize 时提供。
TranscriptionTextDoneEvent object { text, type, languages, 2 more }
转录完成时发出,包含完整转录文本。仅在创建转录时将 stream 参数设为 true 才会发出。
text: string
已转录的文本。
type: "transcript.text.done"
事件类型,固定为 transcript.text.done。
"transcript.text.done"
languages: optional array of TranscriptionLanguage
音频中检测到的语言,由 gpt-transcribe 返回。空数组表示未能可靠识别语言。
code: string
音频中检测到的语言代码。
logprobs: optional array of object { token, bytes, logprob }
转录中各词元的对数概率。仅在创建转录时将 include[] 设为 logprobs 才会包含此字段。
token: optional string
用于生成对数概率的词元。
bytes: optional array of number
用于生成对数概率的字节。
logprob: optional number
词元的对数概率。
usage: optional object { input_tokens, output_tokens, total_tokens, 2 more }
按词元计费的模型用量统计。
input_tokens: integer
此请求计费的输入词元数量。
output_tokens: integer
生成的输出词元数量。
total_tokens: integer
使用的词元总数,为输入与输出之和。
type: "tokens"
用量对象的类型,此变体固定为 tokens。
"tokens"
input_token_details: optional object { audio_tokens, text_tokens }
此请求计费输入词元的明细。
audio_tokens: optional integer
此请求计费的音频词元数量。
text_tokens: optional integer
此请求计费的文本词元数量。
转录文本增量事件
TranscriptionTextDeltaEvent object { delta, type, logprobs, segment_id }
有新增文本增量时发出,也是转录开始时的第一个事件。仅在创建转录时将 stream 参数设为 true 才会发出。
delta: string
新增的转录文本增量。
type: "transcript.text.delta"
事件类型,固定为 transcript.text.delta。
"transcript.text.delta"
logprobs: optional array of object { token, bytes, logprob }
增量的对数概率。仅在创建转录时将 include[] 设为 logprobs 才会包含此字段。
token: optional string
用于生成对数概率的词元。
bytes: optional array of number
用于生成对数概率的字节。
logprob: optional number
词元的对数概率。
segment_id: optional string
此增量所属的说话人分离分段标识,仅在使用 gpt-4o-transcribe-diarize 时提供。
转录文本完成事件
TranscriptionTextDoneEvent object { text, type, languages, 2 more }
转录完成时发出,包含完整转录文本。仅在创建转录时将 stream 参数设为 true 才会发出。
text: string
已转录的文本。
type: "transcript.text.done"
事件类型,固定为 transcript.text.done。
"transcript.text.done"
languages: optional array of TranscriptionLanguage
音频中检测到的语言,由 gpt-transcribe 返回。空数组表示未能可靠识别语言。
code: string
音频中检测到的语言代码。
logprobs: optional array of object { token, bytes, logprob }
转录中各词元的对数概率。仅在创建转录时将 include[] 设为 logprobs 才会包含此字段。
token: optional string
用于生成对数概率的词元。
bytes: optional array of number
用于生成对数概率的字节。
logprob: optional number
词元的对数概率。
usage: optional object { input_tokens, output_tokens, total_tokens, 2 more }
按词元计费的模型用量统计。
input_tokens: integer
此请求计费的输入词元数量。
output_tokens: integer
生成的输出词元数量。
total_tokens: integer
使用的词元总数,为输入与输出之和。
type: "tokens"
用量对象的类型,此变体固定为 tokens。
"tokens"
input_token_details: optional object { audio_tokens, text_tokens }
此请求计费输入词元的明细。
audio_tokens: optional integer
此请求计费的音频词元数量。
text_tokens: optional integer
此请求计费的文本词元数量。
转录文本分段事件
TranscriptionTextSegmentEvent object { id, end, speaker, 3 more }
说话人分离转录返回包含说话人信息的完整分段时发出。仅在创建转录时将 stream 设为 true、response_format 设为 diarized_json 才会发出。
id: string
分段的唯一标识。
end: number
分段结束时间戳,单位为秒。
format: double
speaker: string
此分段的说话人标签。
start: number
分段开始时间戳,单位为秒。
format: double
text: string
此分段的转录文本。
type: "transcript.text.segment"
事件类型,固定为 transcript.text.segment。
"transcript.text.segment"
详细转录对象
TranscriptionVerbose object { duration, language, text, 3 more }
表示模型根据输入返回的详细 JSON 转录响应。
duration: number
输入音频的时长。
format: double
language: string
输入音频的语言。
text: string
转录文本。
segments: optional array of TranscriptionSegment
转录文本的分段及其详情。
id: integer
分段的唯一标识。
avg_logprob: number
分段的平均对数概率。小于 -1 时,可判定未通过对数概率检查。
format: float
compression_ratio: number
分段压缩率,大于 2.4 时可判定未通过压缩率检查。
format: float
end: number
分段结束时间,单位为秒。
format: double
no_speech_prob: number
分段不含语音的概率。官方原文给出的判定条件为此值大于 1.0 且 avg_logprob 小于 -1 时,将分段视为静音。
format: float
seek: integer
分段的查找偏移量。
start: number
分段开始时间,单位为秒。
format: double
temperature: number
生成分段所用的温度参数。
format: float
text: string
分段文本内容。
tokens: array of number
文本内容的词元 ID 数组。
usage: optional object { seconds, type }
按音频输入时长计费的模型用量统计。
seconds: number
输入音频时长,单位为秒。
format: double
type: "duration"
用量对象的类型,此变体固定为 duration。
"duration"
words: optional array of TranscriptionWord
提取出的词语及相应时间戳。
end: number
词语结束时间,单位为秒。
format: double
start: number
词语开始时间,单位为秒。
format: double
word: string
词语的文本内容。
转录词语
TranscriptionWord object { end, start, word }
end: number
词语结束时间,单位为秒。
format: double
start: number
词语开始时间,单位为秒。
format: double
word: string
词语的文本内容。
Translations 翻译资源
创建音频翻译
post /audio/translations
将音频翻译成英语。
此接口仅支持 whisper-1。接口和模型均已弃用,
计划于 2027 年 2 月 26 日停用。请迁移到
/v1/realtime/translations,迁移需要单独集成。详情参阅
弃用时间表
中的说明。
请求体参数
内容类型为 multipart/form-data。
file: string
待翻译的音频文件对象,应传文件内容。支持 flac、mp3、mp4、mpeg、mpga、m4a、ogg、wav 或 webm。请求必须包含足够的格式元数据以识别文件,建议提供带扩展名的文件名和合适的内容类型。
model: string or AudioModel
使用的模型 ID。此接口目前仅支持基于开源 Whisper V2 的 whisper-1。
string
AudioModel = "whisper-1" or "gpt-transcribe" or "gpt-4o-transcribe" or 3 more
"whisper-1"
"gpt-transcribe"
"gpt-4o-transcribe"
"gpt-4o-mini-transcribe"
"gpt-4o-mini-transcribe-2025-12-15"
"gpt-4o-transcribe-diarize"
prompt: optional string
可选文本,用于引导模型的表达风格或续接此前音频片段。提示词应使用英语。
response_format: optional "json" or "text" or "srt" or 2 more (default: "json")
输出格式,可选 json、text、srt、verbose_json 或 vtt。
"json"
"text"
"srt"
"verbose_json"
"vtt"
temperature: optional number (default: 0)
采样温度,范围为 0–1。较高值(如 0.8)使输出更随机,较低值(如 0.2)使输出更集中、更确定。设为 0 时,模型根据对数概率自动提高温度,直到满足相应阈值。
返回值
Translation object { text }
text: string
TranslationVerbose object { duration, language, text, segments }
duration: number
输入音频的时长。
format: double
language: string
翻译输出的语言,固定为 english。
text: string
翻译后的文本。
segments: optional array of TranscriptionSegment
翻译文本的分段及对应详情。
id: integer
分段的唯一标识。
avg_logprob: number
分段的平均对数概率。小于 -1 时,可判定未通过对数概率检查。
format: float
compression_ratio: number
分段压缩率,大于 2.4 时可判定未通过压缩率检查。
format: float
end: number
分段结束时间,单位为秒。
format: double
no_speech_prob: number
分段不含语音的概率。官方原文给出的判定条件为此值大于 1.0 且 avg_logprob 小于 -1 时,将分段视为静音。
format: float
seek: integer
分段的查找偏移量。
start: number
分段开始时间,单位为秒。
format: double
temperature: number
生成分段所用的温度参数。
format: float
text: string
分段文本内容。
tokens: array of number
文本内容的词元 ID 数组。
示例
## 设置 OPENAI_API_KEY,并按示例替换音频文件、音色或授权录音 ID。
curl https://api.openai.com/v1/audio/translations \
-H 'Content-Type: multipart/form-data' \
-H "Authorization: Bearer $OPENAI_API_KEY" \
-F 'file=@/path/to/file' \
-F model=whisper-1
200 响应示例
{
"text": "text"
}
示例
## 设置 OPENAI_API_KEY,并按示例替换音频文件、音色或授权录音 ID。
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"
响应示例
{
"text": "Hello, my name is Wolfgang and I come from Germany. Where are you heading today?"
}
资源类型
翻译对象
Translation object { text }
text: string
创建翻译的响应对象
TranslationCreateResponse = Translation or TranslationVerbose
Translation object { text }
text: string
TranslationVerbose object { duration, language, text, segments }
duration: number
输入音频的时长。
format: double
language: string
翻译输出的语言,固定为 english。
text: string
翻译后的文本。
segments: optional array of TranscriptionSegment
翻译文本的分段及对应详情。
id: integer
分段的唯一标识。
avg_logprob: number
分段的平均对数概率。小于 -1 时,可判定未通过对数概率检查。
format: float
compression_ratio: number
分段压缩率,大于 2.4 时可判定未通过压缩率检查。
format: float
end: number
分段结束时间,单位为秒。
format: double
no_speech_prob: number
分段不含语音的概率。官方原文给出的判定条件为此值大于 1.0 且 avg_logprob 小于 -1 时,将分段视为静音。
format: float
seek: integer
分段的查找偏移量。
start: number
分段开始时间,单位为秒。
format: double
temperature: number
生成分段所用的温度参数。
format: float
text: string
分段文本内容。
tokens: array of number
文本内容的词元 ID 数组。
详细翻译对象
TranslationVerbose object { duration, language, text, segments }
duration: number
输入音频的时长。
format: double
language: string
翻译输出的语言,固定为 english。
text: string
翻译后的文本。
segments: optional array of TranscriptionSegment
翻译文本的分段及对应详情。
id: integer
分段的唯一标识。
avg_logprob: number
分段的平均对数概率。小于 -1 时,可判定未通过对数概率检查。
format: float
compression_ratio: number
分段压缩率,大于 2.4 时可判定未通过压缩率检查。
format: float
end: number
分段结束时间,单位为秒。
format: double
no_speech_prob: number
分段不含语音的概率。官方原文给出的判定条件为此值大于 1.0 且 avg_logprob 小于 -1 时,将分段视为静音。
format: float
seek: integer
分段的查找偏移量。
start: number
分段开始时间,单位为秒。
format: double
temperature: number
生成分段所用的温度参数。
format: float
text: string
分段文本内容。
tokens: array of number
文本内容的词元 ID 数组。
Voice Consents 音色授权
创建音色授权录音
post /audio/voice_consents
上传音色授权录音。
请求体参数
内容类型为 multipart/form-data。
language: string
授权语句的 BCP 47 语言标签,例如 en-US。
name: string
此授权录音使用的标签。
recording: string
授权音频录音文件,最大为 10 MiB。
支持的 MIME 类型如下。
audio/mpeg, audio/wav, audio/x-wav, audio/ogg, audio/aac, audio/flac, audio/webm, audio/mp4.
返回值
VoiceConsent object { id, created_at, language, 2 more }
用于授权创建自定义音色的授权录音。
id: string
授权录音标识。
created_at: integer
授权录音创建时的 Unix 时间戳,单位为秒。
format: unixtime
language: string
授权语句的 BCP 47 语言标签,例如 en-US。
name: string
上传授权录音时提供的标签。
object: "audio.voice_consent"
对象类型,固定为 audio.voice_consent。
"audio.voice_consent"
示例
## 设置 OPENAI_API_KEY,并按示例替换音频文件、音色或授权录音 ID。
curl https://api.openai.com/v1/audio/voice_consents \
-H 'Content-Type: multipart/form-data' \
-H "Authorization: Bearer $OPENAI_API_KEY" \
-F language=language \
-F name=name \
-F 'recording=@/path/to/recording'
200 响应示例
{
"id": "cons_1234",
"created_at": 0,
"language": "language",
"name": "name",
"object": "audio.voice_consent"
}
示例
## 设置 OPENAI_API_KEY,并按示例替换音频文件、音色或授权录音 ID。
curl https://api.openai.com/v1/audio/voice_consents \
-X POST \
-H "Authorization: Bearer $OPENAI_API_KEY" \
-F "name=示例用户" \
-F "language=en-US" \
-F "recording=@$HOME/consent_recording.wav;type=audio/x-wav"
删除音色授权录音
delete /audio/voice_consents/{consent_id}
删除音色授权录音。
路径参数
consent_id: string
要删除的授权录音 ID。
返回值
VoiceConsentDeleted object { id, deleted, object }
id: string
授权录音标识。
deleted: boolean
object: "audio.voice_consent"
"audio.voice_consent"
示例
## 设置 OPENAI_API_KEY,并按示例替换音频文件、音色或授权录音 ID。
curl https://api.openai.com/v1/audio/voice_consents/$CONSENT_ID \
-X DELETE \
-H "Authorization: Bearer $OPENAI_API_KEY"
200 响应示例
{
"id": "cons_1234",
"deleted": true,
"object": "audio.voice_consent"
}
示例
## 设置 OPENAI_API_KEY,并按示例替换音频文件、音色或授权录音 ID。
curl https://api.openai.com/v1/audio/voice_consents/cons_1234 \
-X DELETE \
-H "Authorization: Bearer $OPENAI_API_KEY"
列出音色授权录音
get /audio/voice_consents
返回音色授权录音列表。
查询参数
after: optional string
分页游标。after 使用对象 ID 表示列表中的位置。例如,本次返回 100 个对象,最后一个为 obj_foo,则下次可传入 after=obj_foo 获取下一页。
limit: optional integer (default: 20)
返回对象数量上限,范围为 1–100,默认为 20。
返回值
data: array of VoiceConsent
id: string
授权录音标识。
created_at: integer
授权录音创建时的 Unix 时间戳,单位为秒。
format: unixtime
language: string
授权语句的 BCP 47 语言标签,例如 en-US。
name: string
上传授权录音时提供的标签。
object: "audio.voice_consent"
对象类型,固定为 audio.voice_consent。
"audio.voice_consent"
has_more: boolean
object: "list"
"list"
first_id: optional string or null
last_id: optional string or null
示例
## 设置 OPENAI_API_KEY,并按示例替换音频文件、音色或授权录音 ID。
curl https://api.openai.com/v1/audio/voice_consents \
-H "Authorization: Bearer $OPENAI_API_KEY"
200 响应示例
{
"data": [
{
"id": "cons_1234",
"created_at": 0,
"language": "language",
"name": "name",
"object": "audio.voice_consent"
}
],
"has_more": true,
"object": "list",
"first_id": "first_id",
"last_id": "last_id"
}
示例
## 设置 OPENAI_API_KEY,并按示例替换音频文件、音色或授权录音 ID。
curl https://api.openai.com/v1/audio/voice_consents?limit=20 \
-H "Authorization: Bearer $OPENAI_API_KEY"
获取音色授权录音
get /audio/voice_consents/{consent_id}
获取音色授权录音。
路径参数
consent_id: string
要获取的授权录音 ID。
返回值
VoiceConsent object { id, created_at, language, 2 more }
用于授权创建自定义音色的授权录音。
id: string
授权录音标识。
created_at: integer
授权录音创建时的 Unix 时间戳,单位为秒。
format: unixtime
language: string
授权语句的 BCP 47 语言标签,例如 en-US。
name: string
上传授权录音时提供的标签。
object: "audio.voice_consent"
对象类型,固定为 audio.voice_consent。
"audio.voice_consent"
示例
## 设置 OPENAI_API_KEY,并按示例替换音频文件、音色或授权录音 ID。
curl https://api.openai.com/v1/audio/voice_consents/$CONSENT_ID \
-H "Authorization: Bearer $OPENAI_API_KEY"
200 响应示例
{
"id": "cons_1234",
"created_at": 0,
"language": "language",
"name": "name",
"object": "audio.voice_consent"
}
示例
## 设置 OPENAI_API_KEY,并按示例替换音频文件、音色或授权录音 ID。
curl https://api.openai.com/v1/audio/voice_consents/cons_1234 \
-H "Authorization: Bearer $OPENAI_API_KEY"
更新音色授权录音
post /audio/voice_consents/{consent_id}
更新音色授权录音,仅修改元数据。
路径参数
consent_id: string
要更新的授权录音 ID。
请求体参数
内容类型为 application/json。
name: string
此授权录音更新后的标签。
返回值
VoiceConsent object { id, created_at, language, 2 more }
用于授权创建自定义音色的授权录音。
id: string
授权录音标识。
created_at: integer
授权录音创建时的 Unix 时间戳,单位为秒。
format: unixtime
language: string
授权语句的 BCP 47 语言标签,例如 en-US。
name: string
上传授权录音时提供的标签。
object: "audio.voice_consent"
对象类型,固定为 audio.voice_consent。
"audio.voice_consent"
示例
## 设置 OPENAI_API_KEY,并按示例替换音频文件、音色或授权录音 ID。
curl https://api.openai.com/v1/audio/voice_consents/$CONSENT_ID \
-H 'Content-Type: application/json' \
-H "Authorization: Bearer $OPENAI_API_KEY" \
-d '{
"name": "name"
}'
200 响应示例
{
"id": "cons_1234",
"created_at": 0,
"language": "language",
"name": "name",
"object": "audio.voice_consent"
}
示例
## 设置 OPENAI_API_KEY,并按示例替换音频文件、音色或授权录音 ID。
curl https://api.openai.com/v1/audio/voice_consents/cons_1234 \
-X POST \
-H "Authorization: Bearer $OPENAI_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"name": "示例用户"
}'
资源类型
音色授权对象
VoiceConsent object { id, created_at, language, 2 more }
用于授权创建自定义音色的授权录音。
id: string
授权录音标识。
created_at: integer
授权录音创建时的 Unix 时间戳,单位为秒。
format: unixtime
language: string
授权语句的 BCP 47 语言标签,例如 en-US。
name: string
上传授权录音时提供的标签。
object: "audio.voice_consent"
对象类型,固定为 audio.voice_consent。
"audio.voice_consent"
音色授权删除结果
VoiceConsentDeleted object { id, deleted, object }
id: string
授权录音标识。
deleted: boolean
object: "audio.voice_consent"
"audio.voice_consent"
Voices 音色资源
创建音色
post /audio/voices
通过文本提示词,或授权录音与音频样本创建音色。
基于提示词创建时,以 JSON 或多部分表单发送 type: "prompt"、name 和 prompt。基于音频样本创建时,以多部分表单发送 type: "audio_sample"、name、audio_sample 和 consent 录音 ID。省略 type 时默认为 audio_sample。
返回已保存音色的元数据。通过文本提示词创建的音色仅适用于 Live,不适用于 Realtime 或语音合成接口。响应不含试听音频。
请求体参数
内容类型为 application/json。
name: string
新音色的名称。
minLength: 1, maxLength: 256
prompt: string
所需音色的描述,不能只包含空白字符。
minLength: 1, maxLength: 2000
type: "prompt"
设为 prompt,以根据文本描述创建音色。
"prompt"
model: optional string or "auto" or "2026-10-08" (default: "auto")
用于创建音色的模型,默认为 auto。
string
"auto" or "2026-10-08"
用于创建音色的模型,默认为 auto。
"auto"
"2026-10-08"
script_hint: optional string
可选的音色创建时朗读文本。省略时会根据提示词生成文本。去除首尾空白后不能为空,过短的朗读文本会被拒绝。
minLength: 1, maxLength: 2000
返回值
Voice object { id, created_at, name, 3 more }
可用于音频输出的自定义音色。通过文本提示词创建的音色仅适用于 Live。
id: string
音色标识,可在 API 接口中引用。
created_at: integer
音色创建时的 Unix 时间戳,单位为秒。
format: unixtime
name: string
音色名称。
object: "audio.voice"
对象类型,固定为 audio.voice。
"audio.voice"
type: "audio_sample" or "prompt"
音色的创建方式。
"audio_sample"
"prompt"
prompt: optional string
创建音色时使用的原始文本提示词。基于提示词生成且保存了提示词的音色会提供此字段;基于音频样本创建的音色,以及未保存提示词的早期音色会省略。
示例
## 设置 OPENAI_API_KEY,并按示例替换音频文件、音色或授权录音 ID。
curl https://api.openai.com/v1/audio/voices \
-H 'Content-Type: application/json' \
-H "Authorization: Bearer $OPENAI_API_KEY" \
-d '{
"name": "x",
"prompt": "x",
"type": "prompt"
}'
200 响应示例
{
"id": "id",
"created_at": 0,
"name": "name",
"object": "audio.voice",
"type": "audio_sample",
"prompt": "prompt"
}
示例
## 设置 OPENAI_API_KEY,并按示例替换音频文件、音色或授权录音 ID。
curl https://api.openai.com/v1/audio/voices \
-X POST \
-H "Authorization: Bearer $OPENAI_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"type": "prompt",
"name": "温暖旁白",
"prompt": "温暖、平静的旁白音色,吐字清晰,语速从容。",
"model": "auto"
}'
删除音色
delete /audio/voices/{voice_id}
删除通过文本提示词或音频样本创建的音色。
要求具有音色写入权限,以及音色所属项目的访问权限。通过录音创建的音色仅向符合条件的客户开放。参阅自定义音色指南。
删除音色不会删除其授权录音。删除已删除的音色会返回 404 错误。
路径参数
voice_id: string
要删除的音色 ID。
返回值
VoiceDeleted object { id, deleted, object }
id: string
音色标识。
deleted: boolean
音色是否已删除。
object: "audio.voice.deleted"
对象类型,固定为 audio.voice.deleted。
"audio.voice.deleted"
示例
## 设置 OPENAI_API_KEY,并按示例替换音频文件、音色或授权录音 ID。
curl https://api.openai.com/v1/audio/voices/$VOICE_ID \
-X DELETE \
-H "Authorization: Bearer $OPENAI_API_KEY"
200 响应示例
{
"id": "voice_1234",
"deleted": true,
"object": "audio.voice.deleted"
}
示例
## 设置 OPENAI_API_KEY,并按示例替换音频文件、音色或授权录音 ID。
curl https://api.openai.com/v1/audio/voices/voice_1234 \
-X DELETE \
-H "Authorization: Bearer $OPENAI_API_KEY"
响应示例
{
"id": "voice_1234",
"object": "audio.voice.deleted",
"deleted": true
}
资源类型
音色对象
Voice object { id, created_at, name, 3 more }
可用于音频输出的自定义音色。通过文本提示词创建的音色仅适用于 Live。
id: string
音色标识,可在 API 接口中引用。
created_at: integer
音色创建时的 Unix 时间戳,单位为秒。
format: unixtime
name: string
音色名称。
object: "audio.voice"
对象类型,固定为 audio.voice。
"audio.voice"
type: "audio_sample" or "prompt"
音色的创建方式。
"audio_sample"
"prompt"
prompt: optional string
创建音色时使用的原始文本提示词。基于提示词生成且保存了提示词的音色会提供此字段;基于音频样本创建的音色,以及未保存提示词的早期音色会省略。
音色删除结果
VoiceDeleted object { id, deleted, object }
id: string
音色标识。
deleted: boolean
音色是否已删除。
object: "audio.voice.deleted"
对象类型,固定为 audio.voice.deleted。
"audio.voice.deleted"