<!-- Generated from public website sources; do not edit this file. -->

# Generate and edit images with GPT Image 2.5
Use your DSSUB Multi-Model key to generate a product photo with Flare, then edit its color with Sunburst. Each request produces one image.

## Check your key and price
Open [API keys](https://dssub.com/account/keys) and use a **Plan only** or **Auto** key from an account with an active Multi-Model plan. Image tasks use plan points. DeepSeek-only plans and API credit do not fund image tasks. Use Bash, curl and jq for the examples below. Run the blocks in order in the same Bash session.

```bash
BASE=https://api.dssub.com/v1
read -rsp "DSSUB API key: " DSSUB_API_KEY
printf '\n'
AUTH="Authorization: Bearer ${DSSUB_API_KEY:?Enter your DSSUB API key}"
curl --fail-with-body -sS "$BASE/image-models" -H "$AUTH" |
  jq '{available, models: [.data[] | {id, prices}]}'
```

Check that the response lists the model you want. Both models charge the same number of plan points per generated or edited image.

| Output resolution | Points per image |
| --- | --- |
| 1K | 5,000,000 |
| 2K | 8,000,000 |
| 4K | 14,000,000 |

The example below uses **10,000,000 points** for two 1K outputs. Listing models, requesting a quote and polling an existing task do not generate another image.

## Get a quote for a Flare image
Send the subject, composition and lighting in the prompt. Check the model, resolution, points and expiry returned by the gateway. You can stop here without starting a paid task.

```bash
set -euo pipefail
QUOTE=$(curl --fail-with-body -sS "$BASE/image-quotes" -H "$AUTH" \
  -H 'Content-Type: application/json' --data '{
    "model": "gpt-image-2.5-flare",
    "resolution": "1K",
    "aspect_ratio": "1:1",
    "prompt": "Studio photo of one white ceramic mug. Handle facing right, light gray table, soft daylight from the left. No lettering."
  }')
jq '{model, resolution, points, expiresAt}' <<< "$QUOTE"
QUOTE_ID=$(jq -er '.quoteId' <<< "$QUOTE")
```

## Submit once and save the result
Define these two Bash functions for both examples. Submitting queues the paid task. Reuse the **same request ID and quote ID** if the submission response is lost. Looking up the task uses your DSSUB key. The temporary download URL carries its own access permission.

```bash
submit_image() {
  curl --fail-with-body -sS "$BASE/image-tasks" -H "$AUTH" \
    -H 'Content-Type: application/json' -H "Idempotency-Key: $1" \
    --data "$(jq -n --arg id "$2" '{quoteId:$id}')" | jq -er '.id'
}

save_image() {
  local task="$1" name="$2" result state mime ext url
  for ((attempt=0; attempt<120; attempt++)); do
    result=$(curl --fail-with-body -sS "$BASE/image-tasks/$task" -H "$AUTH") || return 1
    state=$(jq -er '.state' <<< "$result")
    case "$state" in
      succeeded)
        mime=$(jq -er '.outputs[0].contentType' <<< "$result")
        case "$mime" in
          image/png) ext=png ;; image/jpeg) ext=jpg ;; image/webp) ext=webp ;; *) return 1 ;;
        esac
        url=$(jq -er '.outputs[0].url' <<< "$result")
        curl --fail -sS "$url" -o "$name.$ext" || return 1
        printf '%s\n' "$name.$ext"
        return 0 ;;
      failed|review|submission_unknown)
        jq '{id,state,error}' <<< "$result" >&2
        return 1 ;;
      *) sleep "$(jq -r '.retryAfter // 3' <<< "$result")" ;;
    esac
  done
  printf 'Still processing. Check the same task again: %s\n' "$task" >&2
  return 1
}

REQUEST_ID=$(uuidgen)
TASK_ID=$(submit_image "$REQUEST_ID" "$QUOTE_ID")
printf 'Flare task: %s\n' "$TASK_ID"
PHOTO=$(save_image "$TASK_ID" mug)
```

Open the saved mug photo. Keep the task ID if you need a fresh download link. The response to the same task reports the original result.

## Upload the photo and quote a Sunburst edit
Use the photo you just downloaded, or set `PHOTO` to a local PNG, JPEG or WebP. Request an upload ticket, send the exact bytes using the ticket headers, and confirm the upload. Use the returned asset ID in the edit. The gateway accepts up to 16 reference images, each at most 30,000,000 bytes.

```bash
MIME=$(file -b --mime-type "$PHOTO")
BYTES=$(wc -c < "$PHOTO")
UPLOAD=$(curl --fail-with-body -sS "$BASE/assets/uploads" -H "$AUTH" \
  -H 'Content-Type: application/json' \
  --data "$(jq -n --arg mime "$MIME" --argjson size "$BYTES" '{contentType:$mime,size:$size}')")
ASSET=$(jq -er '.assetId' <<< "$UPLOAD")
curl --fail-with-body -sS -X PUT "$(jq -er '.upload.url' <<< "$UPLOAD")" \
  -H "Authorization: $(jq -er '.upload.headers.Authorization' <<< "$UPLOAD")" \
  -H "Content-Type: $MIME" --data-binary "@$PHOTO"
curl --fail-with-body -sS -X POST "$BASE/assets/$ASSET/complete" -H "$AUTH" |
  jq -e '.state == "sealed"'

EDIT=$(curl --fail-with-body -sS "$BASE/image-quotes" -H "$AUTH" \
  -H 'Content-Type: application/json' \
  --data "$(jq -n --arg asset "$ASSET" '{
    model:"gpt-image-2.5-sunburst", resolution:"1K", assets:[$asset],
    prompt:"Change only the glaze to cobalt blue. Preserve the handle, camera angle, gray table and direction of the shadow."
  }')")
jq '{model, mode, resolution, points, expiresAt}' <<< "$EDIT"
```

After checking the edit quote, submit it with a new request ID and save the result. Compare the two photos to check the color, handle and shadow.

```bash
EDIT_REQUEST_ID=$(uuidgen)
EDIT_TASK=$(submit_image "$EDIT_REQUEST_ID" "$(jq -er '.quoteId' <<< "$EDIT")")
printf 'Sunburst task: %s\n' "$EDIT_TASK"
save_image "$EDIT_TASK" mug-blue
```

## Check usage or resolve an error
- **Empty model list or MODEL_DENIED.** Check the key’s billing mode and your active Multi-Model entitlement in [Your plan](https://dssub.com/account/plan).
- **IMAGE_PLAN_EXHAUSTED.** Check both allowance windows. A 1K image needs 5,000,000 points in each applicable window. Image requests cannot fall back to a wallet.
- **QUOTE_EXPIRED.** Request and review a fresh quote for a new submission. For an already accepted task, check the original task ID.
- **submission_unknown or review.** Save the task ID and contact [support](https://dssub.com/support/index.md) so the original request can be reconciled.
- **A completed task.** Use the task ID to find the charge in [Usage](https://dssub.com/account/usage). The point charge follows the output resolution.

---

HTML source: [Generate and edit images with GPT Image 2.5 — dssub Tutorials](https://dssub.com/docs/gpt-image-2-5/)
