Skip to content

Grok Imagine 2.0 Ext ​

grok-imagine-2.0-ext is xAI Grok Imagine text-to-image generation. This model supports generation only; do not send edit requests.

API surface ​

OperationEndpointMode
Image generationPOST /v1/images/generationsSync
Image generation taskPOST /v1/async/images/generationsAsync

Model ids ​

Model idBest for
grok-imagine-2.0-extText-to-image generation only

Pricing ​

Model idCredits / image
grok-imagine-2.0-ext2

Request fields ​

Send the common fields at the top level. Put the model-specific controls listed below inside providerOptions.

FieldTypeRequiredDescription
modelstringYesgrok-imagine-2.0-ext. Case-sensitive model ID.
promptstringYesDescribe the subject, composition, style, and requested edits. Pixapi keeps the first 2,000 characters; provide a non-empty prompt for both generation and editing.
nintegerNoDefault 1; 1–9 on Pixapi (maximum 12).
sizestringNoAspect ratio: 1:1, 2:3, 3:2, 3:4, 4:3, 9:16, 16:9; the pixel aliases 1024x1024, 1024x1792, 1792x1024, 720x1280, 1280x720 are also accepted. Actual returned pixels may differ for the same ratio. No auto.
providerOptionsobjectNoModel-specific options; see the table below.

providerOptions ​

All fields in this table are nested inside providerOptions, not alongside model.

FieldTypeDescription
nsfw_checkbooleanOptional prompt/image moderation; default false.
response_formatstringOnly url (default).

Input rules ​

Text-to-image only. Omit quality and resolution.

Example ​

bash
curl https://api.pixapi.ai/v1/images/generations \
  -H "Authorization: Bearer $PIXAPI_KEY" \
  -H "Content-Type: application/json" \
  -d '{"model":"grok-imagine-2.0-ext","prompt":"A clean editorial product photo on a warm gray background","n":1,"size":"1024x1024"}'
py
import os
import requests

response = requests.post(
    "https://api.pixapi.ai/v1/images/generations",
    headers={
        "Authorization": f"Bearer {os.environ['PIXAPI_KEY']}",
        "Content-Type": "application/json",
    },
    json={
  "model": "grok-imagine-2.0-ext",
  "prompt": "A clean editorial product photo on a warm gray background",
  "n": 1,
  "size": "1024x1024"
},
)
response.raise_for_status()
print(response.json())
js
const response = await fetch('https://api.pixapi.ai/v1/images/generations', {
  method: 'POST',
  headers: {
    Authorization: `Bearer ${process.env.PIXAPI_KEY}`,
    'Content-Type': 'application/json',
  },
  body: JSON.stringify({
  "model": "grok-imagine-2.0-ext",
  "prompt": "A clean editorial product photo on a warm gray background",
  "n": 1,
  "size": "1024x1024"
}),
});

if (!response.ok) {
  throw new Error(await response.text());
}

console.log(await response.json());
go
package main

import (
  "bytes"
  "fmt"
  "io"
  "net/http"
  "os"
)

func main() {
  body := []byte(`{
  "model": "grok-imagine-2.0-ext",
  "prompt": "A clean editorial product photo on a warm gray background",
  "n": 1,
  "size": "1024x1024"
}`)

  req, err := http.NewRequest(
    "POST",
    "https://api.pixapi.ai/v1/images/generations",
    bytes.NewBuffer(body),
  )
  if err != nil {
    panic(err)
  }
  req.Header.Set("Authorization", "Bearer "+os.Getenv("PIXAPI_KEY"))
  req.Header.Set("Content-Type", "application/json")

  resp, err := http.DefaultClient.Do(req)
  if err != nil {
    panic(err)
  }
  defer resp.Body.Close()

  result, _ := io.ReadAll(resp.Body)
  fmt.Println(string(result))
}

For async requests and task polling, see Async Media Tasks.

For the shared response shape, see the API Reference.