APIKO
Image Series

GPT Image 2 Upscale Reference

  • gpt-image-2-upscale generates images with POST /v1/images/generations and edits reference images with POST /v1/images/edits.
  • Send "async": true to get a task id right away, then poll GET /v1/tasks/{id}. Asynchronous calls are recommended.
  • Result links are APIKO-signed and kept for 24 hours; download anything you need to keep.
POST
/
v1
/
images
/
generations
TASK_ID=$(curl https://api.apiko.app/v1/images/generations \
  -H "Authorization: Bearer $APIKO_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
  "model": "gpt-image-2-upscale",
  "prompt": "A cinematic product photo on a marble table",
  "async": true
}' | python3 -c 'import json,sys; print(json.load(sys.stdin)["id"])')

while :; do
  TASK=$(curl -s https://api.apiko.app/v1/tasks/$TASK_ID \
    -H "Authorization: Bearer $APIKO_API_KEY")
  printf '%s\n' "$TASK"
  printf '%s' "$TASK" | grep -qE '"status": *"(completed|failed)"|"error": *\{' && break
  sleep 5
done
{
  "id": "task_abc123",
  "object": "image.task",
  "status": "queued",
  "created": 1790000000
}

Authorizations

Authorization
stringrequired
All requests use Bearer authentication: Authorization: Bearer <API_KEY>.
Create a key in Console → API Keys.
Routes
string
  • POST /v1/images/generations — text to image
  • POST /v1/images/edits — edit or combine reference images (JSON body with images)
  • GET /v1/tasks/{id} — query an asynchronous task

Body

application/json
model
stringdefault:gpt-image-2-upscalerequired
Use this exact public model id.
Available options: gpt-image-2-upscale
Example:"gpt-image-2-upscale"
prompt
stringrequired
Image description, at most 8,000 characters.
  • At most 8,000 characters. Chinese, English, digits and punctuation each count as one.
  • A longer prompt is rejected with HTTP 400 before any charge (prompt is too long: at most 8000 characters).
Minimum length: 1
Example:"A cinematic product photo on a marble table"
size
stringdefault:1:1
Aspect ratio, returned at the fixed pixel size of the resolution tier (1:1 at 1k may come back as 1024x1024 or 1254x1254; 2k and 4k are upscaled output); or one of those table sizes as WIDTHxHEIGHT.
① Aspect ratio: 1:1, 16:9, 9:16, 3:2, 2:3, 4:3, 3:4, 5:4, 4:5, 21:9. The pixel size is set by resolution; see the table there.
② Explicit pixels: WxH taken from the table under resolution, e.g. 1024x1024, 2720x1536, 2160x3840. It is billed at that size's tier and resolution is ignored. Any other WxH is rejected before any charge.
③ auto is not supported.
With reference images the output size is not guaranteed to match the request.
Available options: 1:1, 16:9, 9:16, 3:2, 2:3, 4:3, 3:4, 5:4, 4:5, 21:9
Example:"1:1"
resolution
enum<string>default:1k
Resolution tier used for aspect-ratio sizes; explicit table pixels select their table tier.
Pixel budget per tier:
  • 1k: about 1 MP (up to 1,048,576 px)
  • 2k: about 4 MP (up to 4,194,304 px)
  • 4k: about 8.29 MP (up to 8,294,400 px, the maximum)
Pixel size for each ratio. Portrait ratios (9:16, 2:3, 3:4, 4:5) swap width and height:
Ratio1k2k4k
1:11024×10242048×20482880×2880
16:91360×7682720×15363840×2160
3:21248×8322496×16803520×2352
4:31184×8802352×17763312×2496
5:41136×9122288×18243216×2576
21:91536×6563120×13443840×1648
Images come back at these sizes, except 1:1 at 1k, which may come back as 1024×1024 or 1254×1254. 2k and 4k are upscaled output.
Quality is fixed at medium on every tier. quality is not a parameter of this model; omit it, a value sent anyway does not change the result.
Values are lowercase. Each tier has its own price; see the model page (its gpt-image-2-upscale tab).
Available options: 1k, 2k, 4k
Example:"1k"
images
string<uri>[]
Reference image HTTPS URLs; required for /v1/images/edits.
  • Accepted only by POST /v1/images/edits, where at least one image is required. Send the edits request as JSON, not multipart form data.
  • Every entry must be a publicly reachable HTTPS URL; file uploads, base64 and data URLs are rejected. For a local image, upload it to POST /v1/uploads/images first (multipart field file) and pass the returned url; uploads are kept 72 hours.
  • Up to 16 reference images; the output size of an edit is not guaranteed (see size). Masks are not supported: mask is rejected. Omit quality; the output is always rendered at medium quality.
Items: 1–16
Example:["https://example.com/reference.png"]
n
enum<integer>default:1
Only 1 is accepted. Send separate requests for more images.
Available options: 1
Example:1
response_format
enum<string>default:url
Asynchronous task results are always APIKO-signed URLs. A synchronous request with b64_json gets data[].b64_json in addition to data[].url.
Available options: url, b64_json
Example:"url"
async
booleandefault:false
True returns a task id; poll GET /v1/tasks/{id}.
  • Recommended. With true the response is a task object right away; poll GET /v1/tasks/{id} until it completes.
  • With false the request stays open until the image is ready. A request with no response after 100 seconds is closed with HTTP 524 but is still charged, and no task id comes back to fetch the image.
Example:false
callback_url
string<uri>
Optional public HTTPS URL notified when the task finishes.
  • When the task ends in completed or failed, APIKO POSTs the same JSON as GET /v1/tasks/{id} with header X-Apiko-Task-Id.
  • Each delivery waits up to 10 seconds; any 2xx response counts as delivered. A failed delivery is retried 3 times, after 2, 10 and 30 seconds.
  • Redirects are not followed: a 3xx response counts as a failed delivery. A callback_url that is not a public HTTPS URL is rejected when you submit (invalid_callback_url).
  • Callbacks are not signed: re-fetch the task to confirm the result.
Example:"https://your-domain.com/webhooks/apiko-task"

Response

200 - application/json

Charged when the request is accepted; a task that ends in failed is refunded in full.

id
string
Task id returned by an async request. Use it with GET /v1/tasks/{id}.
Example:"task_abc123"
status
enum<string>
Task status. Poll every 5–10 seconds until it is completed or failed.
Available options: queued, in_progress, completed, failed
progress
string
Progress reported by the task, e.g. "100%".
data
object[]
Present when the task is completed. Each data[].url is an APIKO-signed image link kept for 24 hours; download anything you need to keep.
A synchronous request (async omitted or false) returns { "created": …, "data": [{ "url": … }] } directly.
fail_reason
string
Why the task failed. Failed tasks are refunded in full.
Image models answer one of: the prompt or a reference image was rejected by the content safety review; change them and try again (retrying the same input fails the same way), the image service is busy or temporarily unavailable; please retry later, the request or a reference image was not accepted; check the parameters and reference images, a reference image could not be downloaded; use a public https:// image URL or upload the image, or image generation failed.
GET /v1/tasks/{id}
object
The 200 response example is what submitting returns. Polling returns the task in this shape (a callback POSTs the same JSON):
Example:
{
  "id": "task_abc123",
  "task_id": "task_abc123",
  "status": "completed",
  "progress": "100%",
  "created_at": 1790000000,
  "finished_at": 1790000060,
  "fail_reason": "",
  "data": [
    {
      "url": "https://api.apiko.app/v1/tasks/task_abc123/artifacts/image-0/content?access=…"
    }
  ]
}

Errors

application/json

Errors use the shape { "error": { "message", "type", "param", "code" } }; most messages end with a request id to quote when you contact support.

400
error
Invalid request, rejected before any charge. Fix the request instead of retrying it.
  • A value outside the documented options, e.g. resolution must be one of: 1k, 2k, 4k.
  • size: "auto"; mask; images on /v1/images/generations; n other than 1.
  • A WIDTHxHEIGHT that is not in the table under resolution (size must be one of the documented ratios or table WxH pixels).
  • A prompt over 8,000 characters (prompt is too long: at most 8000 characters).
  • An edit without images (images is required for edits), or an edit sent as multipart form data (JSON body required).
  • A callback_url that is not a public HTTPS URL: code: "invalid_callback_url", callback_url must be an HTTPS public URL (no request id).
401
error
Missing or invalid API key (Invalid token).
403
error
Insufficient balance (code: "insufficient_user_quota"). Add credit in Console → Billing.
404
error
GET /v1/tasks/{id} for a task that does not exist or belongs to another account (Task not found).
503
error
The model exists but none of its routes can take the request right now: No available channel for model … (code: "model_not_found"). Retry later with backoff, or pick another model. A missing or misspelled model returns 404 with the same message; check the id instead of retrying.
524
error
A synchronous request (async omitted or false) got no response within 100 seconds and the edge closed it. The request was still accepted and charged, but no task id was returned, so the image cannot be retrieved. Use "async": true for anything that may take over a minute.
A synchronous response with an empty data array also means no image was produced; send the request again asynchronously.