API调用文档
  1. 音频模型(Audio)
API调用文档
  • 前言(必读)
  • 常见错误代码及其含义
  • 聊天模型(chat)
    • 聊天接口(通用)
      POST
    • 列出可用模型
      GET
    • 聊天接口(o1系列模型)
      POST
    • 聊天补全
      POST
    • Claude3+(Openai格式调用)
      POST
    • Gemini1.5+(全系列)
      POST
    • GPTs
      POST
    • gpt-4-all 文件分析
      POST
    • gpt-4o-all 文件分析
      POST
    • 聊天接口(图片分析)
      POST
  • 创建嵌入
    • 创建嵌入
      POST
  • 音频模型(Audio)
    • 文字转语音 TTS
      POST
    • 语音转文字 whisper-1
      POST
    • 创建翻译
      POST
  • 绘画模型(Painting)
    • Dalle
      • 图像生成
      • 图像编辑
    • MidJourney
      • 提交模式与状态码说明
  • 常用调用代码整理
    • Python 示例1-1: 普通Post文本对话
    • Python 示例1-2: Openai官方库使用示例
    • Python 示例1-3: 流式输出 复制代码
    • Python 示例2:Json固定格式输出 代码展示 复制代码
    • Python 示例3:embedding代码例子 复制代码
    • Python 示例4:O1系列模型代码例子
  1. 音频模型(Audio)

文字转语音 TTS

POST
/v1/audio/speech

请求参数

Body 参数application/json
model
string 
模型名称
必需
可用的 TTS 型号之一:tts-1 或 tts-1-hd
input
string 
待生成文字
必需
要为其生成音频的文本,最大长度为 4096 个字符。
voice
string 
音色选择
必需
生成音频时音色风格选择。可选值为 alloy、echo、fable、onyx、nova、shimmer
response_format
string  | null 
音频格式
可选
默认为 mp3,可选值为 mp3、opus、aac、flac、wav、pcm,用于指定音频格式。
speed
string  | null 
播放速度
可选
默认为 1,生成的音频播放速度。可选值为 0.25 ~ 4.0 之间。
示例
{
  "model": "tts-1",
  "input": "敏捷的棕色狐狸从懒惰的狗身上跳过去。",
  "voice": "alloy"
}

示例代码

Shell
JavaScript
Java
Swift
Go
PHP
Python
HTTP
C
C#
Objective-C
Ruby
OCaml
Dart
R
请求示例请求示例
Shell
JavaScript
Java
Swift
curl --location --request POST '/v1/audio/speech' \
--header 'Content-Type: application/json' \
--data-raw '{
    "model": "tts-1",
    "input": "敏捷的棕色狐狸从懒惰的狗身上跳过去。",
    "voice": "alloy"
}'

返回响应

🟢200成功
application/json
Body
object {0}
示例
// 直接返回音频文件 xxx.mp3
上一页
创建嵌入
下一页
语音转文字 whisper-1
Built with