Overview
Agent sessions are conversation threads backed by the Gizzi runtime on your data-plane node. The public path is on the Cloud API: it authenticates the Clerk session, resolves your default healthy node, and relays the request to Allternit API. Session rows live in that node’s SQLite, not in Cloud API Postgres. The node translates the session contract (/api/v1/agent-sessions) into the Gizzi runtime contract (/v1/session/*). Sessions support messages, abort, revert/unrevert, compaction, ephemeral incognito chats, and real-time event synchronization via SSE.
HTTP 428 means this account has no healthy paired or provisioned node. Pair a desktop/VPS or start a provisioned instance, then retry.
Base URL
http://127.0.0.1:8013/api/v1.
Authentication
All production requests must include a Clerk session JWT in theAuthorization header. The Cloud API forwards that header to the node. Gizzi-specific Basic auth is handled internally on the node when GIZZI_PASSWORD / GIZZI_SERVER_PASSWORD is configured.
Session object
Endpoints
List sessions
Query parameters
Example request
Example response
Create a session
model, else the bound agent’s saved brain, else the user’s chosen default), resolves the agent harness config, and records the original surface so it can be restored later. There is no default model: when none of these is set the session is created without one, and its first turn answers 409 no_brain.
Request body
Example request
Example response
The surface
design is normalized to chat for Gizzi compatibility; the original value is preserved in metadata.originSurface.Plain chats on a picked runtime
A plain chat created withmetadata.botBrain or metadata.runtime naming a runtime other than allternit runs on that runtime, the way a bot with a native-harness brain does. The gateway checks the pick, stores the normalized botBrain and runtime on the session, and runs every turn on the runtime CLI’s provider (for Claude Code, claude-cli/<model>). A turn’s model is kept when that CLI runs it. Otherwise the turn uses the session brain’s model, and if that does not fit, the CLI’s default model. The session never falls back to the default runtime without telling you.
The 422 checks run only when the request names
runtime itself (in botBrain or metadata.runtime). The brain checked is botBrain.modelRef, else the request’s model. Show message to the user as it is.
Get a session
Example request
Example response
Same shape as the create response.Update a session
Request body
Changing a plain chat’s runtime
When an update to a plain chat (not a bot or agent session) carriesmetadata.runtime or metadata.botBrain, and the runtime or the brain (modelRef) differs from what the session stores, the gateway runs the same checks as create before it changes anything. It returns the same 422 (runtime_unknown, brain_not_fit, plan_not_allowed_on_runtime) and 409 runtime_not_installed bodies. If the checks pass, it stores the new runtime and normalized botBrain, and the next turn runs on the new runtime’s CLI. The old runtime’s agent_session is dropped unless the new brain names a nativeSessionId. Moving to allternit stores runtime: "allternit", and turns go back to the default path. An update that sends back the same runtime and brain (for example the whole bag) is not checked. Bot and agent sessions are never checked or moved this way.
| markReviewed | boolean | true clears readyForReview. Clients send it when the user opens a session. |
Session status flags
The server keeps two status flags inmetadata and returns them on every session read. A missing key means false. Clients can’t set or clear them through metadata.
Rules:
needsInputturns on when the runtime asks for permission or asks a question. It turns off when the last open ask of that session is answered or dismissed, when the run errors or ends, and when a new run starts.readyForReviewturns on when a run ends after a file write or edit (thefile.editedruntime event) or a completedartifact_create/artifact_updatetool call. It turns off when a new run starts or a client sendsmarkReviewed: true.- The API server watches the runtime’s event stream all the time, so the flags change while no app is open. Each change is also sent on the sync stream as
session_flags.
Example request
Example response
Same shape as the create response, withactive: false.
Delete a session
Example response
204 No Content
List messages
Example response
Send a message
role: "user" messages are forwarded to the runtime. role: "assistant" with noReply: true stores a static assistant message without a model turn (a bot’s greeting in its new main chat); it is labelled with metadata.source and stored once per session and source, however many clients post it. Other roles are accepted locally and echoed back immediately.
Request body
In a plain chat created on a runtime, the turn runs on that runtime’s CLI (see Plain chats on a picked runtime). Otherwise the turn runs on
metadata.model, else the user’s chosen default, else (in a bot’s thread) the thread’s or the bot’s saved brain. With none of these, the call returns 409 {"error":"no_brain","message":"Pick a brain first."} and nothing is sent. A noReply message needs no brain.
Example request
Example response
Same shape as a message fromlist messages.
List earlier versions
GET /v1/session/:sessionID/branches.
Example response
anchorMessageId is the message the edit or retry started from. messages has the same shape as List messages. Large inline attachments are stored without their data.
Abort a session
Example response
Revert a session
Request body
Example response
Same shape asget session.
Unrevert a session
Example response
Same shape asget session.
Compact a session
Example response
Sync sessions (SSE)
Last-Event-ID reconnection.
Supported event types
Linked pull requests
GitHub pull requests a code session created or pushed to, or that were linked by hand. Each item is aLinkedPR:
Statuses are cached for at least a minute and refresh in the background; changes arrive on the sync stream as
session_prs.
Example curl
Example event
Additional routes
These routes are registered by the same router on the Allternit API node. See the code incmd/allternit-api/src/agent_session_routes.rs for request shapes.