← FAQ Accordion Generator
Your token

FAQ Accordion Generator API

Reading the FAQ, checking it and writing the accordion HTML, the CSS and the FAQPage schema all run free in the browser and need no API. The API is for the one metered step: send your questions with each answer split into numbered parts, and get back, as JSON, a rephrased question where one reads like a label, the part ids to keep in order (the direct answer first, long answers trimmed), topic groups for a FAQ page, and pairs of questions that ask the same thing. The model never writes answer text; the page rebuilds each answer from your own sentences and refuses any change that adds a fact.

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

taskWhat it doesReply
tidyRephrases label-like questions, picks and orders the answer parts to keep, groups a FAQ page of 6 or more questions by topic, and names duplicate questions. It never writes answer text.One JSON object

Input fields

All values are strings. task and items are required.

FieldMeaning
task"tidy"
placement"section" (a FAQ block on another page) or "page" (a dedicated FAQ page). Topics are only returned for "page".
itemsJSON text: a list of questions in page order, each {id, question, words, parts}, where parts is the answer as [{id, text, list?}], one sentence or list item each, ids like q3.2. At most 40 questions and 40 parts per answer.
items_noteEmpty, or a sentence saying what was cut.

The reply

job.output.output is text holding one JSON object (sometimes inside a ```json fence) with three keys: items, one {id, question, keep} per question in input order (keep is the list of part ids to show, in order); groups, a list of {name, ids} or []; and same, a list of id pairs or []. Before using it, check that every id is one you sent, that a rewritten question adds no number or name your text lacks, and that no real sentence was dropped from an answer of 80 words or fewer; the page does all three and lists what it refused. If the balance ran low, truncated is true and the object may stop early; the page keeps every entry that arrived whole.

Worked example

Input (input.json), the online shop sample on the page (5 questions):

{
  "task": "tidy",
  "placement": "section",
  "items": "[{\"id\":\"q1\",\"question\":\"Shipping times\",\"words\":115,\"parts\":[{\"id\":\"q1.1\",\"text\":\"Orders placed before 2 pm (UK time) on a weekday leave our workshop the same day.\"},{\"id\":\"q1.2\",\"text\":\"Standard delivery in the UK takes 2 to 4 working days and costs £3.95, or nothing on orders over £40.\"},{\"id\":\"q1.3\",\"text\":\"Express delivery arrives the next working day for £7.50.\"},{\"id\":\"q1.4\",\"text\":\"We also ship to the EU, the US and Canada; international orders usually arrive in 5 to 10 working days, and any import duties are shown at checkout so there is nothing extra to pay on the doorstep.\"},{\"id\":\"q1.5\",\"text\":\"You get a tracking link by email as soon as the parcel is handed to the courier, and you can change the delivery address until then by replying to your order email.\"}]},{\"id\":\"q2\",\"question\":\"Can I return a candle I don't like?\",\"words\":72,\"parts\":[{\"id\":\"q2.1\",\"text\":\"Yes.\"},{\"id\":\"q2.2\",\"text\":\"Send it back unused within 30 days of delivery and we refund the full price to your original payment method within 5 working days of it reaching us.\"},{\"id\":\"q2.3\",\"text\":\"Start a return from the link in your order email, print the free label, and drop the parcel at any post office.\"},{\"id\":\"q2.4\",\"text\":\"Candles that have been lit can't be resold, so we can only accept those back if they arrived damaged or faulty.\"}]},{\"id\":\"q3\",\"question\":\"What if my candle arrives broken?\",\"words\":33,\"parts\":[{\"id\":\"q3.1\",\"text\":\"As mentioned above, damaged items can be returned.\"},{\"id\":\"q3.2\",\"text\":\"Send us a photo of the candle and the box within 7 days and we will post a replacement the same day, at no cost.\"}]},{\"id\":\"q4\",\"question\":\"Are your candles vegan?\",\"words\":4,\"parts\":[{\"id\":\"q4.1\",\"text\":\"Yes, all of them.\"}]},{\"id\":\"q5\",\"question\":\"How long does a candle burn?\",\"words\":62,\"parts\":[{\"id\":\"q5.1\",\"text\":\"Our 200 g candles burn for about 45 hours and the 400 g candles for about 90 hours.\"},{\"id\":\"q5.2\",\"text\":\"To get the full burn time, let the first burn run until the melted wax reaches the edge of the jar, usually 2 to 3 hours, and trim the wick to 5 mm before each lighting.\"},{\"id\":\"q5.3\",\"text\":\"That stops tunnelling and keeps the flame steady.\"}]}]",
  "items_note": ""
}

Reply:

{
  "items": [
    {"id": "q1", "question": "How long does shipping take?", "keep": ["q1.2", "q1.3", "q1.1"]},
    {"id": "q2", "question": "Can I return a candle I don't like?", "keep": ["q2.1", "q2.2", "q2.3", "q2.4"]},
    {"id": "q3", "question": "What if my candle arrives broken?", "keep": ["q3.2"]},
    {"id": "q4", "question": "Are your candles vegan?", "keep": ["q4.1"]},
    {"id": "q5", "question": "How long does a candle burn?", "keep": ["q5.1", "q5.2", "q5.3"]}
  ],
  "groups": [],
  "same": []
}

On the page, "Shipping times" becomes "How long does shipping take?", its 115-word answer is cut to 45 words of your own sentences, and the answer that pointed "above" loses that sentence.

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://faq-accordion-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":"faq-accordion-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": "tidy", "placement": "section", "items": "[...]", "items_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="faq-accordion-generator:tidy:$(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: items, groups, same
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: faq-accordion-generator:tidy:$(shasum -a 256 input.json | cut -c1-16):a1" --data @input.json