Errors & reliability
Status codes, and the one behaviour worth handling in code: a cold start.
Status codes
200OKoptionalSuccess. The body contains reply, model, region, and usage.
400Bad RequestoptionalThe request body was invalid (e.g. missing message, or an unknown region).
401UnauthorizedoptionalMissing, invalid, or revoked API key.
503Service UnavailableoptionalThe network is warming up (see below). The body includes "code": "no_node". Retry.
Error responses are JSON with an error message, for example:
{ "error": "Invalid or revoked API key." }Cold starts & warm‑up
To keep costs low, idle compute is powered down. The first request after an idle period wakes a node and loads the model, which can take up to a minute or two. During that window the API returns 503 with "code": "no_node" instead of a wrong or fake answer.
This isn't an error to surface to your users — it just means “not ready yet, try again shortly.” Retry the same request a few times with a short delay; a warm node answers in a couple of seconds.
async function chat(message, key) {
for (let attempt = 0; attempt < 6; attempt++) {
const res = await fetch("https://stevai.com/api/v1/chat", {
method: "POST",
headers: { "Authorization": `Bearer ${key}`, "Content-Type": "application/json" },
body: JSON.stringify({ message }),
});
const data = await res.json();
if (res.ok) return data.reply;
if (res.status === 503) { // warming up — wait and retry
await new Promise((r) => setTimeout(r, 5000));
continue;
}
throw new Error(data.error || "Request failed"); // 400 / 401 — a real error
}
throw new Error("The network did not warm up in time. Try again.");
}Idempotency & retries
- Retrying a
503is safe — a request that didn't produce an answer isn't billed. - Back off a few seconds between attempts; the model keeps loading between your retries, so a later attempt lands.
- Don't retry a
400or401— those are real problems (bad input or bad key), not transient.
Cost & billing
Every successful response reports the real cost of that request in its usageobject, and that cost is metered to the API key's account. Only successful requests are billed.