curl https://api.yelu.ai/v1/audio/transcriptions \
-H "Authorization: Bearer $YELU_API_KEY" \
-F "[email protected]" \
-F "model=whisper-1" \
-F "language=zh" \
-F "response_format=json"
import { openAsBlob } from 'node:fs';
const form = new FormData();
form.append('file', await openAsBlob('meeting.m4a'), 'meeting.m4a');
form.append('model', 'whisper-1');
form.append('language', 'zh');
form.append('response_format', 'json');
const response = await fetch('https://api.yelu.ai/v1/audio/transcriptions', {
method: 'POST',
headers: { Authorization: `Bearer ${process.env.YELU_API_KEY}` },
body: form,
});
if (!response.ok) throw new Error(await response.text());
console.log((await response.json()).text);
import os
import requests
with open("meeting.m4a", "rb") as audio:
response = requests.post(
"https://api.yelu.ai/v1/audio/transcriptions",
headers={"Authorization": f"Bearer {os.environ['YELU_API_KEY']}"},
files={"file": ("meeting.m4a", audio, "audio/mp4")},
data={"model": "whisper-1", "language": "zh", "response_format": "json"},
timeout=300,
)
response.raise_for_status()
print(response.json()["text"])
{"text":"今天我们评审了网关迁移计划,并决定在上线前测试流式响应。"}
{"error":{"message":"An audio file is required.","type":"invalid_request_error","param":"file","code":"missing_required_parameter"}}
创建音频转录
使用兼容 OpenAI 的 Yelu Audio Transcriptions API 将音频转换为文本。
POST
/
v1
/
audio
/
transcriptions
curl https://api.yelu.ai/v1/audio/transcriptions \
-H "Authorization: Bearer $YELU_API_KEY" \
-F "[email protected]" \
-F "model=whisper-1" \
-F "language=zh" \
-F "response_format=json"
import { openAsBlob } from 'node:fs';
const form = new FormData();
form.append('file', await openAsBlob('meeting.m4a'), 'meeting.m4a');
form.append('model', 'whisper-1');
form.append('language', 'zh');
form.append('response_format', 'json');
const response = await fetch('https://api.yelu.ai/v1/audio/transcriptions', {
method: 'POST',
headers: { Authorization: `Bearer ${process.env.YELU_API_KEY}` },
body: form,
});
if (!response.ok) throw new Error(await response.text());
console.log((await response.json()).text);
import os
import requests
with open("meeting.m4a", "rb") as audio:
response = requests.post(
"https://api.yelu.ai/v1/audio/transcriptions",
headers={"Authorization": f"Bearer {os.environ['YELU_API_KEY']}"},
files={"file": ("meeting.m4a", audio, "audio/mp4")},
data={"model": "whisper-1", "language": "zh", "response_format": "json"},
timeout=300,
)
response.raise_for_status()
print(response.json()["text"])
{"text":"今天我们评审了网关迁移计划,并决定在上线前测试流式响应。"}
{"error":{"message":"An audio file is required.","type":"invalid_request_error","param":"file","code":"missing_required_parameter"}}
转录上传的音频文件。本端点使用
Verbose 格式还可能包含语言、时长、Word 和 Segment。Text、SRT 与 VTT 返回非 JSON Body。
multipart/form-data,而不是 JSON。
端点
POST https://api.yelu.ai/v1/audio/transcriptions
请求头
格式为
Bearer $YELU_API_KEY。带自动生成 boundary 的
multipart/form-data。请让客户端库自动设置。请求体
要转录的音频。格式与大小限制取决于模型和部署配置。
账号可用的转录模型 ID,例如已开启时使用
whisper-1。ISO 639-1 语言代码,例如
zh。辅助专有名词拼写或上下文延续的提示。
json、text、srt、verbose_json 或 vtt,取决于模型。转录模型支持的采样温度。
兼容模型可返回
word 或 segment 时间戳。响应
当response_format=json 时:
转录文本。
curl https://api.yelu.ai/v1/audio/transcriptions \
-H "Authorization: Bearer $YELU_API_KEY" \
-F "[email protected]" \
-F "model=whisper-1" \
-F "language=zh" \
-F "response_format=json"
import { openAsBlob } from 'node:fs';
const form = new FormData();
form.append('file', await openAsBlob('meeting.m4a'), 'meeting.m4a');
form.append('model', 'whisper-1');
form.append('language', 'zh');
form.append('response_format', 'json');
const response = await fetch('https://api.yelu.ai/v1/audio/transcriptions', {
method: 'POST',
headers: { Authorization: `Bearer ${process.env.YELU_API_KEY}` },
body: form,
});
if (!response.ok) throw new Error(await response.text());
console.log((await response.json()).text);
import os
import requests
with open("meeting.m4a", "rb") as audio:
response = requests.post(
"https://api.yelu.ai/v1/audio/transcriptions",
headers={"Authorization": f"Bearer {os.environ['YELU_API_KEY']}"},
files={"file": ("meeting.m4a", audio, "audio/mp4")},
data={"model": "whisper-1", "language": "zh", "response_format": "json"},
timeout=300,
)
response.raise_for_status()
print(response.json()["text"])
{"text":"今天我们评审了网关迁移计划,并决定在上线前测试流式响应。"}
{"error":{"message":"An audio file is required.","type":"invalid_request_error","param":"file","code":"missing_required_parameter"}}
错误码
| 状态码 | 含义 |
|---|---|
400 | 文件/模型缺失,或格式、选项无效 |
401 | Key 缺失或无效 |
403 | 转录能力或模型未开启 |
404 | 模型不可用 |
413 | 音频过大 |
415 | 媒体类型或 multipart 编码不支持 |
429 | 达到请求限制 |
500–504 | 网关或上游转录失败 |
Node.js 20 及以上版本支持
openAsBlob。不要手动设置 multipart 的 Content-Type,Fetch 会添加正确的 boundary。最后修改于 2026年7月13日
⌘I