Skip to main content
POST
Text-to-Image: generate an image from a text prompt
The interactive Playground on the right lets you call the API directly. Set Authorization to your API key (format: Bearer sk-xxx), enter a prompt, pick a model and size, and hit send.
Scope: this page covers pure text-to-image (no image field). For reference-image editing, multi-image fusion, or batch sequence generation, see Image Editing — same endpoint, just different parameters.
🖥️ Browser Playground limitation (b64_json mode only)In the default response_format: "url" mode, the Playground works fine (the response is just a temporary BytePlus TOS link). If you switch to response_format: "b64_json", the response contains a multi-MB base64 string and the browser Playground may show 请求时发生错误: unable to complete requestthe request actually succeeded; the browser just can’t render such a long base64 string.Recommended workflow:
  • Just want to view the image? Keep the default url mode — the Playground returns the link directly (remember to download to your own storage within 24 hours).
  • Need b64_json? Copy the code sample below and run it locally — the code will decode and save the image to a file automatically.
⚠️ Resolution tiers vary by version
  • seedream-5-0-pro-260628 — presets 1K / 2K plus exact WxH up to 4.19M total pixels (at 16:9 the longest edge reaches 2720×1530, verified; no 3K/4K presets; sequential_image_generation / stream not accepted — passing them returns 400; ~2 min per image)
  • seedream-5-0-2601282K / 3K only (no 4K)
  • seedream-4-5-2511282K / 4K
  • seedream-4-0-2508281K / 2K / 4K
Unsupported sizes return 400. Exact pixels must satisfy total ∈ [1280×720, 4096×4096] and aspect ratio ∈ [1/16, 16].
All image APIs are synchronous — there is no task ID to poll, and if your client disconnects the result is lost while the request is still billed. Set a generous timeout for this model; see Image API Essentials & Best Practices.

Code Examples

Python (OpenAI SDK)

Python (raw requests)

cURL

Node.js (fetch)

Browser JavaScript

Parameter Reference

Detailed parameter constraints, allowed values, and examples are visible in the Playground panel on the right. Editing / multi-image parameters (image, sequential_image_generation, etc.) are documented on the Image Editing page.

Response Format

⚠️ Response field caveats
  • When response_format=url, data[].url is a temporary signed BytePlus TOS URL (typically valid for 24 hours). For production, download immediately to your own storage.
  • When response_format=b64_json, data[].b64_json is a plain base64 string, without the data:image/...;base64, prefix. Decode it (base64.b64decode) for file output, or prepend the prefix yourself for browser rendering.
  • data[].size reflects the actual output size, which may differ slightly from the requested size after the model’s aspect-ratio normalization.
usage.generated_images reflects the billed image count. Seedream bills per image; output_tokens / total_tokens are observability metrics and do not affect billing.

Authorizations

Authorization
string
header
required

API Key obtained from APIYI Console

Body

application/json
model
enum<string>
default:seedream-5-0-260128
required

Model ID

Available options:
seedream-5-0-260128,
seedream-5-0-lite-260128,
seedream-4-5-251128,
seedream-4-0-250828,
seedream-5-0-pro-260628
prompt
string
required

Prompt, supports both English and Chinese. Describe scene, style, and lighting in detail for better results.

Example:

"A serene Japanese garden with cherry blossoms, koi pond, traditional bridge, golden hour, ultra detailed"

size
string
default:2K

Output size. Preset tiers (vary by version):

  • 1K (~1024×1024) — 4.0 only
  • 2K (~2048×2048) — 5.0 / 4.5 / 4.0
  • 3K (~3072×3072) — 5.0 only
  • 4K (~4096×4096) — 4.5 / 4.0

Or exact pixel size WxH, total pixels ∈ [1280×720, 4096×4096], aspect ratio ∈ [1/16, 16]

Example:

"2K"

response_format
enum<string>
default:url

url returns a temp signed link (24h validity); b64_json returns plain base64 (no data: prefix)

Available options:
url,
b64_json
output_format
enum<string>
default:jpeg

Output format. 5.0 supports png/jpeg; 4.5/4.0 only jpeg

Available options:
png,
jpeg
seed
integer

Random seed. Note: officially supported only by seedream-3-0-t2i; ignored by the current 4.x / 5.x models

Example:

42

watermark
boolean
default:false

Whether to include the BytePlus watermark. Set to false for commercial use

stream
boolean
default:false

Enable streaming output. Useful for long prompts and high-resolution generation

Response

Image generated successfully

model
string
Example:

"seedream-5-0-260128"

created
integer

Unix timestamp

Example:

1768518000

data
object[]
usage
object