Back to Onyx

Onyx CLI

cli/README.md

4.0.0-cloud.27.5 KB
Original Source

Onyx CLI

A CLI for querying enterprise knowledge from Onyx. Includes an interactive chat TUI for humans and non-interactive commands for AI agents and scripts.

Installation

shell
pip install onyx-cli

Or with uv:

shell
uv pip install onyx-cli

Setup

Run the interactive chat TUI — on first launch it will guide you through setup:

shell
onyx-cli chat

This prompts for your Onyx server URL and personal access token (PAT), tests the connection, and saves config to ~/.config/onyx-cli/config.json (or $XDG_CONFIG_HOME/onyx-cli/config.json if set). To reconfigure later, use the /configure command inside the TUI.

Environment variables override config file values:

VariableRequiredDescription
ONYX_SERVER_URLNoServer URL (default: https://cloud.onyx.app)
ONYX_PATNoPersonal access token for authentication (required if no config file)
ONYX_PERSONA_IDNoDefault agent/persona ID
ONYX_STREAM_MARKDOWNNoEnable/disable progressive markdown rendering (true/false)
ONYX_SSH_HOST_KEYNoPath to SSH host key for serve command

Usage

Interactive chat

shell
onyx-cli chat
onyx-cli chat --no-stream-markdown
FlagDescription
--no-stream-markdownDisable progressive markdown rendering during streaming

One-shot question

shell
onyx-cli ask "What is our company's PTO policy?"
onyx-cli ask --agent-id 5 "Summarize this topic"
onyx-cli ask --json "Hello"
FlagDescription
--agent-id <int>Agent ID to use (overrides default)
--jsonOutput NDJSON stream events instead of plain text
--prompt <string>Question text (use with piped stdin context)
--quietBuffer output and print once at end
--max-output <int>Max bytes before truncating (0 to disable)

List agents

shell
onyx-cli agents
onyx-cli agents --json

Serve over SSH

shell
# Start a public SSH endpoint for the CLI TUI
onyx-cli serve --host 0.0.0.0 --port 2222

# Connect as a client
ssh your-host -p 2222

Clients can either:

  • paste a personal access token (PAT) at the login prompt, or
  • skip the prompt by sending ONYX_PAT over SSH:
shell
export ONYX_PAT=your-pat
ssh -o SendEnv=ONYX_PAT your-host -p 2222

Useful hardening flags:

  • --host-key (default ~/.config/onyx-cli/host_ed25519)
  • --idle-timeout (default 15m)
  • --max-session-timeout (default 8h)
  • --rate-limit-per-minute (default 20)
  • --rate-limit-burst (default 40)
  • --rate-limit-cache (default 4096)

Commands

CommandModeDescription
chatInteractiveLaunch the interactive chat TUI (requires terminal)
askAgent / ScriptAsk a question and print the answer to stdout
agentsAgent / ScriptList available agents (ID, name, description)
validate-configAgent / ScriptCheck CLI configuration and server connectivity
install-skillAgent / ScriptInstall the Onyx CLI agent skill file
experimentsAgent / ScriptList experimental features and their status
serveInteractiveServe the Onyx TUI over SSH

Global Flags

FlagDescription
--version, -vPrint client and server version information
--debugRun in debug mode (verbose logging)

Agent / Non-Interactive Use

When called without a TTY (e.g., by an AI agent or piped into another command), onyx-cli adjusts its behavior:

  • No subcommand: prints help and exits 0 (instead of launching the TUI)
  • Results to stdout, progress/errors to stderr
  • No ANSI codes or interactive prompts
  • ask output truncated to 50000 bytes by default; full response saved to a temp file. Use --max-output 0 to disable.

Configuration

If a human has already run onyx-cli chat (which includes first-time setup), the CLI works out of the box — no additional setup needed. Environment variables can override the config file or serve as an alternative when no config file exists:

shell
export ONYX_SERVER_URL="https://your-onyx-server.com"
export ONYX_PAT="your-pat"

Exit Codes

CodeNameWhen
0SuccessCommand completed
1GeneralUnknown error
2BadRequestInvalid arguments
3NotConfiguredMissing config/PAT
4AuthFailureInvalid PAT (401/403)
5UnreachableServer unreachable
6RateLimitedServer returned 429
7TimeoutRequest timed out
8ServerErrorServer returned 5xx
9NotAvailableFeature/endpoint doesn't exist

Skill File

Install the bundled SKILL.md so AI coding agents can discover the CLI:

shell
onyx-cli install-skill
onyx-cli install-skill --global
onyx-cli install-skill --copy
onyx-cli install-skill --agent claude-code
FlagDescription
--global, -gInstall to home directory instead of project
--copyCopy files instead of symlinking
--agent, -aTarget specific agents (e.g. claude-code; can be repeated)

Slash Commands (in TUI)

CommandDescription
/helpShow help message
/clearClear chat and start a new session
/agentList and switch agents
/attach <path>Attach a file to next message
/sessionsList recent chat sessions
/configureRe-run connection setup
/connectorsOpen connectors in browser
/settingsOpen settings in browser
/quitExit Onyx CLI

Keyboard Shortcuts

KeyAction
EnterSend message
EscapeCancel current generation
Ctrl+OToggle source citations
Ctrl+DQuit (press twice)
Scroll / Shift+Up/DownScroll chat history
Page Up / Page DownScroll half page

Building from Source

Requires Go 1.24+.

shell
cd cli
go build -o onyx-cli .

Development

shell
# Run tests
go test ./...

# Build
go build -o onyx-cli .

# Lint
golangci-lint run ./...

Publishing to PyPI

The CLI is distributed as a Python package via PyPI. The build system uses hatchling with manygo to cross-compile Go binaries into platform-specific wheels.

Tag a release and push — the release-cli.yml workflow builds wheels for all platforms and publishes to PyPI automatically:

shell
tag --prefix cli

To do this manually:

shell
git tag cli/v0.1.0
git push origin cli/v0.1.0

The workflow builds wheels for: linux/amd64, linux/arm64, darwin/amd64, darwin/arm64, windows/amd64, windows/arm64.

Manual release

Build a wheel locally with uv. Set GOOS and GOARCH to cross-compile for other platforms (Go handles this natively — no cross-compiler needed):

shell
# Build for current platform
uv build --wheel

# Cross-compile for a different platform
GOOS=linux GOARCH=amd64 uv build --wheel

# Upload to PyPI
uv publish

Versioning

Versions are derived from git tags with the cli/ prefix (e.g. cli/v0.1.0). The tag is parsed by internal/_version.py and injected into the Go binary via -ldflags at build time.