Appearance
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
| Operation | Endpoint | Mode |
|---|---|---|
| Image generation | POST /v1/images/generations | Sync |
| Image generation task | POST /v1/async/images/generations | Async |
Model ids
| Model id | Best for |
|---|---|
grok-imagine-2.0-ext | Text-to-image generation only |
Pricing
| Model id | Credits / image |
|---|---|
grok-imagine-2.0-ext | 2 |
Request fields
Send the common fields at the top level. Put the model-specific controls listed below inside providerOptions.
| Field | Type | Required | Description |
|---|---|---|---|
model | string | Yes | grok-imagine-2.0-ext. Case-sensitive model ID. |
prompt | string | Yes | Describe the subject, composition, style, and requested edits. Pixapi keeps the first 2,000 characters; provide a non-empty prompt for both generation and editing. |
n | integer | No | Default 1; 1–9 on Pixapi (maximum 12). |
size | string | No | Aspect 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. |
providerOptions | object | No | Model-specific options; see the table below. |
providerOptions
All fields in this table are nested inside providerOptions, not alongside model.
| Field | Type | Description |
|---|---|---|
nsfw_check | boolean | Optional prompt/image moderation; default false. |
response_format | string | Only 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.
