← CSS Animation Generator
Your token

CSS Animation Generator API

The effect library, reading your CSS, the preview, the check and every copy and download run free in the browser and need no API. The API is for the one metered step: send an animation as CSS, what it is for, its timing and a description, and get back, as JSON, the animation that fits the description: keep it, adjust it or a new one, with keyframes, timing and a before/after table. The page builds this input for you, rebuilds the CSS from the reply and checks it with the same rules.

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": "write".

taskWhat it doesReply
writeReads one CSS keyframe animation, its use and timing, the page's measurements and your description, and returns a verdict (keep, adjust, new), the keyframes as offsets with styles, the timing, what it is for, a Before/After table, what people who ask for less motion see, and checks to try.One JSON object

Input fields

Every field is a string; page_check holds JSON text.

FieldMeaning
task"write"
animation_cssThe current animation: one @keyframes block, a rule with its animation line and a reduced-motion rule (at most 4,000 characters; longer CSS loses middle frames).
nameThe @keyframes name.
useenter, exit, micro, hover, page, attention or loading.
duration_ms, delay_msMilliseconds.
easingA CSS easing: keyword, cubic-bezier(), steps() or linear().
iterationsA number or infinite.
direction, fill_modeCSS animation-direction and animation-fill-mode values.
page_check{verdict, notes, animated_properties: {composite, paint, layout}, flashes_per_second, usual_range_ms, frames}, from the page.
descriptionOptional: what the motion should do and what it is on (at most 1,200 characters).
clipped_noteEmpty, or a sentence saying the description or the CSS was cut.

The reply

job.output.output is text holding one JSON object: verdict, summary, name, use, keyframes (a list of {offset: 0-1, styles: {css-property: value}, easing}), timing ({duration_ms, easing, delay_ms, iterations, direction, fill_mode}), changes (at most 6 {before, after} rows), reduced_motion and checks. Before using it, check the offsets are between 0 and 1, the property names are CSS, the easing is valid and the duration suits the use, as the page does. If the balance ran low, truncated is true and the object may stop early; the page keeps every part that arrived whole.

Worked example

Input (input.json), from the page's "Slow drawer" example:

{
  "task": "write",
  "animation_css": "@keyframes drawerIn {\n  from { left: -320px; }\n  to { left: 0; }\n}\n\n.drawer-in {\n  animation: drawerIn 800ms ease-in;\n}\n\n@media (prefers-reduced-motion: reduce) {\n  .drawer-in {\n    animation: none;\n  }\n}",
  "name": "drawerIn",
  "use": "enter",
  "duration_ms": "800",
  "easing": "ease-in",
  "iterations": "1",
  "direction": "normal",
  "fill_mode": "none",
  "delay_ms": "0",
  "page_check": "{\"verdict\":\"avoid\",\"notes\":[\"avoid layout: Animates left: the browser redoes layout every frame. Move it with transform (translate, scale) instead.\",\"consider duration: 800 ms is outside the usual 200-300 ms for something appearing.\",\"consider slow: The skill keeps interface feedback under 300 ms; 800 ms will feel slow when people use it often.\",\"consider easing: ease-in is not the usual ease-out for something appearing.\",\"consider no-reduced: Your CSS has no prefers-reduced-motion rule. The copied CSS adds one that turns the animation off for people who ask for less motion.\"],\"animated_properties\":{\"composite\":[],\"paint\":[],\"layout\":[\"left\"]},\"flashes_per_second\":0,\"usual_range_ms\":[200,300],\"frames\":2}",
  "description": "A 320 px navigation drawer that slides in from the left edge when the menu button is tapped on a phone.",
  "clipped_note": ""
}

Reply:

{"verdict":"adjust","summary":"I kept your slide-in from the left edge but moved it with transform: translateX(-100%) to none instead of animating left, so the phone does not redo layout every frame. I also shortened it from 800 ms ease-in to 280 ms ease-out, so the 320 px drawer arrives quickly and settles gently after the menu tap.","name":"drawerIn","use":"enter","keyframes":[{"offset":0,"styles":{"transform":"translateX(-100%)"},"easing":null},{"offset":1,"styles":{"transform":"none"},"easing":null}],"timing":{"duration_ms":280,"easing":"ease-out","delay_ms":0,"iterations":"1","direction":"normal","fill_mode":"both"},"changes":[{"before":"left: -320px -> 0","after":"transform: translateX(-100%) -> none"},{"before":"800ms","after":"280ms"},{"before":"ease-in","after":"ease-out"},{"before":"fill-mode none","after":"fill-mode both"}],"reduced_motion":"People who ask for less motion see the drawer appear in place at the left edge at once, with no slide.","checks":["Set the drawer's resting position with left: 0 (or position it at the edge) so only the transform animates.","Tap the menu button on a real phone and confirm the drawer starts fully off-screen with no flash at the edge.","Pair it with a shorter exit (150-200 ms, ease-in, forwards) for closing."]}

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.
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://css-animation-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":"css-animation-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": "write", "animation_css": "@keyframes drawerIn { from { left: -320px; } to { left: 0; } } ...", "name": "drawerIn", "use": "enter", "duration_ms": "800", "easing": "ease-in", "iterations": "1", "direction": "normal", "fill_mode": "none", "delay_ms": "0", "page_check": "{...}", "description": "A 320 px navigation drawer", "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="css-animation-generator:write:$(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: verdict, summary, name, use, keyframes, timing, changes, ...
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: css-animation-generator:write:$(shasum -a 256 input.json | cut -c1-16):a1" --data @input.json