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-keyPOST /generate
Generate an SVG from a text prompt. This is the primary endpoint for SVG generation.
Request Body
| Parameter | Type | Required | Description |
|---|---|---|---|
| prompt | string | Yes | Text description of the desired SVG |
| model | string | Yes | Model ID: liff-v3-pro or liff-v3-flash |
| colors | string[] | No | Hex color codes to enforce (e.g., [#DC2626, #1F2937]) |
| size | object | No | Output dimensions: { width, height } |
| alpha_edges | boolean | No | Enable clean alpha transparent edges (default: true) |
| max_anchors | number | No | Maximum anchor point budget (default: model-dependent) |
| negative_prompt | string | No | What 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
| Parameter | Type | Required | Description |
|---|---|---|---|
| svg | string | Yes | The source SVG content to modify |
| region | object | Yes | Bounding box: { x, y, width, height } |
| prompt | string | Yes | Description of the desired change |
| model | string | Yes | Must be liff-v3-pro or liff-v3.5-* |
Error Codes
| Code | HTTP Status | Description |
|---|---|---|
| invalid_api_key | 401 | Invalid or missing API key |
| quota_exceeded | 429 | Monthly generation quota reached |
| model_not_available | 403 | Model not available on current plan |
| invalid_color | 400 | Invalid hex color code format |