快速开始
- 1
获取密钥
在控制台的API密钥页面创建密钥。密钥以gwk_开头,只显示一次。
- 2
提交
调用生成接口后,会立即返回id和消耗的积分。文件此时尚未生成完成。
- 3
获取结果
用该id轮询任务。状态变为COMPLETED后,result_url中就是文件。
export GWANGGO_API_KEY="gwk_..."
# 1. Submit: credits are charged now, the result comes later
curl -X POST https://gwanggo.ai/api/v1/generate/image \
-H "Authorization: Bearer $GWANGGO_API_KEY" \
-H "Content-Type: application/json" \
-d '{"model": "gpt-image-2", "prompt": "A neon sneaker on a wet street at night", "aspectRatio": "16:9", "quality": "medium"}'
# {"id": "8f6c2d1e-...", "task_id": "...", "credits_used": 2}
# 2. Poll with the id until status is COMPLETED or FAILED
curl https://gwanggo.ai/api/v1/tasks/8f6c2d1e-... \
-H "Authorization: Bearer $GWANGGO_API_KEY"Node.js示例
const BASE = 'https://gwanggo.ai/api/v1'
const headers = {
Authorization: `Bearer ${process.env.GWANGGO_API_KEY}`,
'Content-Type': 'application/json',
}
async function generateImage(prompt) {
const res = await fetch(`${BASE}/generate/image`, {
method: 'POST',
headers,
body: JSON.stringify({ model: 'gpt-image-2', prompt, aspectRatio: '1:1', quality: 'medium' }),
})
const job = await res.json()
if (!res.ok) throw new Error(`${job.error.code}: ${job.error.message}`)
while (true) {
await new Promise((r) => setTimeout(r, 4000))
const task = await (await fetch(`${BASE}/tasks/${job.id}`, { headers })).json()
if (task.status === 'COMPLETED') return task.result_url
if (task.status === 'FAILED') throw new Error(task.error) // credits are refunded
}
}
generateImage('A neon sneaker on a wet street at night').then(console.log)认证
每个请求都要在Authorization请求头中以Bearer令牌的形式发送API密钥。只有模型列表(GET /models)无需密钥。
Authorization: Bearer gwk_...请把密钥保存在服务器端。密钥一旦出现在浏览器或应用代码中,任何人都可以消耗你的积分。密钥泄露后,请立即在API密钥页面吊销。
生成的流程
生成是异步的。提交请求时会扣除积分并返回id,再用该id调用GET /tasks/{id}查看状态。
| status | 含义 |
|---|---|
| PENDING | 已受理 |
| IN_QUEUE | 等待模型处理 |
| IN_PROGRESS | 生成中 |
| COMPLETED | 已完成。result_url中是文件;视频还有thumbnail_url |
| FAILED | 失败。error说明原因,积分会自动退还 |
图像每3-5秒轮询一次,视频和3D每10秒轮询一次。视频和3D可能需要几分钟。
请求体
三个生成接口使用相同的格式。除model外,可用的键因模型而异。决定价格的选项(quality、resolution、duration、tier)务必传入,缺少时请求会返回400。
| 键 | 类型 | 说明 |
|---|---|---|
| model | string | 来自GET /models的模型slug。必填 |
| prompt | string | 要生成的内容。除图生3D外必填 |
| imageUrl | string | 参考图或起始帧。视频模型和图生3D模型都使用这个键 |
| imageUrls | string[] | 多张参考图(GPT Image、Seedance 1.5 Pro、Seedance 2.5) |
| endImageUrl | string | 结束帧(MiniMax H3、Kling O3、Wan 3.0) |
| videoUrl | string | 用于复制动作的源视频(kling-3-mc) |
| aspectRatio | string | 宽高比,例如"16:9"、"9:16"、"1:1" |
| quality | string | 质量等级:图像为low、medium、high等,3D为none、standard、detailed |
| resolution | string | 视频分辨率,例如"720p" |
| duration | number | 视频时长(秒) |
| tier | string | standard或pro,用于按档位计价的模型 |
| generateAudio | boolean | 随视频一起生成声音 |
| style, faceLimit, pbr, pose | 3D | 3D选项:风格、面数上限、PBR材质、绑定姿势(a-pose、t-pose) |
查看模型的选项
GET /models返回的form_config.fields列出了模型接受的字段,以及可选值和默认值。带有field_name的字段,用该名称作为键;否则请按下表对应其type。
| form_config的field type | 请求中的键 |
|---|---|
| prompt | prompt |
| image_upload | imageUrl |
| multi_image_upload | imageUrls |
| video_upload | videoUrl |
| aspect_ratio | aspectRatio |
| quality | quality |
| resolution | resolution |
| duration | duration |
| tier | tier |
积分
积分在提交时扣除,生成失败时自动退还。价格由模型的credit_config决定。可用GET /me查询余额。
| credit_config的type | 价格 | 示例 |
|---|---|---|
| fixed | cost | {"type":"fixed","cost":3} -> 3 |
| quality | costs[quality] | gpt-image-2, quality "medium" -> 2 |
| per_second | (generateAudio ? audio_rates : rates)[resolution] x duration | seedance-2.0, 720p, 5 s -> 6 x 5 = 30 |
| tier_per_second | tiers[tier][resolution] x duration | kling-3, pro, 720p, 5 s -> 6 x 5 = 30 |
错误
错误会附带HTTP状态码和如下响应体。请根据code判断分支;message是给人看的说明,可能是韩语。
| 状态码 | code | 含义 |
|---|---|---|
| 400 | invalid_request | 请求体缺失或无效:模型未知、缺少必填值或价格选项 |
| 400 | unsupported | 公开API不支持该功能 |
| 401 | unauthorized | API密钥缺失、错误或已被吊销 |
| 402 | insufficient_credits | 积分不足,响应中包含required、available和billing_url |
| 404 | not_found | 找不到任务或资源,其他账户的id也属于此类 |
| 500 | provider_error | 模型提供方出错,积分已退还。请稍后重试 |
{
"error": {
"code": "insufficient_credits",
"message": "Not enough credits",
"required": 30,
"available": 12,
"billing_url": "https://gwanggo.ai/dashboard/subscription"
}
}接口
/models无需密钥模型列表
返回所有可用模型,包含选项(form_config)和价格(credit_config)。请使用is_coming_soon为false的模型。
curl https://gwanggo.ai/api/v1/models{
"models": [
{
"slug": "gpt-image-2",
"name": "GPT Image 2",
"type": "image",
"creator": "OpenAI",
"credit_config": { "type": "quality", "costs": { "low": 1, "medium": 2, "high": 7 } },
"form_config": {
"fields": [
{ "type": "prompt", "required": true },
{ "type": "image_upload", "required": false },
{ "type": "aspect_ratio", "default": "1:1", "options": ["1:1", "4:3", "3:4", "16:9", "9:16"] },
{ "type": "quality", "default": "high", "options": ["low", "medium", "high"] }
]
},
"is_coming_soon": false
}
]
}/meAPI密钥你的账户
返回密钥所有者的账户id、邮箱和积分余额。
curl https://gwanggo.ai/api/v1/me \
-H "Authorization: Bearer $GWANGGO_API_KEY"{ "id": "2b1f0c9e-...", "email": "you@example.com", "credits": 982 }/uploadAPI密钥上传文件
在生成中使用本地图像或视频之前,先上传。将文件PUT到uploadUrl,再把返回的publicUrl作为imageUrl或videoUrl传入。uploadUrl的有效期为5分钟。
contentTypestring必填- image/*或video/*
extstring可选- 文件扩展名;省略时根据contentType确定
curl -X POST https://gwanggo.ai/api/v1/upload \
-H "Authorization: Bearer $GWANGGO_API_KEY" \
-H "Content-Type: application/json" \
-d '{"contentType": "image/png"}'
# Then upload the file bytes to uploadUrl (within 5 minutes)
curl -X PUT "$UPLOAD_URL" \
-H "Content-Type: image/png" \
--data-binary @photo.png{
"uploadUrl": "https://...r2.cloudflarestorage.com/...?X-Amz-Signature=...",
"publicUrl": "https://.../studio-uploads/.../5c1e....png"
}/generate/imageAPI密钥生成图像
根据文字或参考图生成图像。用返回的id获取结果。
curl -X POST https://gwanggo.ai/api/v1/generate/image \
-H "Authorization: Bearer $GWANGGO_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"model": "gpt-image-2",
"prompt": "A neon sneaker on a wet street at night",
"aspectRatio": "16:9",
"quality": "medium"
}'{ "id": "8f6c2d1e-...", "task_id": "fal-gptimg2:...", "credits_used": 2 }/generate/videoAPI密钥生成视频
根据文字或起始图生成视频。价格取决于分辨率和时长。
curl -X POST https://gwanggo.ai/api/v1/generate/video \
-H "Authorization: Bearer $GWANGGO_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"model": "seedance-2.0",
"prompt": "The sneaker spins slowly, camera pushes in",
"imageUrl": "https://.../studio-uploads/.../sneaker.png",
"resolution": "720p",
"duration": 5,
"aspectRatio": "9:16",
"generateAudio": true
}'{ "id": "41d7a0b3-...", "task_id": "...", "credits_used": 30 }/generate/3dAPI密钥生成3D模型
根据文字或图像生成GLB模型。图像模型(-image)必须传入imageUrl。
curl -X POST https://gwanggo.ai/api/v1/generate/3d \
-H "Authorization: Bearer $GWANGGO_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"model": "tripo-h31-image",
"imageUrl": "https://.../studio-uploads/.../robot.png",
"style": "roblox",
"quality": "standard"
}'{ "id": "c93e5f20-...", "task_id": "...", "credits_used": 10 }/tasks/{id}API密钥任务状态
获取生成结果。请使用生成响应中的id,而不是task_id。
idstring必填- 生成接口返回的id
curl https://gwanggo.ai/api/v1/tasks/8f6c2d1e-... \
-H "Authorization: Bearer $GWANGGO_API_KEY"{
"id": "8f6c2d1e-...",
"type": "image",
"model": "gpt-image-2",
"status": "COMPLETED",
"result_url": "https://.../8f6c2d1e.png",
"credits_used": 2
}/generationsAPI密钥生成历史
返回你的生成记录,按时间从新到旧排列。
typeimage | video | 3d可选- 按类型筛选;省略时为all
pagenumber可选- 从1开始。默认1
pageSizenumber可选- 最大50。默认24
curl "https://gwanggo.ai/api/v1/generations?type=image&page=1&pageSize=24" \
-H "Authorization: Bearer $GWANGGO_API_KEY"{
"generations": [
{
"id": "8f6c2d1e-...",
"type": "image",
"model": "gpt-image-2",
"prompt": "A neon sneaker on a wet street at night",
"status": "COMPLETED",
"result_url": "https://.../8f6c2d1e.png",
"thumbnail_url": null,
"credits_used": 2,
"created_at": "2026-11-21T09:12:44.000Z"
}
],
"pagination": { "page": 1, "pageSize": 24, "totalCount": 57, "totalPages": 3, "hasMore": true }
}创建密钥,发送第一个请求
新账户可获得35积分。API消耗的积分与网页应用相同。