gpt-image-2
openai/gpt-image-2Generate an image from a written description.
- token
- Price: $5.00Price: $0Price: $30.00
- OpenAI
- 5 min
Overview
Generate an image from a text prompt. The request may return RUNNING before the image is ready; poll GET /v1/runs/{runId} until COMPLETED. Returns one image. Low and high quality require 1:1 at 1024 × 1024. Medium is the default and retains 1:1, 3:2 and 2:3 framing.
After COMPLETED, decode run.output.data[0].b64_json from base64 to save the image.
Input
These go in the input object of the run request.
| Field | Type | Required | Description |
|---|---|---|---|
| prompt | string | Yes | What to draw, in plain language. Maximum: 1000 |
| aspect_ratio | string | No | Shape of the image: 1:1; medium also accepts 3:2 or 2:3. Square when omitted. |
| resolution | string | No | Size class of the image: 1K. 1K when omitted. |
| quality | string | No | Image quality. A quality must be available in pricing_tiers before it can run. Allowed: low, medium, high Default: "medium" |
Requests up to 1 MB, prompt up to 1,000 characters.
Example
Use your own API key and a saved idempotency key for each new job. Replace image or media placeholders with your own publicly reachable HTTPS URLs. Keep the same key and request body when recovering a timeout.
# Set once per job; reuse this key and the identical body after a timeout.
: "${AGENTSKY_IDEMPOTENCY_KEY:?Set a unique, saved key for this job}"
curl --fail-with-body https://gateway.agentsky.dev/v1/run \
-H "authorization: Bearer $AGENTSKY_API_KEY" \
-H "content-type: application/json" \
-H "Idempotency-Key: $AGENTSKY_IDEMPOTENCY_KEY" \
-d '{"provider":"openai","endpoint":"gpt-image-2","input":{"prompt":"A paper airplane over a city at dusk, flat illustration"}}'
# If status is READY/RUNNING, poll GET /v1/runs/{runId} with the same API key.Pricing
Prices per million tokens, using your plan when signed in. Read the final customer charge from price.amount.value after the run finishes. A RUNNING response is not the final bill.
| Quality | Availability | Text input | Text output | Image output |
|---|---|---|---|---|
| low | Available | Price: $5.00 | Price: $0 | Price: $30.00 |
| medium (default) | Available | Price: $5.00 | Price: $0 | Price: $30.00 |
| high | Available | Price: $5.00 | Price: $0 | Price: $30.00 |
