0x CLI
0x CLI is now available, allowing you or your agent to swap and bridge tokens from your terminal.
June 25, 2026
Feature Release
.png)
The 0x CLI is now available, allowing you to swap and bridge tokens from your terminal. The CLI (command line interface) grants you Access Swap, Gasless, Cross-Chain, and Solana APIs through one command-line tool packaged as a single binary, 0x, built for both human traders and AI agents.
Using 0x APIs to trade previously meant wiring up price calls, quotes, approvals, signing, and status polling yourself, per chain and per API. 0x CLI collapses that into one command surface, with transaction simulation before every execution and wallets managed through OS-keyring.
How to use 0x CLI
Install the latest release for macOS or Linux, then run the one-time setup:
# Install (macOS/Linux, x86_64 and arm64). Downloads the binary, verifies its SHA-256, drops it in ~/.local/bin
curl -fsSL <https://raw.githubusercontent.com/0xProject/0x-cli/main/scripts/install.sh> | sh
# Interactive setup: API key, default chain, wallet
0x config initA 0x API key is required unless using the --pay flag (see Pay per request below). Price commands need only the key, while swaps also need a wallet. Wallet secrets live in the OS keyring by default, never on disk in plaintext. Amounts are in base units, and tokens are passed as contract addresses (EVM) or base58 mint addresses (Solana), not ticker symbols.
# Indicative price, read-only, no wallet needed. USDC -> WETH on Base
0x price --chain base \
--sell 0x833589fCD6eDb6E08f4c7C32D4f71b54bdA02913 \
--buy 0x4200000000000000000000000000000000000006 \
--amount 1000000
# Execute a swap
0x swap --chain base \
--sell 0x833589fCD6eDb6E08f4c7C32D4f71b54bdA02913 \
--buy 0x4200000000000000000000000000000000000006 \
--amount 1000000
# Bridge USDC from Base to Arbitrum in one command
0x cross-chain --from base --to arbitrum \
--sell 0x833589fCD6eDb6E08f4c7C32D4f71b54bdA02913 \
--buy 0xaf88d065e77c8cC2239327C5EDb3A432268e5831 \
--amount 1000000The full command set is documented in 0x docs. The CLI is also built for agents, bundling the 0x-trade agent skill into the binary, so it stays in sync with the installed version. This is distinct from the 0x-api skill, which teaches an agent to write code against the 0x REST APIs; 0x-trade teaches it to use the CLI as a tool.
Pay per request (no API key needed)
For autonomous agent payments, price and swap can pay roughly $0.01 in USDC per request through the 0x agent gateway instead of using an API key. Add --pay:
# x402 over Base. The EVM wallet signs an EIP-3009 USDC authorization (no gas)
0x price --chain base \
--sell 0x833589fCD6eDb6E08f4c7C32D4f71b54bdA02913 \
--buy 0x4200000000000000000000000000000000000006 \
--amount 1000000 --pay x402-evm --max-payment 0.05 -o json-envelope-pay x402-evm settles over x402 on Base (needs USDC on Base); -pay mpp settles over MPP on Tempo, chainId 4217 (needs USDC.e plus native gas). Settlement (tx hash, payer, amount) is reported under metadata.payment. This is the same gateway behind the broader Autonomous Agent Payments launch.
Tips before you start
- The CLI is in beta; commands, flags, and output formats may change between releases, so pin a version for production workflows.
- Token addresses are chain-specific. USDC on Base and USDC on Ethereum are different contracts.
-paycharges real, non-refundable money per request, even if a later swap reverts;swap --paycovers only the quote, while the swap still uses your wallet and RPC.-payis EVM AllowanceHolder only and is rejected, with no spend, on-gasless, Solana/Tron, or exact-out.-max-payment(default0.05) caps it; the CLI refuses before signing if the gateway asks for more (exit 41, nothing spent).- Telemetry is anonymous and opt-out (command, exit code, chain, duration only; never addresses, amounts, keys, or RPC URLs). Disable with
0x config set telemetry.enabled falseorDO_NOT_TRACK=1.
Use cases for 0x CLI
Terminal trading: A trader can bridge USDC from Base to Arbitrum with a single 0x cross-chain command, reviewing the quote and confirmation prompt before signing.
Coding agent as operator: An AI coding agent runs 0x skill install, then drives the binary with --yes -o json-envelope, matching on exit codes to retry, poll, or stop without human prompting.
Keyless autonomous agent: A background agent calls 0x swap --pay x402-evm from a pre-funded Base wallet, paying per request with no API key to manage or rotate.
CI price checks: A script runs 0x price and 0x swap --dry-run to validate routing and simulate execution in a pipeline, signing nothing.
See the 0x CLI guide for the full API reference & examples. Start building for free by signing up for a 0x account.
Contents
Subscribe to newsletter