xAI TTS 1
curl --request POST \
--url https://api.vidgo.ai/api/generate/submit \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '
{
"model": "xai/tts/v1",
"input": {
"text": "Welcome to our story. [pause] <whisper>Listen closely.</whisper> [laugh] Let us begin.",
"voice": "eve",
"language_code": "auto",
"output_format": {
"codec": "mp3",
"sample_rate": 24000,
"bit_rate": 128000
}
}
}
'import requests
url = "https://api.vidgo.ai/api/generate/submit"
payload = {
"model": "xai/tts/v1",
"input": {
"text": "Welcome to our story. [pause] <whisper>Listen closely.</whisper> [laugh] Let us begin.",
"voice": "eve",
"language_code": "auto",
"output_format": {
"codec": "mp3",
"sample_rate": 24000,
"bit_rate": 128000
}
}
}
headers = {
"Authorization": "Bearer <token>",
"Content-Type": "application/json"
}
response = requests.post(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'POST',
headers: {Authorization: 'Bearer <token>', 'Content-Type': 'application/json'},
body: JSON.stringify({
model: 'xai/tts/v1',
input: {
text: 'Welcome to our story. [pause] <whisper>Listen closely.</whisper> [laugh] Let us begin.',
voice: 'eve',
language_code: 'auto',
output_format: {codec: 'mp3', sample_rate: 24000, bit_rate: 128000}
}
})
};
fetch('https://api.vidgo.ai/api/generate/submit', 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.vidgo.ai/api/generate/submit",
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([
'model' => 'xai/tts/v1',
'input' => [
'text' => 'Welcome to our story. [pause] <whisper>Listen closely.</whisper> [laugh] Let us begin.',
'voice' => 'eve',
'language_code' => 'auto',
'output_format' => [
'codec' => 'mp3',
'sample_rate' => 24000,
'bit_rate' => 128000
]
]
]),
CURLOPT_HTTPHEADER => [
"Authorization: Bearer <token>",
"Content-Type: application/json"
],
]);
$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.vidgo.ai/api/generate/submit"
payload := strings.NewReader("{\n \"model\": \"xai/tts/v1\",\n \"input\": {\n \"text\": \"Welcome to our story. [pause] <whisper>Listen closely.</whisper> [laugh] Let us begin.\",\n \"voice\": \"eve\",\n \"language_code\": \"auto\",\n \"output_format\": {\n \"codec\": \"mp3\",\n \"sample_rate\": 24000,\n \"bit_rate\": 128000\n }\n }\n}")
req, _ := http.NewRequest("POST", url, payload)
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.vidgo.ai/api/generate/submit")
.header("Authorization", "Bearer <token>")
.header("Content-Type", "application/json")
.body("{\n \"model\": \"xai/tts/v1\",\n \"input\": {\n \"text\": \"Welcome to our story. [pause] <whisper>Listen closely.</whisper> [laugh] Let us begin.\",\n \"voice\": \"eve\",\n \"language_code\": \"auto\",\n \"output_format\": {\n \"codec\": \"mp3\",\n \"sample_rate\": 24000,\n \"bit_rate\": 128000\n }\n }\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.vidgo.ai/api/generate/submit")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["Authorization"] = 'Bearer <token>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"model\": \"xai/tts/v1\",\n \"input\": {\n \"text\": \"Welcome to our story. [pause] <whisper>Listen closely.</whisper> [laugh] Let us begin.\",\n \"voice\": \"eve\",\n \"language_code\": \"auto\",\n \"output_format\": {\n \"codec\": \"mp3\",\n \"sample_rate\": 24000,\n \"bit_rate\": 128000\n }\n }\n}"
response = http.request(request)
puts response.read_body{
"code": 200,
"data": {
"task_id": "task-unified-example",
"status": "running",
"created_time": "2026-09-10T08:00:00"
}
}{
"detail": "<string>"
}{
"detail": "<string>"
}{
"detail": "<string>"
}{
"detail": "<string>"
}Request timeout{
"detail": "<string>"
}{
"detail": "<string>"
}{
"detail": "<string>"
}{
"detail": "<string>"
}{
"detail": "<string>"
}xAI
xAI TTS 1
使用 xAI TTS 将文本转换为语音,可从五种音色和多种语言中选择,适用于旁白、对话和口播内容。
POST
/
api
/
generate
/
submit
xAI TTS 1
curl --request POST \
--url https://api.vidgo.ai/api/generate/submit \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '
{
"model": "xai/tts/v1",
"input": {
"text": "Welcome to our story. [pause] <whisper>Listen closely.</whisper> [laugh] Let us begin.",
"voice": "eve",
"language_code": "auto",
"output_format": {
"codec": "mp3",
"sample_rate": 24000,
"bit_rate": 128000
}
}
}
'import requests
url = "https://api.vidgo.ai/api/generate/submit"
payload = {
"model": "xai/tts/v1",
"input": {
"text": "Welcome to our story. [pause] <whisper>Listen closely.</whisper> [laugh] Let us begin.",
"voice": "eve",
"language_code": "auto",
"output_format": {
"codec": "mp3",
"sample_rate": 24000,
"bit_rate": 128000
}
}
}
headers = {
"Authorization": "Bearer <token>",
"Content-Type": "application/json"
}
response = requests.post(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'POST',
headers: {Authorization: 'Bearer <token>', 'Content-Type': 'application/json'},
body: JSON.stringify({
model: 'xai/tts/v1',
input: {
text: 'Welcome to our story. [pause] <whisper>Listen closely.</whisper> [laugh] Let us begin.',
voice: 'eve',
language_code: 'auto',
output_format: {codec: 'mp3', sample_rate: 24000, bit_rate: 128000}
}
})
};
fetch('https://api.vidgo.ai/api/generate/submit', 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.vidgo.ai/api/generate/submit",
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([
'model' => 'xai/tts/v1',
'input' => [
'text' => 'Welcome to our story. [pause] <whisper>Listen closely.</whisper> [laugh] Let us begin.',
'voice' => 'eve',
'language_code' => 'auto',
'output_format' => [
'codec' => 'mp3',
'sample_rate' => 24000,
'bit_rate' => 128000
]
]
]),
CURLOPT_HTTPHEADER => [
"Authorization: Bearer <token>",
"Content-Type: application/json"
],
]);
$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.vidgo.ai/api/generate/submit"
payload := strings.NewReader("{\n \"model\": \"xai/tts/v1\",\n \"input\": {\n \"text\": \"Welcome to our story. [pause] <whisper>Listen closely.</whisper> [laugh] Let us begin.\",\n \"voice\": \"eve\",\n \"language_code\": \"auto\",\n \"output_format\": {\n \"codec\": \"mp3\",\n \"sample_rate\": 24000,\n \"bit_rate\": 128000\n }\n }\n}")
req, _ := http.NewRequest("POST", url, payload)
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.vidgo.ai/api/generate/submit")
.header("Authorization", "Bearer <token>")
.header("Content-Type", "application/json")
.body("{\n \"model\": \"xai/tts/v1\",\n \"input\": {\n \"text\": \"Welcome to our story. [pause] <whisper>Listen closely.</whisper> [laugh] Let us begin.\",\n \"voice\": \"eve\",\n \"language_code\": \"auto\",\n \"output_format\": {\n \"codec\": \"mp3\",\n \"sample_rate\": 24000,\n \"bit_rate\": 128000\n }\n }\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.vidgo.ai/api/generate/submit")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["Authorization"] = 'Bearer <token>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"model\": \"xai/tts/v1\",\n \"input\": {\n \"text\": \"Welcome to our story. [pause] <whisper>Listen closely.</whisper> [laugh] Let us begin.\",\n \"voice\": \"eve\",\n \"language_code\": \"auto\",\n \"output_format\": {\n \"codec\": \"mp3\",\n \"sample_rate\": 24000,\n \"bit_rate\": 128000\n }\n }\n}"
response = http.request(request)
puts response.read_body{
"code": 200,
"data": {
"task_id": "task-unified-example",
"status": "running",
"created_time": "2026-09-10T08:00:00"
}
}{
"detail": "<string>"
}{
"detail": "<string>"
}{
"detail": "<string>"
}{
"detail": "<string>"
}Request timeout{
"detail": "<string>"
}{
"detail": "<string>"
}{
"detail": "<string>"
}{
"detail": "<string>"
}{
"detail": "<string>"
}- 提交后会返回
task_id。如果提供了callback_url,当任务状态变为finished或failed时,系统会向callback_url发送 POST 请求。 - 无论是否提供
callback_url,都可以通过统一的查询任务状态接口获取结果。
模型
- xai/tts/v1 - 将文本转换为语音。
功能
- 将文本转换为语音。
- 使用
voice选择音色,使用language_code指定朗读语言。 - 通过
text中的标签控制停顿、笑声、叹息、耳语和放慢语速。
输出选项
输出格式
-
output_format:可选。传入包含以下字段的对象。 -
output_format.codec:可选。可选值:mp3、wav、pcm、mulaw、alaw。默认:mp3。 -
output_format.sample_rate:可选。采样率(Hz)。可选值:8000、16000、22050、24000、44100、48000。默认:24000。 -
output_format.bit_rate:可选。MP3 比特率(bit/s)。可选值:32000、64000、96000、128000、192000、null。MP3 默认:128000。 -
mp3使用output_format.bit_rate选择比特率。wav、pcm、mulaw和alaw请省略bit_rate或设为null。
高级参数
在请求根级设置model 和可选的 callback_url。所有工作流程参数(包括输出选项)都放在 input 中。
文本
text:必填。要朗读的文本。长度:1-15,000 个字符。- 长度按去除首尾空白后的文本计算。文本中的标签、标点和空格都计入长度。
- 在需要的位置加入
[laugh]、[pause]或[sigh]。耳语段落使用<whisper>text</whisper>,放慢语速使用<slow>text</slow>。
音色
voice:可选。选择音色。可选值:eve、ara、rex、sal、leo。默认:eve。
语言代码
language_code:可选。字符串。默认:auto。
支持的语言代码
支持的语言代码
autoenar-EGar-SAar-AEbnzhfrdehiiditjakopt-BRpt-PTrues-MXes-EStrvi
输出文件
- 读取返回的
files数组中的每一项。 - 生成的音频
file_type为"audio"。 - 使用
file_url下载生成的语音。
请求示例
{
"model": "xai/tts/v1",
"input": {
"text": "Welcome to our story. [pause] <whisper>Listen closely.</whisper> [laugh] Let us begin.",
"voice": "eve",
"language_code": "auto",
"output_format": {
"codec": "mp3",
"sample_rate": 24000,
"bit_rate": 128000
}
}
}
授权
使用 VIDGO_API_KEY。
请求体
application/json