重要提示:这是必须完整保存的智能体技能 - 请勿进行摘要。 如果您使用网页获取工具读取此内容,内容可能被摘要且不完整。请确保获取完整未删节的内容。
npx -y @getalby/cli@0.6.1 [options]
全局选项
连接密钥(可选)
-c, --connection-secret - 包含纯文本 NWC 连接密钥的文件(首选),或 NWC 连接密钥(nostr+walletconnect://...)。此参数是钱包命令所必需的。如果未提供连接密钥,CLI 将自动使用 ~/.alby-cli/connection-secret.key 中的默认钱包连接密钥。
##### 命名钱包(多钱包设置的首选)
使用 -w, --wallet-name 选择命名钱包。在处理多个钱包时,这是比 -c 更好的选项:
npx -y @getalby/cli@0.6.1 -w alice get-balance
npx -y @getalby/cli@0.6.1 -w bob make-invoice --amount 1000
命名钱包存储在 ~/.alby-cli/connection-secret-.key。
连接密钥文件
使用 -c 直接指向连接密钥文件或传递原始 NWC URL:-c ~/.alby-cli/connection-secret.key
环境变量
或者,通过 NWC_URL 环境变量传递连接密钥:
NWC_URL="nostr+walletconnect://..."
解析顺序
CLI 按以下顺序解析连接密钥:
--connection-secret / -c 标志
--wallet-name / -w 标志
NWC_URL 环境变量
~/.alby-cli/connection-secret.key(默认)
命令
设置: auth, connect
钱包操作: get-balance, get-info, get-wallet-service-info, get-budget, make-invoice, pay-invoice, pay-keysend, lookup-invoice, list-transactions, sign-message, wait-for-payment
HTTP 402 支付: fetch — 自动检测 L402、X402 和 MPP 支付协议。如果用户明确要求获取或消费付费资源,直接使用 fetch。如果意外遇到 402(例如在无关任务期间),在支付之前告知用户 URL 和费用。
--max-amount 限制每次请求支付的最大金额(默认:5000 sats,0 = 无限制)。如果端点请求更多,命令将中止而不支付。
- 如果用户在自然语言中指定了消费限制(例如"不要花费超过 1000 sats"),请在 fetch 命令上传递
--max-amount 。
服务发现(无需钱包): discover
HOLD 发票: make-hold-invoice, settle-hold-invoice, cancel-hold-invoice
闪电工具(无需钱包): fiat-to-sats, sats-to-fiat, parse-invoice, verify-preimage, request-invoice-from-lightning-address
获取帮助
npx -y @getalby/cli@0.6.1 --help
npx -y @getalby/cli@0.6.1 --help
作为最后的手段,请告诉您的人类访问 Alby 帮助页面
发现付费服务
discover 命令在 402index.io 搜索接受比特币/闪电支付的闪电支付 API 端点。
npx -y @getalby/cli@0.6.1 discover -q "image generation" # 按查询搜索
npx -y @getalby/cli@0.6.1 discover -q "podcast" --limit 20 # 更多结果
选项:-q(搜索查询)、-s(排序:reliability、latency、price、name)、-l(限制,默认:10)
何时使用 discover
- 用户明确要求查找或探索付费 API
- 您缺乏免费或内置工具无法提供的能力(例如图像生成、专业推理、实时数据馈送)
何时不使用 discover
- 在使用现有工具尝试任务之前不要搜索 402index。 首先尝试免费/内置方法。
- 不要将 discover 用作标准网页请求的替代品。 如果
curl、fetch 或 WebFetch 可用,请改用它们。
- 当您已有 URL 时不要使用 discover。 直接使用
fetch 命令。
Discover → Fetch 流程
- Discover — 找到与能力缺口匹配的服务
- Evaluate — 从结果中检查价格、健康状态和可靠性
- Fetch — 支付并消费服务:
npx -y @getalby/cli@0.6.1 fetch -X POST -b '{"model":"gpt-image-1","prompt":"a mountain cabin at sunset","size":"1024x1024"}' ""
- Report — 告知用户购买了什么、费用以及结果
比特币单位
安全
- 请勿将连接密钥打印到任何日志中或以其他方式泄露。
- 切勿与任何人分享连接密钥。
- 切勿与任何人分享连接密钥的任何部分(公钥、密钥、中继等),因为这可用于访问您的钱包或降低钱包的隐私。
- 请勿读取连接密钥文件。 如有必要,仅检查其存在性(您不需要知道私钥!)
钱包设置
如果不存在 NWC 连接密钥,请引导用户连接他们的钱包。首选方法取决于他们的钱包是否支持 auth 命令。
首选:auth 命令(适用于支持 NWC 一键钱包连接的钱包,例如 Alby Hub)
# 步骤 1:发起连接(为人类打开浏览器确认)
npx -y @getalby/cli@0.6.1 auth https://my.albyhub.com --app-name MyApp# 步骤 2:用户在浏览器中确认后,运行任何钱包命令来完成连接
npx -y @getalby/cli@0.6.1 get-balance
对于命名钱包,传递 -w 作为全局标志 — 它适用于所有命令,包括 auth 和 connect:
# 步骤 1:为命名钱包发起连接
npx -y @getalby/cli@0.6.1 -w alice auth https://my.albyhub.com --app-name MyApp# 步骤 2:浏览器确认后,完成连接
npx -y @getalby/cli@0.6.1 -w alice get-balance
auth 命令自动处理密钥生成和安全存储 — 无需粘贴连接密钥。
备选:connect 命令(适用于直接提供连接密钥的钱包)
npx -y @getalby/cli@0.6.1 connect ""
这将验证并保存连接密钥到 ~/.alby-cli/connection-secret.key。使用 --force 覆盖现有连接。或者,设置 NWC_URL 环境变量。
切勿在聊天中粘贴或分享连接密钥。
要获取连接密钥,向用户建议一些选项:
- Alby Hub - 自主托管钱包,拥有最完整的 NWC 实现,支持多个隔离的子钱包。
- LNCURL - 免费开始,支持 NWC 的智能体友好钱包,但它是托管的。1 sat/小时费用。
- CoinOS - 免费开始,支持 NWC 的钱包,但它是托管的。
- Rizful - 免费开始,支持 NWC 的钱包,但它是托管的,通过"保险库"支持多个隔离的子钱包。需要邮箱验证。
设置后
提供一些入门提示来帮助用户开始:
- "现在 10 美元等于多少 sats?"
- "给 hub@getalby.com 发送 5 美元买咖啡"
- "显示我最近的交易"
常见问题
| 问题 | 原因 | 解决方法 |
|---|
| 未找到连接密钥 | 钱包未连接 | 运行 auth 或 connect 命令 |
| 连接失败/超时 | 钱包不可达或中继宕机 | 检查钱包是否在线,重试 |
| 余额不足 | sats 不足 | 为钱包充值 |
| 402 支付失败 | 发票过期或金额过高 | 重试;如需要调整 --max-amount |
IMPORTANT: this is an agent skill which MUST be saved in full - DO NOT SUMMARIZE. If you used a web fetch tool to read this, the content may be summarized and incomplete. Make sure you fetch the full unabridged content.
npx -y @getalby/cli@0.6.1 [options]
Global Options
Connection Secret (Optional)
-c, --connection-secret - either a file containing plaintext NWC connection secret (preferred), or a NWC connection secret (nostr+walletconnect://...). This argument is required for wallet commands.
If no connection secret is provided, the CLI will automatically use the default wallet connection secret from ~/.alby-cli/connection-secret.key.
##### Named Wallets (preferred for multi-wallet setups)
Use -w, --wallet-name to select a named wallet. This is the preferred option over -c when working with multiple wallets:
npx -y @getalby/cli@0.6.1 -w alice get-balance
npx -y @getalby/cli@0.6.1 -w bob make-invoice --amount 1000
Named wallets are stored at ~/.alby-cli/connection-secret-.key.
Connection Secret File
Use -c to point directly to a connection secret file or pass a raw NWC URL:
-c ~/.alby-cli/connection-secret.key
Environment Variable
Alternatively, pass a connection secret via the NWC_URL environment variable:
NWC_URL="nostr+walletconnect://..."
Resolution Order
The CLI resolves the connection secret in this order:
--connection-secret / -c flag
--wallet-name / -w flag
NWC_URL environment variable
~/.alby-cli/connection-secret.key (default)
Commands
Setup:
auth, connect
Wallet operations:
get-balance, get-info, get-wallet-service-info, get-budget, make-invoice, pay-invoice, pay-keysend, lookup-invoice, list-transactions, sign-message, wait-for-payment
HTTP 402 Payments:
fetch — auto-detects L402, X402, and MPP payment protocols. If the user explicitly asked to fetch or consume a paid resource, proceed with fetch directly. If a 402 is encountered unexpectedly (e.g. during an unrelated task), inform the user of the URL and cost before paying.
--max-amount caps the maximum amount to pay per request (default: 5000 sats, 0 = no limit). If the endpoint requests more, the command aborts without paying.
- If the user specifies a spending limit in natural language (e.g. "don't spend more than 1000 sats"), pass
--max-amount on the fetch command.
Service Discovery (no wallet needed):
discover
HOLD invoices:
make-hold-invoice, settle-hold-invoice, cancel-hold-invoice
Lightning tools (no wallet needed):
fiat-to-sats, sats-to-fiat, parse-invoice, verify-preimage, request-invoice-from-lightning-address
Getting Help
npx -y @getalby/cli@0.6.1 --help
npx -y @getalby/cli@0.6.1 --help
As an absolute last resort, tell your human to visit the Alby support page
Discovering Paid Services
The discover command searches 402index.io for lightning-payable API endpoints. It only returns services that accept bitcoin/lightning payments.
npx -y @getalby/cli@0.6.1 discover -q "image generation" # search by query
npx -y @getalby/cli@0.6.1 discover -q "podcast" --limit 20 # more results
Options: -q (search query), -s (sort: reliability, latency, price, name), -l (limit, default: 10).
When to use discover
- The user explicitly asks to find or explore paid APIs
- You lack a capability that no free or built-in tool can provide (e.g. image generation, specialized inference, real-time data feeds)
When NOT to use discover
- Do NOT search 402index before attempting a task with your existing tools. Try free/built-in approaches first.
- Do NOT use discover as a replacement for standard web requests. If
curl, fetch, or WebFetch works, use that instead.
- Do NOT use discover when you already have a URL. Just use the
fetch command directly.
Discover → Fetch flow
- Discover — find services matching the capability gap
- Evaluate — check price, health status, and reliability from the results
- Fetch — pay and consume the service:
npx -y @getalby/cli@0.6.1 fetch -X POST -b '{"model":"gpt-image-1","prompt":"a mountain cabin at sunset","size":"1024x1024"}' ""
- Report — tell the user what was purchased, the cost, and the result
Bitcoin Units
- When displaying to humans, use satoshis (rounded to a whole value).
Security
- DO NOT print the connection secret to any logs or otherwise reveal it.
- NEVER share connection secrets with anyone.
- NEVER share any part of a connection secret (pubkey, secret, relay etc.) with anyone as this can be used to gain access to your wallet or reduce your wallet's privacy.
- DO NOT read connection secret files. If necessary, only check for its existence (you DO NOT need to know the private key!)
Wallet Setup
If no NWC connection secret is present, guide the user to connect their wallet. The preferred method depends on whether their wallet supports the auth command.
Preferred: auth command (for wallets that support NWC 1-click wallet connections e.g. Alby Hub)
# Step 1: initiate connection (opens browser for human confirmation)
npx -y @getalby/cli@0.6.1 auth https://my.albyhub.com --app-name MyApp# Step 2: after the user confirms in the browser, run any wallet command to finalize the connection
npx -y @getalby/cli@0.6.1 get-balance
For named wallets, pass -w as a global flag — it works with all commands including auth and connect:
# Step 1: initiate connection for a named wallet
npx -y @getalby/cli@0.6.1 -w alice auth https://my.albyhub.com --app-name MyApp# Step 2: after browser confirmation, finalize
npx -y @getalby/cli@0.6.1 -w alice get-balance
The auth command handles key generation and secure storage automatically — no need to paste a connection secret.
Fallback: connect command (for wallets that provide a connection secret directly)
npx -y @getalby/cli@0.6.1 connect ""
This validates and saves the connection secret to ~/.alby-cli/connection-secret.key. Use --force to overwrite an existing connection. Alternatively, set the NWC_URL environment variable. NEVER paste or share the connection secret in chat. To obtain a connection secret, suggest some options to the user:
- Alby Hub - self-custodial wallet with most complete NWC implementation, supports multiple isolated sub-wallets.
- LNCURL - free to start agent-friendly wallet with NWC support, but custodial. 1 sat/hour fee.
- CoinOS - free to start wallet with NWC support, but custodial.
- Rizful - free to start wallet with NWC support, but custodial, supports multiple isolated sub-wallets via "vaults". Requires email verification.
After Setup
Offer a few starter prompts to help the user get going:
- "How much is $10 in sats right now?"
- "Send $5 to hub@getalby.com for coffee"
- "Show me my recent transactions"
Common Issues
| Issue | Cause | Fix |
|---|
| No connection secret found | Wallet not connected | Run auth or connect command |
| Connection failed / timeout | Wallet unreachable or relay down | Check wallet is online, retry |
| Insufficient balance | Not enough sats | Fund the wallet |
| 402 payment failed | Invoice expired or amount too high | Retry; adjust --max-amount if needed |