Grok Imagine - image generation API

Grok Imagine API

active

xAI's Grok Imagine — powerful AI image generation and upscaling from the creators of Grok. Fast, high-quality, and unrestricted.

xAIimage5 credits/call
Provider
xAI
Pricing
5–12 credits per request (~$0.01–$0.024)
Speed
3–10 seconds
Output
image

Quick Start

Send a request to the Grok Imagine API:

bash
curl -X POST https://apiin.one/api/v1/images/generations \
  -H "Authorization: Bearer YOUR_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
  "model": "grok-imagine/text-to-image",
  "prompt": "An astronaut riding a horse on Mars, photorealistic"
}'

API Endpoint

POST/api/v1/images/generations
Send a POST request with your API key to generate content using Grok Imagine.

Headers

HeaderTipoObrigatórioDescrição
AuthorizationstringObrigatórioBearer YOUR_API_KEY
Content-TypestringObrigatórioapplication/json

Body Parameters

ParâmetroTipoObrigatórioDescrição
modelstringObrigatórioModel identifier: "grok-imagine"
promptstringObrigatórioText prompt for image generation (max 5000 chars)
modelstringOpcionalSub-model: "grok-imagine/text-to-image" (5cr) or "grok-imagine/upscale" (12cr) (Padrão: grok-imagine/text-to-image)
task_idstringOpcionalTask ID for upscale mode (upscale a previously generated image)

Example Request

json
{
  "model": "grok-imagine/text-to-image",
  "prompt": "An astronaut riding a horse on Mars, photorealistic"
}

Example Response

Successful task creation response.

{
  "code": 200,
  "message": "success",
  "data": {
    "task_id": "n31xxxx_grok",
    "status": "IN_PROGRESS"
  }
}

Check Task Status

For asynchronous tasks, poll the status endpoint to check when your task is complete:

GET/api/v1/tasks/{task_id}
Returns the current status of a generation task. Poll until status is 'completed' or 'failed'.
bash
curl https://apiin.one/api/v1/tasks/task_abc123 \
  -H "Authorization: Bearer aio_your_key"

Use Cases

  • Generate creative and unrestricted AI imagery
  • Upscale AI-generated images for higher resolution
  • Build AI art generation features into apps
  • Create marketing and social media visuals

API Tester

Test the Grok Imagine API directly from your browser:

Playground da APIPOST

Error Codes

{
  "error": {
    "code": 400,
    "message": "Invalid parameters",
    "type": "invalid_request"
  }
}

Frequently Asked Questions

How much does Grok Imagine cost?

Text-to-image: 5 credits (~$0.01), upscale: 12 credits (~$0.024).

What modes does Grok Imagine support?

Two image modes: text-to-image and upscale. For video generation, see Grok Video.

Do I need a Twitter/X Premium subscription?

No. API in One provides direct API access without any X/Twitter subscription.

Why Use Grok Imagine Through API in One?

1No X/Twitter Premium subscription needed
2Direct API access to xAI's Grok Imagine
3Fast generation speed
4Built-in upscale mode

Ready to use Grok Imagine?

Get Your API Key →