Image generation API
Generate and edit images with GPT Image and Grok Imagine through the OpenAI-compatible images endpoint, using the same key as every other model.
Models
| Model | Billed | Parameters |
|---|---|---|
gpt-image-2, gpt-image-2.5-flare, gpt-image-2.5-sunburst | By tokens, so size and quality change the price | size, quality, response_format |
grok-imagine-image, grok-imagine-image-quality | A fixed price per picture | aspect_ratio, resolution, response_format |
Prices are on each model page. All of them answer on POST /v1/images/generations with Authorization: Bearer, so switching is a change to the model field plus that family’s parameters.
Generate an image
export TOKEN_SHARE_KEY="<your-pool-api-key>"
curl -sS "https://token-share.app/v1/images/generations" \
-H "Authorization: Bearer $TOKEN_SHARE_KEY" \
-H "Content-Type: application/json" \
-d '{"model":"gpt-image-2","prompt":"A cute baby sea otter","size":"1024x1024","quality":"high","response_format":"b64_json"}'response_format: "b64_json" returns the picture inline as base64; "url" returns a link to download it. With the OpenAI SDK, pass the Grok parameters through extra_body.
Edit an image
POST /v1/images/edits takes a multipart form: the source image, a prompt, and the model. It is checked against the same model list as generation.
export TOKEN_SHARE_KEY="<your-pool-api-key>"
curl -sS "https://token-share.app/v1/images/edits" \
-H "Authorization: Bearer $TOKEN_SHARE_KEY" \
-F model="gpt-image-2" \
-F image="@input.png" \
-F prompt="Add a small red hat"/v1/images/variations is not supported; use /v1/images/edits. Video is a separate model and route — see the Grok Imagine video guide.
What it cost
GPT Image responses include a usage object with the tokens you were billed for. For any image request, pass the x-token-share-request-id response header to the Billing API to read the exact charge.
Ready? Three steps to start
- 1Sign in to the console
- 2Top up your balance
- 3Create an API key