跳转到主要内容
POST
/
v3
/
gemini-2.5-flash-tts
Gemini 2.5 Flash TTS Text-to-Speech
curl --request POST \
  --url https://api.jiekou.ai/v3/gemini-2.5-flash-tts \
  --header 'Authorization: <authorization>' \
  --header 'Content-Type: <content-type>' \
  --data '
{
  "contents": {
    "role": "<string>",
    "parts": {
      "text": "<string>"
    }
  },
  "generation_config": {
    "temperature": 123,
    "speech_config": {
      "voice_config": {
        "prebuilt_voice_config": {
          "voice_name": "<string>"
        }
      },
      "language_code": "<string>",
      "multi_speaker_voice_config": {
        "speaker_voice_configs": [
          {
            "speaker": "<string>",
            "voice_config": {
              "prebuilt_voice_config": {
                "voice_name": "<string>"
              }
            }
          }
        ]
      }
    }
  }
}
'
{
  "audioContent": "<string>",
  "usageMetadata": {
    "totalTokenCount": 123,
    "promptTokenCount": 123,
    "candidatesTokenCount": 123
  }
}
基于 Vertex AI generateContent 接口将文本转换为语音。请求体格式与官方 Vertex AI API 完全一致。支持同步(单请求单响应)和流式(单请求流式响应)两种模式。输出为 LINEAR16 PCM 格式(24kHz, 单声道, 16-bit signed little-endian),不包含 WAV 头。

请求头

Content-Type
string
必填
枚举值: application/json
Authorization
string
必填
Bearer 身份验证格式: Bearer {{API 密钥}}。

请求体

contents
object
必填
generation_config
object
必填

响应

audioContent
string
Base64 编码的音频内容。格式为 LINEAR16 PCM(24kHz, 单声道, 16-bit signed little-endian),不包含 WAV 头。客户端可使用 ffmpeg 转换:ffmpeg -f s16le -ar 24k -ac 1 -i input.raw output.wav
usageMetadata
object