Response Example
| Parameter | Type | Required | Default | Range | Description |
|---|---|---|---|---|---|
model | string | ✅ Yes | - | - | Model to be used. |
prompt | string | ✅ Yes | - | - | Prompt for image generation. |
image | string or file | ❌ No | - | - | base64-encoded data string of the picture or a public URL. |
n | integer | ❌ No | 1 | 1-10 | The number of images to generate. Must be between 1 and 10. |
aspect_ratio | string | ❌ No | 1:1 | 1:13:44:39:1616:92:33:29:19.519.5:99:2020:91:22:1auto | Aspect ratio of the generated image. Only supported by grok-imagine models. |
response_format | string | ❌ No | url | b64_jsonurl | Response format to return the image in. Can be url or b64_json. If b64_json is specified, the image will be returned as a base64-encoded string instead of a url to the generated image file. |
| Error Code | Error Name | Description |
|---|---|---|
| 401 | Unauthorized | API key is missing or invalid |
| 403 | Forbidden | Your API key doesn’t have permission to access this resource, or insufficient balance for the requested operation |
| 429 | Too Many Requests | You’ve exceeded your rate limit |
| 500 | Internal server error | An internal server error occurred |
| 503 | Content policy violation | Content blocked due to safety concerns (actual status code is 400) |