REST API Reference

Complete reference for the LIFF AI REST API. Base URL: https://api.liffai.com/v1

Authentication

All API requests require a Bearer token in the Authorization header.

Authorization: Bearer sk-liff-your-api-key

POST /generate

Generate an SVG from a text prompt. This is the primary endpoint for SVG generation.

Request Body

ParameterTypeRequiredDescription
promptstringYesText description of the desired SVG
modelstringYesModel ID: liff-v3-pro or liff-v3-flash
colorsstring[]NoHex color codes to enforce (e.g., [#DC2626, #1F2937])
sizeobjectNoOutput dimensions: { width, height }
alpha_edgesbooleanNoEnable clean alpha transparent edges (default: true)
max_anchorsnumberNoMaximum anchor point budget (default: model-dependent)
negative_promptstringNoWhat to avoid in the generation

Example Request

curl -X POST https://api.liffai.com/v1/generate -H "Authorization: Bearer $LIFF_API_KEY" -H "Content-Type: application/json" -d '{ "prompt": "A settings gear icon, 24x24, single color" "model": "liff-v3-flash" "colors": ["#1F2937"] "size": { "width": 24, "height": 24 } "alpha_edges": true }'

Response

{ "id": "gen_abc123", "object": "generation", "svg": "<svg xmlns=...>...</svg>", "model": "liff-v3-flash", "metadata": { "anchorCount": 12, "sizeBytes": 483, "viewBox": "0 0 24 24", "colors": ["#1F2937"], "layers": 2 }, "usage": { "promptTokens": 28, "generationTimeMs": 412 } }

POST /redraw

Perform non-destructive partial redraw on an existing SVG. Only available with liff-v3-pro and liff-v3.5 models.

Request Body

ParameterTypeRequiredDescription
svgstringYesThe source SVG content to modify
regionobjectYesBounding box: { x, y, width, height }
promptstringYesDescription of the desired change
modelstringYesMust be liff-v3-pro or liff-v3.5-*

Error Codes

CodeHTTP StatusDescription
invalid_api_key401Invalid or missing API key
quota_exceeded429Monthly generation quota reached
model_not_available403Model not available on current plan
invalid_color400Invalid hex color code format