GPT-4o Mini TTS 语音合成

GPT-4o Mini TTS

POST https://api.apizt.com/v1/audio/speech 在线调试 →
▼ Authorization

在 Header 添加参数 Authorization,其值为 Bearer 之后拼接 Token

示例: Authorization: Bearer ********************

请求参数

Header 参数
Authorizationstring必需
Bearer Token;从环境变量 tokenba_API_KEY 读取。
Content-Typestring必需
示例:application/json
Body 参数application/json
modelstring必需
示例:gpt-4o-mini-tts
inputstring必需
示例:The quick brown fox jumped over the lazy dog.
voicestring可选
示例:alloy
response_formatstring可选
示例:mp3

完整 JSON 请求体

{
  "model": "gpt-4o-mini-tts",
  "input": "The quick brown fox jumped over the lazy dog.",
  "voice": "alloy",
  "response_format": "mp3"
}

请求示例代码

curl --fail-with-body --request POST 'https://api.apizt.com/v1/audio/speech' \
  --header "Authorization: Bearer ${tokenba_API_KEY}" \
  --header 'Content-Type: application/json' \
  --output speech.mp3 \
  --data-raw '{
  "model": "gpt-4o-mini-tts",
  "input": "The quick brown fox jumped over the lazy dog.",
  "voice": "alloy",
  "response_format": "mp3"
}'
async function main() {
  const headers = {
  "Authorization": "Bearer " + process.env.tokenba_API_KEY,
  "Content-Type": "application/json"
};
  const body = JSON.stringify({
  "model": "gpt-4o-mini-tts",
  "input": "The quick brown fox jumped over the lazy dog.",
  "voice": "alloy",
  "response_format": "mp3"
});
  const response = await fetch("https://api.apizt.com/v1/audio/speech", { method: "POST", headers, body });
  if (!response.ok) throw new Error("HTTP " + response.status + ": " + await response.text());
  const fs = require("node:fs");
  fs.writeFileSync("speech.mp3", Buffer.from(await response.arrayBuffer()));
  console.log("speech.mp3");
}
main().catch(console.error);
import os
import requests

headers = {"Authorization": "Bearer " + os.environ["tokenba_API_KEY"]}
payload = {'model': 'gpt-4o-mini-tts',
 'input': 'The quick brown fox jumped over the lazy dog.',
 'voice': 'alloy',
 'response_format': 'mp3'}
response = requests.post('https://api.apizt.com/v1/audio/speech', headers=headers, json=payload, timeout=120)
response.raise_for_status()
with open("speech.mp3", "wb") as output:
    output.write(response.content)
print("speech.mp3")

返回响应

成功响应为 audio/mpeg 音频字节。本例设置 response_format: mp3 并保存为 speech.mp3;接口错误返回 JSON,应先检查 HTTP 状态。目录仍列有 GPT-4o Mini TTS;文本 GPT-6.1 Sol 不生成音频。

当前模型与版本

依据 apizt 价格页,同步于 。以下型号按目录声明的协议与本页用途筛选;不代表所有参数和功能通用。切换前请核对型号说明、令牌分组与参数差异。Gemini 原生接口需同时替换 URL 中的模型 ID。

模型 ID能力标签支持分组
gpt-4o-mini-tts音频
分组(7)

Azure-Gpt-1、Azure-Gpt-2、Azure-Gpt-3、Azure-Gpt-4、Azure-Gpt-5、Openai-Gpt-1、Openai-Gpt-2

tts-1音频
分组(7)

Azure-Gpt-1、Azure-Gpt-2、Azure-Gpt-3、Azure-Gpt-4、Azure-Gpt-5、Openai-Gpt-1、Openai-Gpt-2

tts-1-hd音频
分组(7)

Azure-Gpt-1、Azure-Gpt-2、Azure-Gpt-3、Azure-Gpt-4、Azure-Gpt-5、Openai-Gpt-1、Openai-Gpt-2

tts-1-1106音频
分组(5)

Azure-Gpt-1、Azure-Gpt-2、Azure-Gpt-3、Openai-Gpt-1、Openai-Gpt-2

tts-1-hd-1106音频
分组(5)

Azure-Gpt-1、Azure-Gpt-2、Azure-Gpt-3、Openai-Gpt-1、Openai-Gpt-2

共列入 5 个候选型号。查看完整模型、版本与接口目录。