← Modal Generator
Your token

Modal Generator API

Modal Generator API

The dialog, the preview, the check against the timing rules and every copy and download run free in the browser and need no API. The API is for the one metered step: send the current dialog's settings and words and a description of what it is for, and get back, as JSON, advice for that dialog: keep or change, a summary, how it arrives (kind, entrance, time, curve), how fast it leaves, how the page behind dims (fade time, dim, blur, what a click outside does), how the content follows the box (delay, stagger), the animation principles at work and what to avoid. The page builds this input for you, checks the reply against the rules and draws the dialog.

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

taskWhat it doesReply
adviseReads one dialog's settings and words, the page's check and your description of what it is for, and returns keep or change, a summary, the entrance (kind, entrance, time, curve), the exit time, the backdrop (time, dim, blur, click outside), the content timing (delay, stagger), principles and things to avoid.One JSON object

Input fields

Every field is a string; page_check holds JSON text. task, title and description are required.

FieldMeaning
task"advise"
kindcenter, sheet or drawer.
entrancescale, pop, fade or rise (used by a centred dialog).
titleThe dialog's title. The advice keeps the words.
messageThe message, one paragraph per line (may be empty).
ok_labelThe main button's label.
cancel_labelThe second button's label, or empty.
destructiveyes when the main button deletes or discards something, else no.
item_countHow many items follow the box in (title, message lines, buttons).
enter_msHow long the dialog takes to arrive.
exit_msHow long it takes to leave (ease-in).
backdrop_msHow long the page behind takes to dim.
easingsmooth (cubic-bezier(0.16, 1, 0.3, 1)), ease-out, ease-in-out or linear.
content_delay_msHow long after the box the first item starts.
stagger_msThe gap between one item and the next ("0" = together).
dim_percentHow dark the page behind gets, 0-90.
blur_pxHow much the page behind blurs ("0" = none).
outside_clickclose or shake.
page_check{enter_range_ms, exit_target_ms, exit_range_ms, backdrop_range_ms, content_delay_range_ms, stagger_range_ms, dim_range_percent, blur_range_px, shake_ms, last_item_start_ms, content_in_ms, text_contrast, button_contrast, verdict, notes}, from the page.
descriptionWhat the dialog is for, who sees it, how often and on which devices, and the brand's character (at most 1,200 characters).
clipped_noteEmpty, or a sentence saying the description was cut.

The reply

job.output.output is text holding one JSON object: verdict (keep or change), summary, enter ({kind, entrance, ms, easing, why}), exit ({ms, why}), backdrop ({ms, dim, blur, outside, why}), content ({delay, stagger, why}), principles ([{name, how}], names from the 12 principles of animation) and avoid. Before using it, check the values as the page does: an entrance of 250-350 ms on smooth or ease-out (never linear), an exit near 200 ms (150-250) that is quicker than the entrance, a backdrop fade of 200-250 ms, a dim of 50-70%, a blur of 0 or 4-8 px, content 50-100 ms after the box and 30-50 ms apart (0 only when asked for). 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 "Delete confirm" example:

{
  "task": "advise",
  "kind": "center",
  "entrance": "scale",
  "title": "Delete this project?",
  "message": "All 24 files and their history will be removed. This can't be undone.",
  "ok_label": "Delete project",
  "cancel_label": "Cancel",
  "destructive": "yes",
  "item_count": "3",
  "enter_ms": "300",
  "exit_ms": "200",
  "backdrop_ms": "250",
  "easing": "smooth",
  "content_delay_ms": "80",
  "stagger_ms": "40",
  "dim_percent": "60",
  "blur_px": "4",
  "outside_click": "shake",
  "page_check": "{\"enter_range_ms\":[250,350],\"exit_target_ms\":200,\"exit_range_ms\":[150,250],\"backdrop_range_ms\":[200,250],\"content_delay_range_ms\":[50,100],\"stagger_range_ms\":[30,50],\"dim_range_percent\":[50,70],\"blur_range_px\":[4,8],\"shake_ms\":300,\"last_item_start_ms\":160,\"content_in_ms\":370,\"text_contrast\":17.74,\"button_contrast\":4.83,\"verdict\":\"good\",\"notes\":[]}",
  "description": "Confirmation before someone deletes a project in a project-management web app, mostly on laptops. It is destructive and permanent, so people should read it and choose; a stray click outside must not dismiss it. Calm, professional brand.",
  "clipped_note": ""
}

Reply:

{"verdict":"keep","summary":"This delete confirmation should arrive with a calm, controlled scale-in, then let the title, the warning line and the buttons follow one after another so people read before they choose. The current settings already suit a rare, permanent action on laptops for a calm, professional brand, and a click outside should shake the box rather than close it.","enter":{"kind":"center","entrance":"scale","ms":300,"easing":"smooth","why":"A centred box with a subtle scale-in is the steady default for a destructive confirmation, and the smooth curve decelerates in without drama."},"exit":{"ms":200,"why":"Leaving quickly and quicker than the entrance keeps the app feeling responsive once an answer is given."},"backdrop":{"ms":250,"dim":60,"blur":4,"outside":"shake","why":"A 60 percent dim with a light blur puts the focus on the question, and the shake tells people an answer is needed because deleting is permanent."},"content":{"delay":80,"stagger":40,"why":"The box lands first, then the title, the warning and the buttons come in 40 ms apart, which gives a rare, serious dialog time to be read."},"principles":[{"name":"Staging","how":"The dimmed, slightly blurred project page behind makes the delete question the only thing to look at."},{"name":"Timing","how":"A 300 ms arrival with a quicker 200 ms exit feels deliberate on the way in and light on the way out."},{"name":"Follow Through & Overlapping Action","how":"The text and the Delete project and Cancel buttons settle in just after the box, so the box leads and the words follow."},{"name":"Appeal","how":"A smooth, unhurried entrance fits the calm, professional brand and avoids a jarring interruption."}],"avoid":["Do not use a pop overshoot, because deleting a project is serious and should not feel playful.","Do not let a click outside dismiss the dialog.","Do not shorten the stagger to make it feel instant, since people should read the warning before the buttons."]}

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 a required field is missing or empty.
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://modal-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":"modal-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": "advise", "kind": "center", "entrance": "scale", "title": "Delete this project?", "message": "All 24 files and their history will be removed. This can't be undone.", "ok_label": "Delete project", "cancel_label": "Cancel", "destructive": "yes", "item_count": "3", "enter_ms": "300", "exit_ms": "200", "backdrop_ms": "250", "easing": "smooth", "content_delay_ms": "80", "stagger_ms": "40", "dim_percent": "60", "blur_px": "4", "outside_click": "shake", "page_check": "{...}", "description": "Confirmation before someone deletes a project in a project-management web app, mostly on laptops. It is destructive and permanent, so people should read it and choose; a stray click outside must not dismiss it. Calm, professional brand.", "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="modal-generator:advise:$(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, enter, exit, backdrop, content, principles, avoid
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: modal-generator:advise:$(shasum -a 256 input.json | cut -c1-16):a1" --data @input.json