Decompose a flat image into an ordered stack of editable visual layers for compositing, animation, and downstream design workflows.
curl 'https://api.codia.ai/v1/open/image/layering' \
-H 'Authorization: Bearer {codia_api_key}' \
-H 'Content-Type: application/json' \
--data '{
"image_url": "https://example.com/campaign.png"
}'{
"code": 0,
"message": "ok",
"data": {
"type": 1,
"dsl": "{\"layers\":[...]}"
}
}Each Codia Open API shares the same authentication, billing, and operational model, so teams can add new visual conversion capabilities without new infrastructure.
Separate background, subject, overlays, and other visual regions into reusable pieces.
Receive a JSON-encoded layer tree that can be stored, parsed, or handed to another renderer.
Use decomposed layers as a starting point for compositing, animation, and fine-grained edits.
The fields below are the pieces most teams need before wiring the API into a real product flow.
| Field | Type | Required | Notes |
|---|---|---|---|
| image_url* | string URL | Yes | Publicly fetchable source image for JSON mode. |
| image* | binary | Yes | Source image file for multipart mode. The compatible field name file is also accepted. |
| Field | Type | Required | Notes |
|---|---|---|---|
| type* | number | Yes | Layering result type used by downstream renderers. |
| dsl* | string | Yes | JSON-encoded editable layer tree. Parse this string before traversing layers. |
Build the happy path first, then add polling, retry, and terminal error handling around it. Async APIs should store the returned task or record ID before the user leaves the current screen.
Pass a public URL or upload the source image directly in multipart form.
Read the returned JSON string to access layer metadata and generated image URLs.
Stack, animate, mask, or edit layers independently in your own application.
Start with curl, then adapt the TypeScript or Python flow for your backend worker.
curl 'https://api.codia.ai/v1/open/image/layering' \
-H 'Authorization: Bearer {codia_api_key}' \
-H 'Content-Type: application/json' \
--data '{
"image_url": "https://example.com/campaign.png"
}'| Code | Meaning | What to do |
|---|---|---|
| 400 | Invalid request body, missing required fields, unsupported file, or malformed URL. | Validate input client-side and log the API response message for the failed request. |
| 401 | Missing or invalid API key. | Send Authorization: Bearer {codia_api_key}; rotate the key if validation keeps failing. |
| 402 | Insufficient Open API credits. | Stop retrying automatically and ask the workspace owner to top up or upgrade. |
| 429 | Rate limit or concurrency limit reached. | Retry with exponential backoff and a small amount of jitter. |
| 500 | Temporary server-side failure. | Retry idempotent polling calls; for submit calls, store your client request ID and avoid duplicate work. |
Codia APIs are designed for applications that need visual understanding, asset conversion, and editable outputs at scale.
Turn campaign graphics into editable layer sets.
Prepare subject and background layers for AI-assisted image editing.
Create animated reveal effects from a single static image.
Extract layer assets for creative automation pipelines.
Similar visual APIs solve different integration problems. Use this table to route users to the right endpoint.
| API | Best for | Not for |
|---|---|---|
| Image Layering | Separating a flat image into background, subject, overlay, and other editable visual layers. | Extracting semantic UI components, text hierarchy, or code-friendly layout structure. |
| Image to DSL | Reconstructing screenshots into structured design nodes and editable UI layout. | Keeping visual regions as independent raster/compositing layers. |
| RemoveBG | Fast subject cutout and transparent-background output. | Building a full ordered layer tree from the entire image. |
ราคาโปร่งใสสำหรับทุกผลิตภัณฑ์ เริ่มต้นฟรี ขยายตามการเติบโตของคุณ
Common implementation questions for Image Layering API.
Image to Design returns a structural design tree with layout and style fields. Image Layering returns visual layers that can be stacked and edited independently.
The layer tree is returned as a JSON-encoded string in data.dsl so it can be stored or streamed without re-encoding.
No. It uses Codia’s dedicated layering pipeline and currently exposes a focused request shape.
All three APIs use the unified Codia Open API balance. You can subscribe to an Open API plan or buy add-on credits: 100 credits for $19.99, 200 credits for $29.99, or 500 credits for $49.99.
Use one Codia Open API balance across visual structure, presentation conversion, vectorization, background removal, and image processing workflows.