Quickstart Crew CLI

View as Markdown

The smallestai agent-crew CLI is built for rapid iteration. Test your crew locally with a single command, then deploy to the cloud when ready. No configuration files, no Docker, no infrastructure management.

Local-first development: Run and test your agent entirely on your machine. Deploy only when you’re satisfied.


Installation

The CLI comes bundled with the SDK:

$pip install smallestai

Expected boot output on smallestai>=5.0.0. Startup includes a validation routine that exercises your setup_handler against a placeholder WebSocket to surface init-time errors. This dry-run reaches await session.start() before any client has connected and logs:

ERROR | Startup validation failed — pod will not accept sessions. ValueError: Session not initialized

The server proceeds past this point — Application startup complete. follows, Uvicorn binds on :8080, and real client connections handshake normally.

A different error at the same point in startup — for example OpenAIError: Missing credentials — indicates a real configuration issue. Set OPENAI_API_KEY (or configure Electron, below) before booting.

Verify the installation:

$smallestai --help

You’ll need a Smallest API key (from app.smallest.ai/dashboard/api-keys) for the CLI and SDK helpers. Export it:

$export SMALLEST_API_KEY=sk_...

Plus an LLM for the example below. The Atoms Crews SDK ships an OpenAIClient that accepts any OpenAI-compatible endpoint — pick one:

Smallest’s voice-optimized SLM. Reuses SMALLEST_API_KEY — no separate LLM key required.

1from smallestai.atoms.crew.clients.openai import OpenAIClient
2import os
3
4llm = OpenAIClient(
5 model="electron",
6 api_key=os.getenv("SMALLEST_API_KEY"),
7 base_url="https://api.smallest.ai/waves/v1",
8)

The Atoms Crews OpenAIClient is async — call sites use await llm.chat(messages=[...]) inside a crew node’s generate_response() method (which already runs in an event loop). It does not expose the OpenAI-Python-SDK shape llm.chat.completions.create(...); the call surface is await llm.chat(messages, stream=False, tools=None, ...) returning a ChatResponse with .content and .tool_calls.

Test connectivity outside a crew

For a one-off sanity check (verify your key works, the endpoint responds), use the standard openai Python SDK — Electron is OpenAI-compatible, so the official client works as a drop-in by overriding base_url:

1import os
2from openai import OpenAI
3
4client = OpenAI(
5 api_key=os.environ["SMALLEST_API_KEY"],
6 base_url="https://api.smallest.ai/waves/v1",
7)
8
9resp = client.chat.completions.create(
10 model="electron",
11 messages=[{"role": "user", "content": "Respond with a one-sentence greeting."}],
12 max_tokens=50,
13)
14print(resp.choices[0].message.content)

Same code works against OpenAI itself by dropping base_url and swapping model to gpt-4o-mini (and using OPENAI_API_KEY). Use this pattern for backend scripts or smoke tests that aren’t inside a crew node.


Create Your First Agent Crew

Before the CLI has anything to connect to, you need a Python file that defines a crew and starts a WebSocket server. Pick one of the two patterns below and pull the example folder straight from the cookbook — the tar command drops a getting_started/ or background_agent/ directory into your cwd, ready to cd into. For local development, no .env is needed — the examples read SMALLEST_API_KEY (and optionally OPENAI_API_KEY) straight from your shell. For cloud deployment, you’ll need a .env file (see the Ship env vars in a .env step further down). Each folder ships a one-line requirements.txt pinning smallestai, which the cloud build also uses when you deploy.

Single-node crew

A minimal, single-node crew that streams chat completions from an LLM and greets the caller on join — copied from the cookbook’s getting_started.

$curl -sL https://github.com/smallest-inc/cookbook/archive/refs/heads/main.tar.gz \
> | tar -xz --strip-components=2 cookbook-main/voice-agents/getting_started
$cd getting_started
$pip install -r requirements.txt

server.py is the entry point — it boots an AtomsCrewApp on ws://localhost:8080/ws. assistant.py contains the OutputCrewNode subclass that streams the LLM response; extend it with your own prompt, tools, and logic.

Multi-node crew with background processing

A two-node example from background_agent — a support agent talking to the user, and a sentiment analyzer running silently in parallel that flags frustration and triggers auto-escalation.

$curl -sL https://github.com/smallest-inc/cookbook/archive/refs/heads/main.tar.gz \
> | tar -xz --strip-components=2 cookbook-main/voice-agents/background_agent
$cd background_agent
$pip install -r requirements.txt

Multi-node uses smallestai>=5.0.0 because sentiment_analyzer.py imports SDKAgentLogEvent (introduced in 4.4.7). Same boot-log caveat as the Installation section applies — you’ll see the Session not initialized ERROR; the pod still serves.

app.py wires both nodes into a single CrewSession. support_agent.py is the user-facing OutputCrewNode; it can query the sibling sentiment node mid-conversation. sentiment_analyzer.py is a BackgroundCrewNode — it listens to every transcript event, classifies sentiment, and updates state the support agent reads.

What you’re working with:

  • OutputCrewNode — base class for nodes that produce user-facing output. Override generate_response() to define what the agent says.
  • BackgroundCrewNode — base class for nodes that observe events silently. Override process_event() to react. No audio output, no interrupts.
  • CrewSession — the runtime that owns the WebSocket connection and runs your nodes in parallel for each call.
  • AtomsCrewApp — the FastAPI WebSocket server that the CLI’s chat command, and the production Atoms orchestrator, connect to.

Local Development Workflow

The CLI’s best feature is instant local testing. No need to deploy to test changes.

1

Start Your Agent Server

Run the entry point to start a local WebSocket server:

$python server.py

This spins up a server on localhost:8080 that mimics the production environment.

2

Connect via CLI

In another terminal, start an interactive voice session:

$smallestai agent-crew chat

The CLI connects to your local server and lets you converse with your agent in real-time.

CLI Chat

3

Iterate Rapidly

Make code changes, restart the server, and reconnect with chat. No redeploys needed.


Cloud Deployment

When you’re ready for production, deploy to Smallest AI’s managed infrastructure.

Prerequisite: You need an existing agent on the Atoms platformagent-crew init links your local code to it. Create one from the dashboard, or programmatically via the SDK:

1from smallestai import SmallestAI
2
3# Reads SMALLEST_API_KEY from the environment, or pass api_key="sk_..." explicitly.
4client = SmallestAI()
5response = client.atoms.agents.create_agent(name="my-test-agent")
6agent_id = response.data # the agent id is a string at .data
7print(agent_id)
1

Authenticate

$smallestai auth login

Prompts for your Smallest API key (paste it from app.smallest.ai/dashboard/api-keys). The key is stored at ~/.smallestai/credentials.json with 0600 permissions.

Already have SMALLEST_API_KEY exported? Pipe it in:

$echo $SMALLEST_API_KEY | smallestai auth login
3

Ship env vars in a .env (required)

Platform-side secrets injection isn’t built yet. The deploy zip does not carry your shell environment.

How .env works on the cloud: the zip ships every file in your dir except __pycache__/, .venv/, etc. — .env is not excluded. The cookbook’s assistant.py calls load_dotenv() at import time, so on the cloud it reads .env from the same directory. Keys defined locally end up available to os.getenv(...) in the cloud agent.

Create one next to server.py:

$cat > .env <<EOF
$OPENAI_API_KEY=$OPENAI_API_KEY
$SMALLEST_API_KEY=$SMALLEST_API_KEY
$EOF
4

Deploy

$smallestai agent-crew deploy --entry-point server.py

Packages your code and pushes it to the cloud. Takes about 30 seconds.

5

Go Live

A successful deploy is not live by default. Builds land in SUCCEEDED with isLive: null — your agent will not answer calls until you promote one.

$smallestai agent-crew builds

Select your build and choose Make Live to start serving traffic.

No TTY? The builds command needs an interactive terminal. Promote via REST:

$curl -X PATCH "https://api.smallest.ai/atoms/v1/sdk/agents/$AGENT_ID/builds/$BUILD_ID" \
> -H "Authorization: Bearer $SMALLEST_API_KEY" \
> -H "Content-Type: application/json" \
> -d '{"isLive": true}'

Command Reference

Authentication

CommandDescription
smallestai auth loginPrompts for your Smallest API key and stores it at ~/.smallestai/credentials.json. Accepts the key piped on stdin.
smallestai auth logoutClear stored credentials

Agent Management

CommandDescription
smallestai agent-crew initLink local directory to a platform agent
smallestai agent-crew deployDeploy code to the cloud
smallestai agent-crew buildsView and manage deployments
smallestai agent-crew chatStart interactive session with local agent

Common Options

OptionDescription
--entry-point <file>Specify the main Python file (default: server.py)
--helpShow help for any command

Build Management

Deployments are not live by default. This gives you a safety buffer.

One Live Build Per Agent: Making a new build live automatically takes down the previous one.

To promote a build:

  1. Run smallestai agent-crew builds
  2. Select the desired build
  3. Choose Make Live

To roll back:

  1. Run smallestai agent-crew builds
  2. Select the previous build
  3. Choose Make Live

To take down completely:

  1. Run smallestai agent-crew builds
  2. Select the LIVE build
  3. Choose Take Down

Running the CLI in CI / non-interactive environments

A few commands prompt you for input (an agent picker, a build picker, a password field). These only work in a real terminal. The table below shows which commands work non-interactively and how to substitute for the ones that don’t.

CommandWorks in CI?Notes
smallestai auth loginYesPipe the key on stdin: echo "$SMALLEST_API_KEY" | smallestai auth login.
smallestai agent-crew initNoOpens an interactive picker over your agents. In CI, write the config directly instead — see below.
smallestai agent-crew deployYesFully non-interactive. Reads agent_id from .smallestai/config.toml, the API key from stored credentials, prints a deploy summary, and exits non-zero on failure.
smallestai agent-crew buildsNoLists builds, then prompts you to pick one and choose Make Live / Take Down. For CI promotion or rollback, call the API directly — see below.
smallestai agent-crew chatNoInteractive WebSocket REPL against ws://localhost:8080/ws. For local development only.

Skipping init in CI

init exists to write .smallestai/config.toml with your agent ID. In CI you can write the same file yourself before running deploy:

$mkdir -p .smallestai
$cat > .smallestai/config.toml <<EOF
$agent_id = "$ATOMS_AGENT_ID"
$EOF

Promoting and rolling back builds in CI

builds calls the same endpoint for both Make Live and Take Down. You can call it directly:

$# Promote a build (Make Live)
$curl -X PATCH "https://api.smallest.ai/atoms/v1/sdk/agents/$ATOMS_AGENT_ID/builds/$BUILD_ID" \
> -H "Authorization: Bearer $SMALLEST_API_KEY" \
> -H "Content-Type: application/json" \
> -d '{"isLive": true}'
$
$# Roll back (Take Down)
$curl -X PATCH "https://api.smallest.ai/atoms/v1/sdk/agents/$ATOMS_AGENT_ID/builds/$BUILD_ID" \
> -H "Authorization: Bearer $SMALLEST_API_KEY" \
> -H "Content-Type: application/json" \
> -d '{"isLive": false}'

The build ID is printed by deploy on success, and is also available from GET /atoms/v1/sdk/agents/{agentId}/builds.

Only one build per agent can be live at a time. Setting isLive: true on a new build automatically takes down the previously-live one.


Error handling

When deployed code raises, the SDK auto-records the error on the call (in calllog.errors[], the Events tab, and webhooks) — you don’t need to wire anything up to get this. The deploy command also warns about env vars your code references before zip upload, and the pod’s /ready endpoint blocks traffic until your crew’s __init__ succeeds. See Error Handling for severity semantics, graceful-fallback patterns, and how to emit your own application-level errors.


More examples

The two crews above are the starting points. The Smallest AI cookbook ships ~15 ready-to-run voice-agent examples covering tool calling, call control, multi-language support, knowledge-base grounding, real banking / scheduling / IVR flows, observability, and more — each in its own directory with the same curl-and-run shape.

Need Help?