Skip to content

Image to SVG

IMAGEfal-image-to-svg

Image-to-SVG vectorization with tunable path, color and detail settings: https://fal.ai/models/fal-ai/image2svg

POST
/v2/workspaces/{workspace_id}/base-models/fal-image-to-svg/inferences
curl --request POST \
--url https://api.app.layer.ai/api/v2/workspaces/:workspace_id/base-models/fal-image-to-svg/inferences \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '{
"vectorization_color_mode": "COLOR",
"vectorization_mode": "SPLINE",
"vectorization_layering": "STACKED",
"guidance_file_init_image": [
{
"url": "<file_url>"
}
]
}'
workspace_id
required
Workspace Id

Id of the workspace that owns the resource.

string format: uuid

Id of the workspace that owns the resource.

session_name
Session Name

Organize this run under a named session. A new session is created if none matches.

string
nullable

Organize this run under a named session. A new session is created if none matches.

Idempotency-Key
string
<= 255 characters

Opaque key making a retry of this request return the first result. A 2xx response is replayed for 24 hours with Idempotent-Replayed: true. A 4xx releases the key. A 5xx, or a request still running, holds the key for 120 seconds, during which a retry gets 409; after that a retry executes again. The key covers the method, path, query, and byte-identical body it was first used with; reusing it for a different request is rejected with 422. Protection is best effort: if the key store is unavailable, or a record is lost early, a retry can execute again even after an earlier 409. See the Idempotency section of the API description.

Media typeapplication/json
Image to SVG
object
vectorization_color_mode
Colors

Full color, or black and white only.

string
default: COLOR
Allowed values: COLOR BINARY
vectorization_mode
Paths

Smooth curves, or straight-edged polygons.

string
default: SPLINE
Allowed values: SPLINE POLYGON
vectorization_layering
Layering

Stacked shapes overlap the ones beneath. Cutout shapes leave holes where others sit, so no two overlap. Color output only.

string
default: STACKED
Allowed values: STACKED CUTOUT
vectorization_filter_speckle
Speckle filter

Drops specks smaller than this many pixels. Higher cleans up noise but loses fine detail.

Advanced field.

integer
default: 4 <= 20 multiple of 1
vectorization_color_precision
Color precision

How finely colors are told apart. Lower merges similar colors into fewer flat regions. Color output only.

Advanced field.

integer
default: 6 >= 1 <= 10 multiple of 1
vectorization_layer_difference
Gradient step

How different two colors must be to become separate layers. Lower keeps more gradient bands. Color output only.

Advanced field.

integer
default: 16 >= 1 <= 32 multiple of 1
vectorization_corner_threshold
Corner threshold

The angle, in degrees, a turn must reach to stay a sharp corner. Higher rounds more corners into curves. Curves only.

Advanced field.

integer
default: 60 <= 180 multiple of 1
vectorization_length_threshold
Segment length

The longest a curve segment may run before it is subdivided. Lower follows the outline more closely, with more points. Curves only.

Advanced field.

number
default: 4 <= 10
vectorization_splice_threshold
Splice threshold

The angle, in degrees, at which a curve is split into separate segments. Lower splits more often. Curves only.

Advanced field.

integer
default: 45 <= 90 multiple of 1
vectorization_max_iterations
Curve fitting passes

How many passes the curve fitting makes. More can tidy curves, at the cost of time.

Advanced field.

integer
default: 10 >= 1 <= 20 multiple of 1
vectorization_path_precision
Path precision

Decimal places kept in path coordinates. Lower makes a smaller file, higher keeps shapes exact.

Advanced field.

integer
default: 3 >= 1 <= 10 multiple of 1
guidance_file_init_image
required
Source image

The image to modify

Array<object>
>= 1 items
InferenceFormFileRef

A single guidance/reference file supplied to a reference_image_list field.

The slot’s guidance type is fixed by the field it’s attached to; the caller supplies the file (its URL, or the id of a file it can read) and, where the model supports per-file weighting, a weight.

object
url
required
Url

The file’s URL, or the id of a file in this workspace or a public file.

string
weight
Weight
number
nullable
output_fit
Output canvas

Trim the transparent margin, and place the image on a canvas of a fixed size.

object
trim
Trim
boolean
canvas
OutputFitCanvas
string
default: CONTENT
Allowed values: CONTENT FIXED
width
Width
integer
nullable >= 1 <= 4096
height
Height
integer
nullable >= 1 <= 4096
scale
OutputFitScale

How the drawing goes onto a fixed canvas. The names follow the workflow Resize node’s.

string
default: PLACE
Allowed values: PLACE SHRINK_AND_PAD FIT_AND_PAD FIT_AND_CROP STRETCH
anchor
OutputFitAnchor

The point of the drawing that lands on the same point of the canvas.

BASE is a game tile’s base: its anchor, the bottom centre of the cell it stands on, lands at the bottom centre of the canvas, so tiles of one grid stand on the same point whatever rises above them.

string
default: CENTER
Allowed values: TOP_LEFT TOP_CENTER TOP_RIGHT CENTER_LEFT CENTER CENTER_RIGHT BOTTOM_LEFT BOTTOM_CENTER BOTTOM_RIGHT BASE
padding
Padding
integer
0 <= 512
Example
{
"vectorization_color_mode": "COLOR",
"vectorization_mode": "SPLINE",
"vectorization_layering": "STACKED",
"guidance_file_init_image": [
{
"url": "<file_url>"
}
]
}

Successful Response

Media typeapplication/json
ExecuteForgeOutput
object
inference_id
required
Inference Id

Unique identifier for this forge run.

string format: uuid
status
required
InferenceStatus

Current status: IN_PROGRESS.

string
Allowed values: in_progress complete failed cancelled deleted
estimated_price_creative_units
Estimated Price Creative Units

Estimated price in Creative Units.

number
nullable
poll_interval_seconds
required
Poll Interval Seconds

Suggested polling interval in seconds.

integer
created_at
required
Created At

Timestamp of when the run was created.

string format: date-time
session_id
Session Id

Session ID the run was added to, if a session was specified.

string format: uuid
nullable
normalized_parameters
Any of:
NormalizedInferenceParameters

Inference parameters after model-specific normalization.

These reflect the actual values used for generation, including model defaults applied for any parameters not explicitly set.

object
width
Width

Resolved output width in pixels.

integer
nullable
height
Height

Resolved output height in pixels.

integer
nullable
batch_size
Batch Size

Number of outputs to generate.

integer
nullable
num_inference_steps
Num Inference Steps

Resolved number of diffusion steps.

integer
nullable
guidance_scale
Guidance Scale

Resolved guidance scale.

number
nullable
duration_seconds
Duration Seconds

Resolved output length in seconds — video duration or audio clip length.

number
nullable
fps
Fps

Resolved FPS.

integer
nullable
Example
{
"status": "in_progress"
}

Unauthenticated — missing or invalid Bearer token.

Media typeapplication/problem+json
object
type
required
string
title
required
string
status
required
integer
detail
required
string
Example
{
"type": "https://api.layer.ai/errors/ERROR_CODE",
"title": "Error Title",
"status": 400,
"detail": "Human-readable description."
}

Forbidden — insufficient permissions, or the access token lacks the scope the operation requires.

Media typeapplication/problem+json
object
type
required
string
title
required
string
status
required
integer
detail
required
string
Example
{
"type": "https://api.layer.ai/errors/ERROR_CODE",
"title": "Error Title",
"status": 400,
"detail": "Human-readable description."
}

Resource not found.

Media typeapplication/problem+json
object
type
required
string
title
required
string
status
required
integer
detail
required
string
Example
{
"type": "https://api.layer.ai/errors/ERROR_CODE",
"title": "Error Title",
"status": 400,
"detail": "Human-readable description."
}

The outcome of the request with this Idempotency-Key is not known yet: it is still running, or it failed without a stored response. Retry after the number of seconds in Retry-After.

Media typeapplication/problem+json
object
type
required
string
title
required
string
status
required
integer
detail
required
string
Example
{
"type": "https://api.layer.ai/errors/ERROR_CODE",
"title": "Error Title",
"status": 400,
"detail": "Human-readable description."
}

Invalid input parameters, or an Idempotency-Key reused for a different request.

Media typeapplication/problem+json
object
type
required
string
title
required
string
status
required
integer
detail
required
string
Example
{
"type": "https://api.layer.ai/errors/ERROR_CODE",
"title": "Error Title",
"status": 400,
"detail": "Human-readable description."
}

Rate limited — retry after the number of seconds in Retry-After.

Media typeapplication/problem+json
object
type
required
string
title
required
string
status
required
integer
detail
required
string
Example
{
"type": "https://api.layer.ai/errors/ERROR_CODE",
"title": "Error Title",
"status": 400,
"detail": "Human-readable description."
}

Internal server error.

Media typeapplication/problem+json
object
type
required
string
title
required
string
status
required
integer
detail
required
string
Example
{
"type": "https://api.layer.ai/errors/ERROR_CODE",
"title": "Error Title",
"status": 400,
"detail": "Human-readable description."
}