Skip to main content
Install and authenticate the Python or TypeScript client. Both SDKs are generated from the same OpenAPI contract that produces the API reference, so every operation, field, and error there exists in both, with the same semantics. Method names follow the operation ids: sessions.run_session / sessions.runSession, secrets.create_secret / secrets.createSecret, and so on.

Authentication

The two clients spell it differently: Python takes the credential directly (api_key= or access_token=, and supplying both raises ValueError), while TypeScript takes a security object (apiKey or bearerAuth). Constructed with no credential, both read ALBUS_API_KEY and ALBUS_BEARER_AUTH from the environment — the same ALBUS_API_KEY the CLI reads, see Authentication. whoami() names whichever credential signed the request: user for a bearer token, api_key / apiKey for a key. The other is absent.

Responses

An operation with response headers you need returns them alongside the body: response.result is the parsed body and response.headers the headers. That is how you read the effective invocation key of a run:
A run returns the one message it produced, in message — absent when the invocation has not answered yet. get_session / getSession returns the session’s history as messages. The key names an invocation in the SDKs (invocation_key=, invocationKey:) and travels as the HTTP Idempotency-Key header, which is why it is read back out of response.headers.

Traces, memories, and models

Beyond sessions, secrets, agents, and tokens, both clients expose the invocations Albus recorded, the memories agents wrote, and the models it serves:
get_trace / getTrace pages spans with after and limit, returns only the latest attempt’s spans unless you pass attempts="all", and takes payloads=False for the shape of an invocation without its prompts and tool output — which raises the span limit to 500, so a whole trace usually fits in one request. See the API reference.

Errors

Every non-2xx status raises a typed error carrying status_code, message, and body (errors.AlbusError and its subclasses in Python). Handle at least 423, 429, and 504 — see Errors. Retries are configured on the client (retry_config=), and run_session takes a retry_config= of its own to override it for that call. When configured, the retried statuses are 429, 500, 502, 503, and 504. Be careful combining that with a long-polling run: a 504 retry is a new request, so supply an invocation key or you will start a second invocation. No other per-request transport arguments exist — the timeout, base URL, and extra headers are client-level (timeout_ms=, server_url=, and the HTTP client you pass in).

Waiting for a reply

Both clients take the wait on the run itself, matching the API’s wait_timeout_seconds query parameter: wait_timeout_seconds=<n> in Python, and waitTimeoutSeconds: <n> beside body in TypeScript. Both default it to 1800 (30 minutes, the API’s maximum) and give run_session / runSession a matching 31-minute transport timeout, so a plain waiting run works without configuring anything.
Pass 0 to return as soon as the invocation is accepted, then poll getSession / get_session until session.state leaves RUNNING.
A client-level timeout_ms / timeoutMs applies to the waiting run too, and replaces that 31-minute default. Set it above the longest wait you ask for, or the transport gives up while the run is still going.

Versions

SDKs are released after the API they document is deployed, never before. Current floors for the examples on this page: Runtime requirements: Python 3.10+; for TypeScript, ECMAScript 2020+ — Node.js active or maintenance LTS (v18, v20), Bun 1+, or Deno 1.39+.