← Clip-path Generator
Your token

Clip-path Generator API

Reading, previewing, dragging, checking and writing a clip-path all run free in the browser and need no API. The API is for the one metered step: send a description of a shape, and optionally the clip-path you have now, and get back, as JSON, the points of one polygon(), its cut size and the element it suits. The page builds this input for you and re-reads and checks every point in the reply.

Base URL: https://api.skillsafe.ai/v1/app-api. Every response is {"data": ...} or {"error": {"code", "message"}}; read error.code and error.message rather than the HTTP status alone.

The task field

This app has one task. Always send "task": "shape".

taskWhat it doesReply
shapeReads a description of a shape and the current clip-path (if any), and returns the points of one clip-path polygon. With a description that asks for a change, it edits the current shape; with an empty description, it fixes the current shape's flagged problems.One JSON object

Input fields

Every field is a string; page_check holds JSON text. Only task is required.

FieldMeaning
task"shape"
descriptionThe shape you want, or what to change in the current one (at most 1,500 characters). May be empty when current is set.
currentEmpty, or the current clip-path value: polygon(...), inset(...), circle(...) or ellipse(...).
page_check{component, size_px, shape, verdict, cut_px, notes} about current, from the page; component is button, card, panel or photo.
clipped_noteEmpty, or a sentence saying the description was cut.

The reply

job.output.output is text holding one JSON object: summary, name, points (3 to 24 [x, y] pairs of strings, each 0, Npx, N% or calc(100% - Npx), clockwise), cut_px (the corner cut in px, or null), component (button, card, panel or photo) and notes. Join the points as clip-path: polygon(x1 y1, x2 y2, ...). Before using it, check every value reads, the points stay inside the box and no edges cross at your element's size, as the page does. If the balance ran low, truncated is true and the object may stop early; the page keeps every point that arrived whole.

Worked example

Input (input.json): a card with four 14 px cuts, asking for only two corners at 18 px:

{
  "task": "shape",
  "description": "Keep the cut only on the top right and the bottom left corners, and make those cuts 18px.",
  "current": "polygon(14px 0, calc(100% - 14px) 0, 100% 14px, 100% calc(100% - 14px), calc(100% - 14px) 100%, 14px 100%, 0 calc(100% - 14px), 0 14px)",
  "page_check": "{\"component\":\"card\",\"size_px\":\"320x200\",\"shape\":\"All four corners cut, 14 px\",\"verdict\":\"good\",\"cut_px\":14,\"notes\":[]}",
  "clipped_note": ""
}

Reply:

{"summary":"Only the top right and bottom left corners are cut, each by 18px, while the top left and bottom right stay square. The two cuts mirror each other across the diagonal, so the shape reads as a pair.","name":"Top right bottom left cut","points":[["0","0"],["calc(100% - 18px)","0"],["100%","18px"],["100%","100%"],["18px","100%"],["0","calc(100% - 18px)"]],"cut_px":18,"component":"card","notes":["Give the text at least 18px padding near the top right and bottom left corners so it clears the cuts","Check that the square top left and bottom right corners match the rest of your layout"]}

Errors

HTTPWhat to do
401The token is missing, expired or a guest token on a run. Get a personal token on the token page.
402The balance is below what the run reserves. Top up at skillsafe.ai/account/billing.
400The body is not a JSON object of the fields above, or task is missing.
429Wait and retry with the same Idempotency-Key.

Step 1 — a tiny client helper

One function that sends JSON and unwraps the {data, error} envelope.

BASE="https://api.skillsafe.ai/v1/app-api"
TOKEN="paste-your-token-here"   # from https://clip-path-generator.skillsafe.ai/tokens.html
api() { # api METHOD PATH [JSON-BODY]
  curl -s -X "$1" "$BASE$2" -H "Content-Type: application/json" \
    ${TOKEN:+-H "Authorization: Bearer $TOKEN"} ${3:+--data "$3"}
}

Step 2 — a token

A guest token is enough for /me and /estimate. A run is metered, so it needs your personal token: sign in on the token page and copy it.

# a guest token (enough for /me and /estimate); a run needs your personal token from /tokens.html
TOKEN=$(curl -s -X POST "$BASE/guest" -H "Content-Type: application/json" -d '{"slug":"clip-path-generator"}' | jq -r '.data.token')

Step 3 — who am I, and my balance

subject_type is guest or user; credits is the balance (1 credit = $0.0001).

api GET /me | jq '.data | {subject_type, credits}' 

Step 4 — price a run for free

/estimate charges nothing and starts no job. hold_credits is the amount reserved while a run is in flight, not the price; the run is charged what it uses.

# input.json: the run input object - {"task": "shape", "description": "Four 12px cut corners on a card", "current": "", "page_check": "{}", "clipped_note": ""}
api POST /estimate "$(cat input.json)" | jq '.data | {hold_credits, min_credits, model, model_alias, markup_bps, warnings}' 

Step 5 — run it and wait for the job

Send an Idempotency-Key derived from the input: a retry with the same key is never billed twice.

KEY="clip-path-generator:shape:$(shasum -a 256 input.json | cut -c1-16):a1"
JOB=$(curl -s -X POST "$BASE/run" -H "Content-Type: application/json" -H "Authorization: Bearer $TOKEN" \
  -H "Idempotency-Key: $KEY" --data @input.json | jq -r '.data.job_id')
while :; do
  J=$(api GET "/jobs/$JOB"); S=$(echo "$J" | jq -r '.data.status')
  case "$S" in succeeded|failed|cancelled) break;; esac; sleep 2
done
echo "$J" | jq -r '.data.output.output' > reply.json   # one JSON object: summary, name, points, cut_px, component, notes
echo "$J" | jq '.data | {charged_credits, truncated}' 

Step 6 — or stream it

/run-stream sends Server-Sent Events while the job runs and the finished job at the end.

# Server-Sent Events: tick/delta events while the job runs, then a final event with the job
curl -N -s -X POST "$BASE/run-stream" -H "Content-Type: application/json" -H "Authorization: Bearer $TOKEN" \
  -H "Idempotency-Key: clip-path-generator:shape:$(shasum -a 256 input.json | cut -c1-16):a1" --data @input.json