Skip to content

GPT-4o-audio

POST https://az.gptplus5.com/v1/chat/completions

官方文档:https://platform.openai.com/docs/api-reference/chat/create

请求参数

Authorization

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

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

Header 参数

参数名类型必需说明示例
Content-Typestring必需application/json
Authorizationstring必需Bearer $OPENAI_API_KEY

Body 参数 (application/json)

参数名类型必需说明
modelstring必需要使用的模型 ID。
modalitiesarray[string]可选模型生成的输出类型。默认设置:["text"]。要请求此模型生成文本和音频响应,您可以使用:["text", "audio"]。
audioobject可选
  └ voicestring必需模型用于响应支持的语音有alloy, ash, ballad, coral, echo, fable, nova, onyx, sage,或者 shimmer。
  └ formatstring必需指定输出音频格式必须是wav, mp3, flac, opus, 或者 pcm16。
messagesarray[object]必需构成当前对话的消息列表。
  └ rolestring必需
  └ contentstring必需

请求示例

json
{
      "model": "gpt-4o-audio-preview",
      "modalities": ["text", "audio"],
      "audio": { "voice": "alloy", "format": "wav" },
      "messages": [
        {
          "role": "user",
          "content": "Is a golden retriever a good family dog?"
        }
      ]
    }

cURL 示例

bash
curl --location --request POST 'https://az.gptplus5.com/v1/chat/completions' \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data-raw '{
      "model": "gpt-4o-audio-preview",
      "modalities": ["text", "audio"],
      "audio": { "voice": "alloy", "format": "wav" },
      "messages": [
        {
          "role": "user",
          "content": "Is a golden retriever a good family dog?"
        }
      ]
    }'

返回响应

🟢200成功

响应示例

json
{}