Skip to content

Grok Imagine Image 2.0 图片编辑 ​

接口 ​

POST /images/generations

完整 URL: https://modelfold.ai/v1/images/generations

鉴权:所有请求都需要 Authorization: Bearer <API_KEY> 请求头。

模型参数直接放在 JSON 请求体中,不要套 input。请求等待生成完成后返回 data[].url;支持的媒体模型也可使用 异步创建、轮询及回调。示例素材地址须替换为自己的公开可访问文件。计费及错误说明见 API 网关。

生成任务的输入参数

请求参数 ​

请求体 (application/json) ​

参数类型必填说明
modelstring是用于生成的模型名称。必填字段。
- 对于此端点,必须为 grok-imagine-image-2-0/image-edit 默认值:"grok-imagine-image-2-0/image-edit"。 可选值:grok-imagine-image-2-0/image-edit。 示例:grok-imagine-image-2-0/image-edit。
promptstring是本站网关要求传入 prompt,最长 2000 字。指定生成图像的所需内容或样式的文本描述。最长 8000 字符。 maxLength: 2000. 示例:Recreate the Titanic movie poster with two adorable anthropomorphic cats in the same romantic pose at the bow of the ship. The male cat is an orange tabby wearing a vest, standing behind a white long-haired female cat in a lace dress, holding her paws as they stretch forward in the wind. Both cats are photorealistic with detailed fur, wind-swept hair, and dramatic sunset lighting (warm golden highlights, cool blue shadows). Background: the Titanic ship at dusk with four smokestacks, glowing deck lights, calm ocean, and orange-pink sunset sky. Center title: “CATANIC” in the same gold metallic serif style as Titanic, same size and position.。
aspect_ratiostring是指定生成图像的宽高比。控制输出的宽高比例。此字段为必填项。 可选值:1:1 / 2:3 / 3:2 / 16:9 / 9:16 / auto。 示例:1:1。
image_urlsarray&lt;string&gt;是包含最多5张,最少1张指向参考图像的 URL 字符串的数组。 maxItems: 5.

请求示例 ​

bash
curl -X POST "https://modelfold.ai/v1/images/generations" \
  -H "Authorization: Bearer $MODELFOLD_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
  "model": "grok-imagine-image-2-0/image-edit",
  "aspect_ratio": "1:1",
  "image_urls": [
    "https://example.com/reference.png"
  ],
  "prompt": "Recreate the Titanic movie poster with two adorable anthropomorphic cats in the same romantic pose at the bow of the ship. The male cat is an orange tabby wearing a vest, standing behind a white long-haired female cat in a lace dress, holding her paws as they stretch forward in the wind. Both cats are photorealistic with detailed fur, wind-swept hair, and dramatic sunset lighting (warm golden highlights, cool blue shadows). Background: the Titanic ship at dusk with four smokestacks, glowing deck lights, calm ocean, and orange-pink sunset sky. Center title: “CATANIC” in the same gold metallic serif style as Titanic, same size and position."
}'
json
{
  "model": "grok-imagine-image-2-0/image-edit",
  "aspect_ratio": "1:1",
  "image_urls": [
    "https://example.com/reference.png"
  ],
  "prompt": "Recreate the Titanic movie poster with two adorable anthropomorphic cats in the same romantic pose at the bow of the ship. The male cat is an orange tabby wearing a vest, standing behind a white long-haired female cat in a lace dress, holding her paws as they stretch forward in the wind. Both cats are photorealistic with detailed fur, wind-swept hair, and dramatic sunset lighting (warm golden highlights, cool blue shadows). Background: the Titanic ship at dusk with four smokestacks, glowing deck lights, calm ocean, and orange-pink sunset sky. Center title: “CATANIC” in the same gold metallic serif style as Titanic, same size and position."
}

响应 ​

200 — 生成完成。usage 返回实际计费明细;结果地址仅作结构示例。 ​

json
{
  "ok": true,
  "created": 1792134000,
  "data": [
    {
      "url": "https://modelfold.ai/uploads/outputs/result.png"
    }
  ],
  "usage": {}
}

ModelFold — 一个 API,接入所有主流 AI 模型。