xAI
Grok Imagine Image Quality
xAI 旗舰图像生成与编辑模型(Quality 模式),支持文生图、单图/多图参考编辑、可选比例与 1K/2K 分辨率
模型类型图像生成与编辑
输入/输出文本和图像输入,图像输出
API 端点支持 Image API 的 generations 与 edits
定价与规格
💰 定价
价格$0.05 / image (1K)
⚙️ 规格
模型类型图像生成与编辑
输入/输出文本和图像输入,图像输出
API 端点支持 Image API 的 generations 与 edits
编辑能力单张参考图使用 image 对象,多张参考图使用 images 数组,可融合多图主体与风格
分辨率resolution 可选 1k / 2k
比例aspect_ratio 可选 auto、1:1、16:9、9:16、3:2、2:3 等
输出格式response_format 使用 b64_json,结果位于 data[].b64_json
标准定价1K 分辨率 $0.05/张,2K 分辨率 $0.07/张,编辑输入参考图 $0.01/张
发布信息xAI 于 2026 年 1 月发布 Grok Imagine 图像生成 API;Quality 模式官方定位为其最先进的图像生成模型,主打更强细节与文本渲染
文档状态根据 xAI 官方模型页与 XAI Router 图片端点文档更新
API 调用示例
Python
from openai import OpenAI
import base64
client = OpenAI(
base_url="https://api.xairouter.com/v1",
api_key="your-api-key"
)
result = client.images.generate(
model="grok-imagine-image-quality",
prompt="一只戴宇航员头盔的橘猫,电影感光线",
n=1,
response_format="b64_json",
extra_body={"aspect_ratio": "1:1", "resolution": "1k"},
)
with open("grok-image.jpg", "wb") as f:
f.write(base64.b64decode(result.data[0].b64_json))cURL
# 文生图
curl --fail-with-body -sS https://api.xairouter.com/v1/images/generations \
-H 'Authorization: Bearer YOUR_API_KEY' \
-H 'Content-Type: application/json' \
-d '{
"model": "grok-imagine-image-quality",
"prompt": "一只戴宇航员头盔的橘猫,电影感光线",
"n": 1,
"aspect_ratio": "1:1",
"resolution": "1k",
"response_format": "b64_json"
}' > grok-image-response.json
jq -er '.data[0].b64_json' grok-image-response.json \
| base64 --decode > grok-image.jpg
# 图生图编辑(单张参考图使用 image 对象)
REFERENCE_B64="$(base64 < reference.jpg | tr -d '\r\n')"
curl --fail-with-body -sS https://api.xairouter.com/v1/images/edits \
-H 'Authorization: Bearer YOUR_API_KEY' \
-H 'Content-Type: application/json' \
--data-binary @- <<JSON > grok-edit-response.json
{
"model": "grok-imagine-image-quality",
"prompt": "保留主体与构图,把背景改成雨夜霓虹街道",
"n": 1,
"resolution": "1k",
"response_format": "b64_json",
"image": {
"url": "data:image/jpeg;base64,${REFERENCE_B64}"
}
}
JSON
jq -er '.data[0].b64_json' grok-edit-response.json \
| base64 --decode > grok-edited.jpg