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