daisyUI Checker API
Checking markup against daisyUI 5, the mechanical fixes, the preview and the downloads all run free in the browser and need no API. The API is for the one metered step: send the markup (with the page's fixes already in it) and the list of what is still wrong, and get the markup rewritten for daisyUI 5 with a list of changes and anything left to do by hand.
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
Send "task" first. This app has one job:
| task | What it does | Reply |
|---|---|---|
fix | Rewrites the markup so every class is correct daisyUI 5: form-control and label-text into fieldset and label, input-group into join, parts outside their component wrapped, modifiers given their component class, typos corrected, two colours or sizes on one element reduced to one. Everything else - ids, links, text, Tailwind utilities, JavaScript - stays as it was. | Marker text, below |
Input fields
| Field | Type | Meaning |
|---|---|---|
task | string | "fix". Required. |
code | string | The HTML or JSX. The page sends its own fixed copy (renamed daisyUI 4 classes already changed) and at most 30,000 characters: a longer file keeps its start and its end on whole lines, with a comment line where the middle was left out. Required. |
facts | string | JSON text from the page's checker: markup (html or jsx), from_daisyui (4 or 5), prefix, daisyui (the version checked against), fixed_by_page (line, class, now), to_fix (line, class, level, finding, suggestion), more_to_fix, notes and lines_left_out. Send "{}" if you have none; the reply is better with it. |
The reply
job.output.output is plain text in this shape:
TASK: fix SUMMARY: one sentence === FIXED === the complete fixed markup === CHANGES === - line 10: `old` -> `new`: why === CHECK BY HAND === - something left to do, or None === END ===
On the page, the fixed markup is checked again with the same rules, and any id, link or word of text that disappeared, any change naming a class the markup never had, and anything still wrong are shown next to the answer. A reply without === END === was cut short.
Worked examples
task: fix - a daisyUI 4 page (form-control, label-text, footer, theme variable)
Input (input.json):
{
"task": "fix",
"code": "<div class=\"navbar bg-base-100\">\n <a class=\"btn btn-ghost text-xl\">Acme</a>\n <div class=\"avatar avatar-online\">\n <div class=\"bg-neutral text-neutral-content w-10 rounded-full\"><span>AK</span></div>\n </div>\n</div>\n<div class=\"card card-border card-sm w-96 bg-base-100\">\n <div class=\"card-body\">\n <h2 class=\"card-title\">Sign in</h2>\n <div class=\"form-control w-full max-w-xs\">\n <label class=\"label\"><span class=\"label-text\">Email</span></label>\n <input type=\"email\" class=\"input w-full max-w-xs\" />\n <label class=\"label\"><span class=\"label-text-alt\">We never share it</span></label>\n </div>\n <select class=\"select\"><option>Admin</option></select>\n <div class=\"join\">\n <button class=\"btn btn-active join-item\">Day</button>\n <button class=\"btn join-item\">Week</button>\n </div>\n <div class=\"tabs tabs-box\">\n <a class=\"tab tab-active\">Profile</a><a class=\"tab\">Billing</a>\n </div>\n </div>\n</div>\n<ul class=\"menu bg-base-200 w-56\">\n <li><a class=\"menu-active\">Inbox</a></li>\n <li class=\"menu-disabled\"><a>Spam</a></li>\n</ul>\n<table class=\"table\"><tbody><tr class=\"hover:bg-base-300\"><td>Row</td></tr></tbody></table>\n<div class=\"dock dock-sm\">\n <button class=\"dock-active\"><span class=\"dock-label\">Home</span></button>\n <button><span class=\"dock-label\">Stats</span></button>\n</div>\n<div class=\"mockup-phone\"><div class=\"mockup-phone-camera\"></div><div class=\"mockup-phone-display\"><div class=\"w-[320px] h-[568px]\">Hi.</div></div></div>\n<footer class=\"footer p-10 bg-neutral text-neutral-content\"><nav><h6 class=\"footer-title\">Company</h6></nav></footer>\n<style>.brand { color: var(--color-primary); border-radius: var(--rounded-btn); }</style>\n",
"facts": "{\"markup\":\"html\",\"from_daisyui\":\"4\",\"prefix\":\"\",\"daisyui\":\"5.8.3\",\"fixed_by_page\":[{\"line\":3,\"class\":\"online\",\"now\":\"avatar-online\"},{\"line\":7,\"class\":\"card-bordered\",\"now\":\"card-border\"},{\"line\":7,\"class\":\"card-compact\",\"now\":\"card-sm\"},{\"line\":12,\"class\":\"input-bordered\",\"now\":\"(removed)\"},{\"line\":15,\"class\":\"select-bordered\",\"now\":\"(removed)\"},{\"line\":16,\"class\":\"btn-group\",\"now\":\"join\"},{\"line\":20,\"class\":\"tabs-boxed\",\"now\":\"tabs-box\"},{\"line\":26,\"class\":\"active\",\"now\":\"menu-active\"},{\"line\":27,\"class\":\"disabled\",\"now\":\"menu-disabled\"},{\"line\":29,\"class\":\"hover\",\"now\":\"hover:bg-base-300\"},{\"line\":30,\"class\":\"btm-nav\",\"now\":\"dock\"},{\"line\":30,\"class\":\"btm-nav-sm\",\"now\":\"dock-sm\"},{\"line\":31,\"class\":\"active\",\"now\":\"dock-active\"},{\"line\":31,\"class\":\"btm-nav-label\",\"now\":\"dock-label\"},{\"line\":32,\"class\":\"btm-nav-label\",\"now\":\"dock-label\"},{\"line\":34,\"class\":\"camera\",\"now\":\"mockup-phone-camera\"},{\"line\":34,\"class\":\"display\",\"now\":\"mockup-phone-display\"},{\"line\":34,\"class\":\"artboard\",\"now\":\"w-[320px] h-[568px]\"},{\"line\":34,\"class\":\"artboard-demo\",\"now\":\"(removed)\"},{\"line\":34,\"class\":\"phone-1\",\"now\":\"(removed)\"},{\"line\":36,\"class\":\"hsl(var(--p))\",\"now\":\"var(--color-primary)\"}],\"to_fix\":[{\"line\":10,\"class\":\"form-control\",\"level\":\"bad\",\"finding\":\"form-control was removed in daisyUI 5. Use a fieldset (fieldset, fieldset-legend) around the field, or drop the wrapper.\",\"suggestion\":\"\"},{\"line\":11,\"class\":\"label-text\",\"level\":\"bad\",\"finding\":\"label-text was removed in daisyUI 5. Use the label class (span class=\\\"label\\\") from the new label syntax.\",\"suggestion\":\"\"},{\"line\":12,\"class\":\"w-full max-w-xs\",\"level\":\"info\",\"finding\":\"daisyUI 5 inputs and selects are 20rem wide by default, so w-full max-w-xs is no longer needed for that.\",\"suggestion\":\"\"},{\"line\":13,\"class\":\"label-text-alt\",\"level\":\"bad\",\"finding\":\"label-text-alt was removed in daisyUI 5. Use the label class (for example p class=\\\"label\\\" under the field).\",\"suggestion\":\"\"},{\"line\":35,\"class\":\"footer\",\"level\":\"info\",\"finding\":\"A daisyUI 5 footer is vertical by default. To keep it horizontal on wider screens, add md:footer-horizontal (the upgrade guide's fix).\",\"suggestion\":\"md:footer-horizontal\"},{\"line\":36,\"class\":\"--rounded-btn\",\"level\":\"bad\",\"finding\":\"--rounded-btn is --radius-field in daisyUI 5.\",\"suggestion\":\"--radius-field\"}],\"more_to_fix\":0,\"notes\":2,\"lines_left_out\":null}"
}
Reply:
TASK: fix
SUMMARY: Replaced the form-control wrapper and the label-text spans with a fieldset, legend and helper label, switched --rounded-btn to --radius-field and added md:footer-horizontal; the only thing to check is the footer layout at wider widths.
=== FIXED ===
<div class="navbar bg-base-100">
<a class="btn btn-ghost text-xl">Acme</a>
<div class="avatar avatar-online">
<div class="bg-neutral text-neutral-content w-10 rounded-full"><span>AK</span></div>
</div>
</div>
<div class="card card-border card-sm w-96 bg-base-100">
<div class="card-body">
<h2 class="card-title">Sign in</h2>
<fieldset class="fieldset w-full max-w-xs">
<legend class="fieldset-legend">Email</legend>
<input type="email" class="input" />
<p class="label">We never share it</p>
</fieldset>
<select class="select"><option>Admin</option></select>
<div class="join">
<button class="btn btn-active join-item">Day</button>
<button class="btn join-item">Week</button>
</div>
<div class="tabs tabs-box">
<a class="tab tab-active">Profile</a><a class="tab">Billing</a>
</div>
</div>
</div>
<ul class="menu bg-base-200 w-56">
<li><a class="menu-active">Inbox</a></li>
<li class="menu-disabled"><a>Spam</a></li>
</ul>
<table class="table"><tbody><tr class="hover:bg-base-300"><td>Row</td></tr></tbody></table>
<div class="dock dock-sm">
<button class="dock-active"><span class="dock-label">Home</span></button>
<button><span class="dock-label">Stats</span></button>
</div>
<div class="mockup-phone"><div class="mockup-phone-camera"></div><div class="mockup-phone-display"><div class="w-[320px] h-[568px]">Hi.</div></div></div>
<footer class="footer md:footer-horizontal p-10 bg-neutral text-neutral-content"><nav><h6 class="footer-title">Company</h6></nav></footer>
<style>.brand { color: var(--color-primary); border-radius: var(--radius-field); }</style>
=== CHANGES ===
- line 10: `<div class="form-control w-full max-w-xs">` -> `<fieldset class="fieldset w-full max-w-xs">`: form-control removed, fieldset wraps the field
- line 11: `<label class="label"><span class="label-text">Email</span></label>` -> `<legend class="fieldset-legend">Email</legend>`: top label text becomes the legend
- line 12: `input w-full max-w-xs` -> `input`: inputs are 20rem wide by default
- line 13: `<label class="label"><span class="label-text-alt">We never share it</span></label>` -> `<p class="label">We never share it</p>`: helper text under the field
- line 35: `footer p-10 bg-neutral text-neutral-content` -> `footer md:footer-horizontal p-10 bg-neutral text-neutral-content`: keeps the footer horizontal on wider screens
- line 36: `var(--rounded-btn)` -> `var(--radius-field)`: renamed theme variable
=== CHECK BY HAND ===
- None
=== END ===
task: fix - typos, parts outside their component and a drawer label that opens nothing
Input:
{
"task": "fix",
"code": "<div class=\"drawer\">\n <input id=\"nav-drawer\" type=\"checkbox\" class=\"drawer-toggle\" />\n <div class=\"drawer-content\">\n <div class=\"navbar bg-base-200\">\n <label for=\"main-drawer\" class=\"btn btn-ghost drawer-button\">Menu</label>\n <a class=\"btn btn-ghost text-xl\">Dashboard</a>\n </div>\n <div class=\"stats shadow\">\n <div class=\"stat\">\n <div class=\"stat-title\">Revenue</div>\n <div class=\"stat-value\">$89,400</div>\n </div>\n </div>\n <div class=\"stat-desc\">21% more than last month</div>\n <button class=\"btn btn-primary btn-outline btn-soft\" onclick=\"invite_modal.showModal()\">Invite</button>\n <span class=\"badge badge-sucess badge-sm\">Live</span>\n <div class=\"card-body bg-base-100 rounded-box\">\n <h2 class=\"card-title\">Recent orders</h2>\n <progress class=\"progress-primary w-56\" value=\"40\" max=\"100\"></progress>\n </div>\n </div>\n <div class=\"drawer-side\">\n <label for=\"nav-drawer\" aria-label=\"close sidebar\" class=\"drawer-overlay\"></label>\n <ul class=\"menu bg-base-200 min-h-full w-64 p-4\">\n <li><a class=\"menu-active\">Overview</a></li>\n <li><a>Customers</a></li>\n </ul>\n </div>\n</div>\n<dialog id=\"invite_modal\" class=\"modal\">\n <div class=\"modal-box\">\n <h3 class=\"text-lg font-bold\">Invite a teammate</h3>\n <input type=\"email\" placeholder=\"name@company.com\" class=\"input input-primray\" />\n <div class=\"modal-action\"><button class=\"btn\">Send</button></div>\n </div>\n</dialog>\n",
"facts": "{\"markup\":\"html\",\"from_daisyui\":\"5\",\"prefix\":\"\",\"daisyui\":\"5.8.3\",\"fixed_by_page\":[],\"to_fix\":[{\"line\":5,\"class\":\"drawer-button\",\"level\":\"warn\",\"finding\":\"This label points at for=\\\"main-drawer\\\", but no drawer-toggle input has that id, so it opens nothing.\",\"suggestion\":\"\"},{\"line\":14,\"class\":\"stat-desc\",\"level\":\"warn\",\"finding\":\"stat-desc belongs inside an element with stats, and this <div> has none around it.\",\"suggestion\":\"\"},{\"line\":15,\"class\":\"btn-soft\",\"level\":\"warn\",\"finding\":\"btn-outline and btn-soft are both style classes of btn on one element; daisyUI expects one. Keep the one you want.\",\"suggestion\":\"\"},{\"line\":16,\"class\":\"badge-sucess\",\"level\":\"warn\",\"finding\":\"badge-sucess is not a daisyUI 5 class; did you mean badge-success?\",\"suggestion\":\"badge-success\"},{\"line\":17,\"class\":\"card-body\",\"level\":\"warn\",\"finding\":\"card-body belongs inside an element with card, and this <div> has none around it.\",\"suggestion\":\"\"},{\"line\":18,\"class\":\"card-title\",\"level\":\"warn\",\"finding\":\"card-title belongs inside an element with card, and this <h2> has none around it.\",\"suggestion\":\"\"},{\"line\":19,\"class\":\"progress-primary\",\"level\":\"warn\",\"finding\":\"progress-primary only works on an element that also has progress (progress color). Add progress to this <progress>.\",\"suggestion\":\"\"},{\"line\":30,\"class\":\"modal\",\"level\":\"warn\",\"finding\":\"This <dialog class=\\\"modal\\\"> has no <form method=\\\"dialog\\\"> inside it. The daisyUI modal guide adds one (often as the modal-backdrop) so a button or a click outside closes the modal without JavaScript.\",\"suggestion\":\"\"},{\"line\":33,\"class\":\"input-primray\",\"level\":\"warn\",\"finding\":\"input-primray is not a daisyUI 5 class; did you mean input-primary?\",\"suggestion\":\"input-primary\"}],\"more_to_fix\":0,\"notes\":0,\"lines_left_out\":null}"
}
Reply:
TASK: fix
SUMMARY: Matched the drawer label to its toggle, wrapped the lone stat-desc and card-body in their components, and fixed the typo'd badge and input classes, the doubled btn style, the bare progress and the modal close form; the stat-desc and card wrappers may need moving.
=== FIXED ===
<div class="drawer">
<input id="nav-drawer" type="checkbox" class="drawer-toggle" />
<div class="drawer-content">
<div class="navbar bg-base-200">
<label for="nav-drawer" class="btn btn-ghost drawer-button">Menu</label>
<a class="btn btn-ghost text-xl">Dashboard</a>
</div>
<div class="stats shadow">
<div class="stat">
<div class="stat-title">Revenue</div>
<div class="stat-value">$89,400</div>
</div>
</div>
<div class="stats">
<div class="stat">
<div class="stat-desc">21% more than last month</div>
</div>
</div>
<button class="btn btn-primary btn-outline" onclick="invite_modal.showModal()">Invite</button>
<span class="badge badge-success badge-sm">Live</span>
<div class="card">
<div class="card-body bg-base-100 rounded-box">
<h2 class="card-title">Recent orders</h2>
<progress class="progress progress-primary w-56" value="40" max="100"></progress>
</div>
</div>
</div>
<div class="drawer-side">
<label for="nav-drawer" aria-label="close sidebar" class="drawer-overlay"></label>
<ul class="menu bg-base-200 min-h-full w-64 p-4">
<li><a class="menu-active">Overview</a></li>
<li><a>Customers</a></li>
</ul>
</div>
</div>
<dialog id="invite_modal" class="modal">
<div class="modal-box">
<h3 class="text-lg font-bold">Invite a teammate</h3>
<input type="email" placeholder="name@company.com" class="input input-primary" />
<div class="modal-action"><button class="btn">Send</button></div>
</div>
<form method="dialog" class="modal-backdrop"><button>close</button></form>
</dialog>
=== CHANGES ===
- line 5: `for="main-drawer"` -> `for="nav-drawer"`: the label now matches the existing drawer-toggle id
- line 14: `<div class="stat-desc">` -> `<div class="stats"><div class="stat"><div class="stat-desc">`: stat-desc needs stats and stat around it
- line 15: `btn btn-primary btn-outline btn-soft` -> `btn btn-primary btn-outline`: two style classes on one button, kept the first
- line 16: `badge badge-sucess badge-sm` -> `badge badge-success badge-sm`: typo of badge-success
- line 17: `card-body bg-base-100 rounded-box` -> `<div class="card">` around the `card-body bg-base-100 rounded-box` div: card-body and card-title need a card around them
- line 19: `progress-primary w-56` -> `progress progress-primary w-56`: the color class needs progress
- line 30: `<dialog class="modal">` -> `<dialog class="modal">` with `<form method="dialog" class="modal-backdrop"><button>close</button></form>` added as last child: closes the modal without JavaScript
- line 33: `input input-primray` -> `input input-primary`: typo of input-primary
=== CHECK BY HAND ===
- The new `stats` wrapper around the "21% more than last month" stat-desc stands alone; move it into the Revenue `stat` if it belongs there.
- The new `card` wrapper around the "Recent orders" card-body is a plain wrapper; check its spacing and background in the page.
- The added modal-backdrop button reads "close"; translate or restyle it if needed.
=== END ===
On the page, press an AI example to see these replies checked and rendered.
Errors
| HTTP | What to do |
|---|---|
| 401 | The token is missing, expired or a guest token on a run. Get a personal token on the token page. |
| 402 | The balance is below what the run reserves. Top up at skillsafe.ai/account/billing. |
| 400 | The body is not a JSON object of the fields above, or task or code is missing. |
| 429 | Wait 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://daisyui-checker.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"}
}import json, urllib.request
BASE = "https://api.skillsafe.ai/v1/app-api"
TOKEN = "paste-your-token-here" # from https://daisyui-checker.skillsafe.ai/tokens.html
def api(method, path, body=None, headers=None):
req = urllib.request.Request(BASE + path, method=method,
data=None if body is None else json.dumps(body).encode(),
headers={"Content-Type": "application/json", **({"Authorization": "Bearer " + TOKEN} if TOKEN else {}), **(headers or {})})
with urllib.request.urlopen(req) as r:
env = json.load(r)
if env.get("error"):
raise RuntimeError(env["error"])
return env["data"]// daisyui-checker.mjs -- Node 18+ (global fetch)
const BASE = "https://api.skillsafe.ai/v1/app-api";
let TOKEN = "paste-your-token-here"; // from https://daisyui-checker.skillsafe.ai/tokens.html
async function api(method, path, body, headers = {}) {
const r = await fetch(BASE + path, { method, headers: { "Content-Type": "application/json",
...(TOKEN ? { Authorization: "Bearer " + TOKEN } : {}), ...headers },
body: body === undefined ? undefined : JSON.stringify(body) });
const env = await r.json();
if (env.error) throw new Error(env.error.code + ": " + env.error.message);
return env.data;
}package main
import ("bytes"; "encoding/json"; "fmt"; "net/http")
const base = "https://api.skillsafe.ai/v1/app-api"
var token = "paste-your-token-here" // from https://daisyui-checker.skillsafe.ai/tokens.html
func api(method, path string, body any, headers map[string]string) (map[string]any, error) {
var buf bytes.Buffer
if body != nil { json.NewEncoder(&buf).Encode(body) }
req, _ := http.NewRequest(method, base+path, &buf)
req.Header.Set("Content-Type", "application/json")
if token != "" { req.Header.Set("Authorization", "Bearer "+token) }
for k, v := range headers { req.Header.Set(k, v) }
res, err := http.DefaultClient.Do(req)
if err != nil { return nil, err }
defer res.Body.Close()
var env struct { Data map[string]any; Error map[string]any }
json.NewDecoder(res.Body).Decode(&env)
if env.Error != nil { return nil, fmt.Errorf("%v", env.Error) }
return env.Data, nil
}// DaisyuiChecker.java -- Java 17+, with com.fasterxml.jackson.core:jackson-databind
import com.fasterxml.jackson.databind.*;
import java.net.URI; import java.net.http.*; import java.util.*;
public class DaisyuiChecker {
static final String BASE = "https://api.skillsafe.ai/v1/app-api";
static String token = "paste-your-token-here"; // from https://daisyui-checker.skillsafe.ai/tokens.html
static final ObjectMapper M = new ObjectMapper();
static final HttpClient C = HttpClient.newHttpClient();
static JsonNode api(String method, String path, Object body, Map<String, String> headers) throws Exception {
var b = HttpRequest.newBuilder(URI.create(BASE + path)).header("Content-Type", "application/json");
if (!token.isEmpty()) b.header("Authorization", "Bearer " + token);
if (headers != null) headers.forEach(b::header);
b.method(method, body == null ? HttpRequest.BodyPublishers.noBody() : HttpRequest.BodyPublishers.ofString(M.writeValueAsString(body)));
JsonNode env = M.readTree(C.send(b.build(), HttpResponse.BodyHandlers.ofString()).body());
if (env.hasNonNull("error")) throw new RuntimeException(env.get("error").toString());
return env.get("data");
}
}require "json"
require "net/http"
BASE = "https://api.skillsafe.ai/v1/app-api"
TOKEN = "paste-your-token-here" # from https://daisyui-checker.skillsafe.ai/tokens.html
def api(method, path, body = nil, headers = {})
uri = URI(BASE + path)
req = Net::HTTPGenericRequest.new(method, !body.nil?, true, uri.request_uri,
{ "Content-Type" => "application/json" }.merge(TOKEN.empty? ? {} : { "Authorization" => "Bearer #{TOKEN}" }).merge(headers))
req.body = JSON.generate(body) unless body.nil?
env = JSON.parse(Net::HTTP.start(uri.host, uri.port, use_ssl: true) { |h| h.request(req) }.body)
raise env["error"].to_s if env["error"]
env["data"]
end<?php
const BASE = "https://api.skillsafe.ai/v1/app-api";
$TOKEN = "paste-your-token-here"; // from https://daisyui-checker.skillsafe.ai/tokens.html
function api(string $method, string $path, $body = null, array $headers = []) {
global $TOKEN;
$h = ["Content-Type: application/json"];
if ($TOKEN) $h[] = "Authorization: Bearer $TOKEN";
foreach ($headers as $k => $v) $h[] = "$k: $v";
$ch = curl_init(BASE . $path);
curl_setopt_array($ch, [CURLOPT_CUSTOMREQUEST => $method, CURLOPT_HTTPHEADER => $h, CURLOPT_RETURNTRANSFER => true]);
if ($body !== null) curl_setopt($ch, CURLOPT_POSTFIELDS, json_encode($body));
$env = json_decode(curl_exec($ch), true);
if (!empty($env["error"])) throw new Exception(json_encode($env["error"]));
return $env["data"];
}// Program.cs -- .NET 6+ console app
using System.Net.Http.Json; using System.Text.Json; using System.Text.Json.Nodes;
static class Api {
public const string Base = "https://api.skillsafe.ai/v1/app-api";
public static string Token = "paste-your-token-here"; // from https://daisyui-checker.skillsafe.ai/tokens.html
static readonly HttpClient C = new();
public static async Task<JsonNode?> Call(string method, string path, object? body = null, Dictionary<string, string>? headers = null) {
var req = new HttpRequestMessage(new HttpMethod(method), Base + path);
if (Token != "") req.Headers.Add("Authorization", "Bearer " + Token);
if (headers != null) foreach (var h in headers) req.Headers.Add(h.Key, h.Value);
if (body != null) req.Content = JsonContent.Create(body);
var env = JsonNode.Parse(await (await C.SendAsync(req)).Content.ReadAsStringAsync())!;
if (env["error"] is JsonNode e && e.GetValueKind() != JsonValueKind.Null) throw new Exception(e.ToJsonString());
return env["data"];
}
}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":"daisyui-checker"}' | jq -r '.data.token')# a guest token (enough for /me and /estimate); a run needs your personal token from /tokens.html
TOKEN = ""
TOKEN = api("POST", "/guest", {"slug": "daisyui-checker"})["token"]// a guest token (enough for /me and /estimate); a run needs your personal token from /tokens.html
TOKEN = "";
TOKEN = (await api("POST", "/guest", { slug: "daisyui-checker" })).token;// inside main: a guest token (enough for /me and /estimate); a run needs your personal token
token = ""
g, err := api("POST", "/guest", map[string]string{"slug": "daisyui-checker"}, nil)
if err != nil { panic(err) }
token = g["token"].(string)// inside main: a guest token (enough for /me and /estimate); a run needs your personal token
token = "";
token = api("POST", "/guest", Map.of("slug", "daisyui-checker"), null).get("token").asText();# a guest token (enough for /me and /estimate); a run needs your personal token from /tokens.html
TOKEN.replace("")
TOKEN.replace(api("POST", "/guest", { slug: "daisyui-checker" })["token"])// a guest token (enough for /me and /estimate); a run needs your personal token from /tokens.html
$TOKEN = "";
$TOKEN = api("POST", "/guest", ["slug" => "daisyui-checker"])["token"];// a guest token (enough for /me and /estimate); a run needs your personal token from /tokens.html
Api.Token = "";
Api.Token = (await Api.Call("POST", "/guest", new { slug = "daisyui-checker" }))!["token"]!.GetValue<string>();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}' me = api("GET", "/me")
print(me["subject_type"], me.get("credits"))const me = await api("GET", "/me");
console.log(me.subject_type, me.credits);me, _ := api("GET", "/me", nil, nil)
fmt.Println(me["subject_type"], me["credits"])JsonNode me = api("GET", "/me", null, null);
System.out.println(me.get("subject_type") + " " + me.get("credits"));me = api("GET", "/me")
puts [me["subject_type"], me["credits"]].inspect$me = api("GET", "/me");
echo $me["subject_type"], " ", $me["credits"] ?? "", "\n";var me = await Api.Call("GET", "/me");
Console.WriteLine($"{me!["subject_type"]} {me["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": "fix", "code": "<div class=...>...</div>", "facts": "{...}"}
api POST /estimate "$(cat input.json)" | jq '.data | {hold_credits, min_credits, model, model_alias, markup_bps, warnings}' inp = json.load(open("input.json")) # {"task": "fix", "code": "<div class=...>...</div>", "facts": "{...}"}
est = api("POST", "/estimate", inp)
print(est["hold_credits"], est["min_credits"], est["model"], est.get("warnings"))import { readFileSync } from "node:fs";
const input = JSON.parse(readFileSync("input.json", "utf8")); // {task, facts}
const est = await api("POST", "/estimate", input);
console.log(est.hold_credits, est.min_credits, est.model, est.warnings);raw, _ := os.ReadFile("input.json") // add "os" to the imports
var input map[string]any
json.Unmarshal(raw, &input)
est, _ := api("POST", "/estimate", input, nil)
fmt.Println(est["hold_credits"], est["min_credits"], est["model"])Map<String, Object> input = M.readValue(new java.io.File("input.json"), Map.class);
JsonNode est = api("POST", "/estimate", input, null);
System.out.println(est.get("hold_credits") + " " + est.get("min_credits") + " " + est.get("model"));input = JSON.parse(File.read("input.json"))
est = api("POST", "/estimate", input)
puts [est["hold_credits"], est["min_credits"], est["model"]].inspect$input = json_decode(file_get_contents("input.json"), true);
$est = api("POST", "/estimate", $input);
echo $est["hold_credits"], " ", $est["min_credits"], " ", $est["model"], "\n";var input = JsonNode.Parse(File.ReadAllText("input.json"))!;
var est = await Api.Call("POST", "/estimate", input);
Console.WriteLine($"{est!["hold_credits"]} {est["min_credits"]} {est["model"]}");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="daisyui-checker:fix:$(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 # marker text: TASK, SUMMARY, === FIXED ===, === CHANGES ===, === CHECK BY HAND ===, === END ===
echo "$J" | jq '.data | {charged_credits, truncated}' import hashlib, time
key = "daisyui-checker:" + inp["task"] + ":" + hashlib.sha256(json.dumps(inp).encode()).hexdigest()[:16] + ":a1"
job = api("POST", "/run", inp, {"Idempotency-Key": key})
while True:
j = api("GET", "/jobs/" + job["job_id"])
if j["status"] in ("succeeded", "failed", "cancelled"):
break
time.sleep(2)
reply = j["output"]["output"] # marker text; the fixed markup is between === FIXED === and === CHANGES ===
print(j["charged_credits"], j.get("truncated"), reply.splitlines()[0])import { createHash } from "node:crypto";
const key = `daisyui-checker:${input.task}:${createHash("sha256").update(JSON.stringify(input)).digest("hex").slice(0, 16)}:a1`;
const job = await api("POST", "/run", input, { "Idempotency-Key": key });
let j;
do { await new Promise((r) => setTimeout(r, 2000)); j = await api("GET", "/jobs/" + job.job_id); }
while (!["succeeded", "failed", "cancelled"].includes(j.status));
const reply = j.output.output; // marker text
console.log(j.charged_credits, j.truncated, reply.split("\n")[0]);sum := sha256.Sum256(raw) // add "crypto/sha256", "encoding/hex", "time" to the imports
key := "daisyui-checker:" + input["task"].(string) + ":" + hex.EncodeToString(sum[:8]) + ":a1"
job, _ := api("POST", "/run", input, map[string]string{"Idempotency-Key": key})
var j map[string]any
for {
time.Sleep(2 * time.Second)
j, _ = api("GET", "/jobs/"+job["job_id"].(string), nil, nil)
if s := j["status"]; s == "succeeded" || s == "failed" || s == "cancelled" { break }
}
fmt.Println(j["charged_credits"], j["truncated"], j["output"].(map[string]any)["output"])var digest = java.security.MessageDigest.getInstance("SHA-256").digest(M.writeValueAsBytes(input));
String key = "daisyui-checker:" + input.get("task") + ":" + HexFormat.of().formatHex(digest, 0, 8) + ":a1";
JsonNode job = api("POST", "/run", input, Map.of("Idempotency-Key", key)), j;
do { Thread.sleep(2000); j = api("GET", "/jobs/" + job.get("job_id").asText(), null, null); }
while (!Set.of("succeeded", "failed", "cancelled").contains(j.get("status").asText()));
String reply = j.get("output").get("output").asText(); // marker text
System.out.println(j.get("charged_credits") + " " + reply);require "digest"
key = "daisyui-checker:#{input["task"]}:#{Digest::SHA256.hexdigest(JSON.generate(input))[0, 16]}:a1"
job = api("POST", "/run", input, { "Idempotency-Key" => key })
j = nil
loop do
sleep 2
j = api("GET", "/jobs/#{job["job_id"]}")
break if %w[succeeded failed cancelled].include?(j["status"])
end
reply = j["output"]["output"] # marker text
puts [j["charged_credits"], j["truncated"], reply.lines.first].inspect$key = "daisyui-checker:" . $input["task"] . ":" . substr(hash("sha256", json_encode($input)), 0, 16) . ":a1";
$job = api("POST", "/run", $input, ["Idempotency-Key" => $key]);
do { sleep(2); $j = api("GET", "/jobs/" . $job["job_id"]); }
while (!in_array($j["status"], ["succeeded", "failed", "cancelled"]));
$reply = $j["output"]["output"]; // marker text
echo $j["charged_credits"], " ", $reply.lines.first, "\n";var digest = System.Security.Cryptography.SHA256.HashData(System.Text.Encoding.UTF8.GetBytes(input.ToJsonString()));
var key = $"daisyui-checker:{input["task"]}:{Convert.ToHexString(digest, 0, 8).ToLowerInvariant()}:a1";
var job = await Api.Call("POST", "/run", input, new() { ["Idempotency-Key"] = key });
JsonNode j;
do { await Task.Delay(2000); j = (await Api.Call("GET", "/jobs/" + job!["job_id"]))!; }
while (!new[] { "succeeded", "failed", "cancelled" }.Contains(j["status"]!.GetValue<string>()));
var reply = j["output"]!["output"]!.GetValue<string>(); // marker text
Console.WriteLine($"{j["charged_credits"]} {reply}");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: daisyui-checker:fix:$(shasum -a 256 input.json | cut -c1-16):a1" --data @input.jsonrin = json.load(open("input.json")) # {"task": "fix", "code": "<div class=...>...</div>", "facts": "{...}"}
req = urllib.request.Request(BASE + "/run-stream", method="POST", data=json.dumps(rin).encode(),
headers={"Content-Type": "application/json", "Authorization": "Bearer " + TOKEN,
"Idempotency-Key": "daisyui-checker:fix:" + hashlib.sha256(json.dumps(rin).encode()).hexdigest()[:16] + ":a1"})
with urllib.request.urlopen(req) as r:
for line in r:
line = line.decode().strip()
if line.startswith("data:"):
print(line[5:].strip()[:200])const rin = JSON.parse(readFileSync("input.json", "utf8"));
const r = await fetch(BASE + "/run-stream", { method: "POST", body: JSON.stringify(rin), headers: {
"Content-Type": "application/json", Authorization: "Bearer " + TOKEN,
"Idempotency-Key": `daisyui-checker:fix:${createHash("sha256").update(JSON.stringify(rin)).digest("hex").slice(0, 16)}:a1` } });
const dec = new TextDecoder();
for await (const chunk of r.body) for (const line of dec.decode(chunk).split("\n"))
if (line.startsWith("data:")) console.log(line.slice(5).trim().slice(0, 200));rraw, _ := os.ReadFile("input.json") // add "bufio", "strings" to the imports
rs := sha256.Sum256(rraw)
req, _ := http.NewRequest("POST", base+"/run-stream", bytes.NewReader(rraw))
req.Header.Set("Content-Type", "application/json")
req.Header.Set("Authorization", "Bearer "+token)
req.Header.Set("Idempotency-Key", "daisyui-checker:fix:"+hex.EncodeToString(rs[:8])+":a1")
res, _ := http.DefaultClient.Do(req)
sc := bufio.NewScanner(res.Body)
for sc.Scan() { if l := sc.Text(); strings.HasPrefix(l, "data:") { fmt.Println(l[5:]) } }String rin = java.nio.file.Files.readString(java.nio.file.Path.of("input.json"));
var rd = java.security.MessageDigest.getInstance("SHA-256").digest(rin.getBytes());
var sreq = HttpRequest.newBuilder(URI.create(BASE + "/run-stream")).header("Content-Type", "application/json")
.header("Authorization", "Bearer " + token).header("Idempotency-Key", "daisyui-checker:fix:" + HexFormat.of().formatHex(rd, 0, 8) + ":a1")
.POST(HttpRequest.BodyPublishers.ofString(rin)).build();
C.send(sreq, HttpResponse.BodyHandlers.ofLines()).body().filter(l -> l.startsWith("data:")).forEach(System.out::println);rin = File.read("input.json")
uri = URI(BASE + "/run-stream")
req = Net::HTTP::Post.new(uri, "Content-Type" => "application/json", "Authorization" => "Bearer #{TOKEN}",
"Idempotency-Key" => "daisyui-checker:fix:#{Digest::SHA256.hexdigest(rin)[0, 16]}:a1")
req.body = rin
Net::HTTP.start(uri.host, uri.port, use_ssl: true) do |h|
h.request(req) { |res| res.read_body { |chunk| chunk.each_line { |l| puts l if l.start_with?("data:") } } }
end$rin = file_get_contents("input.json");
$ch = curl_init(BASE . "/run-stream");
curl_setopt_array($ch, [CURLOPT_POST => true, CURLOPT_POSTFIELDS => $rin, CURLOPT_HTTPHEADER => [
"Content-Type: application/json", "Authorization: Bearer $TOKEN",
"Idempotency-Key: daisyui-checker:fix:" . substr(hash("sha256", $rin), 0, 16) . ":a1"],
CURLOPT_WRITEFUNCTION => function ($ch, $chunk) { foreach (explode("\n", $chunk) as $l) if (str_starts_with($l, "data:")) echo $l, "\n"; return strlen($chunk); }]);
curl_exec($ch);var rin = File.ReadAllText("input.json");
var rd = System.Security.Cryptography.SHA256.HashData(System.Text.Encoding.UTF8.GetBytes(rin));
var sreq = new HttpRequestMessage(HttpMethod.Post, Api.Base + "/run-stream") { Content = new StringContent(rin, System.Text.Encoding.UTF8, "application/json") };
sreq.Headers.Add("Authorization", "Bearer " + Api.Token);
sreq.Headers.Add("Idempotency-Key", $"daisyui-checker:fix:{Convert.ToHexString(rd, 0, 8).ToLowerInvariant()}:a1");
using var http = new HttpClient();
using var res = await http.SendAsync(sreq, HttpCompletionOption.ResponseHeadersRead);
using var rdr = new StreamReader(await res.Content.ReadAsStreamAsync());
for (string? l; (l = await rdr.ReadLineAsync()) != null;) if (l.StartsWith("data:")) Console.WriteLine(l);