Grok
使用 Grok 生成图像
使用 JSON 请求生成 Grok 图像,并支持宽高比控制、分辨率控制以及 URL 或 Base64 输出。
POST
使用此路由通过 Grok 图像模型根据文本创建图像。请求正文使用
application/json。
该请求支持 model、prompt、n、aspect_ratio、resolution 和 response_format。
选择模型
从 模型页面中选择一个 Grok 图像模型 ID。API 示例使用grok-imagine-image-quality。
配置输出
- 使用
aspect_ratio选择输出形状,或使用auto让模型选择形状。 - 使用
resolution请求1k或2k输出。 - 使用
n最多请求 10 张图像。 - 使用
response_format返回临时 URL 或 Base64 编码的图像数据。
请求完成后下载 URL 结果。生成的图像 URL 可能会过期。
授权
Use your CometAPI API key as the bearer value.
请求体
application/json
The Grok image model ID. See the Models page for available model IDs.
可用选项:
grok-imagine-image, grok-imagine-image-quality 示例:
"grok-imagine-image-quality"
A text description of the image to generate.
Minimum string length:
1示例:
"A glass observatory above a quiet alpine lake at sunrise"
The number of images to generate. Use an integer from 1 through 10.
必填范围:
1 <= x <= 10The output shape. Use auto to let the model select the aspect ratio.
可用选项:
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, auto 示例:
"16:9"
The requested output resolution.
可用选项:
1k, 2k 示例:
"1k"
The image representation in each response item. Use url for a temporary download URL or b64_json for Base64-encoded image bytes.
可用选项:
url, b64_json