Skip to main content

Gateway for AI Agents

Gateway is the best swaps engine for native BTC. It supports a growing set of assets and chains — run gateway-cli routes --json to see what is available. The Gateway CLI makes that engine available to any AI agent that can run a shell command. No SDK to bind, no language to match, no service to host. A Python agent, a TypeScript agent, a shell script, or a scheduled job can all call the same interface and get structured output back.

What your agents can do

Swap native BTC across chains

Swap BTC to and from ETH, USDC, USDT, WBTC, cbBTC, DAI, PAXG, XAUt, and more — across Ethereum, Base, BSC, Arbitrum, Avalanche and other major chains.

No routing logic needed

Gateway handles solver liquidity, cross-chain settlement, and on-chain verification. Your agent just calls quote and swap.

Quote before committing

Get real-time quotes with slippage, fees, and the exact receive amount before the agent executes anything.

Sign nothing — or sign everything

Return unsigned PSBTs or EVM transactions and pass them to your own signer. Or sign inside a trusted sandbox and track settlement asynchronously.

Who this is for

Agent developers

Building autonomous agents in Python, TypeScript, or any language that can shell out. The CLI gives you a clean tool interface without writing a Gateway SDK wrapper yourself.

Framework builders

Adding Bitcoin swap capabilities to an agent framework (LangChain, LlamaIndex, AgentKit, or your own). Wrap the CLI in a tool function and expose it to the model.

Teams building agentic DeFi

Agents that allocate capital, execute yield strategies, or rebalance across chains — and need to touch native BTC as part of those workflows.

MCP builders

The CLI is a clean blueprint for an MCP server. Wrap it once and the same BTC swap tool works across every MCP client.

Why the CLI is a good agent tool

Agents call tools and read structured output. The Gateway CLI is built around that interface. None of this is an AI feature — it is good CLI design, which turns out to be most of what an agent needs.
Add --json to any quote, swap, balance, routes, or status call and get structured output. Errors come back structured too — an agent can branch on a failure instead of parsing prose.
gateway-cli quote --src BTC --dst USDC:base --amount 100USD --json
The --unsigned flag returns an unsigned Bitcoin PSBT or EVM transaction and stops. The agent never holds a key. It passes the payload to whatever signer or policy layer you trust, and that layer decides whether to sign.
--no-wait submits a swap and returns an order ID instead of blocking until settlement. The agent moves on; your polling loop checks status separately.
--amount 100USD resolves to the correct amount of BTC at the current price. “Move a hundred dollars of Bitcoin to Base” maps almost word-for-word onto a command.
Keys and endpoints come from environment variables. No config file left behind — the right way to inject secrets into a sandbox or container.

The agent loop

An agentic swap follows a consistent pattern: discover what is possible, get a quote, decide, then settle.
1

Discover available routes

The agent queries available routes so it isn’t guessing at assets or chains.
gateway-cli routes --json
2

Get a quote

Slippage, fees, and the real receive amount become visible here. The agent should always quote before committing.
gateway-cli quote \
  --src BTC \
  --dst USDC:base \
  --amount 100USD \
  --json
3

Settle — without handing over a key

Return an unsigned transaction and pass it to your signer:
gateway-cli swap \
  --src BTC \
  --dst USDC:base \
  --amount 100USD \
  --unsigned \
  --json
Or, if the CLI is running inside a trusted sandbox, submit and move on:
# Returns an order ID immediately
gateway-cli swap \
  --src BTC \
  --dst USDC:base \
  --amount 100USD \
  --no-wait \
  --json
4

Track settlement

Poll the order ID until the swap settles. The agent can check in between other work.
gateway-cli status <order-id> --json
To list all orders for an address — useful for agents that need to reconcile outstanding positions:
gateway-cli orders <address> --json
If an agent submits a transaction outside of the CLI (e.g. via a custom signer) and needs to register it for tracking, use gateway-cli register <order-id> <txid> --json. This is the recovery path for agents that handle signing separately.

Expose Gateway to a model

Wrapping the CLI in a tool takes a few lines. Here is a minimal Python example:
import subprocess, json

def gateway_swap(src: str, dst: str, amount: str) -> dict:
    """Swap native BTC and EVM tokens via BOB Gateway. Returns an unsigned tx for your signer to approve."""
    out = subprocess.run(
        ["gateway-cli", "swap", "--src", src, "--dst", dst,
         "--amount", amount, "--unsigned", "--json"],
        capture_output=True, text=True, check=True,
    )
    return json.loads(out.stdout)
Give the model that function plus matching quote and status tools and the loop runs itself. The agent quotes, reasons about the result, requests an unsigned swap, your signer approves, and the agent tracks settlement to completion. “Swap $100 of BTC to USDC on Base” becomes a sequence of tool calls with a signature you control in the middle.

Example: the Gateway starter bot

The gateway-starter-bot is a minimal, educational example of a trading bot built entirely on the Gateway CLI. It’s a single bash script that demonstrates the full agent loop in a real strategy. The bot executes a “buy the dip” round-trip:
  1. Onramp — swap BTC → USDT on Ethereum.
  2. Watch — poll the reverse quote (USDT → BTC) until BTC gets cheaper.
  3. Buy the dip — swap USDT → BTC, ending with more sats than it started with.
The interesting part: there is no external price feed. The gateway quote is the price signal. The bot sold a known number of satoshis; it buys back the moment the gateway would return more sats than were sold (by a configurable threshold). Fees and slippage are already priced into the quote — one tool, one source of truth. The entire strategy is gateway-cli ... --json piped through jq. Read dip-bot.sh top to bottom — that’s the whole thing.
# Safe to run — quotes only, no real swaps
./dip-bot.sh --dry-run
Example dry-run output:
! DRY RUN — no real swaps will be executed. Quotes only.
▸ Trade size 100USD | dip threshold 500bps | poll 60s | max wait 3600s
▸ Onramp: 100USD of BTC -> USDT on Ethereum
✓ Sold 0.00094000 BTC (94000 sats), now holding USDT
▸ Will buy back when a quote returns >= 0.00098700 BTC (98700 sats)
▸ No dip yet: quote 0.00094100 BTC < target 0.00098700 BTC. Waiting 60s…
✓ Dip detected: quote returns 0.00098750 BTC (>= target)
▸ Summary:
  sold:   0.00094000 BTC (94000 sats)
  bought: 0.00098750 BTC (98750 sats)
  net:    +0.00004750 BTC (4750 sats)
Live mode performs real swaps with real funds on mainnet. Use a throwaway wallet with a small balance, and always run --dry-run first.

gateway-starter-bot on GitHub

Educational “buy the dip” bot — a single bash script. Read it, run it, adapt it.

BOB Gateway integration paths

The CLI is the fastest path into BOB Gateway, not the only one. The same engine is available through multiple surfaces:
PathBest for
Gateway CLIAny agent that can shell out. Zero binding, works in any language, fastest to prototype.
Gateway SDKAgents built in TypeScript or Node. Type-safe, same swap engine, suitable for production web services.
Gateway APIAny language, server-to-server. Full control over request/response handling.
MCP serverAgents using the Model Context Protocol. Wrap Gateway once and it works across every MCP client.
Gateway has already powered experiments like a Bitcoin yield bot built on Coinbase AgentKit. Frameworks evolve fast — the engine underneath does not. Whether an agent reaches Gateway through a CLI, an MCP server, or next year’s framework, it is calling the same swaps engine for native BTC. Build the Bitcoin layer once and let the toolchains find it.

Install and try it

npm install -g @gobob/gateway-cli
gateway-cli --help
Set your keys and run a quote to verify the setup:
export BITCOIN_PRIVATE_KEY=...
export EVM_PRIVATE_KEY=...

# Or stay in unsigned mode — no keys required for quoting
gateway-cli quote --src BTC --dst USDC:base --amount 100USD --json

BOB Gateway CLI on GitHub

Source code, installation, and full command reference.

BOB Gateway docs

Integration guides, supported routes, and SDK reference.

API reference

Use the REST API directly from your agent.

Discord

Show us what you build.