CQTAI
Chat

Gemini ProtocolComing Soon

Google Gemini generateContent compatible. Text capability implemented, in gray release, not yet open.

This model is not live yet. The doc below is a preview. It will be callable once released.

Endpoints

UsageMethodPath
Non-streamingPOST/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

ParamTypeRequiredDescription
contentsarrayRequiredConversation (role/parts)
systemInstructionobjectSystem instruction
generationConfigobjecttemperature/topP/maxOutputTokens, etc.
toolsTools / function calling

Streaming (SSE)

Use the :streamGenerateContent endpoint for SSE streaming.

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

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

UsageMethodPath
Sync image generationPOST/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

ParamTypeRequiredDescription
{model}pathRequiredModel 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)
contentsarrayRequiredNative Gemini contents array; each item has role and parts[]. Text-to-image usually needs a single role="user" item.
contents[].rolestringRole; use "user" for image generation
contents[].parts[].textstringRequiredText prompt describing the image to generate
contents[].parts[].inlineDataobjectReference 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.fileUristringhttps 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.
generationConfigobjectRequiredGeneration config object; see the sub-fields below
generationConfig.responseModalitiesstring[]RequiredOutput modalities; must include "IMAGE" for image output (e.g. ["TEXT","IMAGE"]); omitting it returns text only
generationConfig.candidateCountnumberNumber of images: 1-4, default 1. Charged per image (xN) and settled by the number of successful images (failures refunded)
generationConfig.imageConfig.imageSizestringResolution: 1K / 2K / 4K, default 1K (Nano is 1K only; Nano Pro / Nano 2 support 2K/4K)
generationConfig.imageConfig.aspectRatiostringOutput 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

Nano (gemini-2.5-flash-image) 10/img; Nano Pro (gemini-3-pro-image-preview) 20/img; Nano 2 (gemini-3.1-flash-image-preview) 20/img. Multiple images are charged per image (candidateCount, xN) and settled by the number of successful images (failures refunded).
Besides Authorization: Bearer <API_KEY>, x-goog-api-key is also accepted (your APIKey; either one, not both). Generating multiple images is charged per image (candidateCount) and settled by the number that succeed; a reference image can be inline base64 or an https URL via fileData.fileUri. multipart/form-data submission: fields prompt (required for text-to-image / edit instruction for image-to-image), image (reference file, repeatable up to 4), n (count, max 4, maps to candidateCount); model comes from the URL path only, image models + non-stream only, request body capped at 20MB (over → 413); request format (JSON / multipart) and response format (base64 / add ?respFormat=url for a CDN link) are orthogonal, and billing is identical to the JSON path.

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"
    }
  ]
}

Billing & Credits

Billed per token: input × input price + output × output price (cache write ×1.25, cache read ×0.1), then × your rate. count_tokens is free. See the Intro page for model prices.