CLI
Use @21st-sdk/cli to authenticate, deploy agents, manage environment variables, and inspect logs from your terminal.
Install & Auth
The CLI is usually run with npx. It stores credentials in ~/.an/credentials, or you can pass an API key with the API_KEY_21ST environment variable.
npx @21st-sdk/cli login
# non-interactive
API_KEY_21ST=an_sk_... npx @21st-sdk/cli login --api-key $API_KEY_21STProject Layout
The current deploy structure is one agent per folder under agents/. The primary entrypoint is agents/<slug>/index.ts or agents/<slug>/index.js.
agents/
my-agent/
index.ts # or index.js
template/
...
package.jsonUse one folder per deployable agent. See Build & Deploy for the full project structure.
Deploy
Deploy scans the agents/ directory, bundles each detected agent, uploads it, and prints a link to the Agents dashboard. Use --agent <slug> if you only want to deploy one agent.
# deploy every agent under agents/
npx @21st-sdk/cli deploy
# deploy only one agent
npx @21st-sdk/cli deploy --agent my-agentEnvironment Variables
Use the CLI to list configured environment variable keys, set a single key, or remove a single key for a deployed agent.
# list configured keys
npx @21st-sdk/cli env list my-agent
# set or update one key
npx @21st-sdk/cli env set my-agent OPENAI_API_KEY sk-live-...
# remove one key
npx @21st-sdk/cli env remove my-agent OPENAI_API_KEYThe list command only returns keys, not secret values.
Logs
The CLI can list recent chat sessions, inspect a chat, or fetch one specific thread directly.
# list chats
npx @21st-sdk/cli logs my-agent
# inspect one chat
npx @21st-sdk/cli logs my-agent <chat-id>
# inspect one thread
npx @21st-sdk/cli logs my-agent <chat-id> <thread-id>
# machine-readable output
npx @21st-sdk/cli logs my-agent --jsonFiltering & Pagination
The logs list supports status filtering, search, date filtering, and cursor-based pagination.
| Flag | Description |
|---|---|
| --status active|error | Filter chats by status |
| --search TEXT | Search by chat ID or sandbox ID |
| --since ISO | Only include chats created at or after the timestamp |
| --until ISO | Only include chats created at or before the timestamp |
| --limit N | Page size, from 1 to 100 |
| --cursor UUID | Fetch the next page while keeping the same filters |
npx @21st-sdk/cli logs my-agent --status active --limit 20
npx @21st-sdk/cli logs my-agent --status active --limit 20 --cursor <nextCursor>CLI Environment Variables
| Variable | Purpose |
|---|---|
| API_KEY_21ST | Override the API key used by the CLI |