Everything you can do in the console, your code can do too. The public API base is https://asksybil.codexlabsai.com/api/v1 (the shorter /v1 spelling is a permanent alias - same routes, same auth). /v1 is a programmatic surface over the same chat engine, metering ledger, and model router that powers the interactive workspace - same models, same tools, same accounting. Responses are JSON, streaming is SSE, and errors are structured so your client can react properly. This reference documents the API as it's deployed on this host, nothing aspirational.
/v1 endpoints require an hs_ API key in the Authorization header. Browser session tokens are rejected - keys are the programmatic credential, sessions are for people. That separation means a key you hand to a script can never be used to log in as you.
Authorization: Bearer hs_xxxxxxxxxxxxxxxx
Optional X-Org-Id: <org id> header attributes the request's metered spend to an organization you belong to - membership is verified on every call, so the header is a claim the server checks, never a bypass. Org-attributed usage rolls up in the org's portal view and invoices.
Create keys after signing in (via the portal or directly). Secrets are shown once at creation/rotation - only the hash is stored, so even we can't recover a lost key; you'd rotate it instead. Keys can be scoped to specific API areas and given an expiry, and rotation mints a new secret on the same row so all of your historical usage attribution survives.
# create a scoped, expiring key (session token auth)
POST /auth/keys {"name": "prod", "password": "…", "scopes": ["api"], "expires_at": "2026-12-31T00:00:00"}
→ 201 {"id": 1, "key": "hs_…", "scopes": ["api"], …} # key shown once
GET /auth/keys # list (metadata only)
POST /auth/keys/{id}/rotate # new secret, same row → usage attribution survives
DELETE /auth/keys/{id}
The workhorse: a chat completion through the same routing engine the console uses. Send a message and optionally pin a model, continue a session_id, enable oracle routing or council multi-model deliberation, steer with pref (speed|balanced|quality|local), or attach images. The reply comes back with the model that actually answered and the metered usage your request generated - the real ledger events, not an estimate.
curl -X POST https://asksybil.codexlabsai.com/api/v1/chat \
-H "Authorization: Bearer hs_…" -H "Content-Type: application/json" \
-d '{"message": "Explain retry budgets in one paragraph."}'
→ 200 {
"reply": "…", "model": "qwen3:0.6b", "provider": "ollama",
"session_id": "…", "request_id": "req_…",
"usage": {"prompt_tokens": N, "completion_tokens": N, "events": N}
}
Retries are safe. Send an Idempotency-Key header with any unique value and a replayed request returns the stored response with idempotent_replay: true instead of re-executing - no double model work, no double metering. Keys live 24h and are scoped to your credential. A key is claimed before execution: a concurrent request on the same key gets 409 idempotency_in_progress - retry it after the first finishes and you'll get the stored replay. A failed request releases the key, so a corrected retry re-executes cleanly.
Server-sent events stream of the same turn: meta, token deltas, routing/verification events, and a terminal done carrying the final model, Oracle-mode metadata, usage (same ledger read as /v1/chat), and request_id.
Installed model inventory on the configured provider, plus the configured chat and vision models - the catalog the router selects from.
Your own metering summary: event counts, token totals, provider cost and customer charge in integer millicents, and unpriced-event counts - plus by_kind, by_model, and by_day breakdowns of the same period. ?days=1..365 (default 30).
→ 200 {"summary": {"events": N, "tokens_in": …, "tokens_out": …,
"provider_cost_millicents": …, "charge_millicents": …,
"unpriced_events": …, "by_kind": […], "by_model": […], "by_day": […]},
"request_id": "req_…"}
The same tool layer the console orchestrates - research fetches, document processing, data analysis, code execution - callable directly. GET /v1/caps lists the commercial catalog (user-permission capabilities only; admin tools are never advertised or reachable here). POST /v1/caps/call executes one synchronously with schema-validated args.
GET /v1/caps # catalog + availability
POST /v1/caps/call {"capability": "web_get", "args": {"url": "…"}}
→ 200 {"result": {…}, "usage": {…}, "request_id": "req_…"}
Work that outlives an HTTP window runs on the durable job layer: submit, poll, cancel, resume. Jobs queue by priority, checkpoint progress to disk, survive restarts, and meter exactly like synchronous calls.
POST /v1/jobs {"capability": "doc_summarize", "args": {…}, "priority": 5}
→ 201 {"job": {"id": "…", "status": "queued"}}
GET /v1/jobs # your jobs, newest first
GET /v1/jobs/{id} # status, live progress, result
POST /v1/jobs/{id}/cancel # cooperative stop
GET /v1/requests?limit=1..200 rolls your metered usage up per request_id - event counts, token totals, charge, the models and kinds involved. Metadata only: the ledger never stores prompt or response content.
Accounts on prepaid plans (or deployments with strict prepay) draw from a credit balance: GET /v1/credits shows balance_millicents plus available_millicents - the balance minus in-flight reservations. Each billable call reserves a bounded hold at admission (402 insufficient_credit when the remainder can't cover it), the real metered charge settles against the balance after execution, and credit-settled usage never reappears on an invoice.
Topping up is self-service: POST /v1/credits/topup {amount_millicents} mints a payment intent with a TOP-… reference, payment instructions, and (when a checkout link is configured) a checkout_url you can send the customer straight to. The APEX processor's signed webhook settles it (a captured checkout payment posts as checkout.completed) and the credit lands automatically. Accounts with an invoice past its grace period get 402 account_past_due on billable calls until settlement - reads and the top-up path itself stay open.
The whole surface is also published as JSON at GET /v1/spec - anonymous, interface metadata only (routes, request/response shapes, scopes, limits). Point your codegen or docs tooling at it; the section below renders from that live endpoint when this page is served by the API host, so the reference you read is the contract the server enforces.
curl https://asksybil.codexlabsai.com/api/v1/spec # no auth - interface metadata only
| Method | Path | Scope | Summary |
|---|---|---|---|
| POST | /v1/chat | api | chat completion |
| POST | /v1/chat/stream | api | SSE streaming chat |
| GET | /v1/models | api | model inventory |
| GET | /v1/usage | api | metering summary (?days=) |
| GET | /v1/caps | api | capability catalog |
| POST | /v1/caps/call | api | run a capability |
| GET | /v1/jobs | api | list your jobs |
| POST | /v1/jobs | api | submit async job |
| GET | /v1/jobs/{id} | api | job status/result |
| POST | /v1/jobs/{id}/cancel | api | cooperative job stop |
| GET | /v1/requests | api | per-request history |
| GET | /v1/credits | api | prepaid balance |
| POST | /v1/credits/topup | api | mint a top-up payment intent |
| GET | /v1/spec | anonymous | this machine-readable contract |
| GET | /v1/openapi.json | anonymous | OpenAPI 3.0 document |
Failures are structured JSON with a stable type:
| Status | type | Meaning |
|---|---|---|
| 400 | invalid_request | validation failed (message too long, bad field) |
| 401 | - | missing/invalid/expired key |
| 403 | authentication_error | session token used on /v1 - use an hs_ key |
| 403 | insufficient_scope | key lacks the scope this route requires |
| 403 | entitlement | your plan does not include API access (or this model) |
| 402 | insufficient_credit | prepaid balance exhausted - top up first |
| 402 | account_past_due | an invoice is past grace - settle it to resume billable access |
| 404 | not_found | the referenced object does not exist |
| 409 | idempotency_in_progress | a request with this Idempotency-Key is still running - retry shortly |
| 429 | rate_limit | key rate limit or plan daily quota - honor Retry-After |
| 503 | provider_unavailable | inference provider unreachable/refused admission |
| 503 | maintenance | the API is in maintenance - retry shortly |
Each key is rate-limited per minute, so one busy script can't starve the rest of the platform. The effective limit is your plan's max_rpm entitlement when subscribed, else the platform default of 120 requests/min per key. On this deployment the window is shared platform-wide in the ledger database - the same budget applies whichever instance or restart your request lands on. Plans can also set a daily_requests quota - counted over distinct request ids in the ledger, resetting 00:00 UTC. Over-limit requests return 429 with Retry-After - back off for that many seconds and you're fine.
Scopes are least-privilege for your own credentials: a key with a scopes list is confined to those API areas, so a key that only needs to chat can't also read your invoices. An unscoped key is full-access (legacy behavior) - fine for a personal key, but give production integrations only what they need. Known scope areas: api (/v1), chat, caps, docs, media, usage, models, account (/auth/keys, /billing, /portal - financial data), admin. Scope checks are enforced on every request, and usage events attribute to the key's identity - key-level analytics appear in your portal.
No SDK needed - the surface is plain JSON over HTTPS. Both snippets below are dependency-free and runnable as-is.
# Python 3 stdlib
import json, urllib.request
req = urllib.request.Request(
"https://asksybil.codexlabsai.com/api/v1/chat",
data=json.dumps({"message": "Explain retry budgets."}).encode(),
headers={"Authorization": "Bearer hs_…",
"Content-Type": "application/json",
"Idempotency-Key": "run-42"}, # safe retry
method="POST")
with urllib.request.urlopen(req, timeout=120) as r:
print(json.load(r)["reply"])
// JavaScript (browser or Node 18+)
const r = await fetch("https://asksybil.codexlabsai.com/api/v1/chat", {
method: "POST",
headers: {"Authorization": "Bearer hs_…",
"Content-Type": "application/json",
"Idempotency-Key": "run-42"},
body: JSON.stringify({message: "Explain retry budgets."})});
const {reply, usage, request_id} = await r.json();
console.log(reply);
usage in a chat response reflects exactly what this request cost - provider-reported token counts where the provider reports them, capability executions itemized separately. Your portal and invoices read the same ledger, so the numbers always agree.