Ana içeriğe geç
xai avatarı

Grok Imagine Image API

xai/grok-imagine/image

Metin prompt’undan yüksek kaliteli görseller üretin; en-boy oranını seçin, standart ya da yüksek çözünürlüklü (2k) çıktı alın.

0.02

Model girdisi

Input

Text description of the desired image.

Aspect ratio (width:height) of the generated image.

Additional Settings

Customize your input with more control.

Min: 1 - Max: 4

The number of images to generate. Each generated image is billed.

Output resolution tier: 1k (standard) or 2k (high resolution).

The image file format of the output.

You need to be logged in to run this model and view results.
Log in

Model çıktısı

Output

Generated image output
Generated in 7.034 seconds
Logs (1 lines)

Örnek istekler

Örnekler

Example output 1Example output 2Example output 3Example output 4

Grok Imagine Image API

Grok Imagine Image is a text-to-image AI model by xai. On ModelRunner it runs through a REST API or via MCP from any AI assistant, at $0.02 per image.

POST https://queue.modelrunner.run/xai/grok-imagine/image

cURL

# Submit a request to the queue. Input fields go at the top level of the
# body. The optional reserved "metadata" object holds your own flat string
# tags — stored on the request, never sent to the model; filter later with
# GET https://queue.modelrunner.run/requests?metadata=<url-encoded JSON>.
curl -X POST https://queue.modelrunner.run/xai/grok-imagine/image \
  -H "Authorization: Key $MRUN_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "prompt": "a hand-lettered vintage travel poster for Kyoto in autumn, warm muted palette, bold legible typography",
    "num_images": 1,
    "resolution": "1k",
    "aspect_ratio": "16:9",
    "output_format": "jpeg",
    "metadata": {
      "project": "my-project"
    }
  }'
# → { "request_id": "...", "status_url": "...", "response_url": "..." }

# Poll status_url until "COMPLETED", then fetch the result
curl "https://queue.modelrunner.run/xai/grok-imagine/image/requests/$REQUEST_ID/status" \
  -H "Authorization: Key $MRUN_API_KEY"
curl "https://queue.modelrunner.run/xai/grok-imagine/image/requests/$REQUEST_ID" \
  -H "Authorization: Key $MRUN_API_KEY"

JavaScript

import { modelrunner } from "@modelrunner/client";

const result = await modelrunner.subscribe("xai/grok-imagine/image", {
  input: {
    "prompt": "a hand-lettered vintage travel poster for Kyoto in autumn, warm muted palette, bold legible typography",
    "num_images": 1,
    "resolution": "1k",
    "aspect_ratio": "16:9",
    "output_format": "jpeg"
  },
});
console.log(result);

Python

import os
import requests

headers = {"Authorization": f"Key {os.environ['MRUN_API_KEY']}"}

submitted = requests.post(
    "https://queue.modelrunner.run/xai/grok-imagine/image",
    headers=headers,
    json={
      "prompt": "a hand-lettered vintage travel poster for Kyoto in autumn, warm muted palette, bold legible typography",
      "num_images": 1,
      "resolution": "1k",
      "aspect_ratio": "16:9",
      "output_format": "jpeg"
    },
).json()

# Poll submitted["status_url"] until "COMPLETED", then:
result = requests.get(submitted["response_url"], headers=headers).json()

Input parameters

Input parameters of Grok Imagine Image
NameTypeRequiredDescription
promptstringyesText description of the desired image.
aspect_ratioenumnoAspect ratio (width:height) of the generated image. One of: 2:1, 20:9, 19.5:9, 16:9, 4:3, 3:2, 1:1, 2:3, 3:4, 9:16, 9:19.5, 9:20, 1:2. Default: "1:1".
num_imagesintegernoThe number of images to generate. Each generated image is billed. Default: 1.
resolutionenumnoOutput resolution tier: 1k (standard) or 2k (high resolution). One of: 1k, 2k. Default: "1k".
output_formatenumnoThe image file format of the output. One of: jpeg, png, webp. Default: "jpeg".

Machine-readable: OpenAPI schema · llms.txt

Use Grok Imagine Image from Claude & Cursor (MCP)

Point Claude Code, Claude Desktop, Cursor, or any MCP client at the ModelRunner MCP server and Grok Imagine Image becomes a tool your assistant can call directly — it authorizes via OAuth (no API key in config) and runs this model with the run_model tool using the endpoint xai/grok-imagine/image.

MCP client config (Claude Desktop, Cursor)

{
  "mcpServers": {
    "modelrunner": {
      "command": "npx",
      "args": ["-y", "mcp-remote", "https://mcp.modelrunner.run/mcp"]
    }
  }
}

Claude Code

claude mcp add --transport http modelrunner https://mcp.modelrunner.run/mcp

Then ask your assistant, for example: “Run xai/grok-imagine/image on ModelRunner to generate image”. MCP setup guide.

Model Detayları

Model Detayları

Grok Imagine Image, metin prompt’undan yüksek kaliteli görseller üretir. Sahneyi, stili, özneyi ve kompozisyonu doğal bir dille tarif edin; model bir ila dört görsel döndürür. Fotogerçekçi sahneler, illüstrasyon ve stilize sanat üretebilir, ayrıntılı ve çok parçalı prompt’ları izler; kadrajı (en-boy oranı) ve standart ya da yüksek çözünürlüklü çıktıyı seçmenize olanak tanır. Görselin içine yazılmasını istediğiniz metni prompt’a ekleyin.

## En uygun olduğu işler - Yazılı bir açıklamayı bitmiş bir görsele dönüştürmek (konsept çizim, ürün mockup’ları, pazarlama görselleri) - Ayrıntılı bir prompt’tan fotogerçekçi sahneler ve portreler - Tamamen metinle yönlendirilen illüstrasyon, dijital resim ve stilize sanat - Tek bir istekte aynı fikrin birkaç varyasyonunu üretmek (`num_images` en fazla 4) - En-boy oranı hazır ayarlarıyla yatay, dikey ya da kare sosyal medya ve banner formatları

## Şu durumlarda başka bir model seçin - Sıfırdan oluşturmak yerine mevcut bir görseli değiştirmek ya da yeniden tarzlamak istiyorsanız — bir görsel düzenleme modeli kullanın - Bir prompt’u ya da durağan bir görseli harekete geçirmeniz gerekiyorsa — bir text-to-video ya da image-to-video modeli kullanın - Raster görsel yerine vektör/SVG çıktı gerekiyorsa — bir vektörleştirme modeli kullanın

## İpuçları - Özne, mekân, ışık ve stil konusunda net olun; daha uzun ve yapılandırılmış prompt’lar daha güvenilir biçimde izlenir - `aspect_ratio` değerini hedef formata göre seçin (ör. banner’lar için `16:9`, story’ler için `9:16`, avatarlar için `1:1`) - Baskı ya da büyük ekranlar için daha fazla ayrıntı gerektiğinde `resolution` değerini `2k` yapın; `1k` daha hızlı olan standart kademedir - Birkaç denemeyi aynı anda karşılaştırmak için `num_images` değerini artırın — üretilen her görsel faturalanır

## Gelişmiş Yapılandırma - `output_format` dosya türünü seçer: `jpeg` (varsayılan, en küçük), `png` (kayıpsız) ya da `webp` (şeffaflık destekli, kompakt).

ModelRunner JavaScript client ile çalıştırmak için: ```js import { modelrunner } from "@modelrunner/client";

const result = await modelrunner.subscribe("xai/grok-imagine/image", { input: { prompt: "a red vintage bicycle leaning against a pastel blue wall, soft morning light", aspect_ratio: "16:9", resolution: "1k", num_images: 1, }, }); ```