# Image generation

> Part of the ChinaAPI documentation. HTML: https://dash.chinaapi.ai/docs/api/image/

`POST /v1/images/generations` answers in one response rather than as a task. `model` and `prompt` are required; `n`, `size` and `quality` are optional and the models fall back to their own defaults. The reply is `{"created": …, "data": [ … ]}`, where each entry carries a `url` — `b64_json` is present but empty unless you ask for it with `"response_format": "b64_json"`. Editing an existing image goes to `POST /v1/images/edits` with the source in `image`. Billing is per generated image, so `n` multiplies the charge.

**POST /v1/images/generations**

```
curl https://api.chinaapi.ai/v1/images/generations \
  -H "Authorization: Bearer $CHINAAPI_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "model": "image-01",
    "prompt": "a red paper crane on a white desk, soft daylight",
    "n": 1
  }'

# {"created":1786620000,
#  "data":[{"url":"https://.../image_inference_output/....jpg","b64_json":""}],
#  "metadata":{"success_count":"1","failed_count":"0"}}
```

## doubao-seedream-5-0-260128 — 4K output

With `doubao-seedream-4-5-251128`. Both reach 4K and both accept an input image for editing and multi-image composition, so `size` is worth setting explicitly rather than taking the default.

## wan2.7-image — General purpose

With `wan2.7-image-pro`, which adds a 4K tier at roughly twice the price. Same request fields as the rest of this endpoint; the pro variant is the one to reach for when the output is going to be printed or upscaled.

## step-image-edit-2 — Editing and low cost

With `step-2x-large` and `image-01`. `step-image-edit-2` is built for editing an image you supply and is the cheapest of the three; `image-01` is the cheapest text-to-image model on the endpoint.

> [!NOTE]
> Tip
>
> This endpoint bills per call, not per token, and the price already covers one image — the usage log records a single prompt token, which is bookkeeping rather than a measure of your prompt. Asking for `"n": 4` costs four times one image. Prices differ by more than an order of magnitude across the models here, so pick the model before tuning the prompt.
