在 APIMart 通过 Grok Imagine 2.0 API 使用 xAI 的 Grok Imagine 2.0 图像模型,提供两种方式:低价的 grok-imagine-2.0-ext,支持文生图、比例重绘、图层和选区编辑;官方 grok-imagine-image-2.0,支持 1K / 2K 文生图和最多三张参考图编辑。
服务亮点

Image link valid for 72 hours
透明定价,无隐藏费用。按量付费,用多少付多少。
| 型号 | 规格 | 黄金价当前价格 | 铂金价 | 钻石价 | 官方价 | 为你节省 |
|---|---|---|---|---|---|---|
grok-imagine-2.0-ext | 图片上传 | 免费 | 免费 | 免费 | — | — |
| 标准生成 | 0.15Credits(~$0.015)/张 | 0.1425Credits(~$0.0143)/张 | 0.135Credits(~$0.0135)/张 | 0.6Credits(~$0.06)/张 | 75% | |
| 选区编辑 | 0.15Credits(~$0.015)/次 | 0.1425Credits(~$0.0143)/次 | 0.135Credits(~$0.0135)/次 | 0.1875Credits(~$0.0188)/次 | 20% | |
grok-imagine-image-2.0 | 1K low | 0.32Credits(~$0.032)/张 | 0.304Credits(~$0.0304)/张 | 0.288Credits(~$0.0288)/张 | 0.4Credits(~$0.04)/张 | 20% |
| 1K medium | 0.48Credits(~$0.048)/张 | 0.456Credits(~$0.0456)/张 | 0.432Credits(~$0.0432)/张 | 0.6Credits(~$0.06)/张 | 20% | |
| 2K low | 0.48Credits(~$0.048)/张 | 0.456Credits(~$0.0456)/张 | 0.432Credits(~$0.0432)/张 | 0.6Credits(~$0.06)/张 | 20% | |
| 2K medium | 0.64Credits(~$0.064)/张 | 0.608Credits(~$0.0608)/张 | 0.576Credits(~$0.0576)/张 | 0.8Credits(~$0.08)/张 | 20% | |
| 参考图片(每张) | 0.08Credits(~$0.008)/张 | 0.076Credits(~$0.0076)/张 | 0.072Credits(~$0.0072)/张 | 0.1Credits(~$0.01)/张 | 20% |
* 实际费用以最终输出为准。
在 APIMart 用一个 POST 请求调用 grok-imagine-image-2.0。生成是异步的:先提交任务,再查询任务接口获取图片地址。示例使用官方 grok-imagine-image-2.0;Ext 型号把 model 换成 grok-imagine-2.0-ext,n 最多 12,不接受参考图。本示例不带 X-APIMart-Response-Version 请求头,提交返回 HTTP 200,任务 ID 在 data[0].task_id;文档示例带了该请求头,返回 HTTP 202,任务 ID 在 data.id。
把上面创建的密钥保存到环境变量 APIMART_API_KEY,并在每个请求中以 Authorization: Bearer <key> 发送。
POST /v1/images/generations,传入 model grok-imagine-image-2.0、提示词、aspect_ratio、resolution、quality 和 n。编辑图片时加上 image_urls 并去掉 quality。任务 ID 在 data[0].task_id。
轮询 GET /v1/tasks/{task_id} 直到 status 为 completed,再从 data.result.images[0].url[0] 读取图片地址。结果保留 72 小时。任务失败不收费。
完整参数与返回字段见 Grok Imagine 2.0 API 文档。
curl -X POST https://api.apimart.ai/v1/images/generations \
-H "Authorization: Bearer $APIMART_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"model": "grok-imagine-image-2.0",
"prompt": "石质台面上的白色陶瓷杯极简产品摄影,柔和窗光,干净背景",
"n": 1,
"aspect_ratio": "16:9",
"resolution": "2k",
"quality": "medium"
}'import os
import time
import requests
API_BASE = "https://api.apimart.ai"
headers = {"Authorization": f"Bearer {os.environ['APIMART_API_KEY']}"}
# 1. Submit the generation task
payload = {
"model": "grok-imagine-image-2.0",
"prompt": "石质台面上的白色陶瓷杯极简产品摄影,柔和窗光,干净背景",
"n": 1,
"aspect_ratio": "16:9",
"resolution": "2k",
"quality": "medium"
}
resp = requests.post(f"{API_BASE}/v1/images/generations", headers=headers, json=payload, timeout=60)
resp.raise_for_status()
task_id = resp.json()["data"][0]["task_id"]
# 2. Poll the task until it finishes
for _ in range(200):
task_resp = requests.get(f"{API_BASE}/v1/tasks/{task_id}", headers=headers, timeout=30)
task_resp.raise_for_status()
task = task_resp.json()["data"]
if task["status"] == "completed":
print(task["result"]["images"][0]["url"][0])
break
if task["status"] == "failed":
raise RuntimeError(task.get("error", {}).get("message", "generation failed"))
time.sleep(3)
else:
raise TimeoutError(f"task {task_id} did not finish in time; continue GET polling with this task ID")curl -X POST https://api.apimart.ai/v1/images/generations \
-H "Authorization: Bearer $APIMART_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"model": "grok-imagine-image-2.0",
"prompt": "把产品放到晨光下的大理石厨房台面上,产品本身保持不变",
"n": 1,
"image_urls": [
"https://example.com/product.png"
]
}'TASK_ID="task_xxx" # replace with the task_id returned by the POST request
curl "https://api.apimart.ai/v1/tasks/$TASK_ID" \
-H "Authorization: Bearer $APIMART_API_KEY"| 参数 | 类型 | 必填 | 默认值 | 说明 |
|---|---|---|---|---|
model | string | 是 | 默认值: grok-imagine-image-2.0 | grok-imagine-image-2.0。同一个型号负责文生图和编辑。 |
prompt | string | 是 | 默认值: — | 图片描述;传了 image_urls 时为编辑指令。最多 8000 字符。 |
aspect_ratio | string | 否 | 默认值: auto | 画面比例:auto, 1:1, 3:4, 4:3, 9:16, 16:9, 2:3, 3:2, 9:19.5, 19.5:9, 9:20, 20:9, 1:2, 2:1。 |
resolution | string | 否 | 默认值: 1k | 输出分辨率:1k 或 2k。价格随分辨率和质量变化。 |
quality | string | 否 | 默认值: medium | 仅文生图:low 或 medium。传了 image_urls 时不要传该字段。 |
n | integer | 否 | 默认值: 1 | 生成张数,1–10。 |
image_urls | array | 否 | 默认值: — | 编辑用的参考图,1–3 张公网 HTTP(S) 地址。文生图请省略该字段。 |
nsfw_check | boolean | 否 | 默认值: false | 设为 true 时,提交任务前会审核提示词和输入图片。 |
根据 APIMart API 文档,本页 Ext 与官方型号支持的能力
根据文本为常见创意与产品流程生成视觉素材
配置访问权限、提交文生图任务并轮询结果
登录 APIMart 或创建账号,以访问控制面板。
在发送正式生成请求前,为账户余额充值。
生成 API Key,使用提示词提交 grok-imagine-image-2.0(即下方示例)或 grok-imagine-2.0-ext 请求,再通过返回的任务 ID 轮询图片 URL。
关于 Grok Imagine 2.0 API 的型号、价格、参数与结果
它是以接口方式调用 xAI 于 2026 年 8 月 7 日发布的图像模型 Grok Imagine 2.0。本页在 APIMart 提供两个型号:低价文生图、支持比例重绘、图层和选区编辑的 grok-imagine-2.0-ext,以及支持 1K / 2K 文生图和参考图编辑的官方 grok-imagine-image-2.0。
2026 年 10 月黄金会员价:Ext 文生图每张 $0.015(原价 $0.06),选区编辑每次 $0.015,图层提取免费。官方型号 1K low 每张 $0.032,1K medium 或 2K low 每张 $0.048,2K medium 每张 $0.064,参考图每张另加 $0.008。任务失败不收费,实时价格见价格表。
Ext 只支持文生图,单次返回 1–12 张,固定质量模式、7 种比例,另有比例重绘、图层和选区编辑。官方型号支持 1K 或 2K、low 或 medium 质量、auto 加 13 种比例、单次 1–10 张,以及最多三张参考图编辑。
Ext 的 n 可为 1 到 12 之间的任意整数,默认 1。官方型号支持 1 到 10 张。比例重绘和选区编辑每次请求返回一张图。
Ext 支持 1:1、2:3、3:2、3:4、4:3、9:16 和 16:9。官方型号使用 aspect_ratio,可选 auto(默认)加 13 种比例,包括 1:2 和 2:1。
Ext 使用固定的 resolution=quality 模式,也可以不传该字段。官方型号支持 1k 或 2k(默认 1k),文生图时 quality 可选 low 或 medium(默认 medium)。传了 image_urls 时不要再传 quality。
能。官方型号在 image_urls 中传入一到三张公网图片地址并写明编辑指令即可。Ext 可用比例重绘改变已完成图片的比例,或用选区编辑修改选中的区域。
图层提取会把已完成的 Ext 图片或一张上传图片免费拆成对象图层。选区编辑根据你选中的区域和提示词返回一张编辑后的图片,无论选了多少区域,都按完成的任务计费一次。
向 /v1/images/generations 提交请求,保存任务 ID,轮询 /v1/tasks/{task_id} 直到状态为 completed,再从结果中读取图片地址。结果保留 72 小时,请下载到自己的存储。
注册 APIMart,在控制台打开 API Keys 页面创建密钥。同一个密钥可调用两个 Grok Imagine 2.0 型号及平台上的所有其他模型,按量付费,无需订阅。
生图不免费:没有免费额度,按张或按次按量付费。图层提取免费,任务失败不收费,会员所有付费价格享 8 折或更低。
不会。根据 APIMart 服务条款,你的提示词和图片不会用于训练 AI 模型,除提供服务所必需外也不会与第三方共享。
探索同类型的其他模型。

Qwen Image 3.0 Pro
Qwen Image 3.0 Pro is the Pro version of Qwen Image 3.0, with clear instruction following, stable bilingual text rendering, 1K/2K output and image editing with up to 3 references.

Qwen Image 3.0
Qwen Image 3.0 is Alibaba's image model for text-to-image and editing with 1–3 reference images. It offers stable bilingual text rendering and dense layouts, in standard and Pro versions at 1K or 2K, up to 6 images per request.

Flux 2 Max
FLUX.2 Max delivers the highest output quality in the FLUX.2 family for text-to-image and image editing, supporting up to 8 references and output up to 4 MP.

Nano banana
Nano Banana (gemini-2.5-flash-image-preview) is Google DeepMind's fast, conversational image generation and editing model. It delivers natural-language text-to-image, precise multi-turn edits, strong character consistency, and multi-image fusion at low latency.