GPT Image 2 Official
curl --request POST \
--url https://apistable.ai/api/v1/tasks/create_task \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '
{
"model": "gpt-image-2-official",
"input": {
"prompt": "Studio photograph of a cobalt blue ceramic teapot, soft daylight, neutral background.",
"aspect_ratio": "1:1",
"resolution": "1K"
}
}
'const options = {
method: 'POST',
headers: {Authorization: 'Bearer <token>', 'Content-Type': 'application/json'},
body: JSON.stringify({
model: 'gpt-image-2-official',
input: {
prompt: 'Studio photograph of a cobalt blue ceramic teapot, soft daylight, neutral background.',
aspect_ratio: '1:1',
resolution: '1K'
}
})
};
fetch('https://apistable.ai/api/v1/tasks/create_task', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));import requests
url = "https://apistable.ai/api/v1/tasks/create_task"
payload = {
"model": "gpt-image-2-official",
"input": {
"prompt": "Studio photograph of a cobalt blue ceramic teapot, soft daylight, neutral background.",
"aspect_ratio": "1:1",
"resolution": "1K"
}
}
headers = {
"Authorization": "Bearer <token>",
"Content-Type": "application/json"
}
response = requests.post(url, json=payload, headers=headers)
print(response.text){
"code": 200,
"msg": "success",
"data": {
"task_id": "<string>"
}
}{
"code": 123,
"msg": "<string>",
"data": null
}{
"code": 123,
"msg": "<string>",
"data": null
}{
"code": 123,
"msg": "<string>",
"data": null
}{
"code": 123,
"msg": "<string>",
"data": null
}{
"code": 123,
"msg": "<string>",
"data": null
}{
"code": 123,
"msg": "<string>",
"data": null
}{
"code": 123,
"msg": "<string>",
"data": null
}{
"code": 123,
"msg": "<string>",
"data": null
}{
"code": 123,
"msg": "<string>",
"data": null
}{
"code": 123,
"msg": "<string>",
"data": null
}{
"code": 123,
"msg": "<string>",
"data": null
}OpenAI
GPT Image 2 Official
支持文生图、最多 16 张参考图与蒙版编辑及精确像素输出,按实际 Token 计费。
POST
/
api
/
v1
/
tasks
/
create_task
GPT Image 2 Official
curl --request POST \
--url https://apistable.ai/api/v1/tasks/create_task \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '
{
"model": "gpt-image-2-official",
"input": {
"prompt": "Studio photograph of a cobalt blue ceramic teapot, soft daylight, neutral background.",
"aspect_ratio": "1:1",
"resolution": "1K"
}
}
'const options = {
method: 'POST',
headers: {Authorization: 'Bearer <token>', 'Content-Type': 'application/json'},
body: JSON.stringify({
model: 'gpt-image-2-official',
input: {
prompt: 'Studio photograph of a cobalt blue ceramic teapot, soft daylight, neutral background.',
aspect_ratio: '1:1',
resolution: '1K'
}
})
};
fetch('https://apistable.ai/api/v1/tasks/create_task', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));import requests
url = "https://apistable.ai/api/v1/tasks/create_task"
payload = {
"model": "gpt-image-2-official",
"input": {
"prompt": "Studio photograph of a cobalt blue ceramic teapot, soft daylight, neutral background.",
"aspect_ratio": "1:1",
"resolution": "1K"
}
}
headers = {
"Authorization": "Bearer <token>",
"Content-Type": "application/json"
}
response = requests.post(url, json=payload, headers=headers)
print(response.text){
"code": 200,
"msg": "success",
"data": {
"task_id": "<string>"
}
}{
"code": 123,
"msg": "<string>",
"data": null
}{
"code": 123,
"msg": "<string>",
"data": null
}{
"code": 123,
"msg": "<string>",
"data": null
}{
"code": 123,
"msg": "<string>",
"data": null
}{
"code": 123,
"msg": "<string>",
"data": null
}{
"code": 123,
"msg": "<string>",
"data": null
}{
"code": 123,
"msg": "<string>",
"data": null
}{
"code": 123,
"msg": "<string>",
"data": null
}{
"code": 123,
"msg": "<string>",
"data": null
}{
"code": 123,
"msg": "<string>",
"data": null
}{
"code": 123,
"msg": "<string>",
"data": null
}参数与输入模式
model 与 input 必填,省略可选字段时使用模型默认值;完整字段定义见下方 Body 参数列表。
| 请求场景 | input 必填字段 |
|---|---|
| 文生图 | prompt |
| 参考图编辑 | prompt、image_urls(最多 16 张) |
| 蒙版局部编辑 | prompt、image_urls、mask_url |
使用场景
将以下示例提交到POST /api/v1/tasks/create_task,并将提示词与素材链接替换为你的内容。
{
"model": "gpt-image-2-official",
"input": {
"prompt": "Cobalt blue ceramic teapot on warm linen beside a sunlit window, editorial still life.",
"aspect_ratio": "16:9",
"resolution": "2K",
"quality": "high"
}
}
{
"model": "gpt-image-2-official",
"input": {
"prompt": "Replace the transparent masked tabletop area with brushed walnut wood, keeping the product and shadows consistent.",
"image_urls": [
"https://cdn.example.com/product.png"
],
"mask_url": "https://cdn.example.com/mask.png"
}
}
{
"model": "gpt-image-2-official",
"input": {
"prompt": "Minimal studio photograph of a matte stoneware vase on light travertine.",
"size": "1600x1200",
"output_format": "webp",
"output_compression": 80
}
}
通过 查询任务 或 callback_url(Webhook 安全与验签)获取结果,提交错误见 创建任务。结果链接保留 14 天;超过 24 小时未完成的任务将标记失败且不扣费。
试用与价格
单次请求最多生成n 张图片,整笔任务按实际 Token 用量结算一次,向上取整至 0.1 积分(实扣不超过提交预留,未用部分退还)。部分成功仅按实际返回的结果计费,失败不扣费。余额查询见 查询积分余额。| Token 类型 | 积分 / 百万 Token | USD / 百万 Token |
|---|---|---|
| 文本输入 | 950.0 | $4.750 |
| 缓存文本输入 | 237.5 | $1.188 |
| 图像输入 | 1520.0 | $7.600 |
| 缓存图像输入 | 380.0 | $1.900 |
| 图像输出 | 5700.0 | $28.500 |
在线试用
设置参数并在线生成图片。
查看价格
查看 Token 费率、请求估价与预留上限。
授权
登录 APIstable 后,在 API Key 管理 创建并复制密钥。
每次调用都要在 HTTP 请求头传入:
Authorization: Bearer YOUR_API_KEY
将 YOUR_API_KEY 替换为你创建的 API Key。
请求体
application/json
回调
POST{$request.body#/callback_url}Webhook
请求体
application/json
任务成功或失败后,APIstable 向创建任务时传入的 callback_url 发送 JSON POST。验签后返回 HTTP 2xx 确认接收。
请求生成的全部结果返回在 result.urls(可能少于 n),整笔任务总费用记录在 charged_credits。任务失败时返回 status: "failed"、result: null 且不扣费。
签名和去重使用 X-APIstable-Signature、X-APIstable-Timestamp 和 X-APIstable-Event-Id。详见 Webhook 安全与验签。
Webhook 请求体示例
{
"code": 200,
"msg": "success",
"data": {
"task_id": "c6adbc82-8b9a-4d6f-8b60-1114c8c4aafb",
"model": "gpt-image-2-official",
"status": "succeeded",
"created_at": "2026-11-23T08:30:00.000Z",
"completed_at": "2026-11-23T08:30:18.000Z",
"duration": 18000,
"charged_credits": 2.1,
"message": "",
"input": "{\"prompt\":\"Studio photograph of a cobalt blue ceramic teapot, soft daylight, neutral background.\",\"resolution\":\"1K\",\"aspect_ratio\":\"1:1\"}",
"result": {
"urls": [
"https://cdn.example.com/generated/image.png"
],
"items": [
{
"id": "e7aacd19-819a-4747-bbbf-46fb6f2995a5",
"status": "succeeded",
"charged_credits": 2.1,
"urls": [
"https://cdn.example.com/generated/image.png"
]
}
]
}
}
}
响应
2XX
已接收 Webhook。