import Foundationlet url = URL(string: "https://api.apimart.ai/v1/images/generations")!let payload: [String: Any] = [ "model": "seedream-5-0-flash", "prompt": "A cyberpunk city night scene, neon lights reflecting on wet streets", "size": "16:9", "resolution": "2K"]var request = URLRequest(url: url)request.httpMethod = "POST"request.setValue("Bearer <token>", forHTTPHeaderField: "Authorization")request.setValue("application/json", forHTTPHeaderField: "Content-Type")request.httpBody = try? JSONSerialization.data(withJSONObject: payload)let task = URLSession.shared.dataTask(with: request) { data, response, error in if let error = error { print("Error: \(error)") return } if let data = data, let responseString = String(data: data, encoding: .utf8) { print(responseString) }}task.resume()
using System;using System.Net.Http;using System.Text;using System.Threading.Tasks;class Program{ static async Task Main(string[] args) { var url = "https://api.apimart.ai/v1/images/generations"; var payload = @"{ ""model"": ""seedream-5-0-flash"", ""prompt"": ""A cyberpunk city night scene, neon lights reflecting on wet streets"", ""size"": ""16:9"", ""resolution"": ""2K"" }"; using var client = new HttpClient(); client.DefaultRequestHeaders.Add("Authorization", "Bearer <token>"); var content = new StringContent(payload, Encoding.UTF8, "application/json"); var response = await client.PostAsync(url, content); var result = await response.Content.ReadAsStringAsync(); Console.WriteLine(result); }}
(* Requires cohttp and yojson libraries *)open Lwtopen Cohttpopen Cohttp_lwt_unixlet url = "https://api.apimart.ai/v1/images/generations"let payload = {|{ "model": "seedream-5-0-flash", "prompt": "A cyberpunk city night scene, neon lights reflecting on wet streets", "size": "16:9", "resolution": "2K"}|}let () = let headers = Header.init () |> fun h -> Header.add h "Authorization" "Bearer <token>" |> fun h -> Header.add h "Content-Type" "application/json" in let body = Cohttp_lwt.Body.of_string payload in let response = Client.post ~headers ~body (Uri.of_string url) >>= fun (resp, body) -> body |> Cohttp_lwt.Body.to_string >|= fun body_str -> print_endline body_str in Lwt_main.run response
import 'dart:convert';import 'package:http/http.dart' as http;void main() async { final url = Uri.parse('https://api.apimart.ai/v1/images/generations'); final payload = { 'model': 'seedream-5-0-flash', 'prompt': 'A cyberpunk city night scene, neon lights reflecting on wet streets', 'size': '16:9', 'resolution': '2K' }; final response = await http.post( url, headers: { 'Authorization': 'Bearer <token>', 'Content-Type': 'application/json', }, body: jsonEncode(payload), ); print(response.body);}
library(httr)library(jsonlite)url <- "https://api.apimart.ai/v1/images/generations"payload <- list( model = "seedream-5-0-flash", prompt = "A cyberpunk city night scene, neon lights reflecting on wet streets", size = "16:9", resolution = "2K")response <- POST( url, add_headers( Authorization = "Bearer <token>", `Content-Type` = "application/json" ), body = toJSON(payload, auto_unbox = TRUE), encode = "raw")cat(content(response, "text"))
import Foundationlet url = URL(string: "https://api.apimart.ai/v1/images/generations")!let payload: [String: Any] = [ "model": "seedream-5-0-flash", "prompt": "A cyberpunk city night scene, neon lights reflecting on wet streets", "size": "16:9", "resolution": "2K"]var request = URLRequest(url: url)request.httpMethod = "POST"request.setValue("Bearer <token>", forHTTPHeaderField: "Authorization")request.setValue("application/json", forHTTPHeaderField: "Content-Type")request.httpBody = try? JSONSerialization.data(withJSONObject: payload)let task = URLSession.shared.dataTask(with: request) { data, response, error in if let error = error { print("Error: \(error)") return } if let data = data, let responseString = String(data: data, encoding: .utf8) { print(responseString) }}task.resume()
using System;using System.Net.Http;using System.Text;using System.Threading.Tasks;class Program{ static async Task Main(string[] args) { var url = "https://api.apimart.ai/v1/images/generations"; var payload = @"{ ""model"": ""seedream-5-0-flash"", ""prompt"": ""A cyberpunk city night scene, neon lights reflecting on wet streets"", ""size"": ""16:9"", ""resolution"": ""2K"" }"; using var client = new HttpClient(); client.DefaultRequestHeaders.Add("Authorization", "Bearer <token>"); var content = new StringContent(payload, Encoding.UTF8, "application/json"); var response = await client.PostAsync(url, content); var result = await response.Content.ReadAsStringAsync(); Console.WriteLine(result); }}
(* Requires cohttp and yojson libraries *)open Lwtopen Cohttpopen Cohttp_lwt_unixlet url = "https://api.apimart.ai/v1/images/generations"let payload = {|{ "model": "seedream-5-0-flash", "prompt": "A cyberpunk city night scene, neon lights reflecting on wet streets", "size": "16:9", "resolution": "2K"}|}let () = let headers = Header.init () |> fun h -> Header.add h "Authorization" "Bearer <token>" |> fun h -> Header.add h "Content-Type" "application/json" in let body = Cohttp_lwt.Body.of_string payload in let response = Client.post ~headers ~body (Uri.of_string url) >>= fun (resp, body) -> body |> Cohttp_lwt.Body.to_string >|= fun body_str -> print_endline body_str in Lwt_main.run response
import 'dart:convert';import 'package:http/http.dart' as http;void main() async { final url = Uri.parse('https://api.apimart.ai/v1/images/generations'); final payload = { 'model': 'seedream-5-0-flash', 'prompt': 'A cyberpunk city night scene, neon lights reflecting on wet streets', 'size': '16:9', 'resolution': '2K' }; final response = await http.post( url, headers: { 'Authorization': 'Bearer <token>', 'Content-Type': 'application/json', }, body: jsonEncode(payload), ); print(response.body);}
library(httr)library(jsonlite)url <- "https://api.apimart.ai/v1/images/generations"payload <- list( model = "seedream-5-0-flash", prompt = "A cyberpunk city night scene, neon lights reflecting on wet streets", size = "16:9", resolution = "2K")response <- POST( url, add_headers( Authorization = "Bearer <token>", `Content-Type` = "application/json" ), body = toJSON(payload, auto_unbox = TRUE), encode = "raw")cat(content(response, "text"))
import Foundationlet url = URL(string: "https://api.apimart.ai/v1/images/generations")!let payload: [String: Any] = [ "model": "seedream-5-0-flash", "prompt": "A cyberpunk city night scene, neon lights reflecting on wet streets", "size": "16:9", "resolution": "2K"]var request = URLRequest(url: url)request.httpMethod = "POST"request.setValue("Bearer <token>", forHTTPHeaderField: "Authorization")request.setValue("application/json", forHTTPHeaderField: "Content-Type")request.httpBody = try? JSONSerialization.data(withJSONObject: payload)let task = URLSession.shared.dataTask(with: request) { data, response, error in if let error = error { print("Error: \(error)") return } if let data = data, let responseString = String(data: data, encoding: .utf8) { print(responseString) }}task.resume()
using System;using System.Net.Http;using System.Text;using System.Threading.Tasks;class Program{ static async Task Main(string[] args) { var url = "https://api.apimart.ai/v1/images/generations"; var payload = @"{ ""model"": ""seedream-5-0-flash"", ""prompt"": ""A cyberpunk city night scene, neon lights reflecting on wet streets"", ""size"": ""16:9"", ""resolution"": ""2K"" }"; using var client = new HttpClient(); client.DefaultRequestHeaders.Add("Authorization", "Bearer <token>"); var content = new StringContent(payload, Encoding.UTF8, "application/json"); var response = await client.PostAsync(url, content); var result = await response.Content.ReadAsStringAsync(); Console.WriteLine(result); }}
(* Requires cohttp and yojson libraries *)open Lwtopen Cohttpopen Cohttp_lwt_unixlet url = "https://api.apimart.ai/v1/images/generations"let payload = {|{ "model": "seedream-5-0-flash", "prompt": "A cyberpunk city night scene, neon lights reflecting on wet streets", "size": "16:9", "resolution": "2K"}|}let () = let headers = Header.init () |> fun h -> Header.add h "Authorization" "Bearer <token>" |> fun h -> Header.add h "Content-Type" "application/json" in let body = Cohttp_lwt.Body.of_string payload in let response = Client.post ~headers ~body (Uri.of_string url) >>= fun (resp, body) -> body |> Cohttp_lwt.Body.to_string >|= fun body_str -> print_endline body_str in Lwt_main.run response
import 'dart:convert';import 'package:http/http.dart' as http;void main() async { final url = Uri.parse('https://api.apimart.ai/v1/images/generations'); final payload = { 'model': 'seedream-5-0-flash', 'prompt': 'A cyberpunk city night scene, neon lights reflecting on wet streets', 'size': '16:9', 'resolution': '2K' }; final response = await http.post( url, headers: { 'Authorization': 'Bearer <token>', 'Content-Type': 'application/json', }, body: jsonEncode(payload), ); print(response.body);}
library(httr)library(jsonlite)url <- "https://api.apimart.ai/v1/images/generations"payload <- list( model = "seedream-5-0-flash", prompt = "A cyberpunk city night scene, neon lights reflecting on wet streets", size = "16:9", resolution = "2K")response <- POST( url, add_headers( Authorization = "Bearer <token>", `Content-Type` = "application/json" ), body = toJSON(payload, auto_unbox = TRUE), encode = "raw")cat(content(response, "text"))
All API endpoints require Bearer Token authenticationGet your API Key:Visit the API Key Management Page to get your API KeyAdd it to the request header:
Authorization: Bearer YOUR_API_KEY
Single-image model: seedream-5-0-flash generates only 1 image per request (except layer decomposition). The following are rejected (HTTP 400, no task, no charge):
n > 1
sequential_image_generation (group generation is not supported)
stream (streaming is not supported)
tools (web search is not supported)
more than 10 items in image_urls
Interactive editing
Use <point> / <bbox> coordinates in the prompt, or upload an image with hand-drawn annotations, to target edits precisely.
Point coordinates: <point>x y</point> (specify a single point; the model determines the affected area)
Bounding-box coordinates: <bbox>x1 y1 x2 y2</bbox> (specify the top-left and bottom-right coordinates to precisely control the size of the edit area)
Layer decomposition
Split one image into a base image and up to 16 transparent PNG layers, with position and stacking information.
Text description for image generationOptional when layer_decomposition: true; if omitted, the model automatically identifies and separates the main elements in the image.In addition to Chinese and English, native text generation supports Russian, Arabic, Filipino, Thai, Turkish, Korean, Malay, Spanish, Portuguese, Indonesian, French, German, Vietnamese, and Japanese.
Tip: Keep it within 600 English words; overly long descriptions may lose detail.
The tier can be placed directly in size, or supplied through the API Mart extension field resolution:
{ "size": "2K" }
{ "resolution": "2K" }
These forms are equivalent. When only a tier is specified, describe the intended layout in the prompt (for example, “portrait poster” or “landscape cover”) and let the model choose the aspect ratio.
transparent is available only for image-to-image requests with exactly one input image that already has an alpha channel; output_format: "png" is also required.
Whether to decompose the image into layers. When enabled, the model returns one base image and up to 16 PNG layers with alpha channels.Exactly one PNG or JPEG image is required. It must contain [262144, 36000000] total pixels and be no larger than 30 MB. size accepts only 1K, 1.5K, 2K, or auto and defaults to auto. output_format controls only the base image format; decomposed layers are always PNG.
{ "model": "seedream-5-0-flash", "prompt": "Replace the outfit in image 1 with the outfit in image 2", "image_urls": [ "https://example.com/person.jpg", "https://example.com/dress.jpg" ], "resolution": "2K", "size": "auto"}
You can also use <bbox> coordinates normalized to 0–1000 to identify elements to extract precisely:
{ "model": "seedream-5-0-flash", "prompt": "Separate the image into precise layers. The text is at <bbox>180 64 812 198</bbox>; the parrot is at <bbox>347 305 642 997</bbox>.", "image_urls": ["https://example.com/poster.png"], "layer_decomposition": true}
Describe hand-drawn annotations in the image using natural language:
{ "model": "seedream-5-0-flash", "prompt": "Edit the image according to the sketch. Add a stack of magazines in the marked area at the lower left and a cup of coffee in the marked area on the right. Remove all sketch lines and preserve the composition.", "image_urls": ["https://example.com/sketch.png"], "size": "2K", "output_format": "png"}
Or target locations precisely with <point> / <bbox>:
{ "model": "seedream-5-0-flash", "prompt": "Place the subject from image 1 at <bbox>179 283 796 986</bbox> into image 2 at <bbox>118 331 933 871</bbox>.", "image_urls": [ "https://example.com/a.png", "https://example.com/b.png" ]}
{ "model": "seedream-5-0-flash", "prompt": "Change the parrot into a peacock while preserving the transparent background", "image_urls": ["https://cdn.example.com/images/layer.png"], "background": "transparent", "output_format": "png", "size": "2K"}
Complete example: submit a task and retrieve the image
The following script shows the full flow: submit an asynchronous task, poll its status, handle failure states, and read the final image URL. Replace YOUR_API_KEY before running it.
Python
import timeimport requestsAPI_KEY = "YOUR_API_KEY"BASE_URL = "https://api.apimart.ai"headers = { "Authorization": f"Bearer {API_KEY}", "Content-Type": "application/json",}# 1. Submit the generation taskcreate_response = requests.post( f"{BASE_URL}/v1/images/generations", headers=headers, json={ "model": "seedream-5-0-flash", "prompt": "A Jiangnan water town in ink-wash style, with light morning mist", "resolution": "1.5K", "size": "16:9", "output_format": "png", }, timeout=30,)create_response.raise_for_status()task_id = create_response.json()["data"][0]["task_id"]print(f"Task submitted: {task_id}")# 2. Poll task statuswhile True: task_response = requests.get( f"{BASE_URL}/v1/tasks/{task_id}", headers=headers, timeout=30, ) task_response.raise_for_status() task = task_response.json() status = task["status"] print(f"Status: {status}; progress: {task.get('progress', 0)}%") if status == "success": image = task["result"]["images"][0] print("Image URL:", image["url"][0]) print("Image size:", image["sizes"][0]) print("Image format:", image["output_formats"][0]) break if status in {"failed", "cancelled"}: raise RuntimeError(task.get("error", f"Task {status}")) time.sleep(5)
Returned images are mirrored to storage managed by the platform. You should still download and persist them in your own system promptly; do not treat the result URL as permanent storage.
curl -X POST "https://api.apimart.ai/v1/images/generations" \ -H "Authorization: Bearer YOUR_API_KEY" \ -H "Content-Type: application/json" \ -d '{ "model": "seedream-5-0-flash", "prompt": "Place the person from image 1 into the scene from image 2 and unify the lighting at dusk", "image_urls": [ "https://example.com/person.jpg", "https://example.com/scene.jpg" ], "resolution": "1.5K", "size": "16:9", "output_format": "png" }'
Composite layers in ascending z_index order. To reconstruct them on the output base image with absolute coordinates:
x = lefty = topw = right - lefth = bottom - top
To reconstruct them on any W × H canvas, use normalized coordinates:
x = left / 1000 × Wy = top / 1000 × Hw = (right - left) / 1000 × Wh = (bottom - top) / 1000 × H
Layer decomposition is billed per image. Up to 17 images are preauthorized when the task is submitted. After completion, each output is assigned a tier based on its actual pixel count and settled individually; any excess preauthorization is refunded automatically. Your balance must cover the 17-image preauthorization, and size: "auto" is preauthorized at the 2K tier.
Layer-decomposition preauthorization and settlement
Because the final number and dimensions of layers are unknown when a task is submitted, preauthorization uses conservative rules based on the request:
Exact pixels: tiered by the requested pixel area.
1K / 1.5K: preauthorized at the 1K tier.
2K: preauthorized at the 2K tier.
auto: can output up to 2K, so it is preauthorized at the 2K tier.
After completion, the base image and every actual layer are tiered and summed individually using their real pixel areas. Excess preauthorization is refunded automatically. Layers are usually much smaller than the base image, so even a task preauthorized at the 2K tier may ultimately settle entirely at the 1K tier.
Example: a 1080×1080 input is decomposed into 10 images. The task is preauthorized as 17 images × 2K tier. If all 10 final images contain no more than 2.61 million pixels, settlement uses 10 images × 1K tier and the remaining credit is refunded automatically.
Neither 1K / 1.5K / 2K / auto, a supported aspect ratio, nor valid pixel dimensions → 400
Exact-pixel total out of range
Must be in [921600, 4624220]
Exact-pixel aspect out of range
Must be in [1/16, 16]
n > 1 / grouped-image parameters
Rejected by the single-image model
More than 10 reference images
Rejected
Layer decomposition without an image or with multiple images
Exactly one image is required
Layer decomposition with a ratio or exact pixels
size supports only 1K / 1.5K / 2K / auto
Transparent background for text-to-image or multiple inputs
Exactly one input image with an alpha channel is required
Transparent background with JPEG
Set output_format: "png"
stream / tools
Not supported by this model; returns 400
Invalid prompt optimization mode
Only standard is supported
⏱️ Slower generation: ~90s for 1K, ~160s for 2K (quality first). Poll Get Task Status every 5–10 seconds; set the client timeout to 5 minutes. Save generated results promptly.