← Retro Photo Filter
Your token

Retro Photo Filter API

The effects run free in the browser and need no API: your photo never leaves your device. The API is for the one metered step: send a sentence describing the look you want, the numbers the page measured from the photo and the current settings, and get back the settings to apply.

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

taskWhat it doesReply
pick_lookChooses every effect amount, the tone and the stamp for the look the visitor describes, from their sentence and the measured numbers, with a one to three sentence reason. Never sees the photo.One JSON object

Input fields

FieldTypeMeaning
taskstring"pick_look"
notestringThe look wanted, at most 300 characters; may be empty.
factsstringJSON text: width, height, transparent_share, brightness_mean, brightness_spread, brightness_p5, brightness_p95, dark_share, light_share, saturation, warmth, edge_share, main_colors (up to six {"hex", "share"}).
currentstringJSON text: the settings in use, in the same shape as the reply's look.

The reply

job.output.output is JSON text: {"task": "pick_look", "look": {...}, "why": "..."}. look holds preset (vhs, crt, film, glitch, dreamy, noir, none), strength (0 to 150), the effect amounts grain, aberration, scanlines, vignette, glitch, bloom, bleed, softness, curve and fade (0 to 100), grain_size (1 to 4), scanline_gap (2 to 8), the tone values brightness, contrast, saturation and warmth (-100 to 100), and stamp (at most 32 plain characters, or empty). All numbers are whole. The page rejects unknown names, clamps numbers to their ranges and flags any number in why it did not measure or set. If the balance ran low, truncated is true and the object may stop early.

Worked example

Input (input.json), for the page's sunset example, asked for a 1994 camcorder home video:

{
  "task": "pick_look",
  "note": "a camcorder home video from summer 1994 with the date in the corner",
  "facts": "{\"width\":480,\"height\":320,\"transparent_share\":0,\"brightness_mean\":89,\"brightness_spread\":38,\"brightness_p5\":31,\"brightness_p95\":151,\"dark_share\":0.33,\"light_share\":0.01,\"saturation\":0.4,\"warmth\":0.02,\"edge_share\":0.02,\"main_colors\":[{\"hex\":\"#815377\",\"share\":0.26},{\"hex\":\"#48386b\",\"share\":0.25},{\"hex\":\"#39283e\",\"share\":0.22},{\"hex\":\"#9e6a7b\",\"share\":0.13},{\"hex\":\"#b77c78\",\"share\":0.1},{\"hex\":\"#cd9c87\",\"share\":0.04}]}",
  "current": "{\"preset\":\"vhs\",\"strength\":100,\"grain\":22,\"grain_size\":1,\"aberration\":30,\"scanlines\":22,\"scanline_gap\":3,\"vignette\":25,\"glitch\":12,\"bloom\":15,\"bleed\":55,\"softness\":35,\"curve\":0,\"brightness\":0,\"contrast\":8,\"saturation\":12,\"warmth\":6,\"fade\":12,\"stamp\":\"PLAY\"}"
}

Reply:

{
  "task": "pick_look",
  "look": {
    "preset": "vhs",
    "strength": 100,
    "grain": 20,
    "grain_size": 1,
    "aberration": 28,
    "scanlines": 25,
    "scanline_gap": 3,
    "vignette": 22,
    "glitch": 8,
    "bloom": 14,
    "bleed": 60,
    "softness": 40,
    "curve": 0,
    "brightness": 8,
    "contrast": 6,
    "saturation": 5,
    "warmth": 6,
    "fade": 14,
    "stamp": "SUMMER 1994"
  },
  "why": "A VHS camcorder look with colour bleed, soft detail and light scanlines suits a 1994 home video, and the stamp uses the year you gave. The measured brightness_mean of 89 is on the dark side, so I lifted brightness by 8 and kept the glow modest."
}

On the page, the look is applied to the photo at once, with a button to put the earlier settings back.

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://retro-photo-filter.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":"retro-photo-filter"}' | 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": "pick_look", "note": "...", "facts": "{...}", "current": "{...}"}
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="retro-photo-filter:pick_look:$(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: task, look, why
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: retro-photo-filter:pick_look:$(shasum -a 256 input.json | cut -c1-16):a1" --data @input.json