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
1curl -X POST https://apiin.one/api/v1/images/generations \
2 -H "Authorization: Bearer YOUR_API_KEY" \
3 -H "Content-Type: application/json" \
4 -d '{
5 "model": "grok-imagine/text-to-image",
6 "prompt": "An astronaut riding a horse on Mars, photorealistic"
7}'

API Endpoint

POST/api/v1/images/generations

Send a POST request with your API key to generate content using Grok Imagine.

Headers

Body ParametersJSON
Authorization:string

Bearer YOUR_API_KEY

Content-Type:string

application/json

Body Parameters

Body ParametersJSON
model:string

Model identifier: grok-imagine

prompt:string

Text prompt for image generation (max 5000 chars)

model:optional string

Sub-model: grok-imagine/text-to-image (5cr) or grok-imagine/upscale (12cr) Defaults to grok-imagine/text-to-image.

task_id:optional string

Task ID for upscale mode (upscale a previously generated image)

Example Request

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

Example Response

Successful task creation response.

1{
2 "code": 200,
3 "message": "success",
4 "data": {
5 "task_id": "n31xxxx_grok",
6 "status": "IN_PROGRESS"
7 }
8}

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
1curl https://apiin.one/api/v1/tasks/task_abc123 \
2 -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:

API 测试沙盒POST

Error Codes

1{
2 "error": {
3 "code": 400,
4 "message": "Invalid parameters",
5 "type": "invalid_request"
6 }
7}

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?

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

Ready to use Grok Imagine?

Get Your API Key →