跳转到主要内容
POST
/
v1
/
tasks
Grok Imagine 系列
curl --request POST \
  --url https://www.qingbo.dev/v1/tasks \
  --header 'Content-Type: application/json' \
  --data '
{
  "model": "<string>",
  "prompt": "<string>",
  "n": 123,
  "callback_url": "<string>",
  "callback_events": [
    "<string>"
  ],
  "aspect_ratio": "<string>",
  "image_urls": [
    "<string>"
  ]
}
'
import requests

url = "https://www.qingbo.dev/v1/tasks"

payload = {
    "model": "<string>",
    "prompt": "<string>",
    "n": 123,
    "callback_url": "<string>",
    "callback_events": ["<string>"],
    "aspect_ratio": "<string>",
    "image_urls": ["<string>"]
}
headers = {"Content-Type": "application/json"}

response = requests.post(url, json=payload, headers=headers)

print(response.text)
const options = {
  method: 'POST',
  headers: {'Content-Type': 'application/json'},
  body: JSON.stringify({
    model: '<string>',
    prompt: '<string>',
    n: 123,
    callback_url: '<string>',
    callback_events: ['<string>'],
    aspect_ratio: '<string>',
    image_urls: ['<string>']
  })
};

fetch('https://www.qingbo.dev/v1/tasks', options)
  .then(res => res.json())
  .then(res => console.log(res))
  .catch(err => console.error(err));
package main

import (
	"fmt"
	"strings"
	"net/http"
	"io"
)

func main() {

	url := "https://www.qingbo.dev/v1/tasks"

	payload := strings.NewReader("{\n  \"model\": \"<string>\",\n  \"prompt\": \"<string>\",\n  \"n\": 123,\n  \"callback_url\": \"<string>\",\n  \"callback_events\": [\n    \"<string>\"\n  ],\n  \"aspect_ratio\": \"<string>\",\n  \"image_urls\": [\n    \"<string>\"\n  ]\n}")

	req, _ := http.NewRequest("POST", url, payload)

	req.Header.Add("Content-Type", "application/json")

	res, _ := http.DefaultClient.Do(req)

	defer res.Body.Close()
	body, _ := io.ReadAll(res.Body)

	fmt.Println(string(body))

}
HttpResponse<String> response = Unirest.post("https://www.qingbo.dev/v1/tasks")
  .header("Content-Type", "application/json")
  .body("{\n  \"model\": \"<string>\",\n  \"prompt\": \"<string>\",\n  \"n\": 123,\n  \"callback_url\": \"<string>\",\n  \"callback_events\": [\n    \"<string>\"\n  ],\n  \"aspect_ratio\": \"<string>\",\n  \"image_urls\": [\n    \"<string>\"\n  ]\n}")
  .asString();
{
  "task_id": "task-wave1775290140a830128812",
  "model": "grok-imagine-1.5",
  "action": "generate",
  "status": "queued",
  "created_at": 1775290140120,
  "progress": 0
}
xAI Grok Imagine 图像生成与编辑系列。包含两代模型,每代各拆出文生图图像编辑两个 model:
  • grok-imagine-1.0 / grok-imagine-1.5 — 文生图(generate),纯文本提示出图
  • grok-imagine-1.0-edit / grok-imagine-1.5-edit — 图像编辑(需传 image_urls 参考图)
四个 model 统一按张计费,均为 $0.016875 / 张。

定价

模型 ID类型单价(每张)
grok-imagine-1.0文生图$0.016875
grok-imagine-1.5文生图$0.016875
grok-imagine-1.0-edit图像编辑$0.016875
grok-imagine-1.5-edit图像编辑$0.016875

调用示例

curl -X POST https://www.qingbo.dev/v1/tasks \
  -H "Authorization: Bearer $WAVE_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "model": "grok-imagine-1.5",
    "prompt": "赛博朋克都市夜景,霓虹倒映在雨后街道,电影质感",
    "aspect_ratio": "16:9",
    "n": 1
  }'
curl -X POST https://www.qingbo.dev/v1/tasks \
  -H "Authorization: Bearer $WAVE_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "model": "grok-imagine-1.0",
    "prompt": "一只柴犬戴着宇航头盔漂浮在太空,卡通风格",
    "aspect_ratio": "1:1"
  }'
curl -X POST https://www.qingbo.dev/v1/tasks \
  -H "Authorization: Bearer $WAVE_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "model": "grok-imagine-1.5-edit",
    "prompt": "把背景换成雪山日落,人物保持不变",
    "image_urls": ["https://cdn.example.com/portrait.jpg"],
    "n": 1
  }'
curl -X POST https://www.qingbo.dev/v1/tasks \
  -H "Authorization: Bearer $WAVE_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "model": "grok-imagine-1.0-edit",
    "prompt": "给画面加上暖色调滤镜,增强黄昏氛围",
    "image_urls": ["https://cdn.example.com/street.jpg"]
  }'
{
  "task_id": "task-wave1775290140a830128812",
  "model": "grok-imagine-1.5",
  "action": "generate",
  "status": "queued",
  "created_at": 1775290140120,
  "progress": 0
}
提交后用 GET /v1/tasks/{task_id} 轮询状态,详见 任务系统

可用模型

模型 ID类型说明
grok-imagine-1.0文生图Grok Imagine 1.0,纯文本提示生成图像,支持 5 种宽高比
grok-imagine-1.5文生图Grok Imagine 1.5,新一代文生图,支持 5 种宽高比
grok-imagine-1.0-edit图像编辑Grok Imagine 1.0 图像编辑,需传入参考图 image_urls
grok-imagine-1.5-edit图像编辑Grok Imagine 1.5 图像编辑,需传入参考图 image_urls

通用参数

model
string
必填
可用模型 列表中选一个。文生图用 grok-imagine-1.0 / grok-imagine-1.5;图像编辑用 grok-imagine-1.0-edit / grok-imagine-1.5-edit
prompt
string
必填
提示文本,支持中英文。文生图为画面描述;图像编辑为对参考图的修改指令
n
integer
默认值:"1"
生成数量,取决于服务侧上限
callback_url
string
Webhook 回调地址,任务终态时调用。详见 回调机制
callback_events
string[]
订阅的回调事件类型,详见 回调机制

模型特定参数

文生图(grok-imagine-1.0 / grok-imagine-1.5)

aspect_ratio
string
默认值:"1:1"
画面宽高比,共 5 种:
  • 1:1 — 正方形
  • 16:9 / 9:16 — 横/竖版宽屏
  • 3:2 / 2:3 — 横/竖版相机比

图像编辑(grok-imagine-1.0-edit / grok-imagine-1.5-edit)

image_urls
string[]
必填
待编辑的参考图片 URL。图像编辑模型必须传入此字段
图像编辑模型(*-edit)不支持 aspect_ratio 参数,输出比例随参考图决定。

资源限制

项目限制
参考图片(*-edit)image_urls 提供
单张图片大小≤ 30MB,支持 JPG/PNG/WEBP
宽高比(文生图)1:1 / 16:9 / 9:16 / 3:2 / 2:3
输出文件图片链接,24 小时有效

相关文档