Overview
The Realm CLI wraps the same REST API documented in this section. It gives you agent chats with live streaming answers, document management for API data sources, and an interactive chat session, all from a terminal. Every command accepts--json, so the CLI also works as a scripting tool in pipelines.
Installation
The CLI is published to npm and requires Node.js 22.12 or newer.Upgrading
The CLI is versioned and released independently of the Realm web application. Install the newest release over your current one:realm --version to see which version is installed.
Authentication
Create an API key first. See API keys for how to create and manage keys, and note that a key carries scopes:chat:read, chat:write, and documents:write.
Interactive login
GET /agents, and stores it in your operating system credential store. When no credential store is available, for example on a headless Linux host, the key is written to a configuration file with owner-only permissions instead.
A key that carries only documents:write cannot list agents. Login still accepts and stores such a key, and notes that chat commands are unavailable with it. A key that fails authentication outright is never stored.
Check or remove the stored key:
Continuous integration
SetREALM_API_TOKEN in the environment. It takes precedence over any stored key, so no login step is needed in a pipeline.
Multiple tenants
The default base URL ishttps://app.withrealm.com. Single-tenant deployments live on their own host, which you select with --base-url on any command, or persist with realm config set base-url. The REALM_BASE_URL environment variable overrides the persisted value.
Keys are stored per host, because API keys are tenant scoped. Logging in against two hosts keeps two keys side by side, and each command uses the key of the host it targets. Storing a key for a host also clears any copy of it held by the other store, so a single key per host is all the CLI can ever resolve.
The base URL must use https://, because the key travels in an Authorization header. Plain http:// is accepted only for local development hosts: localhost, *.localhost, 127.0.0.1, and ::1.
Global flags
Command reference
Authentication and configuration
Agents and data sources
Chat
realm chat without a subcommand opens an interactive session: pick an agent, send messages, and watch answers stream in. Tool calls that need approval are presented as a prompt, and answering continues the same chat. The session prints its chat ID on exit so you can resume the transcript with realm chat messages. The session needs a terminal on both input and output, so with --json, redirected output, or piped input the command points you at realm chat ask instead.
Flags for
realm chat ask:
realm chat approve invocation that resumes the chat.
Documents
Every document command takes a data source ID fromrealm connectors list and requires the documents:write scope.
{ "documents": [...] } or a bare array of documents, with the fields described in the upsert documents endpoint.
Flags for realm documents upload:
Scripting
With--json, a command prints machine-readable JSON on standard output and nothing else, which makes it safe to pipe into a parser such as jq.
Indexing is asynchronous, so treat a successful
realm documents upsert as accepted rather than searchable. An upsert of more than 100 documents is sent in batches; if a batch fails, the command reports the results of the batches that already succeeded, so you can retry only the remainder instead of duplicating accepted documents. If a batch never returns a response, its outcome is reported as unknown: the server may have applied it, so replay it only when every document in it has an explicit id.
Without --json, redirected output is tab-separated. Cell values are escaped, so a tab, newline, carriage return, or backslash inside a field becomes \t, \n, \r, or \\, and every record stays on one line with a fixed column count.
A streamed answer is occasionally revised by the agent, for example when it repairs the language of a reply. On a terminal the CLI erases the answer and reprints it; with redirected output it cannot erase, so it prints a [answer revised] marker line before the replacement.
Exit codes
Rate limits
The CLI is bound by the API limit of 600 requests per minute per organization per endpoint. When you exceed it, the request fails with429 Too Many Requests, and the CLI reports the Retry-After hint from the response. Space out scripted loops and back off when you hit the limit.
