1. Images
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
        • Native Gemini Format TTS
      • Images
        • Native OpenAI Format Image Editing (JSON)
          POST
        • Native OpenAI Format Image Generation
          POST
        • Native OpenAI Format Image Editing (Multipart)
          POST
        • Native Gemini Format Image Generation
          POST
      • 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. Images

Native Gemini Format Image Generation

POST
/v1beta/models/{model}:generateContent

Gemini Native (Image)#

Invoke the AboAI API using the Google Gemini native format

Introduction#

The Gemini Native API utilizes Google Gemini's request and response formats, making it suitable for official Google clients (such as the google-generativeai SDK) or scenarios that require direct use of Gemini data structures. This interface complies with the Gemini API specifications and fully supports features such as 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#

Supports either of the following methods:
Header ParameterTypeDescription
AuthorizationstringBearer Token: Bearer sk-xxxxxxxxxx (Recommended, consistent with other AboAI interfaces)
x-goog-api-keystringGoogle-style API Key: x-goog-api-key: sk-xxxxxxxxxx
You can also pass the parameter via the URL: ?key=sk-xxxxxxxxxx.

请求参数

Authorization
API Key
在 header 添加参数
x-goog-api-key
示例:
x-goog-api-key: ********************
or
Path 参数

Query 参数

Header 参数

Body 参数application/json

示例
{
    "contents": [
        {
            "role": "user",
            "parts": [
                {
                    "text": "Generate a picture of a cute cartoon cat"
                }
            ]
        }
    ],
    "generationConfig": {
        "responseModalities": [
            "TEXT",
            "IMAGE"
        ],
        "imageConfig": {
            "imageSize": "1k",
            "aspectRatio": "16:9"
        },
        "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-flash-image:generateContent?key=undefined' \
--header 'Authorization;' \
--header 'x-goog-api-key: <api-key>' \
--header 'Content-Type: application/json' \
--data '{
    "contents": [
        {
            "role": "user",
            "parts": [
                {
                    "text": "Generate a picture of a cute cartoon cat"
                }
            ]
        }
    ],
    "generationConfig": {
        "responseModalities": [
            "TEXT",
            "IMAGE"
        ],
        "imageConfig": {
            "imageSize": "1k",
            "aspectRatio": "16:9"
        },
        "maxOutputTokens": 4096
    }
}'

返回响应

🟢200
application/json
Bodyapplication/json

示例
{
  "candidates": [
    {
      "content": {
        "parts": [
          {
            "text": "Response text\n"
          },
          {
            "inlineData": {
              "data": "",
              "mimeType": "image/png"
            }
          }
        ],
        "role": "model"
      },
      "index": 0,
      "finishReason": "STOP"
    }
  ],
  "usageMetadata": {
    "promptTokenCount": integer,
    "candidatesTokenCount": integer,
    "totalTokenCount": integer,
    "promptTokensDetails": [
      {
        "modality": "TEXT",
        "tokenCount": integer
      }
    ],
    "candidatesTokensDetails": [
      {
        "modality": "IMAGE",
        "tokenCount": integer
      },
      {
        "modality": "TEXT",
        "tokenCount": integer
      }
    ]
  },
  "modelVersion": "gemini-2.5-flash-image",
  "responseId": "sXvYaYm-IqjZ8eEP6fv1oAI"
}
修改于 2026-11-02 09:46:28
上一页
Native OpenAI Format Image Editing (Multipart)
下一页
Create Video Generation Task
Built with