Gemini ProtocolComing Soon
Google Gemini generateContent compatible. Text capability implemented, in gray release, not yet open.
Endpoints
| Usage | Method | Path |
|---|---|---|
| Non-streaming | POST | /v1beta/models/{model}:generateContent |
| Streaming (SSE) | POST | /v1beta/models/{model}:streamGenerateContent |
Authentication
Authorization: Bearer <API_KEY> Content-Type: application/json
Supported Models
gemini-* (coming soon)
Request Parameters
| Param | Type | Required | Description |
|---|---|---|---|
| contents | array | Required | Conversation (role/parts) |
| systemInstruction | object | — | System instruction |
| generationConfig | object | — | temperature/topP/maxOutputTokens, etc. |
| tools | — | — | Tools / function calling |
Streaming (SSE)
Request Example
Non-streaming
curl -X POST "https://api.cqtai.com/v1beta/models/gemini-1.5-pro:generateContent" \
-H "Authorization: Bearer <API_KEY>" \
-H "Content-Type: application/json" \
-d '{
"contents": [{"role":"user","parts":[{"text":"你好,介绍一下你自己"}]}]
}'Image Generation (Nano · sync)NEW
Text chat is still in gray release, but synchronous image generation on the same native Gemini generateContent endpoint is already available: pass an image model with generationConfig.responseModalities including "IMAGE", and a single request returns the base64 image directly — no taskId, no polling. The public "Nano tier" is backed by these Gemini image models. Two request formats are supported: default JSON (native Gemini protocol) and multipart/form-data upload (upload reference images directly via the image file field for image-to-image — see the example below).
Endpoints
| Usage | Method | Path |
|---|---|---|
| Sync image generation | POST | /v1beta/models/{model}:generateContent |
Supported Models
gemini-2.5-flash-image (Nano, 10, 1K) / gemini-3-pro-image-preview (Nano Pro, 20, 1K/2K/4K) / gemini-3.1-flash-image-preview (Nano 2, 20, 1K/2K/4K).
Request Parameters
| Param | Type | Required | Description |
|---|---|---|---|
| {model} | path | Required | Model id in the URL path (tier mapping): gemini-2.5-flash-image (Nano, 10, 1K) / gemini-3-pro-image-preview (Nano Pro, 20, 1K/2K/4K) / gemini-3.1-flash-image-preview (Nano 2, 20, 1K/2K/4K) |
| contents | array | Required | Native Gemini contents array; each item has role and parts[]. Text-to-image usually needs a single role="user" item. |
| contents[].role | string | — | Role; use "user" for image generation |
| contents[].parts[].text | string | Required | Text prompt describing the image to generate |
| contents[].parts[].inlineData | object | — | Reference image for image-to-image (inline base64): { "mimeType": "image/png", "data": "<base64>" }; omit for text-to-image. You can also pass a URL via fileData.fileUri below. |
| contents[].parts[].fileData.fileUri | string | — | https URL of a reference image for image-to-image (alternative to inline base64); the server downloads and inlines it. https only, up to 4 reference images; if any download fails the whole request errors and is not charged. |
| generationConfig | object | Required | Generation config object; see the sub-fields below |
| generationConfig.responseModalities | string[] | Required | Output modalities; must include "IMAGE" for image output (e.g. ["TEXT","IMAGE"]); omitting it returns text only |
| generationConfig.candidateCount | number | — | Number of images: 1-4, default 1. Charged per image (xN) and settled by the number of successful images (failures refunded) |
| generationConfig.imageConfig.imageSize | string | — | Resolution: 1K / 2K / 4K, default 1K (Nano is 1K only; Nano Pro / Nano 2 support 2K/4K) |
| generationConfig.imageConfig.aspectRatio | string | — | Output ratio: 1:1 / 16:9 / 9:16 / 4:3 / 3:4 / 3:2 / 2:3 / 5:4 / 4:5 / 21:9, default 1:1; follow the official Google imageConfig spec |
Billing & Credits
Request Example
Text-to-image (sync)
curl -X POST "https://api.cqtai.com/v1beta/models/gemini-2.5-flash-image:generateContent" \
-H "Authorization: Bearer <API_KEY>" \
-H "Content-Type: application/json" \
-d '{
"contents": [{"role":"user","parts":[{"text":"a cute cat on a windowsill, soft morning light"}]}],
"generationConfig": {
"responseModalities": ["TEXT","IMAGE"],
"imageConfig": {"imageSize": "1K", "aspectRatio": "1:1"}
}
}'Image-to-image (sync, URL reference + multiple)
curl -X POST "https://api.cqtai.com/v1beta/models/gemini-3-pro-image-preview:generateContent" \
-H "Authorization: Bearer <API_KEY>" \
-H "Content-Type: application/json" \
-d '{
"contents": [{"role":"user","parts":[
{"text":"turn this photo into an oil painting"},
{"fileData":{"mimeType":"image/png","fileUri":"https://example.com/input.png"}}
]}],
"generationConfig": {
"responseModalities": ["TEXT","IMAGE"],
"candidateCount": 2,
"imageConfig": {"imageSize": "2K", "aspectRatio": "16:9"}
}
}'Image-to-image (sync, multipart file upload)
# 同一端点按 Content-Type 分流:发 multipart/form-data 直接上传参考图文件 # 字段:prompt(文生图必填 / 图生图为编辑指令)、image(参考图文件,可重复最多 4 张)、n(张数,最多 4) # model 只取自 URL 路径;仅图片模型 + 仅非流式支持;请求体上限 20MB # 默认返回 base64;叠加 ?respFormat=url 则返回 CDN 直链 curl -X POST "https://api.cqtai.com/v1beta/models/gemini-2.5-flash-image:generateContent" \ -H "Authorization: Bearer <API_KEY>" \ -F "prompt=把这张图改成水彩风格" \ -F "image=@input.png"
Response Example
{
"candidates": [
{
"content": {
"parts": [
{ "inlineData": { "mimeType": "image/png", "data": "<base64 PNG,原样透传>" } }
]
},
"finishReason": "STOP"
}
]
}