Image modelsImage guide

Image guide

Read the settings

Before submitting, call Get image generation settings (no authentication required). The response contains:

  • available: whether image generation is currently available.
  • models and sizes: the models and output sizes you can submit now.
  • max_reference_images and reference_rates: the reference image limit and reference image surcharge for each model.
  • billing.rates and billing.version: the rate for each model and size, and the rate version.

When submitting, send billing.version as rate_version in the request. Rates may change, so read the settings again before each submission. See Image model overview for model IDs and common specifications.

Text to image

Call POST /v1/image/generate with mode: "text-to-image", model, prompt, size and rate_version. The prompt is 1–32000 characters long.

curl -X POST 'https://shixux.com/api/v1/image/generate' \
  -H 'X-API-Key: yb_xxx_yyy' \
  -H 'Content-Type: application/json' \
  -H 'Idempotency-Key: image-001' \
  -d '{"mode":"text-to-image","model":"doubao-seedream-5-0-pro-260628","prompt":"A yellow ceramic cup on a wooden table","size":"1024x1024","rate_version":1}'

rate_version in these examples is a placeholder; replace it with billing.version from the settings response.

Image to image

Image to image uses mode: "image-to-image" and specifies reference images with reference_asset_id (one image) or reference_asset_ids (several images, in order). Use one of the two fields, with up to 10 images. Reference images must be uploaded and confirmed with purpose: "image_reference".

Image to image can create a new image based on the references, or edit a reference image when the prompt describes the change, for example:

{
  "mode": "image-to-image",
  "model": "doubao-seedream-5-5-261028",
  "prompt": "Make the cup blue and keep the composition and lighting",
  "size": "1536x1024",
  "reference_asset_ids": ["asset_reference_1"],
  "rate_version": 1
}

Whether reference images incur a surcharge is determined by reference_rates in the settings. If the rate version is out of date, the submission returns 409 IMAGE_RATE_CHANGED; read the settings again and confirm the cost before resubmitting.

When no submission response arrives

If a submission times out and you cannot tell whether the image job was created:

  1. Call List jobs with the original Idempotency-Key as the idempotency_key parameter.
  2. If that still does not settle it, call Resolve an image submission with the original request body and the original Idempotency-Key. If the original request was accepted, the endpoint returns that job. If it was not, the endpoint returns an uncharged failed job and makes sure the original request will not be accepted later. The endpoint itself never generates an image.

Jobs and results

A successful submission returns 202, the job ID and the credits reserved. Learn when the job ends through Retrieve a job or a webhook, then call Retrieve a job result for the download URL. The URL is short-lived; call the endpoint again after it expires. retained_until gives how long the result file is retained.

When a job fails, error_code gives the reason, for example a reference image, prompt or generated image that did not pass copyright review (IMAGE_REFERENCE_COPYRIGHT, IMAGE_PROMPT_COPYRIGHT, IMAGE_OUTPUT_COPYRIGHT). Reserved credits are refunded.

For more rules, see Uploads, Webhooks, Asynchronous jobs and Billing and credits.

On this page