Seedream 4.0 (4k) Serverless API

Seedream 4.0 generates high-resolution, professional-grade visuals with superior text rendering for impactful design.

~20.66s
$0.035 per generation
 1import requests
 2import json
 3
 4url = "https://api.segmind.com/v1/seedream-4"
 5headers = {
 6    "x-api-key": "YOUR_API_KEY",
 7    "Content-Type": "application/json"
 8}
 9
10data = {
11    "size": "2K",
12    "width": 2048,
13    "height": 2048,
14    "prompt": "Action hero into an apocalypse survivor zombie hunter, torn leather jacket with spikes, glowing red cybernetic eye, dual chainsaw weapons, burning city ruins background, blood splatter effects, horror movie aesthetic, badass energy, ultra-detailed gore",
15    "max_images": 1,
16    "image_input": [
17        "https://segmind-resources.s3.amazonaws.com/input/ee043397-b857-4bf2-9ad0-70258a286e96-504cf296-f8c3-40af-b200-9b52bdae240c.png"
18    ],
19    "sequential_image_generation": "disabled"
20}
21
22response = requests.post(url, headers=headers, json=data)
23
24if response.status_code == 200:
25    result = response.json()
26    print(json.dumps(result, indent=2))
27else:
28    print(f"Error: {response.status_code}")
29    print(response.text)

API Endpoint

POSThttps://api.segmind.com/v1/seedream-4

Parameters

promptrequired
string

Text describing the image to generate. Include subjects like 'sunset mountain view'.

Default: "Action hero into an apocalypse survivor zombie hunter, torn leather jacket with spikes, glowing red cybernetic eye, dual chainsaw weapons, burning city ruins background, blood splatter effects, horror movie aesthetic, badass energy, ultra-detailed gore"
aspect_ratiooptional
string

Image proportions. When combined with size preset, one dimension is fixed (1K=1024, 2K=2048, 4K=4096). For best quality with non-square ratios, consider using 'custom' size with manual dimensions. Options: '1:1' square, '16:9' widescreen, '9:16' portrait, etc.

Default: null
Allowed values :
"1:1""4:3""3:4""16:9""9:16""3:2""2:3""21:9"
heightoptional
integer

Custom height in pixels (only used when size='custom'). Range: 1024-4096. Both width and height must be set for custom sizing. Dimensions will be validated and rounded to nearest 64 pixels.

Default: 2048Range: 1024 - 4096
image_inputoptional
string[]

List of image URLs to guide generation. Use for reference; add 1-3 URLs.

max_imagesoptional
integer

Sets image generation limit. Choose 1 for single outcome, 5 for multiple.

Default: 1Range: 1 - 15
sequential_image_generationoptional
string

Controls image creation order. Enable 'auto' for batch generation, 'disabled' otherwise.

Default: "disabled"
Allowed values :
"disabled""auto"
sizeoptional
string

Image resolution preset. '1K/2K/4K' sets one dimension (1024/2048/4096), other dimension calculated from aspect_ratio. Use 'custom' to specify exact width/height. Note: Combining with aspect_ratio may not maximize quality for all ratios.

Default: "2K"
Allowed values :
"1K""2K""4K""custom"
widthoptional
integer

Custom width in pixels (only used when size='custom'). Range: 1024-4096. Both width and height must be set for custom sizing. Dimensions will be validated and rounded to nearest 64 pixels.

Default: 2048Range: 1024 - 4096

Response Type

Returns: Image

Common Error Codes

The API returns standard HTTP status codes. Detailed error messages are provided in the response body.

400

Bad Request

Invalid parameters or request format

401

Unauthorized

Missing or invalid API key

403

Forbidden

Insufficient permissions

404

Not Found

Model or endpoint not found

406

Insufficient Credits

Not enough credits to process request

429

Rate Limited

Too many requests

500

Server Error

Internal server error

502

Bad Gateway

Service temporarily unavailable

504

Timeout

Request timed out