Developer Documentation

API Reference

Complete reference for the Akili REST API — authentication, endpoints, rate limits, and error codes.

Base URL

The public API is served by the Akili backend under /api. The web app reaches the same endpoints through its /backend/* proxy, which is what the examples below use when they run in a browser; from your own application, call the API host directly with an API key:

# The public API (use an API key — see Authentication)
https://api.akili.io/api/

# The same endpoints, through the web app's proxy (session cookie)
https://app.akili.io/backend/

Authentication

Every request must include a valid credential. Two methods are supported:

# Create a key in Settings → API keys, or from code while signed in
# (session cookie) with the request below. Scopes are optional: a key with
# no scopes acts as you on every route. Keys expire after 90 days unless you
# pass expiresIn (seconds, 1 to 365 days). The key is shown once, either way.
POST /api/api-keys/create
Content-Type: application/json

{ "name": "nightly-flows", "scopes": ["flows:read", "flows:run"], "expiresIn": 7776000 }
MethodHeaderUse case
Session cookieCookie: better-auth.session_token=...Browser clients (set automatically after sign-in)
API keyx-api-key: ak_...Server-to-server, scripts, CI/CD
API key (Bearer)Authorization: Bearer ak_...Alternative to the x-api-key header
Note: Keys are prefixed with ak_. Scopes: flows:read, flows:run, flows:write, social:read, social:write (write implies read); a route without a declared scope accepts any valid key of the account. Add x-akili-org-id: <organization id> to act in a team workspace; without it the call lands in your Personal workspace.

Core endpoints

MethodPathDescription
GET/api/chatsList your conversations
GET/api/chats/search?q=Search your conversations
POST/api/chatsCreate an empty chat
GET/api/chats/:id?page=&limit=A chat with a page of its messages
POST/api/chatSend a message and stream the answer (SSE); pass agentId to run an agent
GET/api/chat/:chatId/streamReconnect to an answer that is still streaming
GET/api/agentsList the agents you can use
GET/api/knowledge-basesList knowledge bases
POST/api/knowledge-bases/:id/searchSemantic search a knowledge base
GET/api/modelsList the models available to you
GET/api/marketplace/listingsBrowse marketplace (no auth required)
GET/api/healthHealth check (no auth required)

Streaming chat (SSE)

POST /api/chat answers as Server-Sent Events in the AI SDK UI message stream protocol (response header x-vercel-ai-ui-message-stream: v1): each data: line is a JSON chunk with a type such as text-delta, and the stream ends with data: [DONE]. Pass chatId: "new" to start a conversation; messages may be AI SDK UIMessage objects (with parts) or plain { role, content } pairs:

const response = await fetch("https://api.akili.io/api/chat", {
  method: "POST",
  headers: { "Content-Type": "application/json", "x-api-key": "ak_..." },
  body: JSON.stringify({
    chatId: "new",               // or an existing chat id
    model: "gpt-4.1-mini",
    messages: [{ role: "user", content: "Hello!" }],
    enableSearch: false,
    knowledgeBaseIds: [],
    // agentId: "...",           // run a specific agent
  }),
});

const reader = response.body.getReader();
const decoder = new TextDecoder();

while (true) {
  const { done, value } = await reader.read();
  if (done) break;
  const text = decoder.decode(value);
  for (const line of text.split("\n")) {
    if (!line.startsWith("data: ")) continue;
    const data = line.slice(6);
    if (data === "[DONE]") break;
    const chunk = JSON.parse(data);
    if (chunk.type === "text-delta") process.stdout.write(chunk.delta);
  }
}

Rate limits

Limits are applied per route, keyed by user (or by IP address on public routes). There is no plan tier for API traffic: a route without its own limit falls back to 1,000 requests per day per user, and chat is additionally limited by your plan. Model usage is metered in credits, not requests.

RouteLimit
Default (any guarded route)1,000 requests / day per user
POST /api/agents/:id/chat (webchat)60 requests / minute per IP
GET /agents/:id/.well-known/agent.json (A2A)120 requests / minute per IP
Sensitive routes (access requests, codes)As low as 3 per window
Note: Every guarded response carries X-RateLimit-Remaining and X-RateLimit-Reset (an ISO timestamp). A limited request gets 429 with code rate_limit.exceeded and remaining, limit and resetAt in the body; those two are the only rate-limit headers.

Error codes

Errors are application/problem+json: statusCode, error, title, detail, instance, requestId and — when the backend raised a typed error — a dotted machine-readable code. Validation and unexpected errors carry no code.

HTTPCodeMeaning
400— (no code)Request body failed validation; detail lists the field messages
401auth.unauthenticatedNo credential on a route that needs one
401auth.invalid_api_keyThe key is malformed, unknown, revoked or expired
401auth.invalid_token / auth.session_expiredThe session token is invalid or has expired
403permission.deniedValid credentials but the role lacks the permission
403auth.invalid_api_keyThe key is valid but lacks the scope the route declares
404<resource>.not_found (e.g. chat.not_found, agent.not_found)Resource does not exist or is not yours
429rate_limit.exceededToo many requests — wait until X-RateLimit-Reset
500— (no code)"Internal server error" — quote the requestId to your administrator
503— (no code)The web app's /backend proxy could not reach the backend ({ error: "Backend unavailable" })