0x CLI
The 0x CLI is a single binary, 0x, that wraps the 0x APIs — indicative prices, on-chain swaps, gasless swaps, cross-chain bridging, and status polling — behind one command-line tool.
It works two ways:
- For you, it’s a fast, safe way to trade from the terminal: colored quote tables, confirmation prompts, transaction simulation before every execution, and OS-keyring storage for wallet secrets.
- For your AI agent, every command is non-interactive-safe and emits a machine-readable JSON envelope with stable exit codes, structured error codes, and inline response schemas in every
--help. It also bundles its own0x-tradeagent skill so a coding agent knows exactly how to drive the CLI.
The CLI calls the 0x APIs, so a 0x API key is required. Price commands need only the key, on-chain swaps additionally need a wallet (an EVM private key and/or a Solana keypair).
Install
Prebuilt binary (recommended)
From source
One command installs the latest release for macOS or Linux (x86_64 and arm64). It downloads the binary from GitHub Releases, verifies its SHA-256 checksum, and drops it in ~/.local/bin:
Pin a version or change the install directory:
On Windows, download the x86_64-pc-windows-msvc .zip from the latest release and put 0x.exe on your PATH.
Verify the install:
Configure
Run the interactive setup once, or set values manually:
Interactive
Manual
Environment variables
Guides you through your API key, default chain, and wallet.
Wallet secrets are stored in the OS keyring (macOS Keychain, Linux libsecret, Windows Credential Locker) by default and are never written to disk in plaintext. You can opt out with --plaintext (or the ZEROX_* env vars) when a keyring isn’t available.
Quick start
Amounts are in base units: USDC (6 decimals) 1000000 = 1 USDC, ETH (18) 1000000000000000000 = 1 ETH, SOL (9) 1000000000 = 1 SOL.
Tokens must be passed as contract addresses (EVM) or base58 mint addresses (Solana) — ticker symbols like USDC are not accepted. Addresses are chain-specific; USDC on Base and USDC on Ethereum are different contracts.
What it can do
Run any command with --help to see its flags and a RESPONSE: block documenting the JSON it returns.
Built for AI agents
The CLI is designed as a first-class tool for AI agents and scripts. Everything an agent needs to drive it reliably is stable and documented.
A consistent JSON envelope
When stdout is not a TTY, output switches to a JSON envelope automatically. Inside an agent loop, pass -o json-envelope explicitly for stability:
On failure, the envelope carries a stable, actionable error:
Stable exit codes
Agents should match on exit_code first, then error.code. A few of the most useful:
Non-interactive by design
Every interactive prompt has a flag equivalent, so an agent never gets stuck:
Bundled agent skill
The CLI ships with its own 0x-trade agent skill (source) compiled into the binary, so it’s always in sync with the installed version. Drop it into your agent’s skills directory with one command:
The skill teaches the agent the command contract — base-unit amounts, the --yes -o json-envelope pattern, exit-code handling, dry-run discipline — plus deep-dive references for gasless, cross-chain, Solana, config, tokens, and errors.
This is a different skill from the 0x-api Agent Skill. The 0x-api skill teaches an agent to write code against the 0x REST APIs; the bundled 0x-trade skill teaches it to drive this CLI. They’re complementary — use 0x-api when embedding swaps in your own app, 0x-trade when an agent runs the 0x binary as a tool.
Telemetry
The CLI sends anonymous, opt-out usage statistics (command name, exit code, chain, duration) to help prioritize chains and surface common errors. It never sends token addresses, amounts, transaction hashes, wallet addresses, API keys, or RPC URLs. Opt out any time:
Next steps
The complementary 0x-api skill — teaches an agent to write code against the 0x REST APIs.
Live, searchable access to 0x documentation inside your AI tools.
Every EVM chain and Solana the CLI can trade on.
Sign up free at the 0x Dashboard.