Felo API PlatformFelo API Platform
返回模型列表

Grok Imagine Image 2.0 API

xAI 推出的新一代圖像生成與編輯模型,主打精準編輯工具與競技場排名第二的表現。

Grok Imagine Image 2.0 是 xAI 於 2026 年 8 月 7 日發布的新一代圖像生成與編輯模型,可接受文字、圖像與 PDF 輸入並輸出圖像。它支援 1K 與 2K 解析度、1:1、16:9、9:16、3:4、3:2、2:3 等長寬比,單次請求可產生 1 至 10 張圖像,並提供低、中兩種品質模式。

在編輯方面,模型提供魔術棒、分割、背景移除與智慧縮放等工具,可針對圖像中的特定區域進行局部修改,並支援最多 5 張參考圖的多參考編輯。它對複雜多元素提示詞的指令遵循能力強,且能在反覆編輯與生成之間維持一致性,適合需要精準版面控制的專業設計流程。

典型應用包含品牌一致性行銷素材的大量變體製作、產品合成圖與廣告創意、需要反覆小幅修改的迭代式內容創作,以及機密或商業創意專案與遊戲美術概念設計。模型已整合進 Grok 應用程式作為品質模式,並與 X 連結。

更新時間:

模型 ID

grok-imagine-image-2.0
輸入
text / image
輸出
image

核心要點

  • 魔術棒與分割等精準編輯工具
  • 單次請求可產生 1 至 10 張圖像
  • 最多 5 張參考圖的多參考編輯
  • 支援 1K 與 2K 解析度
  • 競技場圖像生成與編輯排名第二
  • 整合進 Grok 應用程式品質模式

供應商

最優價格
2 個供應商

比較不同供應商的呼叫價格,點擊供應商可查看完整費用和適用條件。

供應商 · 計費明細
可用率
$0.08
$0.08$0.032

基準測試

  • Arena 圖像生成排行榜

    全球排名

    第 2 名
  • Arena 圖像編輯排行榜

    全球排名

    第 2 名
  • ImageBench V1 整體

    滿分 100

    75
  • ImageBench V1 文字渲染

    滿分 100

    100
  • ImageBench V1 人類真實感

    滿分 100

    55

分數來自模型廠商公布的資料,未經獨立驗證。

快速开始

提交圖片任務、輪詢狀態,再儲存圖片。以下範例使用 curl 和 Python 3(僅標準函式庫,無須安裝依賴)。

POST https://openapi.felo.ai/api/v1/images/generations

1填入 API key

從 Felo API Platform 帳戶建立 key,並設定為環境變數。

export FELO_API_KEY="YOUR_API_KEY"

2發出第一次請求

選用參數的值依模型而異,範例不預設這些值;加入前請在 Playground 確認。請求欄位與 model、prompt 同層,不包在 input 中。

curl --fail-with-body --max-time 60 "https://openapi.felo.ai/api/v1/images/generations" \
  -H "Authorization: Bearer $FELO_API_KEY" \
  -H "Content-Type: application/json" \
  -o created.json \
  -d '{
  "prompt": "A studio product photo of a ceramic coffee cup on warm linen, soft morning light",
  "model": "grok-imagine-image-2.0"
}'

3輪詢任務

提交後取得 task_id;queued、running 時每 3 秒查詢一次,succeeded、failed 或 interrupted 時停止。範例最多等待 30 分鐘。保留 created.json 可繼續查詢同一任務,避免重複提交。

python3 - <<'PY'
import json, os, time
from pathlib import Path
from urllib.parse import quote
from urllib.request import Request, urlopen

task = json.loads(Path("created.json").read_text())
task_id = task["task_id"]
url = "https://openapi.felo.ai/api/v1/images/generations/" + quote(task_id, safe="")
headers = {"Authorization": "Bearer " + os.environ["FELO_API_KEY"]}
deadline = time.monotonic() + 1800

while task["status"] in ("queued", "running"):
    if time.monotonic() >= deadline:
        raise TimeoutError(f"Keep task_id={task_id} to resume polling")
    time.sleep(3)
    with urlopen(Request(url, headers=headers), timeout=60) as response:
        task = json.load(response)
    if task.get("task_id") != task_id or task.get("kind") != "image":
        raise ValueError("Unexpected task response")
    print(task["status"])

if task["status"] != "succeeded":
    raise RuntimeError(task.get("error") or task["status"])
if not task.get("outputs"):
    raise ValueError("Task succeeded without image outputs")
Path("task.json").write_text(json.dumps(task))
print("Saved task.json")
PY

4下載輸出

成功後從 task.json 讀取 outputs 並儲存。結果相容 HTTPS 位址、URL 物件和 b64_json。簽名位址請及時下載;下載圖片時無須攜帶 API Key。

python3 - <<'PY'
import base64, json
from pathlib import Path
from urllib.request import urlopen

task = json.loads(Path("task.json").read_text())
if task.get("status") != "succeeded" or not task.get("outputs"):
    raise ValueError("No completed image outputs")
extensions = {"image/png": ".png", "image/jpeg": ".jpg", "image/webp": ".webp", "image/gif": ".gif", "image/avif": ".avif"}

for index, output in enumerate(task["outputs"], 1):
    item = output if isinstance(output, dict) else {}
    url = output if isinstance(output, str) else item.get("url") or item.get("unsigned_url")
    mime = item.get("media_type") or "image/png"
    if url and url.startswith("https://"):
        with urlopen(url, timeout=60) as response:
            data = response.read()
            mime = response.headers.get_content_type()
    elif url and url.startswith("data:image/") and ";base64," in url:
        header, encoded = url.split(",", 1)
        mime = header[5:].split(";", 1)[0]
        data = base64.b64decode(encoded, validate=True)
    elif item.get("b64_json"):
        data = base64.b64decode(item["b64_json"], validate=True)
    else:
        raise ValueError("Unrecognized image output")
    path = Path(f"image-{index}" + extensions.get(mime, ".bin"))
    path.write_bytes(data)
    print(path)
PY
input_references

編輯圖片時,將範例位址替換為你的 HTTPS 圖片位址或 base64 圖片 data URL。提交一次後,沿用相同的輪詢與儲存步驟。

curl --fail-with-body --max-time 60 "https://openapi.felo.ai/api/v1/images/generations" \
  -H "Authorization: Bearer $FELO_API_KEY" \
  -H "Content-Type: application/json" \
  -o created.json \
  -d '{
  "prompt": "Keep the product and framing. Replace the background with a sunlit marble countertop.",
  "model": "grok-imagine-image-2.0",
  "input_references": [
    {
      "type": "image_url",
      "image_url": {
        "url": "https://example.com/product.png"
      }
    }
  ]
}'

支援的參數

  • n
  • quality
  • resolution
  • aspect_ratio
  • input_references

想查看完整文件?

API 文件 →

常見問題

什麼是 Grok Imagine Image 2.0?

Grok Imagine Image 2.0 是 xAI 於 2026 年 8 月 7 日發布的新一代圖像生成與編輯模型,可接受文字、圖像與 PDF 輸入並輸出圖像。它支援 1K 與 2K 解析度、1:1、16:9、9:16、3:4、3:2、2:3 等長寬比,單次請求可產生 1 至 10 張圖像,並提供低、中兩種品質模式。 在編輯方面,模型提供魔術棒、分割、背景移除與智慧縮放等工具,可針對圖像中的特定區域進行局部修改,並支援最多 5 張參考圖的多參考編輯。它對複雜多元素提示詞的指令遵循能力強,且能在反覆編輯與生成之間維持一致性,適合需要精準版面控制的專業設計流程。 典型應用包含品牌一致性行銷素材的大量變體製作、產品合成圖與廣告創意、需要反覆小幅修改的迭代式內容創作,以及機密或商業創意專案與遊戲美術概念設計。模型已整合進 Grok 應用程式作為品質模式,並與 X 連結。

如何計算呼叫費用?

費用取決於你使用的供應商、對應價格和實際用量。長文字輸入等情況可能適用不同價格,詳見計費明細。

這個模型支援哪些輸入與輸出格式?

支援文字、圖像與 PDF 輸入,輸出為圖像。可搭配最多 5 張參考圖進行多參考編輯。

上下文與輸出長度是多少?

上下文長度為 65,536 tokens,輸出上限為 58,982 tokens。

它適合哪些任務?

適合需要精準編輯與版面控制的專業設計、品牌一致性行銷素材、產品合成圖與廣告創意,以及反覆小幅修改的迭代創作。

它與同系列模型有何差別?

同系列包含 Grok Imagine Image 2.0、Grok Imagine Image 與 Grok Imagine Image 2,各自適合的場景不同,2.0 為新一代圖像生成與編輯模型。

有什麼限制?

最高解析度僅 2K,且為專有模型,無法自行部署或微調。部分使用者評論指出 GPT Image 在非標準角色風格化與審查寬鬆度上表現更好。