xAI · Image Edit

Grok Imagine Edit Image

Grok Imagine Edit Image at 1K or 2K resolution: combine up to 3 source images with a text prompt. Every source image is billed per input image.

image image
x-ai/grok-imagine-image/image-to-image

Capabilities

Best for

  • Concept art and mood boards
  • Product and marketing visuals
  • Batch generation at scale

Not for

  • Exact text rendering at small sizes
  • Precise brand-logo reproduction
  • Vector output

Authentication

api key header

The Pika API uses API keys to authenticate requests. Send your key in the X-API-Keyheader. Your API key is a secret. Don't expose it in browsers or other client-side code. Instead, call the API from your server. The signed-in playground uses a portal session and never sends your API key.

header
X-API-Key: YOUR_API_KEY

Endpoint

asynchronous · poll for the result

POSThttps://api.dev.pika.art/v1/media/x-ai/grok-imagine-image/image-to-imagegenerate endpoint
GEThttps://api.dev.pika.art/v1/media/jobs/{request_id}poll until completed
GEThttps://api.dev.pika.art/v1/media/jobs/{request_id}/contentget the result URL

Reference Uploads

media inputs

Media inputs accept any public URL. To use a local file, POST its content_type and size_bytes to /v1/media/uploads, PUT the file to the returned upload_url, then pass the url.

upload
# 1. Request a presigned upload URL. Send the file's content
# type and its exact size in bytes.
curl -X POST https://api.dev.pika.art/v1/media/uploads \
-H "X-API-Key: YOUR_API_KEY" \
-H "Content-Type: application/json" \
-d '{"content_type": "image/png", "size_bytes": 12345}'
# The response returns two URLs:
# upload_url: a temporary URL to upload the file to. Expires in 5 minutes.
# url: the permanent Pika URL. Pass it to the model as the input.
# {
# "upload_url": "https://upload.r2.pika.art/...?X-Amz-Signature=...",
# "url": "https://cdn.pika.art/v2/media/uploads/org_abc/9f8e7d.png"
# }
# 2. Upload the file to upload_url, then pass url to the model.
curl -X PUT "<upload_url>" \
-H "Content-Type: image/png" \
--data-binary @input.png

Generate

POST /v1/media/x-ai/grok-imagine-image/image-to-image

Request

curl -X POST https://api.dev.pika.art/v1/media/x-ai/grok-imagine-image/image-to-image \
-H "X-API-Key: YOUR_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"prompt": "Same man, same pose, same sheet cake, same flash-at-dusk court — but now a full marching band in cream uniforms stands in formation behind him across the court, every member deadpan and motionless, instruments raised mid-note, all lit by the same hard flash against the dusk sky. He remains the calm center. Keep him, the flash grade, framing and grain identical.",
"resolution": "1K",
"aspect_ratio": "1:1",
"num_images": 1,
"image_urls": [
"https://msaocnoosm1a4.pika.art/v2/media/uploads/ff78f2c4-2c28-4245-8264-697530fb255f/32c0c7af951a48da841ac19e8e81dbcb.jpg"
]
}'

Response

{
"id": "media_8f3a2c91-5b7d-4e0a-9c26-31d4f2a8e6b0",
"status": "queued"
}

Request body

promptstringrequired
Prompt
resolutionenumdefault: 1K
Resolution
aspect_ratioenumdefault: auto
Aspect Ratio
num_imagesinteger1 – 10default: 1
Num Images
image_urlsstring[]required
Image Urls

Accepted values

resolution
aspect_ratio

Input modes

Image urlsimage_urls

Use a public URL directly, or POST { content_type, size_bytes } to /v1/media/uploads, PUT the image to the returned upload_url, then pass the url.

Returns

Returns a job object with status , not the final output. Store the id from the response and poll the job until it completes.

Poll status

GET /v1/media/jobs/{request_id}

Request

curl https://api.dev.pika.art/v1/media/jobs/{request_id} \
-H "X-API-Key: YOUR_API_KEY"

Response

{
"id": "media_8f3a2c91-5b7d-4e0a-9c26-31d4f2a8e6b0",
"status": "running"
}

Poll the job by id until it reaches a terminal state: completed or failed.

The job object

idstring
Unique identifier for the job.
statusenum
The status of the job.One of:
object
The generation output. Present once the job completes.
errorstring
If the job failed, the reason for the failure.

Get result

GET /v1/media/jobs/{request_id}/content

Request

curl https://api.dev.pika.art/v1/media/jobs/{request_id}/content \
-H "X-API-Key: YOUR_API_KEY"

Response

{
"url": "https://api.dev.pika.art/v1/files/img_8f3a2c91.png"
}

Once the job completes, fetch a download URL for the generated media.

Returns

urlstring
Download URL for the generated file.

Errors

shared across calls

Errors use conventional HTTP status codes with a JSON body of the shape {"message": "..."}. The one exception is validation: a request body that fails validation returns 422 with a plain-text body.

StatusWhenBody
401 UnauthorizedThe API key is missing or invalid.{"message":"Invalid API key"}
403 ForbiddenThe key is not active, or the org balance cannot cover the request.{"message":"Insufficient org balance"}
404 Not FoundNo job with that id exists in your org.{"message":"media job not found"}
409 ConflictThe result was requested before the job completed, or an Idempotency-Key header was reused with a different body.{"message":"media job is not ready"}
422 Unprocessable EntityThe request body failed validation: an invalid enum value, a missing required field, a wrong type, or malformed JSON. Returned as plain text, not JSON. A schema-valid parameter combination that cannot be priced returns the same status with a JSON message.Unprocessable entity
429 Too Many RequestsOrg limit reached: requests per minute or day, or concurrent jobs. Check the Retry-After header.{"message":"rate limit exceeded: rpm"}
503 Service UnavailableThe model rail or a backend dependency is temporarily unavailable. Retry with backoff.{"message":"media dispatch unavailable"}

Pricing

only successful runs are charged

Pricing for this model is shared during onboarding.

Per-model pricing

Transparent, usage-based rates for every xAI model.

Grok Imagine

$0.021 / image
Text to Image

Grok Imagine Video

from $0.053 / sec
Text to Video

Grok Imagine Video

$0.053 / sec
Video Extension

Grok Imagine Image Quality Text To Image

from $0.053 / image
Text to Image

Grok Imagine Video

$0.084 / sec
Video to Video

Grok Imagine

Current
Custom
Image to Image

Grok Imagine Image Quality Edit Image

Custom
Image to Image

Grok Imagine Video

Custom
Image to Video

Grok Imagine Video

Custom
Reference to Video

Grok Imagine Video 1.5

Custom
Image to Video