Grok-2-Image - Text To Image - openai
Grok 2 image text to image generation. Create bold, creative, and high-quality AI visuals with a unique edge from your prompts.
POST
grok-2-image (Text To Image)
Authentication
- Sign up for a GPTProto account at https://gptproto.com
- Navigate to the API Keys section in your dashboard
- Generate a new API key (sk-xxxxx)
- Copy and securely store your API key For authentication details, please refer to the Authentication section.
Initiate Request
Response Example
Response Example
Parameters
Core Parameters
| 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 Codes
Common Error Codes
| 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) |

