← SVG Wave Generator
Your token

SVG Wave Generator API

The waves, the water-ripple filter, the drift, the checks and every export run free in the browser and need no API. The API is for the one metered step: send a description of the wave you want and the current settings, and get back, as JSON, new settings: layers, height, crests, shape, colours, background, place, drift and water ripple. The page checks each setting (in range, real #rrggbb colours, one colour per layer, hex codes from the description used, no drift if the description says no animation) and uses the ones that pass.

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

taskWhat it doesReply
designTurns a description of a wave divider into the page's settings: name, layers (1-5), height (40-600 px), amp (5-100), crests (1-12), shape, irregular (0-100), colors (one #rrggbb per layer, back to front), bg, place, drift, ripple and up to three notes.One JSON object

Input fields

FieldTypeMeaning
taskstring"design"
briefstringThe description of the wave, for example "calm sunset sea for a yoga site footer, slow drift". The page sends at most 1,500 characters: longer text keeps its start and end and loses the middle, with a marker line.
currentstringJSON text with the settings now: layers, height, amp, crests, shape, irregular, colors, bg, place, drift, ripple. Send "{}" if you have none.
named_colorsstringColours found in brief, one per line: #ff6b35 (hex code the visitor typed) or navy = #000080 (colour word). May be empty.
clipped_notestringEmpty, or a sentence saying the middle of brief was cut.

The reply

job.output.output is text holding one JSON object with the keys name, layers, height, amp, crests, shape (smooth, peaks or steps), irregular, colors, bg ("" or #rrggbb), place (bottom or top), drift (off, slow, medium, fast), ripple (off, ocean, choppy, pond, cartoon, glass) and notes. Paste the description into the page to see it drawn, or draw it yourself. 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):

{
  "task": "design",
  "brief": "Soft sunset sea for the footer of a yoga retreat website. Pinks fading into deep blue, gentle and slow moving.",
  "current": "{\"layers\":3,\"height\":240,\"amp\":50,\"crests\":3,\"shape\":\"smooth\",\"irregular\":40,\"colors\":[\"#0369a1\",\"#0369a1\",\"#0369a1\"],\"bg\":\"\",\"place\":\"bottom\",\"drift\":\"off\",\"ripple\":\"off\"}",
  "named_colors": "blue = #0000ff (colour word)",
  "clipped_note": ""
}

Reply:

{"name":"Sunset sea","layers":3,"height":220,"amp":25,"crests":2,"shape":"smooth","irregular":30,"colors":["#fbcfe8","#c084b8","#1e3a8a"],"bg":"","place":"bottom","drift":"slow","ripple":"off","notes":["Kept the background transparent; set one if your footer needs a colour behind the waves."]}

On the page, this reply draws a three-layer pink-to-deep-blue wave with a slow drift.

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://svg-wave-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":"svg-wave-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": "design", "brief": "calm sunset sea, slow drift", "current": "{}", "named_colors": "", "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="svg-wave-generator:design:$(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: name, layers, ... colors, ... 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: svg-wave-generator:design:$(shasum -a 256 input.json | cut -c1-16):a1" --data @input.json