Images
Generate images with gpt-image-2 through the OpenAI-compatible images endpoint. Token-billed, receipt-signed, Scale tier.
POST /v1/images/generations generates images with gpt-image-2. The request and response shapes match OpenAI's Images API, and like every Draftworks endpoint the response carries a signed receipt.
Scale tier
gpt-image-2 is available on the Scale tier, which unlocks automatically at
$5,000 lifetime purchases. Base tier calls return 403 model_requires_scale_tier.
Request
curl https://api.draftworks.dev/v1/images/generations \
-H "Authorization: Bearer dw_live_..." \
-H "Content-Type: application/json" \
-d '{
"model": "gpt-image-2",
"prompt": "A pixel-art drafting table under a desk lamp",
"size": "1024x1024",
"quality": "medium"
}'| Parameter | Type | Notes |
|---|---|---|
model | string, required | gpt-image-2. |
prompt | string, required | What to generate. |
size | string | 1024x1024 (default), 1024x1536, 1536x1024, or auto. |
quality | string | low, medium, or high. Higher quality spends more output tokens. |
n | integer | Number of images, 1-10. |
output_format | string | png (default), jpeg, or webp. |
Streaming (stream: true, partial images) is not supported yet and returns 400 stream_not_supported.
Response
The image arrives base64-encoded in data[0].b64_json, with token usage split by modality:
{
"created": 1783605038,
"data": [{ "b64_json": "iVBORw0KGgo..." }],
"quality": "medium",
"size": "1024x1024",
"usage": {
"input_tokens": 10,
"input_tokens_details": { "text_tokens": 10, "image_tokens": 0 },
"output_tokens": 1056,
"output_tokens_details": { "image_tokens": 1056, "text_tokens": 0 },
"total_tokens": 1066
}
}Billing and receipts
Image generation is token-billed at the gpt-image-2 rates: text input, image input, and image output tokens each at their own rate, 20-25% under list depending on your tier.
The images API returns no request id upstream, so Draftworks mints one (img_...) and returns it in the x-draftworks-receipt-id header. The full receipt is in x-draftworks-receipt and retrievable at GET /v1/receipts/{id}; its response_sha256 covers the exact JSON bytes you received, image payload included.