Skip to content

CLI

The Sleepwalker CLI is a command-line client for the Sleepwalker API.

Use it when you want the same actions available in the Console, MCP, and API from a terminal, script, or CI job. The CLI does not run analysis locally. It sends requests to Sleepwalker, polls when needed, and saves persisted results back to the Console.

Install globally:

Terminal window
npm install -g @sleepwalkerai/cli
sleepwalker init

Or run one command without installing:

Terminal window
npx @sleepwalkerai/cli doctor

The public package is:

@sleepwalkerai/cli

The CLI uses Sleepwalker API keys. Create a key in the Sleepwalker Console, then choose one of two setup paths.

For CI jobs or short-lived shells:

Terminal window
export SLEEPWALKER_API_KEY=sw_api_live_...
sleepwalker doctor

For a local machine:

Terminal window
sleepwalker auth key set sw_api_live_...
sleepwalker doctor

The stored key is written to your local Sleepwalker config file. It is masked in CLI output and should never be committed.

Show current configuration:

Terminal window
sleepwalker config show

Use a different API base URL:

Terminal window
sleepwalker config set api-base-url https://api.sleepwalker.ai

Clear the override:

Terminal window
sleepwalker config clear api-base-url

Environment variables:

VariablePurpose
SLEEPWALKER_API_KEYAPI key for authenticated requests.
SLEEPWALKER_API_BASE_URLAPI base URL. Defaults to https://api.sleepwalker.ai.
SLEEPWALKER_CONFIG_DIROverride local config directory. Useful for tests and isolated environments.
NO_COLORDisable ANSI color.
FORCE_COLORForce ANSI color in non-interactive terminals.

For the guided setup checklist:

Terminal window
sleepwalker init

For an interactive command picker after authentication:

Terminal window
sleepwalker menu

Run:

Terminal window
sleepwalker doctor

doctor checks:

  • API key source;
  • API base URL;
  • authenticated access to the Sleepwalker API;
  • available and used credits when the API can be reached.

Use JSON output in automation:

Terminal window
sleepwalker doctor --json

Read commands do not consume credits.

Terminal window
sleepwalker credits
sleepwalker usage
sleepwalker activity list --limit 10
sleepwalker tests list --type ai_citations
sleepwalker reports by-url https://example.com

Useful patterns:

Terminal window
sleepwalker reports by-url https://example.com --type content_intelligence --days 30
sleepwalker activity list --kind all --limit 20 --json

Use page serialization when a script or agent needs Sleepwalker’s normalized content view for a URL.

Terminal window
sleepwalker page serialize https://example.com

Limit response size:

Terminal window
sleepwalker page serialize https://example.com --max-chars 4000 --offset 0

Suggest prompts:

Terminal window
sleepwalker visibility suggest-prompts https://example.com --brand Example

Create a run:

Terminal window
sleepwalker visibility run https://example.com \
--brand Example \
--prompt "What are the best options for this problem?" \
--platform perplexity \
--platform openai \
--watch

For retryable scripts, provide your own idempotency key:

Terminal window
sleepwalker visibility run https://example.com \
--brand Example \
--prompt "How is Example described?" \
--platform perplexity \
--idempotency-key visibility-example-001

Use a prompt file:

Terminal window
sleepwalker visibility run https://example.com \
--brand Example \
--prompt-file prompts.txt \
--platform perplexity,openai,grok,gemini

Check status later:

Terminal window
sleepwalker visibility status <run_id> --results

List recent runs:

Terminal window
sleepwalker visibility list --limit 20

Run a direct score:

Terminal window
sleepwalker ci score https://example.com

Create a persisted Content Intelligence run:

Terminal window
sleepwalker ci run https://example.com --depth full --watch

For retryable scripts:

Terminal window
sleepwalker ci run https://example.com \
--depth full \
--idempotency-key ci-example-homepage-001

Check status later:

Terminal window
sleepwalker ci status <run_id> --result

List recent runs:

Terminal window
sleepwalker ci list --limit 20

--watch polls until the run reaches a terminal state.

By default, watch mode stops after 15 minutes. Override it:

Terminal window
sleepwalker visibility run https://example.com \
--brand Example \
--prompt "How is Example described?" \
--platform perplexity \
--watch \
--max-wait-seconds 1800

If the wait limit is reached, the CLI exits non-zero and tells you which status command to run later. With --json, the timeout response remains machine readable.

Add --json when another tool should parse the response:

Terminal window
sleepwalker ci run https://example.com --depth full --json

Human output is optimized for terminal reading. JSON output returns the raw API response.

The CLI uses the public API. That means:

  • read commands are unmetered;
  • billable actions use the same credit rules as API, MCP, and Console actions;
  • blocked or failed non-billable work follows the same release behavior as the API;
  • persisted AI Visibility and Content Intelligence runs appear in the Console.

The CLI source lives in the public Sleepwalker developer repository alongside API and MCP examples:

github.com/followanton/sleepwalker

That repository contains client code and examples only. The hosted engine, provider integrations, billing systems, database schema, and deployment operations remain private.