Quickstart

Create a key from your dashboard, then:

curl -X POST https://uzmdqbtflcpikjdrggqc.supabase.co/functions/v1/api-chat \
  -H "Authorization: Bearer ak_live_..." \
  -H "Content-Type: application/json" \
  -d '{"message": "Summarize the plot of Dune in two sentences.", "model": "sonnet"}'
{
  "model": "sonnet",
  "content": "...",
  "usage": { "input_tokens": 18, "output_tokens": 64 },
  "credits_charged": 1,
  "credits_remaining": 199
}

Authentication

Every key starts with ak_live_. Pass it as a bearer token — the API never sees or needs your Aethyro login, so it's safe to use from a server or CI job (never from client-side browser code, since anything in browser JS is visible to whoever loads the page). Keys are shown once at creation; if you lose one, revoke it and create a new one.

Authorization: Bearer ak_live_...

Request

POST /functions/v1/api-chat — stateless: send the full conversation each time, same as most completion APIs. There's no server-side conversation history on this path.

FieldTypeNotes
messagestringShorthand for a single user turn. Use this or messages, not both.
messagesarray[{role: "user"|"assistant", content: string}], up to 20 entries, must end with a user turn.
modelstringhaiku / sonnet / opus / auto. Defaults to sonnet. auto uses the same embedding-based router as chat.html, and the response's model field tells you which one it picked.
streambooleanIf true, returns text/event-stream instead of a single JSON body — see Streaming below. Defaults to false.

Streaming

Pass "stream": true to get a standard Server-Sent Events response instead of waiting for the full reply. Each event is a JSON object on a data: line:

data: {"type": "delta", "text": "Para"}

data: {"type": "delta", "text": "mount"}

data: {"type": "done", "model": "sonnet", "content": "Paramount...", "usage": {"input_tokens": 18, "output_tokens": 64}, "credits_charged": 1, "credits_remaining": 198}

data: [DONE]

Billing happens once, after the stream completes — the done event carries the same credits_charged/credits_remaining fields the non-streaming response does. A stream that errors mid-flight sends a {"type": "error", ...} event (never partially billed) followed by [DONE].

Pricing

Same per-1,000-token credit rates as the chat app — a request never costs less than 1 credit. Buy credit packs from your dashboard; they never expire.

ModelInput / 1k tokOutput / 1k tok
Haiku0.08 credits0.40 credits
Sonnet0.30 credits1.50 credits
Opus1.50 credits7.50 credits

Errors

StatusMeaning
401Missing, malformed, or revoked API key.
400Malformed request body — see the returned error field.
402Insufficient credits on the account that owns the key.
429Over your key's per-minute limit (30, or 90 if the account has ever bought a Power or Pro pack). Check the Retry-After header (seconds).
502The upstream model call failed. Safe to retry.
A note on scope, honestly:

This is still a v1. Streaming and auto model routing are both in now, and Power/Pro pack buyers get 90 req/min instead of 30 — but it's still fully stateless (no server-side conversation history, no file/image attachments, no tool use/web search on this endpoint — those stay chat.html-only for now). If you need any of those, tell us.

Get your key

Free accounts start with 200 credits — enough to try the API before you buy more.

Create an account →