Install
The agentswap CLI is a published Rust crate (cargo install agentswap, version
0.2.0 on crates.io). It is a client for the AgentSwap quote service and a signer
for User Proxy agent orders. It is not part of either on-chain protocol — the
Intent Settler and the User Proxy have their own documentation on this site.
Source and licence: agentswapco/agentswap-cli, MIT.
Install
Section titled “Install”cargo install agentswapagentswap --versionThe binary name is agentswap. Run agentswap --help for the full flag list.
Service endpoint
Section titled “Service endpoint”By default the CLI talks to https://api.agentswap.co. Override with a flag or
environment variable:
| Setting | Flag | Environment variable | Default |
|---|---|---|---|
| Service URL | --url |
AGENTSWAP_URL |
https://api.agentswap.co |
# Point one invocation at a different serviceagentswap --url http://localhost:8080 health
# Or for the whole shellexport AGENTSWAP_URL=http://localhost:8080agentswap healthAn override is only useful against a service you run yourself; the default is the one to use.
A quick connectivity check:
agentswap healthAPI key credentials
Section titled “API key credentials”Authenticated commands need an API key. Supply it on each invocation, or register once and let the CLI cache it.
| Setting | Flag | Environment variable | Default |
|---|---|---|---|
| API key | -k, --key |
SR_API_KEY |
cached key (see below) |
| Raw JSON output | -j, --json |
— | off (formatted tables) |
Cached key. After register succeeds, the CLI writes the key to
$HOME/.agentswap/credentials (mode 0600 on Unix). Later commands read that
file automatically. Whitespace is trimmed; an empty file is ignored. If HOME is
unset, there is no credentials path and you must pass -k or SR_API_KEY every
time.
# Use an explicit key for one commandagentswap -k "$SR_API_KEY" key-info
# Or rely on the cached file after registeragentswap key-infoRegister and the private key
Section titled “Register and the private key”register proves wallet control with a signature and stores the returned API
key. It accepts --private-key inline or --key-file:
agentswap register --address 0xYourWallet --key-file ./signer-key.txtUse --key-file. A private key passed on the command line is recorded in
shell history and visible in process listings (ps). A file with restrictive
permissions avoids both.
--key-file is also available as a global flag (AGENTSWAP_KEY_FILE) for
trade and the MCP server — see Trade.
Global flags
Section titled “Global flags”These apply to every subcommand.
Output and service
Section titled “Output and service”| Flag | Env | Purpose |
|---|---|---|
-j, --json |
— | Emit raw JSON instead of tables |
--url |
AGENTSWAP_URL |
Quote service base URL |
-k, --key |
SR_API_KEY |
API key override |
--key-file |
AGENTSWAP_KEY_FILE |
Local signer key file (trade / MCP) |
Trade safety rails
Section titled “Trade safety rails”| Flag | Env | Purpose |
|---|---|---|
--allow-trade |
— | Opt in to signing and relay; without it, trade is forced to dry-run |
--max-amount |
AGENTSWAP_TRADE_MAX_AMOUNT |
Per-trade cap on amountIn in raw token units; refuses to sign or relay above it |
Both flags are global so they also bound trades invoked through agentswap mcp.
Details are on Trade.
Relay gateway
Section titled “Relay gateway”| Flag | Env | Purpose |
|---|---|---|
--gateway-url |
AGENTSWAP_GATEWAY_URL |
Gateway URL when trade --relay submits through a relay |
x402 paid retry
Section titled “x402 paid retry”When the service answers a request with HTTP 402 Payment Required, the CLI signs an EIP-3009 payment and retries that request. That status is the whole trigger — the CLI does not inspect why the service asked. The knobs are below; what the payment buys is the service’s business, not the CLI’s.
| Flag | Env | Default | Purpose |
|---|---|---|---|
--x402 |
AGENTSWAP_X402 |
off | Enable the x402 paid-retry flow |
--prefer-x402 |
— | off | Prefer x402 even when an API key is configured |
--x402-key-file |
AGENTSWAP_X402_KEY_FILE |
none | Key file for x402 EIP-3009 signatures |
--x402-chain |
AGENTSWAP_X402_CHAIN |
8453 |
Chain ID for x402 payments |
--x402-max-amount |
AGENTSWAP_X402_MAX_AMOUNT |
0 |
Maximum x402 payment in raw token units |
--x402-asset |
AGENTSWAP_X402_ASSET |
USDC |
Asset symbol or address selector |
export AGENTSWAP_X402=1export AGENTSWAP_X402_KEY_FILE=./x402-signer.txtagentswap quote --chain base --from USDC --to WETH --amount 1000000