翻译文本片段(异步)
curl --request POST \
--url https://api.vmeg.ai/openapi/v1/task/translate/create-async \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--header 'X-Idempotency-Key: <x-idempotency-key>' \
--data '
{
"language": {
"source": "zh-CN",
"target": "en-US"
},
"segments": [
{
"text": "<string>",
"gender": "male",
"speaker": "Speaker A",
"locale": "zh-CN",
"context": [
"<string>"
],
"start": 123,
"end": 123
}
],
"options": {
"sourceContext": {
"mode": "independent",
"contextWindow": 5
},
"sceneCustomized": {
"scene": "video",
"allowStutter": true
},
"glossary": {},
"prompt": "<string>",
"skipMissingTranslationCheck": false
},
"extraData": {}
}
'import requests
url = "https://api.vmeg.ai/openapi/v1/task/translate/create-async"
payload = {
"language": {
"source": "zh-CN",
"target": "en-US"
},
"segments": [
{
"text": "<string>",
"gender": "male",
"speaker": "Speaker A",
"locale": "zh-CN",
"context": ["<string>"],
"start": 123,
"end": 123
}
],
"options": {
"sourceContext": {
"mode": "independent",
"contextWindow": 5
},
"sceneCustomized": {
"scene": "video",
"allowStutter": True
},
"glossary": {},
"prompt": "<string>",
"skipMissingTranslationCheck": False
},
"extraData": {}
}
headers = {
"X-Idempotency-Key": "<x-idempotency-key>",
"Authorization": "Bearer <token>",
"Content-Type": "application/json"
}
response = requests.post(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'POST',
headers: {
'X-Idempotency-Key': '<x-idempotency-key>',
Authorization: 'Bearer <token>',
'Content-Type': 'application/json'
},
body: JSON.stringify({
language: {source: 'zh-CN', target: 'en-US'},
segments: [
{
text: '<string>',
gender: 'male',
speaker: 'Speaker A',
locale: 'zh-CN',
context: ['<string>'],
start: 123,
end: 123
}
],
options: {
sourceContext: {mode: 'independent', contextWindow: 5},
sceneCustomized: {scene: 'video', allowStutter: true},
glossary: {},
prompt: '<string>',
skipMissingTranslationCheck: false
},
extraData: {}
})
};
fetch('https://api.vmeg.ai/openapi/v1/task/translate/create-async', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://api.vmeg.ai/openapi/v1/task/translate/create-async",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_POSTFIELDS => json_encode([
'language' => [
'source' => 'zh-CN',
'target' => 'en-US'
],
'segments' => [
[
'text' => '<string>',
'gender' => 'male',
'speaker' => 'Speaker A',
'locale' => 'zh-CN',
'context' => [
'<string>'
],
'start' => 123,
'end' => 123
]
],
'options' => [
'sourceContext' => [
'mode' => 'independent',
'contextWindow' => 5
],
'sceneCustomized' => [
'scene' => 'video',
'allowStutter' => true
],
'glossary' => [
],
'prompt' => '<string>',
'skipMissingTranslationCheck' => false
],
'extraData' => [
]
]),
CURLOPT_HTTPHEADER => [
"Authorization: Bearer <token>",
"Content-Type: application/json",
"X-Idempotency-Key: <x-idempotency-key>"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}package main
import (
"fmt"
"strings"
"net/http"
"io"
)
func main() {
url := "https://api.vmeg.ai/openapi/v1/task/translate/create-async"
payload := strings.NewReader("{\n \"language\": {\n \"source\": \"zh-CN\",\n \"target\": \"en-US\"\n },\n \"segments\": [\n {\n \"text\": \"<string>\",\n \"gender\": \"male\",\n \"speaker\": \"Speaker A\",\n \"locale\": \"zh-CN\",\n \"context\": [\n \"<string>\"\n ],\n \"start\": 123,\n \"end\": 123\n }\n ],\n \"options\": {\n \"sourceContext\": {\n \"mode\": \"independent\",\n \"contextWindow\": 5\n },\n \"sceneCustomized\": {\n \"scene\": \"video\",\n \"allowStutter\": true\n },\n \"glossary\": {},\n \"prompt\": \"<string>\",\n \"skipMissingTranslationCheck\": false\n },\n \"extraData\": {}\n}")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("X-Idempotency-Key", "<x-idempotency-key>")
req.Header.Add("Authorization", "Bearer <token>")
req.Header.Add("Content-Type", "application/json")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(string(body))
}HttpResponse<String> response = Unirest.post("https://api.vmeg.ai/openapi/v1/task/translate/create-async")
.header("X-Idempotency-Key", "<x-idempotency-key>")
.header("Authorization", "Bearer <token>")
.header("Content-Type", "application/json")
.body("{\n \"language\": {\n \"source\": \"zh-CN\",\n \"target\": \"en-US\"\n },\n \"segments\": [\n {\n \"text\": \"<string>\",\n \"gender\": \"male\",\n \"speaker\": \"Speaker A\",\n \"locale\": \"zh-CN\",\n \"context\": [\n \"<string>\"\n ],\n \"start\": 123,\n \"end\": 123\n }\n ],\n \"options\": {\n \"sourceContext\": {\n \"mode\": \"independent\",\n \"contextWindow\": 5\n },\n \"sceneCustomized\": {\n \"scene\": \"video\",\n \"allowStutter\": true\n },\n \"glossary\": {},\n \"prompt\": \"<string>\",\n \"skipMissingTranslationCheck\": false\n },\n \"extraData\": {}\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.vmeg.ai/openapi/v1/task/translate/create-async")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["X-Idempotency-Key"] = '<x-idempotency-key>'
request["Authorization"] = 'Bearer <token>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"language\": {\n \"source\": \"zh-CN\",\n \"target\": \"en-US\"\n },\n \"segments\": [\n {\n \"text\": \"<string>\",\n \"gender\": \"male\",\n \"speaker\": \"Speaker A\",\n \"locale\": \"zh-CN\",\n \"context\": [\n \"<string>\"\n ],\n \"start\": 123,\n \"end\": 123\n }\n ],\n \"options\": {\n \"sourceContext\": {\n \"mode\": \"independent\",\n \"contextWindow\": 5\n },\n \"sceneCustomized\": {\n \"scene\": \"video\",\n \"allowStutter\": true\n },\n \"glossary\": {},\n \"prompt\": \"<string>\",\n \"skipMissingTranslationCheck\": false\n },\n \"extraData\": {}\n}"
response = http.request(request)
puts response.read_body{
"code": 200,
"message": "",
"data": {
"taskId": "<string>",
"createdAt": "<string>"
}
}文本翻译(仅文本)
翻译文本片段(异步)
提交批量文本翻译任务。HTTP 仅返回受理信息(taskId)。译文通过 Webhook 回调投递(event: openapi-translate)。
POST
/
openapi
/
v1
/
task
/
translate
/
create-async
翻译文本片段(异步)
curl --request POST \
--url https://api.vmeg.ai/openapi/v1/task/translate/create-async \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--header 'X-Idempotency-Key: <x-idempotency-key>' \
--data '
{
"language": {
"source": "zh-CN",
"target": "en-US"
},
"segments": [
{
"text": "<string>",
"gender": "male",
"speaker": "Speaker A",
"locale": "zh-CN",
"context": [
"<string>"
],
"start": 123,
"end": 123
}
],
"options": {
"sourceContext": {
"mode": "independent",
"contextWindow": 5
},
"sceneCustomized": {
"scene": "video",
"allowStutter": true
},
"glossary": {},
"prompt": "<string>",
"skipMissingTranslationCheck": false
},
"extraData": {}
}
'import requests
url = "https://api.vmeg.ai/openapi/v1/task/translate/create-async"
payload = {
"language": {
"source": "zh-CN",
"target": "en-US"
},
"segments": [
{
"text": "<string>",
"gender": "male",
"speaker": "Speaker A",
"locale": "zh-CN",
"context": ["<string>"],
"start": 123,
"end": 123
}
],
"options": {
"sourceContext": {
"mode": "independent",
"contextWindow": 5
},
"sceneCustomized": {
"scene": "video",
"allowStutter": True
},
"glossary": {},
"prompt": "<string>",
"skipMissingTranslationCheck": False
},
"extraData": {}
}
headers = {
"X-Idempotency-Key": "<x-idempotency-key>",
"Authorization": "Bearer <token>",
"Content-Type": "application/json"
}
response = requests.post(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'POST',
headers: {
'X-Idempotency-Key': '<x-idempotency-key>',
Authorization: 'Bearer <token>',
'Content-Type': 'application/json'
},
body: JSON.stringify({
language: {source: 'zh-CN', target: 'en-US'},
segments: [
{
text: '<string>',
gender: 'male',
speaker: 'Speaker A',
locale: 'zh-CN',
context: ['<string>'],
start: 123,
end: 123
}
],
options: {
sourceContext: {mode: 'independent', contextWindow: 5},
sceneCustomized: {scene: 'video', allowStutter: true},
glossary: {},
prompt: '<string>',
skipMissingTranslationCheck: false
},
extraData: {}
})
};
fetch('https://api.vmeg.ai/openapi/v1/task/translate/create-async', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://api.vmeg.ai/openapi/v1/task/translate/create-async",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_POSTFIELDS => json_encode([
'language' => [
'source' => 'zh-CN',
'target' => 'en-US'
],
'segments' => [
[
'text' => '<string>',
'gender' => 'male',
'speaker' => 'Speaker A',
'locale' => 'zh-CN',
'context' => [
'<string>'
],
'start' => 123,
'end' => 123
]
],
'options' => [
'sourceContext' => [
'mode' => 'independent',
'contextWindow' => 5
],
'sceneCustomized' => [
'scene' => 'video',
'allowStutter' => true
],
'glossary' => [
],
'prompt' => '<string>',
'skipMissingTranslationCheck' => false
],
'extraData' => [
]
]),
CURLOPT_HTTPHEADER => [
"Authorization: Bearer <token>",
"Content-Type: application/json",
"X-Idempotency-Key: <x-idempotency-key>"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}package main
import (
"fmt"
"strings"
"net/http"
"io"
)
func main() {
url := "https://api.vmeg.ai/openapi/v1/task/translate/create-async"
payload := strings.NewReader("{\n \"language\": {\n \"source\": \"zh-CN\",\n \"target\": \"en-US\"\n },\n \"segments\": [\n {\n \"text\": \"<string>\",\n \"gender\": \"male\",\n \"speaker\": \"Speaker A\",\n \"locale\": \"zh-CN\",\n \"context\": [\n \"<string>\"\n ],\n \"start\": 123,\n \"end\": 123\n }\n ],\n \"options\": {\n \"sourceContext\": {\n \"mode\": \"independent\",\n \"contextWindow\": 5\n },\n \"sceneCustomized\": {\n \"scene\": \"video\",\n \"allowStutter\": true\n },\n \"glossary\": {},\n \"prompt\": \"<string>\",\n \"skipMissingTranslationCheck\": false\n },\n \"extraData\": {}\n}")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("X-Idempotency-Key", "<x-idempotency-key>")
req.Header.Add("Authorization", "Bearer <token>")
req.Header.Add("Content-Type", "application/json")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(string(body))
}HttpResponse<String> response = Unirest.post("https://api.vmeg.ai/openapi/v1/task/translate/create-async")
.header("X-Idempotency-Key", "<x-idempotency-key>")
.header("Authorization", "Bearer <token>")
.header("Content-Type", "application/json")
.body("{\n \"language\": {\n \"source\": \"zh-CN\",\n \"target\": \"en-US\"\n },\n \"segments\": [\n {\n \"text\": \"<string>\",\n \"gender\": \"male\",\n \"speaker\": \"Speaker A\",\n \"locale\": \"zh-CN\",\n \"context\": [\n \"<string>\"\n ],\n \"start\": 123,\n \"end\": 123\n }\n ],\n \"options\": {\n \"sourceContext\": {\n \"mode\": \"independent\",\n \"contextWindow\": 5\n },\n \"sceneCustomized\": {\n \"scene\": \"video\",\n \"allowStutter\": true\n },\n \"glossary\": {},\n \"prompt\": \"<string>\",\n \"skipMissingTranslationCheck\": false\n },\n \"extraData\": {}\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.vmeg.ai/openapi/v1/task/translate/create-async")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["X-Idempotency-Key"] = '<x-idempotency-key>'
request["Authorization"] = 'Bearer <token>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"language\": {\n \"source\": \"zh-CN\",\n \"target\": \"en-US\"\n },\n \"segments\": [\n {\n \"text\": \"<string>\",\n \"gender\": \"male\",\n \"speaker\": \"Speaker A\",\n \"locale\": \"zh-CN\",\n \"context\": [\n \"<string>\"\n ],\n \"start\": 123,\n \"end\": 123\n }\n ],\n \"options\": {\n \"sourceContext\": {\n \"mode\": \"independent\",\n \"contextWindow\": 5\n },\n \"sceneCustomized\": {\n \"scene\": \"video\",\n \"allowStutter\": true\n },\n \"glossary\": {},\n \"prompt\": \"<string>\",\n \"skipMissingTranslationCheck\": false\n },\n \"extraData\": {}\n}"
response = http.request(request)
puts response.read_body{
"code": 200,
"message": "",
"data": {
"taskId": "<string>",
"createdAt": "<string>"
}
}请求体
application/json
回调
POSThttps://{yourWebhookUrl}taskCompleted
请求体
application/json
event 为 openapi-translate 时的文本翻译 Webhook 请求体;data.items 与请求 segments 按序对应。
event 为 openapi-translate 时的翻译结果(data.items)。
Show child attributes
Show child attributes
本次投递的业务结果码
示例:
200
任务的 API 版本号(如 v1、v2),与请求路径中的版本一致(如 /openapi/v1/...)。
示例:
"v1"
已完成的产品类型。请按此值路由:openapi-tts(TTS)、openapi-translate(文本翻译)、openapi-clone-voice(声音克隆)、openapi-media-translation(音视频翻译)。详见 Webhook 请求体。
可用选项:
openapi-tts, openapi-translate, openapi-clone-voice, openapi-media-translation 示例:
"openapi-tts"
该次异步完成的稳定标识。请用此字段对接收端去重 — 见 Webhook 请求体。
示例:
"a1b2c3d4e5f6789012345678901234ab"
当 code 非成功时的说明
与异步提交请求中的 extraData 一致
响应
200
请尽快返回 2xx 以停止重试
⌘I

