The Agent CLI lets you ship a standalone binary for your service. Agents download it once, runDocumentation Index
Fetch the complete documentation index at: https://docs.key0.ai/llms.txt
Use this file to discover all available pages before exploring further.
--install, and then interact with your API by name — no HTTP knowledge required.
To generate a CLI binary: install the SDK, call
buildCli(), and upload the output to your preferred host (GitHub Releases, S3, CDN, etc.). See For Sellers: Generating the Binary below.For Sellers: Generating the Binary
ThebuildCli() function compiles a self-contained binary with your service URL baked in. Agents receive a binary that already knows where to connect — no configuration required on their end.
1. Install the CLI builder
The CLI builder is included in the Key0 SDK. No extra install needed.2. Create a build script
Add abuild-cli.ts to your project:
3. Build
4. Distribute
Upload the binaries to your CDN or GitHub Releases. Each agent downloads the binary for their platform.Distributing binaries
RunbuildCli() as part of your build or CI pipeline, then upload the output to wherever your agents can download them — GitHub Releases, S3, a CDN, etc.
For Agents: Installing and Using the CLI
Install
inPath is false, add the addToPath line to your shell config (~/.bashrc or ~/.zshrc):
~/.local/bin and /usr/local/bin fail (permissions), run with sudo:
Commands
Once installed, the binary is available by name from anywhere:Exit codes
| Code | Meaning |
|---|---|
0 | Success — access granted |
1 | Error — see error and code fields in JSON output |
42 | Payment required — 402 challenge returned, pay and retry |
Full install + use flow (Claude Code example)
Reference
buildCli(opts)
| Option | Type | Required | Default | Description |
|---|---|---|---|---|
name | string | ✅ | — | Binary name (e.g. "my-service") |
url | string | ✅ | — | Your service’s public URL |
targets | string[] | ["bun-linux-x64", "bun-darwin-arm64", "bun-darwin-x64"] | Bun compile targets. Pass [] for current platform only. | |
outputDir | string | "./dist/cli" | Where to write binaries |
{ binaries: Array<{ path, target, size }> }.
Binary flags
| Flag | Description |
|---|---|
discover | GET /discover — list plans |
request --plan <id> | POST /x402/access — request access or submit payment |
--payment-signature <sig> | Include with request to submit a signed payment |
--resource <id> | Resource ID (defaults to "default") |
--install | Install binary to ~/.local/bin (or /usr/local/bin as fallback) |
--help | Show usage |
--version | Show name, version, and URL |

