Skip to content

Grok Image 2.0 API

Very fast image model with fewer content restrictions

grok-image-2-0SynchronousImage inputimageLive price on TokPort: $0.085 per image

Fields marked * are required. The same definitions are published as OpenAPI 3.0 (https://tokport.io/api/openapi?model=grok-image-2-0), ready for code generators and agents.

Text to image

POST /v1/images/generations

Input

FieldTypeDescription
model*stringModel id. Always "grok-image-2-0".
prompt*stringWhat to generate. Be concrete about subject, style, lighting and composition.
sizestring (enum)Output size as "WIDTHxHEIGHT" pixels.1024x10241536x10241024x1536default: 1024x1024
nintegerNumber of images to generate in one request. Each image is billed.default: 1range: 1–4
response_formatstring (enum)Return hosted URLs (expire after a while) or inline base64 PNG data.urlb64_jsondefault: url

Output

Synchronous. `data[]` holds one entry per generated image with `url` (or `b64_json` when requested). The `X-Oneapi-Request-Id` response header identifies the request in your usage log.

{
  "created": 1726400000,
  "data": [
    {
      "url": "https://cdn.example.com/generated/abc.png",
      "revised_prompt": "a neon koi swimming through clouds, cinematic lighting"
    }
  ]
}

Runnable example: API tab.

Image to image

POST /v1/images/edits

Input

FieldTypeDescription
model*stringModel id. Always "grok-image-2-0".
image*string (url | data:)Reference image as a public URL or a data: URL (PNG, JPEG or WebP, up to 8 MB).
prompt*stringHow the reference image should change. The model keeps what you do not mention.
sizestring (enum)Output size as "WIDTHxHEIGHT" pixels.1024x10241536x10241024x1536default: 1024x1024
nintegerNumber of images to generate in one request. Each image is billed.default: 1range: 1–4
response_formatstring (enum)Return hosted URLs (expire after a while) or inline base64 PNG data.urlb64_jsondefault: url

Output

Synchronous. `data[]` holds one entry per generated image with `url` (or `b64_json` when requested). The `X-Oneapi-Request-Id` response header identifies the request in your usage log.

{
  "created": 1726400000,
  "data": [
    {
      "url": "https://cdn.example.com/generated/abc.png",
      "revised_prompt": "a neon koi swimming through clouds, cinematic lighting"
    }
  ]
}

Runnable example: API tab.