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 }| Method | Header | Use case |
|---|---|---|
| Session cookie | Cookie: better-auth.session_token=... | Browser clients (set automatically after sign-in) |
| API key | x-api-key: ak_... | Server-to-server, scripts, CI/CD |
| API key (Bearer) | Authorization: Bearer ak_... | Alternative to the x-api-key header |
Core endpoints
| Method | Path | Description |
|---|---|---|
| GET | /api/chats | List your conversations |
| GET | /api/chats/search?q= | Search your conversations |
| POST | /api/chats | Create an empty chat |
| GET | /api/chats/:id?page=&limit= | A chat with a page of its messages |
| POST | /api/chat | Send a message and stream the answer (SSE); pass agentId to run an agent |
| GET | /api/chat/:chatId/stream | Reconnect to an answer that is still streaming |
| GET | /api/agents | List the agents you can use |
| GET | /api/knowledge-bases | List knowledge bases |
| POST | /api/knowledge-bases/:id/search | Semantic search a knowledge base |
| GET | /api/models | List the models available to you |
| GET | /api/marketplace/listings | Browse marketplace (no auth required) |
| GET | /api/health | Health 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.
| Route | Limit |
|---|---|
| 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 |
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.
| HTTP | Code | Meaning |
|---|---|---|
| 400 | — (no code) | Request body failed validation; detail lists the field messages |
| 401 | auth.unauthenticated | No credential on a route that needs one |
| 401 | auth.invalid_api_key | The key is malformed, unknown, revoked or expired |
| 401 | auth.invalid_token / auth.session_expired | The session token is invalid or has expired |
| 403 | permission.denied | Valid credentials but the role lacks the permission |
| 403 | auth.invalid_api_key | The 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 |
| 429 | rate_limit.exceeded | Too 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" }) |