xAIImage modelChecking
Grok Imagine 2.0 API
xai-grok-imagine-2-0-text-to-image-economyGrok Imagine Image 2.0 text-to-image generation.
- Text to image
- Up to 12 images per request
Run Grok Imagine 2.0 in the playground
The form is the request body: every field shows its key. Sign in to run it; a run is billed like an API task.
Parameters
modelGrok Imagine 2.0xai-grok-imagine-2-0-text-to-image-economy
Credits are reserved when a task is accepted and charged only on success. Failed tasks release the reservation; unconfirmed outcomes remain reserved until verified.
Request preview
{"model": "xai-grok-imagine-2-0-text-to-image-economy","input": {"aspectRatio": "1:1","numImages": "1"}}The web playground sends this body with your signed-in session. From code, send the same body with an API key.
Result
Run the request and the result appears here, with its status and cost.
Grok Imagine 2.0 pricing
Prices are shown in USD for each available variant and specification. The billing unit is shown with its rate; an official reference appears only when a matching list price is published.
- Charged only on successOnly successful tasks are charged. Failed tasks release reserved credits; tasks with an unconfirmed outcome keep their reservation until the result is verified.
- Safe retriesIdempotent retries with the same key do not create a second charge.
- Price changesSend expectedPriceMicros to reject the task with PRICE_CHANGED if the price changed after you displayed it.
What Grok Imagine 2.0 can do
xAI describes Grok Imagine Image 2.0 as supporting image generation and editing with references on its own API. The Hermes catalog currently lists a text-to-image economy variant for this family; an image-editing endpoint should not be assumed from the manufacturer's product page.
The Hermes request lists a prompt, aspect ratio and image-count field. Check the selected variant's allowed values, current status and price before sending a task. The native xAI API's pricing and input limits do not automatically apply to this channel.
Capabilities
7 aspect ratios
1:1, 2:3, 3:2, 3:4, 4:3, 9:16 or 16:9.
aspectRatioEvery variant
Up to 12 images per request
Ask for several results in one task.
numImagesEvery variant
Use cases
Explore a visual idea
Describe the subject, composition and style in a prompt.
Create image variations
Use the image-count setting within the selected variant's limits.
Fit a placement
Choose a supported aspect ratio for the output.
Call Grok Imagine 2.0 from code
Every image, video and music model uses the same asynchronous job API: submit a task, then poll for the result.
- 1
Create an API key
In the dashboard, with the jobs:create and jobs:read scopes. API keys - 2
Submit a task
POST /api/v1/jobswith the model ID and an input object. The response is 202 with a task ID. - 3
Poll for the result
GET /api/v1/jobs/{id}until the status is succeeded, then download the output URLs.
Minimal request
Required fields only, generated from the schema of Text to image. Set HERMES_API_KEY in your environment.
- Model ID
xai-grok-imagine-2-0-text-to-image-economy- Endpoint
https://api.hermes-ai.net/api/v1/jobs
# 1. Submit the task (asynchronous; returns 202 with a task id)
curl -X POST https://api.hermes-ai.net/api/v1/jobs \
-H "Authorization: Bearer $HERMES_API_KEY" \
-H "Content-Type: application/json" \
-H "Idempotency-Key: $(uuidgen)" \
-d '{
"model": "xai-grok-imagine-2-0-text-to-image-economy",
"input": {
"prompt": "A lighthouse on a rocky coast at sunrise, soft light",
"numImages": "1"
}
}'
# 2. Poll until status is succeeded, failed or reconciliation_required
curl https://api.hermes-ai.net/api/v1/jobs/TASK_ID \
-H "Authorization: Bearer $HERMES_API_KEY"Input parameters
Fields of Text to image (xai-grok-imagine-2-0-text-to-image-economy). Unknown fields are rejected with INVALID_MODEL_INPUT.
| Field | Type | Required | Default | Allowed values and constraints |
|---|---|---|---|---|
prompt | string | required | — | ≤ 4000 chars |
aspectRatio | string | optional | "1:1" | Output image aspect ratio (API size whitelist). One of: |
numImages | string | required | "1" | Number of images to generate (1–12). Billed by successfully delivered images. One of: |
Headers, response, task statuses and errors
| Header | Value | Notes |
|---|---|---|
Authorization | Bearer <API key> | Or send the key in x-api-key. |
Content-Type | application/json | |
Idempotency-Key | <unique string ≤128> | Required. Reuse it only to retry the identical request. |
| Field | Type | Notes |
|---|---|---|
id | string | Hermes AI task ID. Use it to poll. |
model | string | Model slug. |
status | string | See task statuses. |
errorCode | string | null | Set when a task fails or needs review. |
priceMicros | integer | Quote fixed at admission, USD micro-units. |
currency | "USD" | |
createdAt / updatedAt | string | ISO 8601 timestamps. |
assets[] | array | { id, type, url?, text? }. url is a same-origin /api/v1/results/<uuid> link. |
replayed | boolean | Submit only. true when an idempotent retry matched. |
| Status | Terminal | Meaning |
|---|---|---|
queued | no | Accepted and waiting for a worker. |
submitting | no | Being sent to the model provider. |
running | no | The model is generating. |
succeeded | yes | Finished. Results are in assets. |
failed | yes | Finished without a result. The hold is released. |
reconciliation_required | yes | The result is being verified. Keep the task ID and do not resubmit automatically. |
| HTTP | Code | Meaning and action |
|---|---|---|
401 | AUTH_REQUIRED | Missing or invalid API key or session. |
403 | INSUFFICIENT_SCOPE | The API key lacks the scope this endpoint needs. |
403 | PERMISSION_DENIED | This credential cannot perform the operation. |
429 | API_KEY_RATE_LIMITED | The API key's rate limit was reached. Honor Retry-After. |
429 | API_KEY_USAGE_EXCEEDED | The API key reached its usage limit. Create a new key. |
400 | INVALID_REQUEST | The body is not a JSON object or a required value is missing. |
400 | INVALID_IDEMPOTENCY_KEY | Idempotency-Key must be 1–128 printable ASCII characters. |
400 | INVALID_MODEL_INPUT | input does not match the model schema (unknown field, missing required field, or invalid value). |
400 / 413 | INPUT_TOO_LARGE | The request body is larger than 256 KB. Upload media first and send a media reference. |
404 | REQUEST_NOT_FOUND | No chat request with this ID belongs to your account. |
404 | MODEL_NOT_FOUND | No model has this slug. |
404 | JOB_NOT_FOUND | No task with this ID belongs to your account. |
409 | IDEMPOTENCY_CONFLICT | This Idempotency-Key was used with different input. Use a new key for a new request. |
409 | PRICE_CHANGED | The price differs from expectedPriceMicros. Fetch the price and confirm again. |
409 | MODEL_PRICE_UNAVAILABLE | No price is configured for this model yet, so it cannot run. |
409 | PAYMENT_REVIEW_REQUIRED | A refund left an uncovered balance. Contact support or cover the balance before submitting tasks. |
409 | INSUFFICIENT_CREDITS | Available credits do not cover the task price. |
429 | RATE_LIMITED | Too many task submissions per minute. Retry later. |
429 | EXPORT_RATE_LIMITED | Too many CSV exports this minute. Honor Retry-After. |
429 | CONCURRENCY_LIMITED | Too many unfinished tasks. Wait for one to finish. |
503 | EXECUTION_UNAVAILABLE | Execution is not configured for this model right now. |
429 | UPSTREAM_RATE_LIMITED | The model provider is rate limiting chat requests. Retry with backoff; nothing was charged. |
502 | UPSTREAM_ERROR | The model provider failed the chat request. Nothing was charged; retry later. |
503 | PLATFORM_BUDGET_EXCEEDED | This model is temporarily unavailable. Try again later. |
503 | EXECUTION_TEMPORARILY_UNAVAILABLE | Execution is temporarily unavailable. Retry with the same Idempotency-Key. |
503 | AUTH_UNAVAILABLE | Authentication is temporarily unavailable. Retry later. |
503 | API_UNAVAILABLE | The API is temporarily unavailable. Retry later. |
Grok Imagine 2.0 API FAQ
Answers built from the model's schema and the Hermes AI API contract.
Can I edit an existing image with this Hermes variant?
The currently listed Image 2.0 economy variant is text-to-image. xAI describes editing on its own API, but this page's Hermes schema does not list an image input.
What can the Grok Imagine 2.0 API do?
Grok Imagine 2.0 by xAI handles text to image. The catalog lists one variant with its own model ID and input schema. Check the current availability before sending a request.
Which durations, resolutions and aspect ratios does Grok Imagine 2.0 support?
Across its variants, Grok Imagine 2.0 supports aspect ratios 1:1, 2:3, 3:2, 3:4, 4:3, 9:16 and 16:9. Each variant accepts its own subset; the variants table on this page lists them.
What input does Grok Imagine 2.0 accept?
A text prompt of up to 4,000 characters. Unknown fields are rejected with INVALID_MODEL_INPUT.
How is Grok Imagine 2.0 priced and billed?
You pay per successful task from prepaid credits, with no subscription. The price depends on the variant and the specification you choose, such as resolution or duration; see the pricing table on this page or the pricing page. Credits are reserved when a task is accepted and charged only when it succeeds; a failed task returns the reservation to your balance.
How do I call the Grok Imagine 2.0 API from code?
Send POST https://api.hermes-ai.net/api/v1/jobs with the variant's model ID and an input object, then poll GET /api/v1/jobs/{id} until the status is succeeded or failed. The API section has cURL, JavaScript and Python examples generated from the schema.
Can I try Grok Imagine 2.0 without writing code?
Yes. Sign in and use the playground on this page: it sends the same request as the API with your session and charges the same price. Code needs an API key from the dashboard.
What happens when a task fails or I hit a rate limit?
A failed task is not charged and its reserved credits are returned. Too many submissions per minute return 429 RATE_LIMITED, and too many unfinished tasks return 429 CONCURRENCY_LIMITED; retry later or wait for a task to finish.