AIGX API
图像生成接口。异步任务模型:创建任务返回 ID,轮询获取结果。
Base URL
https://www.aigx.me/v1
鉴权
请求头携带 Bearer Token。Key 在控制台创建。
Authorization: Bearer sk-aigx-xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
Endpoints
GET/models
模型列表、参数定义与定价。
Response 200
{
"ok": true,
"currency": "credits",
"pricing": {
"BASE_PRICE": { "gpt-image-2.6-sunburst": 10, "nano-banana-2.1": 15 },
"RES_STEP": { "1K": 0, "2K": 5, "4K": 10 },
"QUALITY_STEP": { "low": 0, "medium": 5, "high": 10 },
"GIF_PRICE": 30
},
"models": [
{
"id": "gpt-image-2.6-sunburst",
"name": "GPT Image 2.6 Sunburst",
"unit_price": 10,
"params": [
{ "key": "aspect_ratio", "label": "比例", "type": "ratio",
"options": ["1:1","9:16","16:9","3:4","4:3","2:3","3:2","21:9"],
"default": "1:1" },
{ "key": "resolution", "label": "分辨率", "type": "enum",
"options": ["1K","2K","4K"], "default": "1K" }
]
}
]
}POST/images
创建生成任务。立即返回任务 ID,不等待出图。
Body
| 字段 | 类型 | 说明 | |
|---|---|---|---|
model | string | 必填 | 模型 ID,取自 /models |
prompt | string | 必填 | 画面描述 |
params | object | 可选 | 键名取自模型的 params,缺省用默认值 |
assets | string[] | 可选 | 参考图 URL,公网可访问,上限 16 条 |
count | number | 可选 | 生成张数,默认 1,上限为账号并发数 |
Request
{
"model": "gpt-image-2.6-sunburst",
"prompt": "a red apple on a wooden table, soft daylight",
"params": { "aspect_ratio": "1:1", "resolution": "1K", "quality": "low" },
"count": 1
}Response 200
{
"ok": true,
"id": 1234,
"ids": [1234],
"status": "pending",
"model": "gpt-image-2.6-sunburst",
"count": 1,
"unit_cost": 10,
"cost": 0,
"pay_from": "plan",
"created_at": "2026-11-19T10:03:01.273Z"
}Response 字段
| 字段 | 说明 |
|---|---|
id | 首个记录 ID,用于轮询 |
ids | 本次创建的全部记录 ID |
unit_cost | 单张单价 |
cost | 实扣积分,会员为 0 |
pay_from | plan 或 credits |
GET/images/{id}
查询任务状态。建议轮询间隔 3 秒。
Response 200 — 处理中
{
"ok": true,
"id": 1234,
"status": "processing",
"model": "gpt-image-2.6-sunburst",
"cost": 0,
"pay_from": "plan",
"created_at": "2026-11-19 18:03:01",
"duration_ms": null
}Response 200 — 完成
{
"ok": true,
"id": 1234,
"status": "done",
"model": "gpt-image-2.6-sunburst",
"cost": 0,
"pay_from": "plan",
"created_at": "2026-11-19 18:03:01",
"duration_ms": 42013,
"url": "https://www.aigx.me/f/1234/wnHUcNNgJf7VkEkxvFAqeT"
}| status | 说明 |
|---|---|
processing | 处理中 |
done | 完成,读取 url |
failed | 失败,读取 error;积分已退还 |
url 为长期有效直链,无需鉴权。
POST/uploads
上传本地图片,返回可用作 assets 的公网地址。
| 字段 | 类型 | 说明 | |
|---|---|---|---|
data | string | 必填 | Base64 Data URL |
name | string | 可选 | 文件名,仅用于记录 |
支持 image/png、image/jpeg、image/webp、image/gif,单文件上限 20MB。
Response 200
{
"ok": true,
"url": "https://www.aigx.me/uploads/79bbe41067673769c371.png",
"mime": "image/png",
"bytes": 185
}GET/me
账户余额、会员状态与配额。
Response 200
{
"ok": true,
"account": { "id": 1, "email": "user@example.com" },
"credits": 4204,
"plan": { "active": true, "name": "年卡", "expire": "2027-11-18 20:25:18" }
}GET/usage?limit=20
最近任务,按创建时间倒序。limit 默认 20,上限 100。
Response 200
{
"ok": true,
"items": [
{
"id": 9636,
"model": "gpt-image-2.6-sunburst",
"status": "done",
"cost": 0,
"pay_from": "plan",
"created_at": "2026-11-19 18:03:01",
"duration_ms": 42013,
"url": "https://www.aigx.me/f/9636/wnHUcNNgJf7VkEkxvFAqeT"
}
]
}错误码
错误响应统一为 { ok: false, error: { code, message } }。code 供程序分支,message 为中文描述。
| HTTP | code | 说明 |
|---|---|---|
| 400 | unknown_model | 模型 ID 不存在 |
| 400 | prompt_required | prompt 为空 |
| 400 | invalid_asset | 参考图地址非 http(s) |
| 400 | invalid_body | 请求体格式错误 |
| 400 | unsupported_type | 上传类型不支持 |
| 401 | missing_key | 未携带 Authorization |
| 401 | invalid_key | Key 不存在 |
| 401 | key_revoked | Key 已删除 |
| 401 | account_banned | 账号被封禁 |
| 402 | insufficient_credits | 积分不足 |
| 404 | not_found | 任务不存在或不属于当前账号 |
| 404 | unknown_endpoint | 路径不存在 |
| 413 | file_too_large | 上传文件超过 20MB |
| 500 | internal_error | 服务异常 |
| 502 | upload_failed | 素材上传失败 |