AmikaClient is the entry point for the TypeScript SDK. Construct one with a
credential, then call methods on its collections, such as client.rigs and
client.agentSessions.
Constructor
apiKey: a static Amika API key. This is the preferred option for scripts.accessToken: a static bearer token.tokenSource: an object whosetoken()method the client calls for every request. See Token sources.baseUrl: the API origin. The client appends/api/v0beta1.fetch: a customfetchfor tests or non-standard runtimes.
AmikaError unless exactly one of apiKey,
accessToken, or tokenSource is set, and static credentials must be
non-empty. The SDK does not read AMIKA_API_KEY from the environment or
disk. You source the credential yourself.
Collections
All methods return promises, excepthandle(), which makes no request.
HTTP paths below are relative to the /api/v0beta1 prefix.
Ordinary requests time out after 30 seconds. Agent sends time out after 10
minutes. HTTP failures throw
AmikaHTTPError. See
Errors.
Rigs
createreturns the rig’s initial metadata before setup finishes. Callrig.wait()to wait for it to be ready.getrejects if the rig is missing or inaccessible. It returns stopped rigs too, without starting them.handlebuilds aRigHandlefrom a name or ID without a request or an existence check.getAndWaitfetches a rig and waits for it under one deadline.
hostId. See Bring your own compute.
Rig and RigHandle
A RigHandle has operations but no fetched data. A Rig is the rig’s fetched
metadata (RemoteRig) plus the same operations, bound to the rig’s ID.
start() and stop() resolve when the server accepts the request. Call
wait() to wait for the new state. Fetched data is a snapshot, not a live
view: refresh() and wait() update and return the same object.
Waiting
wait() and getAndWait() take RigWaitOptions:
Waiting for
stopped also accepts suspended. Waiting never creates or
starts a rig. If provisioning fails, setup fails, or the deadline passes,
wait() throws an AmikaWaitError. HTTP errors, including 404, propagate
immediately without retries.
Agent sessions
An agent session is a durable chat with a coding agent. Its transcript is stored on the server and can outlive the rig it ran on.sendresolves when the agent turn finishes. PasssessionIdto continue a chat orrigIdto target a rig. With neither, the server can create a rig, usingrepoUrlif you pass one.sendStreamdoes the same, callingonStatus(phase, rigId)andonDelta(text)in order as the turn runs. The SDK awaits each callback, and a callback that rejects fails the send.list({ limit, rigRef })returns{ sessions, total }, newest first.limitdefaults to 50 on the server.totalcan be larger thansessions.length.getreturns anAgentSession: the chat, itsmessagestranscript, and boundsend,sendStream, andrefreshmethods.
isError: true with details in response, even when
the HTTP request succeeds. If a stream ends without a final result, the SDK
throws. Check the chat before retrying, because the turn may have completed.
Snapshots
A
SnapshotHandle has fetch(), wait(), and delete()
(DELETE /rig-snapshots/{ref}). A fetched Snapshot adds refresh().
create starts the capture and returns before it finishes. snapshot.wait()
polls until the snapshot is active, with the same 3-second interval and
15-minute default deadline as rig waits. It throws AmikaError if the capture
fails or the deadline passes.
mode defaults to scrub_and_delete, which removes Amika-injected secrets,
captures the cleaned filesystem, and deletes the source rig. full keeps the
source rig and captures everything, including credentials. Some providers,
including your own hosts, support only scrub_and_delete, and the server
rejects full there. previewScrub lists the file paths and environment
variable names a scrub would remove, never their values.
list({ repositoryId, sourceRigId }) filters by repository or by source rig.
Services
Services are a rig’s published ports.listwithoutrigReflists every service in your organization.createandreplacereject ports outside 1–65535 and the reserved range 60899–60999 before sending a request.replacelooks the service up by name by default. Passby: "id"orby: "ref"to change that.deletelooks it up by name.
rig.services holds a shorter summary of each service, fetched with the rig.
Secrets
Listings return metadata, never secret values. The SDK has no method to delete
a generic secret. The HTTP API has one,
DELETE /secrets/{id}, and you can
also delete secrets in the web UI.
Agent credentials
Agent credentials are stored Claude or Codex logins that Amika can inject into rigs.provider is "claude" or "codex". Listings never return credential
values.
Repositories
Deprecated flat methods
Earlier SDK versions put every method directly on the client. Those methods still work but are deprecated. Move to the grouped API:
The old wait helpers keep their original behavior. They check provisioning
state only, without checking setup, and have no total deadline. Use
wait() for bounded waits that also check setup.
The SSH methods (getSSH, revokeSSH), the session-record methods
(createSession, listSessions, getLatestSession, getSession,
updateSession), extractAgentAuthError, and StaticTokenSource have been
removed. For SSH, use the CLI. See SSH and connect.
See also
Types
Request and response interfaces.
Errors
Error classes and wait failures.