Connect
Image generation
CoreCode generates images through the OpenAI Images API: the GPT group has gpt-image-2, gpt-image-2.5-flare and gpt-image-2.5-sunburst, and the Grok group has grok-imagine-image. Call them with the OpenAI SDK or curl; each image is billed at a fixed price.
https://corecode.live/v1/v1/images/generations, edit /v1/images/editsAuthorization: Bearer sk-your-key, in the model's group or in autoModels
| Model | Key group | Edits | Returns | Time per image |
|---|---|---|---|---|
gpt-image-2 | GPT or auto | Yes | PNG, base64 | 10 to 20 s |
gpt-image-2.5-flare | GPT or auto | Yes | PNG, base64 | 10 to 20 s |
gpt-image-2.5-sunburst | GPT or auto | Yes | PNG, base64 | 10 to 20 s |
grok-imagine-image | Grok or auto | No | JPEG, URL or base64 | About 5 s |
To get a key, click "Create API key" on the API Keys page and pick the group from the table.
Generate with curl
curl https://corecode.live/v1/images/generations \
-H "Authorization: Bearer sk-your-key" \
-H "Content-Type: application/json" \
-d '{"model": "gpt-image-2.5-flare", "prompt": "a small red fox sitting on a rock, flat illustration", "quality": "low"}' \
| jq -r '.data[0].b64_json' | base64 --decode > fox.png
The image comes back as base64 in data[0].b64_json. To switch models, change model.
Generate with the Python SDK
import base64
from openai import OpenAI
client = OpenAI(base_url="https://corecode.live/v1", api_key="sk-your-key", timeout=180)
r = client.images.generate(
model="gpt-image-2.5-flare",
prompt="a small red fox sitting on a rock, flat illustration",
quality="low",
)
open("fox.png", "wb").write(base64.b64decode(r.data[0].b64_json))
An image takes over ten seconds, so set the client timeout to 60 seconds or more.
Edit an image
gpt-image-2, gpt-image-2.5-flare and gpt-image-2.5-sunburst can edit: as with OpenAI, upload the source image as the form field image.
curl https://corecode.live/v1/images/edits \
-H "Authorization: Bearer sk-your-key" \
-F model=gpt-image-2.5-flare \
-F "prompt=give the fox a blue scarf" \
-F quality=low \
-F image=@fox.png \
| jq -r '.data[0].b64_json' | base64 --decode > fox-scarf.png
In the SDK: client.images.edit(model=..., image=open("fox.png", "rb"), prompt=...).
Generate with Grok
curl https://corecode.live/v1/images/generations \
-H "Authorization: Bearer sk-your-key" \
-H "Content-Type: application/json" \
-d '{"model": "grok-imagine-image", "prompt": "a small red fox in the snow, watercolor", "response_format": "b64_json"}' \
| jq -r '.data[0].b64_json' | base64 --decode > fox.jpg
Pass "response_format": "b64_json". Without it you get data[0].url, a temporary xAI link that may not open from mainland China.
Parameters
| Parameter | Behavior |
|---|---|
size | Ignored by the GPT image models for now, which usually return 1536x1024; Grok returns 1280x720 when omitted. Trust the returned size |
quality | GPT image models accept low, medium, high or auto; the price is the same |
n | GPT image models return one image per request, so leave n out and send more requests for more images |
stream | Leave it out; Grok rejects it |
response_format | GPT image models always return base64; for Grok, pass b64_json |
FAQ
Model not found or no available channel
The key's group does not have the model. GPT image models need a key in GPT or auto; grok-imagine-image needs a key in Grok or auto.
The group accepts only Claude Code requests
The key is in a Claude Code only group. Create a key in GPT, Grok or auto.
The request times out
A GPT image takes 10 to 20 seconds, longer at busy times. Raise the client timeout to 60 seconds or more.
What is the difference between flare and sunburst?
They cost the same and both generate and edit. Which looks better depends on the prompt, so try both.