xAI Grok Imagine 影像生成模型,可根據文字描述建立圖片,適用於創意插畫、視覺素材和概念設計。
grok-imagine-imagegrok-imagine-image:影像生成,含必填項、巢狀響應和虛構示例。
必填參數: model, prompt
可用參數: model, prompt, n, size, response_format
| 參數 | 類型 | 必填 | 說明 |
|---|---|---|---|
model | string | 是 | 精確型號;僅使用本頁名稱,不用顯示別名替代。 可選: grok-imagine-image |
prompt | string | 是 | 影像描述;編輯場景應描述期望的修改。 |
n | integer | 否 | 生成張數,例子為1張。 |
size | string | 否 | 影像規格,允許值依本型號。 |
response_format | string | 否 | 結果返回方式。 可選: url / b64_json |
curl --request POST https://api.router.ai/v1/images/generations \
--header "Authorization: Bearer $API_KEY" \
--header "Content-Type: application/json" \
--data-raw '{
"model": "grok-imagine-image",
"prompt": "A fictional blue paper boat on a plain white background."
}'使用參考圖和編輯指令生成修改後的圖片;支援 JSON 或檔案上傳。
必填參數: model, prompt, image
可用參數: model, prompt, image, images, image_url, n, response_format, stream, aspect_ratio, size
| 參數 | 類型 | 必填 | 說明 |
|---|---|---|---|
model | string | 是 | 必填,精確使用 grok-imagine-image。 |
prompt | string | 是 | 編輯指令,1~32000 字元;請直接說明需要修改的內容。 |
image | string | object | array | 是 | 必填參考圖。可用 HTTPS 地址、圖片 data URL、{"url":"..."}、{"image_url":"..."} 或上述元素陣列。1~5 張;與 images、image_url 三選一。 |
images | array | 否 | image 的可選別名;元素為地址、圖片 data URL 或含 url/image_url 的物件。不能同時傳 image。 |
image_url | string | object | array | 否 | image 的可選別名;不能與 image、images 同時傳入。 |
n | integer | 否 | 可選,預設 1,必須為正整數。多圖數量須在本型號支援範圍內。 |
response_format | string | 否 | 可選,url 或 b64_json。具體支援和返回形式以本型號為準。 |
stream | boolean | 否 | 僅支援省略或 false;本編輯入口不提供流式響應。 |
aspect_ratio | string | 否 | 可選畫面比例,示例 1:1;服務端決定支援的比例。 |
size | string | 否 | 可選相容尺寸:auto、1024x1024、1536x1024、1024x1536、1792x1024、1024x1792,分別對應自動、1:1、3:2、2:3、16:9、9:16;與 aspect_ratio 不得衝突。 |
curl https://api.router.ai/v1/images/edits \
-H "Authorization: Bearer $API_KEY" \
-H "Content-Type: application/json" \
-d '{
"model": "grok-imagine-image",
"prompt": "将示例陶瓷杯改为蓝色,保留背景。",
"image": "https://example.invalid/reference.png",
"n": 1
}'