Skip to main content
xai/grok-imagine-image-2.0 的 API 参考,该模型由 Comfy Router 从 xAI 提供。

快速开始

你的 Comfy 工作区中创建密钥,并将其导出为 COMFY_API_KEY。Python 和 TypeScript 代码片段使用 Comfy SDK(pip install comfy-sdknpm install @comfyorg/sdk);cURL 代码片段是通过原始 HTTP 进行的相同调用。 模型 ID: xai/grok-imagine-image-2.0 端点: POST https://api.comfy.org/v2/models/xai/grok-imagine-image-2.0

Schema

输入

string
默认值:"\"auto\""
已生成图像的宽高比。默认为 auto,即根据提示词自动选择最佳比例。可选值:1:13:44:39:1616:92:33:29:19.519.5:99:2020:91:22:1auto
string
默认值:"\"grok-imagine-image\""
要使用的模型。支持:grok-imagine-image(默认)、grok-imagine-image-pro、grok-imagine-image-quality、grok-imagine-image-2.0。已弃用的 -beta 标识会作为别名指向其 GA 模型。
integer
默认值:"1"
要生成的图像数量范围:110
string
必填
用于图像生成的提示词
string
输出图像的质量。对于 grok-imagine-image-2.0,此项用于选择价格档位(low/medium;medium 为默认值);其他模型目前会忽略此项。可选值:lowmediumhigh
string
默认值:"\"1k\""
已生成图像的分辨率。默认为 1k。可选值:1k2k
string
默认值:"\"url\""
返回图像的响应格式。可以是 url 或 b64_json。Comfy Router(POST /v2/models/xai/{model})会在出站请求中将其强制转换为 url,因为无论哪种格式它都以重新托管的 URL 提供图像结果;而此 /proxy/ 路由会按原样处理。 可选值:urlb64_json
string
图像尺寸(不支持)
string
图像风格(不支持)
string
代表你的最终用户的唯一标识符,可帮助 xAI 监控和检测滥用行为
根据 Router 在 GET /v2/models/xai/grok-imagine-image-2.0/openapi.json 提供的 schema 生成,这与它在请求到达提供商之前用于校验调用的文档相同。

输出

string
如果请求被输入审核拦截,则包含拦截原因
object[]
已生成图像对象的列表
string
已生成图像的 base64 编码字符串表示(jpeg 编码)(如果 response_format 为 b64_json)
string
已生成图像的 MIME 类型(例如 image/png、image/jpeg、image/webp)。
string
已生成图像的 url(如果 response_format 为 url)
object
图像生成请求的使用信息
integer
此请求的准确费用,单位为 USD ticks(10,000,000,000 ticks = 1 USD)

示例

输入

输出

发布前须知

SDK 会生成 Idempotency-Key 并在自动重试中复用它。手动重试时,请复用原始 key。Router 最长可保持连接 10 分钟。 请求失败时,Router 会发送 X-Comfy-Error-Type 响应头说明原因。422 表示 Router 在调用提供商之前就拒绝了输入。生成的资源请及时下载,因为结果链接会过期

请求头

身份验证、幂等性、请求 ID、错误分类、重试节奏、消费限额。

使用 Router API

模型发现、校验错误、重试与计费。

限制

Router 目前不支持的功能,以及替代方案。