Skip to main content
POST
Text-to-image: generate a 2K/4K image from a prompt
The interactive Playground on the right supports live testing. Enter your API key in Authorization (format: Bearer sk-xxx), choose a model, enter a prompt, optionally select response_format, and send. Do not fill in size; both models have fixed output dimensions.
When to use this page: pure text-to-image generation. You only need a prompt. For reference-image generation or editing, use the reference-image API.
⚠️ Three things to know
  • size is overridden by the model: -2k always returns 2048×2048 and -4k always returns 4096×4096. Do not try to switch resolution with size.
  • n is fixed at 1: passing 2 or 3 still returns one image and bills once. Send concurrent requests for multiple images.
  • Responses default to base64: a 2K response is about 6–8.4 MB and a 4K response 17.6–20 MB. For web display, pass response_format: "url".

Code Examples

Python (OpenAI SDK)

Python (raw requests)

cURL

Node.js (native fetch)

Browser JavaScript (URL mode)

Parameters

See the Playground field descriptions for constraints and allowed values. quality, style, and output_format have no effect; do not send them.

Response Format

Default response_format: "b64_json":
With response_format: "url":
Response notes
  • b64_json is plain base64 without a data:image/png;base64, prefix. Decode it directly to a PNG.
  • A 2K PNG is about 4.4–5.7 MB and the base64 response 6–8.4 MB; a 4K PNG is 12.6–18.9 MB and the base64 response 17.6–20 MB.
  • url returns a stable URL on hdcdn.agisuitepro.com. HEAD returns 200 and <img> works, but CORS preflight returns 403, so browser fetch / canvas access needs a server-side proxy.
  • usage is a placeholder and cannot be used for billing reconciliation.
usage is not billable data: prompt_tokens is always 1000 and output_tokens is always 0. This series bills a flat price per image; use the APIYI console bill for actual charges.

Authorizations

Authorization
string
header
required

API key created in the APIYI console

Body

application/json
model
enum<string>
default:hy-image-v3.5-preview-2k
required

Model ID. -2k is fixed at 2048×2048; -4k is fixed at 4096×4096

Available options:
hy-image-v3.5-preview-2k,
hy-image-v3.5-preview-4k
prompt
string
required

Prompt, Chinese or English. Wrap text that must appear in the image in quotes

Example:

"A cinematic movie poster with the Chinese title \"Between Mountains and Seas\" centered, deep blue night sky and golden mountains, premium finish"

response_format
enum<string>
default:b64_json

Response format. Defaults to b64_json; url returns a stable platform CDN URL

Available options:
b64_json,
url
n
enum<integer>
default:1

Fixed at 1. This model always returns exactly one image

Available options:
1

Response

Image generated successfully

created
integer

Unix timestamp

Example:

1795534600

id
string

Task ID for this request

Example:

"tsk_01m8736tvsqp2t27p0k53hjn7z"

data
object[]

Image result array, always exactly one item

usage
object

Placeholder values; do not use for billing reconciliation. prompt_tokens is always 1000 and output_tokens is always 0. Actual charges are flat per image and come from the console bill.