1. Audio
PeakkAI-Doc
English
  • 中文
  • English
  • 首页
  • English
    • Home Page
    • PeakkAI-API
      • Model
        • Native OpenAI Format
        • Native Gemini Format
      • Chat
        • Native OpenAI Format
        • Native Gemini Format
        • Native Claude Format
        • Responses Request (openai)
      • Audio
        • Native OpenAI Format TTS
          POST
        • Native Gemini Format TTS
          POST
      • Images
        • Native OpenAI Format Image Editing (JSON)
        • Native OpenAI Format Image Generation
        • Native OpenAI Format Image Editing (Multipart)
        • Native Gemini Format Image Generation
      • Video
        • Seedance2.0 format
          • Create Video Generation Task
          • Query Video Generation Task Status
      • Vector
        • Embeddings
          • Create Embedding
      • Translation
        • Speech Translation
    • AI application
      • PeakkAI API Integration with Claude Code
      • PeakkAI API Integration with Cursor
      • PeakkAI API Integration with Codex-cli
      • PeakkAI API Integration with Codex Desktop
      • PeakkAI API Integration with Hermes Agent
  1. Audio

Native Gemini Format TTS

POST
/v1beta/models/{model}:generateContent

Native Gemini (Speech)#

Call AboAI API using the native Google Gemini format

Introduction#

The Gemini Native API adopts the request and response format of Google Gemini. It is suitable for official Google clients (such as the google-generativeai SDK) or scenarios that require direct utilization of Gemini data structures. This interface complies with the Gemini API specifications and fully supports features like Thinking mode, multimodal input, tool calling, Google Search (Grounding), and image generation.

API Endpoints#

FeatureMethodPath
Content Generation (Non-streaming)POST/v1beta/models/{model}:generateContent

Authentication#

Either of the following methods is supported:
Header ParameterTypeDescription
AuthorizationstringBearer Token: Bearer sk-xxxxxxxxxx (Recommended, consistent with other AboAI endpoints)
x-goog-api-keystringGoogle-style API Key: x-goog-api-key: sk-xxxxxxxxxx
Alternatively, parameters can be passed in the URL: ?key=sk-xxxxxxxxxx.

请求参数

Path 参数

Query 参数

Header 参数

Body 参数application/json

示例
{
    "contents": [
        {
            "role": "user",
            "parts": [
                {
                    "text": "Read aloud: Hello World"
                }
            ]
        }
    ],
    "generationConfig": {
        "responseModalities": [
            "AUDIO"
        ],
        "speechConfig": {
            "voiceConfig": {
                "prebuiltVoiceConfig": {
                    "voiceName": "Kore"
                }
            },
            "languageCode": "cmn-CN"
        },
        "maxOutputTokens": 4096
    }
}

请求示例代码

Shell
JavaScript
Java
Swift
Go
PHP
Python
HTTP
C
C#
Objective-C
Ruby
OCaml
Dart
R
请求示例请求示例
Shell
JavaScript
Java
Swift
curl --location 'https://api.peakkai.ai/v1beta/models/gemini-2.5-pro-tts:generateContent?key=undefined' \
--header 'x-goog-api-key;' \
--header 'Authorization;' \
--header 'Content-Type: application/json' \
--data '{
    "contents": [
        {
            "role": "user",
            "parts": [
                {
                    "text": "Read aloud: Hello World"
                }
            ]
        }
    ],
    "generationConfig": {
        "responseModalities": [
            "AUDIO"
        ],
        "speechConfig": {
            "voiceConfig": {
                "prebuiltVoiceConfig": {
                    "voiceName": "Kore"
                }
            },
            "languageCode": "cmn-CN"
        },
        "maxOutputTokens": 4096
    }
}'

返回响应

🟢200
application/json
Bodyapplication/json

示例
{
  "candidates": [
    {
      "content": {
        "parts": [
          {
            "inlineData": {
              "data": "",
              "mimeType": "audio/L16;codec=pcm;rate=24000"
            }
          }
        ],
        "role": "model"
      },
      "index": 0,
      "finishReason": "STOP"
    }
  ],
  "usageMetadata": {
    "promptTokenCount": integer,
    "candidatesTokenCount": integer,
    "totalTokenCount": integer,
    "promptTokensDetails": [
      {
        "modality": "TEXT",
        "tokenCount": integer
      }
    ],
    "candidatesTokensDetails": [
      {
        "modality": "AUDIO",
        "tokenCount": integer
      }
    ]
  },
  "modelVersion": "gemini-2.5-pro-tts",
  "responseId": "MnjYaaqvHvnasbwP2J33iAQ"
}
修改于 2026-11-02 09:46:28
上一页
Native OpenAI Format TTS
下一页
Native OpenAI Format Image Editing (JSON)
Built with