Integrations
ai-manager REST reference
GAOS makes exactly eight HTTP calls to ai-manager: four on the chat login, to run and answer turns and to list providers, and four on the admin key, to manage workspaces and delete sessions. This page lists each one as GAOS sends it and reads it, with the code that does so, and where GAOS and ai-manager's own documentation differ.
Source of truth
Everything here is derived from the code in dashboard/, with the file:line of each
caller at v0.45.0. Statements about ai-manager's own behaviour are marked per ai-manager's docs: they come
from its REST documentation, read for this page, and are not checked by GAOS's tests. The host is written
aim.example.org.
Configuration
Read once at boot by ModelConfigFromEnv (modelconfig.go:79-108). An empty value counts as
unset; a malformed number falls back to the default.
| Variable | Default | Meaning |
|---|---|---|
GAOS_MODEL_MODE | off | aimanager enables the gateway; off means no adapter; cli (retired in v0.29.0), api (not built) and anything else are refused at boot |
GAOS_AIM_URL | required | the base, e.g. https://aim.example.org; a trailing / is trimmed |
GAOS_AIM_CHAT_AUTH_FILE | required | JSON {"login_id","secret_key"}: HTTP Basic for the /v1 calls |
GAOS_AIM_ADMIN_KEY_FILE | optional | a file holding only the admin key: Bearer for the /admin calls; without it they fail before sending |
GAOS_AIM_TENANT | GAOS_ARCADE_TENANT, then local | in workspace ids gaos-<tenant>-<product>[-review] and request ids gaos.<tenant>.<run> |
GAOS_AIM_POLL_MS | 2000 | the result poll interval |
GAOS_AIM_TURN_DEADLINE | 660 s | the whole-turn ceiling; also how long a lost turn holds its product |
GAOS_AIM_SESSION_MAX_AGE | 25 days | an older task session is replaced by a new one |
GAOS_MODEL | empty | the Claude model sent as model; never sent to another vendor |
GAOS_RUNNER | off | manual: only a board move dispatches; on (or 1, true, yes): the scheduler dispatches too; anything else is off (runner.go:52-60) |
Common behaviour
Every chat call goes through AIMClient.do (aimanager.go:140-165): Content-Type:
application/json on every method, HTTP Basic from the chat login, X-Request-ID only when GAOS
passes a request id, and a body read up to 8 MiB. Every admin call goes through AIMClient.admin
(aimanager_admin.go:45-70): it refuses before sending when no admin key is loaded, sets Content-Type
and Authorization: Bearer <admin key>, and reads up to 1 MiB. No Accept header is set and
nothing streams. The HTTP client has a 30 s timeout per request (aimanager.go:131-136). An error message
never carries a credential.
Unless a call handles a status itself, statusError (aimanager.go:203-225) maps it:
| Status | GAOS error | Effect on a turn |
|---|---|---|
| 409 | ErrTurnRunning | a run error; the task goes back to READY |
| 410 | ErrSessionGone | the attempt ends as session-lost; the next attempt opens a new session |
| 403, 423 | ErrWorkspaceInactive | a run error |
| 500 and above, or no answer | ErrGatewayTransient | the attempt ends as gateway-failed |
| anything else | ai-manager answered <code>: <error> | a run error |
1 · POST /v1/chat
Submits one turn. Auth: Basic. Headers: X-Request-ID: gaos.<tenant>.<run>,
made URL-safe and capped at 128 characters (RequestIDFor, adapter_aimanager.go:100-106).
Built by AIMClient.Submit (aimanager.go:169-178), called from
AIMAdapter.submit (adapter_aimanager.go:202-211) in turn (:153-190).
A turn starts from a board move (board.go:497), the scheduler (runner.go:554, under
GAOS_RUNNER=on) or POST /tasks/{id}/dispatch.
{"prompt": "…the frozen packet…",
"model": "<GAOS_MODEL or the packet's>", // Claude: no "provider"
"provider": "antigravity", // another vendor only
"new_session": true, "workspace_id": "gaos-<tenant>-p-1", // a fresh session …
"session_id": "<uuid>", // … or a resumed one, never both
"ask_user": true, "caller": "gaos"}
Response: 202 (or 200) is accepted; the body is not read. Anything else goes
through statusError; a session-gone, unknown-request or transient error ends the attempt with that
signal, and any other error is a run error. Per ai-manager's docs a repeated request id answers 202
without a second job, and a body over its request limit is 400 — which GAOS reports as an untyped
error; GAOS's own egress cap is also 256 KiB (GAOS_EGRESS_MAX_BYTES), before the reply contract is added.
2 · GET /v1/requests/{requestId}/result
Polls a turn. Auth: Basic, no request id header. Built by
AIMClient.Result (aimanager.go:181-199), polled by AIMAdapter.poll
(adapter_aimanager.go:228-257) every GAOS_AIM_POLL_MS with no backoff until
GAOS_AIM_TURN_DEADLINE; also called by Resume at boot to collect a turn the previous process
started (turns.go:222-254).
| Status | What GAOS does |
|---|---|
| 202 | still running: wait and poll again |
| 200 | decode the reply below; unreadable JSON counts as transient |
| 404 | ErrRequestUnknown: at boot the task is held as orphaned until its deadline, then requeued |
| other | statusError; past the deadline the attempt ends the turn passed its deadline |
Fields read: text, provider, model, input_tokens, output_tokens,
cost_usd, session_id, metadata.context.workspace (the files the worker loaded) and
metadata.session_warning, and question{id, question, context, options[{label, description}]}.
A session warning marks the turn unsaved; a question with exactly three options goes to the operator's inbox;
otherwise a reply with no handoff block is handoff missing. A missing cost_usd, or 0 with tokens
spent, is recorded as unavailable.
3 · POST /v1/questions/{questionId}/answer
Answers the question a turn asked, and resumes the session. Auth: Basic. Headers:
X-Request-ID of the new turn. Body: {"choice": 1-4, "text"?: "…", "prompt"?: "…the
whole packet…"}. Built by AIMClient.SubmitAnswer
(aimanager_questions.go:70-87), from AIMAdapter.submit when the packet carries the operator's
answer and the turn resumes a session.
202/200: accepted, then polled like call 2. 409: already answered;
410: expired; 404: unknown. On any error GAOS falls back to a plain
POST /v1/chat with the same request id, and the packet already carries the answer.
4 · GET /v1/providers
Lists the vendors. Auth: Basic. Response:
{"providers":[{"name","available","default_model","models":[]}]}; a non-200 goes through
statusError. Built by AIMClient.ProviderInfo (aimanager.go:245-269).
Two callers:
- The boot check,
AIMAdapter.Smoke(adapter_aimanager.go:57-68, frommain.go:197), 15 s: the dashboard does not start unless the call succeeds andclaudeis available. - The vendors pane and a vendor policy save,
AIMAdapter.VendorInfo(vendors.go:280-305), 10 s, cached 60 s on success. The back office's Integrations view reads only that cache and never calls the gateway.
5 · POST /admin/workspaces/provision
Creates a product's workspace. Auth: admin Bearer. Query:
?provider=<vendor> for a non-Claude vendor (onVendor, aimanager_admin.go:76-81).
Body: {"id":"gaos-<tenant>-<product>","files":[{"path","content"}],"active":true}.
Response: {"workspace":{"id","manifest_digest","files":[{"path","sha256"}],"created"}};
200 or 201 is success, anything else statusError. Built by
AIMClient.Provision (aimanager_admin.go:85-101), from SyncWorkspace
(workspace.go:144, :151) when the workspace does not exist yet. Per ai-manager's docs the id must
start with gaos-, which GAOS's always do, and files are limited in path, size and total.
6 · GET /admin/workspaces/{id}/files
Reads a workspace's manifest. Auth: admin Bearer. Query: ?provider= as
above. Response: {"id","manifest_digest","files":[{"path","sha256"}],"created"}.
404 is not provisioned; 409 for a non-Claude vendor is the pool disagrees.
Built by AIMClient.Files (aimanager_admin.go:104-120). Callers:
SyncWorkspace (workspace.go:140) and WorkspaceDigest (workspace.go:126-129),
the drift check after every turn; an error there counts as no evidence of drift.
7 · PUT /admin/workspaces/{id}/files
Replaces a workspace's files with the published Blueprint. Auth: admin Bearer. Query:
?provider=. Body: {"files":[{"path","content"}],"prune":true,"if_match":"<digest>"}
— if_match is the current digest, or "" for the unconditional write after a pool
disagreement. Response: the manifest; 200 is success. A digest after the write that is
not the published one is an error. Built by AIMClient.PutFiles
(aimanager_admin.go:124-135), from SyncWorkspace (workspace.go:152, :155),
reached by a Blueprint sync (POST /products/{id}/blueprint/sync) and before every review dispatch
(reviewer_workspace.go:98).
8 · DELETE /admin/sessions/{sessionId}
Deletes a gateway session when the operator prunes archived conversations. Auth: admin Bearer.
Query: ?provider=. No body either way. 2xx: deleted; 404: already
gone; 409: busy; anything else, or no answer: failed. Built by
AIMClient.DeleteSession (aimanager_admin.go:142-158), from deleteSessions
(conversation.go:491-520) for POST /conversations/prune: one session at a time, 10 s each, 60 s
in all; an id that is not a UUID, or a vendor other than claude or antigravity, is skipped. Each card's tally is
recorded as an event.
Calls GAOS never makes
The request status endpoint, the question list, the /v1/workspaces routes, the health routes, the admin
workspace list, enable, patch and delete, session patch and bulk delete, shared sessions, admin questions, stats and
usage. There is no cancel: a running turn cannot be stopped from GAOS. GAOS's own /api/healthz reports the
adapter without calling ai-manager.
Known gaps against ai-manager's docs
Documented here, not fixed; each is a candidate for a later change.
- A
412on call 7 (a staleif_match) is not retried; per ai-manager's docs the client should read the manifest again and retry. - A
423means the session is inactive per ai-manager's docs; GAOS reports it as a workspace not enabled for chat. finish_reasonandworkspace_idare decoded and never read;Retry-Afterand the202bodies are ignored.- GAOS's 660 s turn deadline is longer than ai-manager's own CLI timeout, per ai-manager's docs.
- A
409on call 6 for Claude is not documented by ai-manager and would read as a running turn.