Skip to main content
POST

Authorization

  • Auth Type: Bearer Auth (In: header)
  • Format: Authorization: Bearer <YOUR_API_KEY>
  • Description: Use Bearer <YOUR_API_KEY>. Format: Authorization: Bearer sk-xxxxxx.
  • API Key: where API Key is your AGCloud API KEY
Create an image generation task with POST /sp/v1/images/generations. The response returns a task ID that you can use with the query task endpoint. The same create endpoint supports both text-to-image and image-to-image flows:
  • Omit image_urls to generate an image from prompt.
  • Provide one or more image_urls to generate or edit images from references.

Headers

Idempotency-Key must match ^[A-Za-z0-9._:-]{1,128}$. Use a new idempotency key for each new task. If a request times out and you retry the same task, reuse the same key with the exact same request body. Reusing a key with a different body returns 409 idempotency_conflict.

Request Parameters

Only model and prompt are strictly required. Other fields are handled according to model capability; unsupported combinations may create a task that later reaches failed with details in error.

Base64 Reference Images

image_urls and mask_url can contain base64 image Data URLs in this format:

Create Response

Creation succeeds with 202 Accepted. The response header contains the idempotency key used for this request.

Error Responses

Non-2xx responses use a unified error format:
  1. Generate a new Idempotency-Key on the client.
  2. Call POST /sp/v1/images/generations to create a task.
  3. Store the returned id.
  4. Poll GET /sp/v1/images/generations/{id} on the query task page until status is terminal.