CQTAI
Chat

OpenAI Protocol (GPT)

OpenAI Chat Completions / Responses compatible. For GPT, plus DeepSeek, GLM, etc.

Endpoints

UsageMethodPath
Chat (REST + SSE)POST/v1/chat/completions
Codex (Responses)POST/v1/responses
Model listGET/v1/models

Authentication

Authorization: Bearer <API_KEY>
Content-Type: application/json

Supported Models

gpt-* (e.g. gpt-4o), deepseek-*, glm-* (e.g. glm-5.2), etc. See GET /v1/models.

Request Parameters

ParamTypeRequiredDescription
modelstringRequiredModel, e.g. gpt-4o
messagesarrayRequiredMessages (role/content)
streambooleantrue for SSE; add stream_options.include_usage=true to get usage
temperature / top_pnumberSampling controls
max_tokens / max_completion_tokensintegerMax output
tools / tool_choiceTool calling

Streaming (SSE)

Set "stream": true and "stream_options": {"include_usage": true}; receive SSE with curl -N. Events data: {chunk}, ends with data: [DONE]; usage in the final chunk.

Request Example

Non-streaming

curl -X POST "https://api.cqtai.com/v1/chat/completions" \
  -H "Authorization: Bearer <API_KEY>" \
  -H "Content-Type: application/json" \
  -d '{
    "model": "gpt-4o",
    "messages": [{"role":"user","content":"你好,介绍一下你自己"}]
  }'

Streaming (SSE with usage)

curl -N -X POST "https://api.cqtai.com/v1/chat/completions" \
  -H "Authorization: Bearer <API_KEY>" \
  -H "Content-Type: application/json" \
  -d '{
    "model": "gpt-4o",
    "stream": true,
    "stream_options": {"include_usage": true},
    "messages": [{"role":"user","content":"写一首关于夏天的短诗"}]
  }'

Response Example

{
  "id": "chatcmpl-xxx",
  "object": "chat.completion",
  "model": "gpt-4o",
  "choices": [
    { "index": 0, "message": { "role": "assistant", "content": "你好!……" }, "finish_reason": "stop" }
  ],
  "usage": { "prompt_tokens": 9, "completion_tokens": 12, "total_tokens": 21 }
}
Image Generation

Image Generation (GPT-Image · sync)NEW

Beyond chat, the same OpenAI protocol also offers synchronous image generation: a single request returns the image (url or b64_json) directly — no taskId, no polling. Developers already using an OpenAI SDK / images client can integrate as-is.

Endpoints

UsageMethodPath
Text-to-imagePOST/v1/images/generations
Image edit (multipart)POST/v1/images/edits
Variations (multipart)POST/v1/images/variations

Supported Models

gpt-image-1 / gpt-image-1.5 / gpt-image-2 (all 6 credits/img).

Request Parameters

ParamTypeRequiredDescription
modelstringRequiredgpt-image-1 / gpt-image-1.5 / gpt-image-2 (all 6/img)
promptstringRequiredImage description
sizestringOutput size (official pixels, default 1024x1024)
response_formatstringurl (a stable, long-lived link on our CDN — it does not expire shortly after generation) or b64_json (inline image data; gpt-image-1 often returns this)

Billing & Credits

gpt-image-1 / gpt-image-1.5 / gpt-image-2 are all 6 credits/img.
⚠ Pricing differs from the async sora channel (POST /api/cqt/generator/sora): here gpt-image-1 / 1.5 / 2 are all 6/img; the async sora channel is 4 / 6 / 12. Image-to-image / variations use multipart /v1/images/edits and /v1/images/variations.

Request Example

Text-to-image (sync)

curl -X POST "https://api.cqtai.com/v1/images/generations" \
  -H "Authorization: Bearer <API_KEY>" \
  -H "Content-Type: application/json" \
  -d '{
    "model": "gpt-image-2",
    "prompt": "a red panda astronaut, studio lighting",
    "size": "1024x1024"
  }'

Image edit (multipart)

# 图生图走 /v1/images/edits,multipart/form-data 上传参考图(字段 image[],可多张)
# 可选 mask 蒙版做局部重绘;不要带 Content-Type: application/json
curl -X POST "https://api.cqtai.com/v1/images/edits" \
  -H "Authorization: Bearer <API_KEY>" \
  -F "model=gpt-image-2" \
  -F "image[]=@input.png" \
  -F "prompt=add a red hat on the cat" \
  -F "size=1024x1024"

Image variations (multipart)

# 变体走 /v1/images/variations,无 prompt,基于参考图生成风格相近的变体
curl -X POST "https://api.cqtai.com/v1/images/variations" \
  -H "Authorization: Bearer <API_KEY>" \
  -F "model=gpt-image-2" \
  -F "image[]=@input.png" \
  -F "size=1024x1024"

Response Example

{
  "created": 1710000000,
  "data": [
    { "url": "https://.../image.png" }
  ]
}

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.