Claude Opus 5.5 is live on SeedRouter

Image

Grok Imagine Image 2.0

View Markdown

Text-to-image and multi-image editing with Grok Imagine Image 2.0 via SeedRouter's asynchronous image task API — 1K, 1.5K, and 2K resolutions, low and medium quality tiers, 16 aspect ratios, up to 10 images per request, and up to 5 reference URLs.

Generate and edit images with Grok Imagine Image 2.0 (grok-imagine-image-2.0) through SeedRouter's asynchronous task API. Both text-to-image generation and single- or multi-image editing use POST /v1/images/generations and poll GET /v1/tasks/{id}.

Quick Examples

cURL

curl -X POST https://api.seedrouter.ai/v1/images/generations \
  -H "Authorization: Bearer $SEEDROUTER_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "model": "grok-imagine-image-2.0",
    "prompt": "An architectural photography poster for a coastal glasshouse at blue hour, crisp serif title text \"GLASS PAVILION\"",
    "n": 1,
    "aspect_ratio": "3:2",
    "resolution": "1k",
    "quality": "auto"
  }'

Python

import os
import time
import requests

api_key = os.environ["SEEDROUTER_API_KEY"]
headers = {"Authorization": f"Bearer {api_key}", "Content-Type": "application/json"}

submitted = requests.post(
    "https://api.seedrouter.ai/v1/images/generations",
    headers=headers,
    json={
        "model": "grok-imagine-image-2.0",
        "prompt": "Render <IMAGE_0> in a detailed architectural pencil sketch style",
        "image_urls": ["https://file.deepytb.com/example.png"],
        "resolution": "2k",
        "quality": "medium",
    },
    timeout=30,
)
submitted.raise_for_status()
task_id = submitted.json()["id"]

while True:
    poll = requests.get(
        f"https://api.seedrouter.ai/v1/tasks/{task_id}",
        headers={"Authorization": f"Bearer {api_key}"},
        timeout=30,
    )
    poll.raise_for_status()
    data = poll.json()
    if data["status"] == "completed":
        print([item["url"] for item in data["output"]["data"]])
        break
    if data["status"] == "failed":
        raise RuntimeError(data["error"])
    time.sleep(2)

JavaScript / TypeScript

const apiKey = process.env.SEEDROUTER_API_KEY!;
const headers = {
  Authorization: `Bearer ${apiKey}`,
  'Content-Type': 'application/json',
};

const submitRes = await fetch('https://api.seedrouter.ai/v1/images/generations', {
  method: 'POST',
  headers,
  body: JSON.stringify({
    model: 'grok-imagine-image-2.0',
    prompt: 'A minimalist ceramic pour-over kettle on limestone, soft morning light',
    n: 2,
    aspect_ratio: '16:9',
    resolution: '1.5k',
    quality: 'low',
  }),
});
const { id } = await submitRes.json();

while (true) {
  const pollRes = await fetch(`https://api.seedrouter.ai/v1/tasks/${id}`, {
    headers: { Authorization: `Bearer ${apiKey}` },
  });
  const task = await pollRes.json();
  if (task.status === 'completed') {
    console.log(task.output.data.map((item: { url: string }) => item.url));
    break;
  }
  if (task.status === 'failed') {
    throw new Error(task.error?.message ?? 'Task failed');
  }
  await new Promise((r) => setTimeout(r, 2000));
}

Go

package main

import (
	"bytes"
	"encoding/json"
	"fmt"
	"net/http"
	"os"
)

func main() {
	body, _ := json.Marshal(map[string]any{
		"model":        "grok-imagine-image-2.0",
		"prompt":       "A coastal glasshouse glowing at dusk, crisp photography",
		"aspect_ratio": "16:9",
		"resolution":   "1k",
		"quality":      "auto",
	})
	req, _ := http.NewRequest(http.MethodPost, "https://api.seedrouter.ai/v1/images/generations", bytes.NewReader(body))
	req.Header.Set("Authorization", "Bearer "+os.Getenv("SEEDROUTER_API_KEY"))
	req.Header.Set("Content-Type", "application/json")
	resp, err := http.DefaultClient.Do(req)
	if err != nil {
		panic(err)
	}
	defer resp.Body.Close()
	fmt.Println("HTTP", resp.StatusCode)
}

Endpoint & Authentication

  • Submit task: POST https://api.seedrouter.ai/v1/images/generations
  • Poll task: GET https://api.seedrouter.ai/v1/tasks/{id}
  • Headers: Authorization: Bearer <YOUR_API_KEY> and Content-Type: application/json
  • Unified path: Do not send Grok Imagine Image 2.0 edit requests to /v1/images/edits — pass image_urls on POST /v1/images/generations instead.

Request Parameters

ParameterTypeRequiredDefaultConstraints & Notes
modelstringYes—Must be "grok-imagine-image-2.0" (or grok-imagine-image-2.0:<tier> when selecting an explicit tier).
promptstringYes—1–10,000 Unicode characters after trimming. For multi-image editing, reference inputs as <IMAGE_0>, <IMAGE_1>, up to <IMAGE_4>.
image_urlsstring[]No—1–5 public HTTP(S) image URLs (JPEG, PNG, or WebP, up to 20 MiB each). Base64 strings and data: URIs are rejected.
nintegerNo1Number of output images to generate (1–10).
aspect_ratiostringNo"auto"One of auto, 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, 21:9, 5:2.
resolutionstringNo"1k"Output resolution tier: "1k", "1.5k", or "2k".
qualitystringNo"auto""auto", "low", or "medium". "auto" serves "low" for text-to-image generation and "medium" for image editing.
userstringNo—Optional end-user identifier (up to 256 characters). Available via API only; not exposed in the web Playground.

Parameters Intentionally Excluded

  • response_format and deferred: SeedRouter always runs asynchronous task polling and returns hosted output URLs.
  • output (upload_urls) and storage_options / file_id: SeedRouter manages result hosting and accepts public HTTP(S) reference URLs.

Modes & Media Constraints

  • Text-to-image: Omit image_urls. Default aspect_ratio: "auto" lets the model pick the framing suited to the prompt.
  • Single-image editing: Provide 1 URL in image_urls. With aspect_ratio: "auto" (or omitted), the output preserves the input image's framing.
  • Multi-image editing: Provide 2–5 URLs in image_urls and reference them by zero-based index (<IMAGE_0>, <IMAGE_1>, ...) in prompt.
  • Input limits: Public HTTP(S) URLs only (no embedded credentials or private hosts), JPEG/PNG/WebP format, maximum 20 MiB per reference image.

Billing Dimensions

Grok Imagine Image 2.0 is billed per delivered output image according to effective quality (low or medium) and resolution (1k, 1.5k, or 2k), plus a per-image fee for each input reference image in image_urls starting from the first reference.

  • When quality is "auto" (or omitted), text-to-image requests are billed at low and image-editing requests are billed at medium.
  • If fewer than n images are delivered, you are settled only for the images actually delivered plus your input references.
  • Failed requests are not charged.
  • Live per-tier USD rates are published on the Grok Imagine Image 2.0 page and GET https://api.seedrouter.ai/v1/pricing.

Task Response & Polling

Submitting returns HTTP 200:

{
  "id": "task_0123456789abcdef0123456789abcdef",
  "model": "grok-imagine-image-2.0",
  "status": "processing",
  "created_at": 1795600000
}

Polling GET /v1/tasks/{id} returns processing, completed, or failed:

{
  "id": "task_0123456789abcdef0123456789abcdef",
  "model": "grok-imagine-image-2.0",
  "status": "completed",
  "output": {
    "data": [
      { "url": "https://file.deepytb.com/media/tasks/task_.../0.jpg" }
    ]
  }
}

Errors

All request and task failures use SeedRouter's unified error envelope ({"error": {"code": <integer>, "message": "..."}}). See the Error Reference for full code definitions and retry guidance.

Tips

  • Pin quality: "low" on editing jobs if you want lower per-image cost instead of the "auto" default (medium for edits).
  • For poster layouts or typography, specify exact quoted text and placement in prompt, and prefer 1.5k or 2k for fine lettering.
  • When combining multiple photos, reference each image explicitly (<IMAGE_0>, <IMAGE_1>) so composition and identity stay predictable.