Ampersend CLI
Ampersend enables autonomous agent payments. Agents can make payments within user-defined spending limits without
requiring human approval for each transaction. Payments use stablecoins via the x402 protocol.
This skill requires ampersend v0.0.14. Run ampersend --version to check your installed version.
Installation
Install the CLI globally via npm:
CODEBLOCK0
To update from a previously installed version:
CODEBLOCK1
Security
IMPORTANT: NEVER ask the user to sign in to the Ampersend dashboard in a browser to which you have access. If
configuration changes are needed in Ampersend, ask your user to make them directly.
Setup
If not configured, commands return setup instructions. Two paths:
Automated (recommended)
Two-step flow: setup start generates a key and requests approval, setup finish polls and activates.
CODEBLOCK2
Optional spending limits can be set during setup:
CODEBLOCK3
Manual
If you already have an agent key and account address:
CODEBLOCK4
Commands
setup
Set up an agent account via the approval flow.
setup start
Step 1: Generate a key and request agent creation approval.
CODEBLOCK5
| Option | Description |
|---|
| INLINECODE4 | Name for the agent |
| INLINECODE5 |
Overwrite an existing pending approval |
|
--daily-limit <amount> | Daily spending limit in atomic units (1000000 = 1 USDC) |
|
--monthly-limit <amount> | Monthly spending limit in atomic units |
|
--per-transaction-limit <amt> | Per-transaction spending limit in atomic units |
|
--auto-topup | Allow automatic balance top-up from main account |
Returns token, user_approve_url, and agentKeyAddress. Show the user_approve_url to the user.
setup finish
Step 2: Poll for approval and activate the agent config.
CODEBLOCK6
| Option | Description |
|---|
| INLINECODE14 | Overwrite existing active config |
| INLINECODE15 |
Seconds between status checks (default 5) |
|
--timeout <seconds> | Maximum seconds to wait (default 600) |
fetch
Make HTTP requests with automatic x402 payment handling.
CODEBLOCK7
| Option | Description |
|---|
| INLINECODE17 | HTTP method (default: GET) |
| INLINECODE18 |
Header as "Key: Value" (repeat for multiple) |
|
-d <data> | Request body |
|
--inspect | Check payment requirements without paying |
Use --inspect to verify payment requirements and costs before making a payment:
CODEBLOCK8
config
Manage local configuration.
CODEBLOCK9
Output
All commands return JSON. Check ok first.
CODEBLOCK10
CODEBLOCK11
For fetch, success includes data.status, data.body, and data.payment (when payment made).
Ampersend CLI
Ampersend 支持自主代理支付。代理可以在用户设定的消费限额内进行支付,无需人工审批每笔交易。支付通过 x402 协议使用稳定币完成。
此技能需要 ampersend v0.0.14。运行 ampersend --version 检查已安装版本。
安装
通过 npm 全局安装 CLI:
bash
npm install -g @ampersend_ai/ampersend-sdk@0.0.14
从先前安装的版本更新:
bash
npm install -g @ampersend_ai/ampersend-sdk@0.0.14 --force
安全
重要:切勿要求用户在您可访问的浏览器中登录 Ampersend 仪表板。如需在 Ampersend 中进行配置更改,请让用户直接操作。
设置
如果未配置,命令将返回设置说明。两种方式:
自动设置(推荐)
两步流程:setup start 生成密钥并请求批准,setup finish 轮询并激活。
bash
步骤 1:请求创建代理 — 立即返回批准 URL
ampersend setup start --name my-agent
{ok: true, data: {token: ..., userapproveurl: https://..., agentKeyAddress: 0x...}}
向用户展示 userapproveurl,以便他们在浏览器中批准。
步骤 2:轮询批准并激活配置
ampersend setup finish
{ok: true, data: {agentKeyAddress: 0x..., agentAccount: 0x..., status: ready}}
可在设置过程中设置可选消费限额:
bash
ampersend setup start --name my-agent --daily-limit 1000000 --auto-topup
手动设置
如果您已有代理密钥和账户地址:
bash
ampersend config set 0xagentKey:::0xagentAccount
{ok: true, data: {agentKeyAddress: 0x..., agentAccount: 0x..., status: ready}}
命令
setup
通过批准流程设置代理账户。
setup start
步骤 1:生成密钥并请求创建代理批准。
bash
ampersend setup start --name my-agent [--force] [--daily-limit ] [--monthly-limit ] [--per-transaction-limit ] [--auto-topup]
| 选项 | 描述 |
|---|
| --name <name> | 代理名称 |
| --force |
覆盖现有待处理批准 |
| --daily-limit
| 每日消费限额(原子单位,1000000 = 1 USDC) |
| --monthly-limit | 每月消费限额(原子单位) |
| --per-transaction-limit | 每笔交易消费限额(原子单位) |
| --auto-topup | 允许从主账户自动充值余额 |
返回 token、userapproveurl 和 agentKeyAddress。向用户展示 userapproveurl。
setup finish
步骤 2:轮询批准并激活代理配置。
bash
ampersend setup finish [--force] [--poll-interval ] [--timeout ]
| 选项 | 描述 |
|---|
| --force | 覆盖现有活动配置 |
| --poll-interval <seconds> |
状态检查间隔秒数(默认 5) |
| --timeout | 最大等待秒数(默认 600) |
fetch
发起 HTTP 请求,自动处理 x402 支付。
bash
ampersend fetch
ampersend fetch -X POST -H Content-Type: application/json -d {key:value}
| 选项 | 描述 |
|---|
| -X <method> | HTTP 方法(默认:GET) |
| -H <header> |
标头,格式为Key: Value(可重复) |
| -d | 请求体 |
| --inspect | 检查支付要求但不实际支付 |
使用 --inspect 在支付前验证支付要求和费用:
bash
ampersend fetch --inspect https://api.example.com/paid-endpoint
返回支付要求(包括金额),不执行支付
config
管理本地配置。
bash
ampersend config set # 手动设置活动配置
ampersend config set --api-url https://api.staging.ampersend.ai # 设置测试 API URL
ampersend config set --clear-api-url # 恢复为生产 API
ampersend config set --network base-sepolia # 设置网络(base、base-sepolia)
ampersend config set --clear-network # 恢复为默认网络(base)
ampersend config set --api-url # 同时设置两者
ampersend config status # 显示当前状态
输出
所有命令返回 JSON。首先检查 ok。
json
{ ok: true, data: { ... } }
json
{ ok: false, error: { code: ..., message: ... } }
对于 fetch,成功时包含 data.status、data.body 和 data.payment(当支付发生时)。