xAI: Grok Imagine Image 2.0
x-ai/grok-imagine-image-2.0Grok Imagine Image 2.0 是 xAI 推出的图像生成与编辑模型。它适用于根据文本提示创建图像以及根据参考编辑图像,具有低和...
- 模态
- text+image->image
- 价格
- $0.01 / 张
- 上下文
- 66K
- 上架
- 2026年8月11日
- 知识截止
- —
接入
请求都从 InfAPI 这一处进入。一把密钥可以调用目录里的全部模型。上游分组、倍率和分档不在这里展示。
| 接入点 | 输入 | 输出 | 上下文 | 状态 |
|---|---|---|---|---|
| InfAPI | $0.01 / 张 | — | 66K | 可调用 |
- 输入
- 文本, 图像
- 输出
- 图像
- 分词器
- Grok
- 最大输出
- 58,982
- 接口
- 图像
价格
下面是这个模型在本网关的标价。Token 价格按每百万 tokens 显示。
| 项目 | 价格 | 单位 |
|---|---|---|
| 输入prompt | $0 | 每百万 tokens |
| 输出completion | $0 | 每百万 tokens |
| 图像image | $0.01 | 每张 |
| 图像 tokenimage_token | $9.58 | 每百万 tokens |
| 图像输出image_output | $9.58 | 每百万 tokens |
API
API
把提示词发到图像接口,响应里的图片是 base64。解码后保存即可。
发起第一次请求
使用 x-ai/grok-imagine-image-2.0
Python
import base64
import requests
response = requests.post(
"https://infapi.cc/v1/images",
headers={
"Authorization": "Bearer $INFAPI_API_KEY",
"Content-Type": "application/json",
},
json={
"model": "x-ai/grok-imagine-image-2.0",
"prompt": "A serene mountain landscape at sunset with dramatic clouds",
},
)
response.raise_for_status()
for index, image in enumerate(response.json().get("data", [])):
raw = base64.b64decode(image["b64_json"])
with open(f"output_{index}.png", "wb") as handle:
handle.write(raw)
print(f"Saved image {index + 1}")接口
POST https://infapi.cc/v1/images
Authorization: Bearer $INFAPI_API_KEY
使用第三方 SDK
OpenAI SDK 把 base_url 指到 https://infapi.cc/v1,密钥用 $INFAPI_API_KEY。上面的 HTTP 示例是这个网关的请求格式。
Python (OpenAI)
import base64
from openai import OpenAI
client = OpenAI(
base_url="https://infapi.cc/v1",
api_key="$INFAPI_API_KEY",
)
result = client.images.generate(
model="x-ai/grok-imagine-image-2.0",
prompt="A serene mountain landscape at sunset with dramatic clouds",
)
for index, image in enumerate(result.data):
raw = base64.b64decode(image.b64_json)
open(f"output_{index}.png", "wb").write(raw)支持的参数
logprobs对数概率
返回每个输出 token 的对数概率。
max_tokens输出上限
最多生成多少 token。达到上限会截断。
response_format响应格式
例如 json_object 或 json_schema,用于约束输出形状。
seed随机种子
固定种子有助于复现采样结果,不保证字节级一致。
temperature温度
采样温度。越低越稳定,越高越发散。常见范围 0 到 2。
top_logprobs候选对数概率
每个位置额外返回概率最高的若干候选。
top_p核采样
只在累计概率达到 top_p 的 token 里采样。
常见问题
这是什么模型?
Grok Imagine Image 2.0 是 xAI 推出的图像生成与编辑模型。它适用于根据文本提示创建图像以及根据参考编辑图像,具有低和...
费用是多少?
$0.01 / 张
支持哪些输入和输出?
text+image->image
什么时候上架的?
2026年8月11日