Integration guide
Code Smith integrates with this platform through a stable, versioned REST API pinned by the live contract suite, published as an OpenAPI 3.1 spec. This page covers the full flow: authenticate, check entitlements, meter usage, and handle failures correctly. For a guided first run, see the API quickstart.
1 · Authentication
The app never stores passwords. Signing in performs a password grant that registers a revocable installation and returns a short-lived access token plus a rotating refresh token. Store both in your OS credential store.
POST /api/v1/auth/token
{ "grant_type": "password",
"email": "you@example.com",
"password": "••••••",
"installation": { "name": "nova-laptop", "platform": "linux" } }
→ { "access_token": "…(15 min JWT)…",
"refresh_token": "…(90d, rotates on use)…",
"installation": { "id": "ins_8f3k…" } }POST /api/v1/auth/token # when access expires
{ "grant_type": "refresh_token", "refresh_token": "…" }
→ new pair; the old refresh token is revoked immediatelySend the access token as Authorization: Bearer <token> on every v1 call. Logout (or web-side revocation) revokes the installation and refuses all its tokens.
2 · Entitlements - ask before you bill
Before spending AI, read the entitlement surface. It answers: which plan, which features, which models/providers are allowed, how much allowance remains, and whether billable usage is currently active.
GET /api/v1/entitlements
→ { plan: { key, name, kind },
features: { cloudModels, advancedAgents, … },
limits: { allowedModels, allowedProviders, maxInstallations, … },
allowances: { requestsPerMonth, inputTokensPerMonth, outputTokensPerMonth },
usage: { requests, inputTokens, requestsRemaining, … },
spendLimit: { limitMicros, spentMicros, exhausted },
billingActive: true|false }Model/provider allowlists use trailing-* glob semantics (e.g. claude-haiku-*). Records marked mode=LOCAL are metered for analytics but never billed.
3 · Usage metering
Report every AI request as a usage record - singly or batched (≤500). Records are idempotent by requestId: safe to retry. Prices are resolved server-side; client-reported amounts are ignored.
POST /api/v1/usage
{ "requestId": "req_9d41…", // unique, 8-128 chars - dedup key
"occurredAt": "2026-10-25T18:04:11Z", // ISO-8601, ±7d skew bound
"provider": "axis",
"model": "axis-lite",
"mode": "CLOUD", // CLOUD (billable) | LOCAL
"status": "SUCCESS", // SUCCESS | ERROR | REJECTED | CANCELED
"inputTokens": 1240,
"outputTokens": 380,
"cachedTokens": 0,
"toolCalls": 2,
"computeMs": 1450 }Batch: { "records": [ … ] } returns per-record status (accepted / duplicate / rejected+reason). A record is rejected if its provider or model fails the plan allowlist, or the timestamp is impossible.
4 · Installations
Each sign-in registers an installation (device identity). Plans cap the count - Free 1, Pro 3, Enterprise negotiated. List them via GET /api/v1/installations, revoke one via DELETE /api/v1/installations/{id}. Revocation takes effect on the next authenticated call: the app receives INSTALLATION_REVOKED and should return to signed-out state.
5 · Errors & resilience
Responses follow { ok, data } / { ok:false, error:{code,message} }. Handle these codes deliberately:
UNAUTHORIZEDMissing, expired, or revoked credentials - re-authenticate via /auth/token.INSTALLATION_REVOKEDThe installation was revoked remotely; return to signed-out state and re-register.MODEL_NOT_ALLOWEDRequested model outside the plan allowlist - check /entitlements limits.allowedModels.PROVIDER_NOT_ALLOWEDProvider outside the plan allowlist - check /entitlements limits.allowedProviders.ALLOWANCE_EXHAUSTEDPlan allowance consumed; overage disabled or spend limit reached.SPEND_LIMIT_REACHEDOrg/account spend cap hit - raise it in billing settings.VALIDATION_FAILEDPayload failed schema validation - check field types and required keys.RATE_LIMITEDToo many requests - back off and retry; limits are per-IP and per-installation.IDEMPOTENCY_CONFLICTrequestId reused with different payload - reuse ids only for retries of the same record.Retry 429/5xx with exponential backoff. Retry usage ingest freely - requestId dedup makes resubmission safe. Never reuse a requestId for different content.
Reference · platform v1
/api/v1/auth/tokenpassword grant (login + installation registration) or refresh_token rotation/api/v1/auth/logoutrevoke calling installation + all its tokens/api/v1/meaccount, installation, and organization context/api/v1/entitlementsplan, features, limits, allowance, spend state/api/v1/usage/summarylightweight usage snapshot/api/v1/usageingest one usage record - or { records: [...] } batch (≤500)/api/v1/installationslist registered installations/api/v1/installations/{id}revoke an installation/api/healthliveness + dependency health (no auth)/api/searchsite search across docs, support, and marketing contentReference · Ask Sybil service (asksybil.codexlabsai.com)
The AI service Code Smith consumes. Chat, capabilities, and missions bill against your plan allowance; records flow through /api/v1/usage here. Inside the IDE, long-running jobs surface as the Mission Engine.
/v1/capscapability catalog - every tool/action the agent may invoke/v1/caps/callinvoke a capability by id with validated arguments/v1/chatstreaming chat completions - the Ask Sybil conversational surface/v1/jobssubmit a long-running mission; returns a job handle/v1/jobs/{id}cancel a running mission/v1/specspecification generation from natural-language intentNever trust the client
Prices, allowances and entitlements are resolved server-side. The app reports measurements; the platform decides cost.
Idempotent by design
Retry any usage submission safely - requestId deduplicates. Refresh tokens rotate on use.
Local is local
mode=LOCAL records meter for analytics but are never billed. Cloud inference is metered and priced.