← Video to ASCII
Your token

Video to ASCII API

Turning a video into ASCII art (the WebM with sound, the GIF, the PNG frame and the text frame) is free in the browser and needs no API. The API is for the one metered step: send a few words about the mood you want and a few numbers measured from your clip, get back three looks as JSON. A look is a set of page settings: the characters, the colours, the brightness curve, the characters across and a finish. Apply a look in the page to remake the video with it.

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

taskWhat it doesReply
styleSuggests three different looks for the clip from the mood: at least one maps brightness onto a palette and at least one does not, no two share both characters and colour kind. Mono and palette colours have at least 3:1 contrast with the background; the brightness curve follows the measured brightness.One ```json block

Input fields

FieldTypeMeaning
taskstring"style". Required.
moodstringA few words about the look you want, up to 200 characters. Required (at least 3 characters).
factsstringJSON text the page measures: clip (seconds, width, height), measured (mean_brightness, dark_p5, bright_p95, saturation, main_colours, motion), current (the settings now) and limits. Send "{}" if you have nothing; the looks then rest on the mood alone.

The reply

job.output.output is text: one fenced ```json block holding {"looks": [...]}. Each look has name, charset (standard, detailed, blocks, binary, matrix, dots or custom), chars (light to heavy, starting with a space, only for custom), colour (video = the clip's own colours, mono = foreground, palette = brightness mapped onto palette, darkest first), foreground, background, palette (all #rrggbb), gamma (0.4-1.2, lower is brighter), columns (40-200 characters across), finish (none, glow or crt), invert and why. If the balance ran low, truncated is true and the array may stop early; the complete looks before the cut are still usable.

Worked example

Input (input.json):

{
  "task": "style",
  "mood": "rainy neon city at night",
  "facts": "{\"clip\":{\"seconds\":3.5,\"width\":640,\"height\":360},\"measured\":{\"mean_brightness\":0.312,\"dark_p5\":0.043,\"bright_p95\":0.78,\"saturation\":0.41,\"main_colours\":[\"#ff8a3d\",\"#3d6aa8\",\"#7a1f05\"],\"motion\":0.021},\"current\":{\"charset\":\"standard\",\"colour\":\"video\",\"columns\":100,\"gamma\":0.75,\"finish\":\"none\"},\"limits\":{\"columns\":[40,200],\"gamma\":[0.4,1.2],\"custom_chars_max\":32}}"
}

Reply:

```json
{"looks": [
  {"name": "Neon rain", "charset": "matrix", "chars": "", "colour": "palette", "foreground": "", "background": "#05030d", "palette": ["#2a0845", "#6a1b9a", "#ff2e88", "#00e5ff"], "gamma": 0.65, "columns": 110, "finish": "glow", "invert": false, "why": "Katakana rain in magenta and cyan on near-black, with a soft glow like wet signs at night."},
  {"name": "Street colour", "charset": "detailed", "chars": "", "colour": "video", "foreground": "", "background": "#000000", "palette": [], "gamma": 0.6, "columns": 130, "finish": "glow", "invert": false, "why": "Keeps the footage's own colours in fine detail; a low curve lifts the dark street."},
  {"name": "Cyan monitor", "charset": "custom", "chars": " .:-=+*#", "colour": "mono", "foreground": "#3ff3ff", "background": "#02090c", "palette": [], "gamma": 0.7, "columns": 90, "finish": "crt", "invert": false, "why": "One cold cyan on a dark screen with scanlines, like a security monitor in the rain."}
]}
```

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://video-to-ascii.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":"video-to-ascii"}' | 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": "style", "mood": "...", "facts": "{...}"}
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="video-to-ascii:style:$(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.txt   # one ```json block: {"looks": [...3 looks]}
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: video-to-ascii:style:$(shasum -a 256 input.json | cut -c1-16):a1" --data @input.json