Codia
Image Decomposition API

Image Layering API

Decompose a flat image into an ordered stack of editable visual layers for compositing, animation, and downstream design workflows.

API pipeline
Image Layering API
POST
Input
Image
Public image URL or multipart upload
Codia Open API
Layer decomposition
Auth
Queue
Result
Output
Layer DSL
Editable structure
Mode
Single request
Credits
1 credit per request
Output
JSON-encoded layer DSL
POST /v1/open/image/layering
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"
  }'
Response
{
  "code": 0,
  "message": "ok",
  "data": {
    "type": 1,
    "dsl": "{\"layers\":[...]}"
  }
}

Built for production API workflows

Each Codia Open API shares the same authentication, billing, and operational model, so teams can add new visual conversion capabilities without new infrastructure.

Ordered layer stack

Separate background, subject, overlays, and other visual regions into reusable pieces.

Layer DSL output

Receive a JSON-encoded layer tree that can be stored, parsed, or handed to another renderer.

Designed for editing

Use decomposed layers as a starting point for compositing, animation, and fine-grained edits.

Developer reference

The fields below are the pieces most teams need before wiring the API into a real product flow.

Endpoint
POST /v1/open/image/layering
Content types
application/jsonmultipart/form-data
Input
Public image URL or multipart upload

Request fields

FieldTypeRequiredNotes
image_url*string URLYesPublicly fetchable source image for JSON mode.
image*binaryYesSource image file for multipart mode. The compatible field name file is also accepted.

Response fields

FieldTypeRequiredNotes
type*numberYesLayering result type used by downstream renderers.
dsl*stringYesJSON-encoded editable layer tree. Parse this string before traversing layers.

Integration flow

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.

1

Send an image

Pass a public URL or upload the source image directly in multipart form.

2

Parse the DSL

Read the returned JSON string to access layer metadata and generated image URLs.

3

Recompose or edit

Stack, animate, mask, or edit layers independently in your own application.

Copy-ready examples

Start with curl, then adapt the TypeScript or Python flow for your backend worker.

Request with curl · bash
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"
  }'

Limits and production notes

Limits

  • Consumes 1 Open API credit per request.
  • Add-on packs: 100 credits for $19.99, 200 credits for $29.99, or 500 credits for $49.99.
  • Codia checks credits before reading or uploading multipart files.
  • Use directly fetchable image URLs; pages that require cookies or JavaScript will fail.
  • Best results come from images with visually separable subjects, backgrounds, and overlays.

Implementation checklist

  • Parse data.dsl as JSON and validate it before passing it into your renderer.
  • Keep the original image URL or file hash alongside the layer tree for traceability.
  • Use the returned layer assets as editable starting points; complex overlaps may still need user review.
  • For UI screenshots where text/layout fidelity matters more than visual separation, use Image to DSL instead.

Error handling

CodeMeaningWhat to do
400Invalid request body, missing required fields, unsupported file, or malformed URL.Validate input client-side and log the API response message for the failed request.
401Missing or invalid API key.Send Authorization: Bearer {codia_api_key}; rotate the key if validation keeps failing.
402Insufficient Open API credits.Stop retrying automatically and ask the workspace owner to top up or upgrade.
429Rate limit or concurrency limit reached.Retry with exponential backoff and a small amount of jitter.
500Temporary server-side failure.Retry idempotent polling calls; for submit calls, store your client request ID and avoid duplicate work.

Where teams use it

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.

Which API should you use?

Similar visual APIs solve different integration problems. Use this table to route users to the right endpoint.

APIBest forNot for
Image LayeringSeparating 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 DSLReconstructing screenshots into structured design nodes and editable UI layout.Keeping visual regions as independent raster/compositing layers.
RemoveBGFast subject cutout and transparent-background output.Building a full ordered layer tree from the entire image.

定價

每項產品都採透明定價。免費開始,隨成長同步升級。

FAQ

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.

Build with Image Layering API

Use one Codia Open API balance across visual structure, presentation conversion, vectorization, background removal, and image processing workflows.