When To Use This Skill
Use this skill whenever the user asks to:
- - find data from external APIs
- call an endpoint
- fetch/search information outside local context
- generate an image, video, voice, transcription, or music with an external API
- scrape/extract data from a URL
- find an API for a task ("is there an API for X?")
If the task needs an external paid API, start with agentspend search.
Playbook (Default Workflow)
- 1. INLINECODE1
- Confirm cost and constraints with the user (
--max-cost, budget, allowlist) - INLINECODE3
Setup
CODEBLOCK0
Opens a URL to add a credit card and set a weekly spending limit. Saves credentials to ~/.agentspend/credentials.json.
If already configured, re-running opens the dashboard to update settings.
Commands
Pay
CODEBLOCK1
Make a paid request. AgentSpend handles the payment automatically.
Options:
- -
--method <method> — HTTP method (default: GET) - INLINECODE7 — Request body (JSON or text)
- INLINECODE8 — Header in
key:value format (repeatable) - INLINECODE10 — Maximum acceptable charge in USD (up to 6 decimal places)
Returns:
- - Response body from the endpoint
- Charge amount and remaining weekly budget
Example:
CODEBLOCK2
Check
CODEBLOCK3
Discover an endpoint's price without paying.
Important:
- -
check must use the same request shape you plan to pay with. - Always pass
--method for non-GET endpoints. - If the endpoint needs headers/body, include the same
--header and --body on check. - If request shape is wrong, endpoint may return
404/400 instead of 402, and no price can be extracted.
Example:
CODEBLOCK4
Returns:
- - Price in USD
- Description (if available)
Search
CODEBLOCK5
Keyword search over service names and descriptions in the catalog. Returns up to 5 matching services.
Example:
CODEBLOCK6
Status
CODEBLOCK7
Show account spending overview.
Returns:
- - Weekly budget
- Amount spent this week
- Remaining budget
- Recent charges with amounts, domains, and timestamps
Configure
CODEBLOCK8
Run onboarding or open the dashboard to update settings (weekly budget, domain allowlist, payment method).
Spending Controls
- - Weekly budget — Set during configure. Requests that would exceed the budget are rejected.
- Per-request max cost — Use
--max-cost on pay to reject requests above a price threshold. - Domain allowlist — Configurable via the dashboard. Requests to non-allowlisted domains are rejected.
Common Errors
- -
WEEKLY_BUDGET_EXCEEDED — Weekly spending limit reached. Run npx agentspend configure to increase the budget. DOMAIN_NOT_ALLOWLISTED — The target domain is not in the allowlist. Run npx agentspend configure to update allowed domains.PRICE_EXCEEDS_MAX — Endpoint price is higher than --max-cost. Increase the value or remove the flag.
何时使用此技能
当用户提出以下请求时使用此技能:
- - 从外部API查找数据
- 调用端点
- 在本地上下文之外获取/搜索信息
- 使用外部API生成图像、视频、语音、转录或音乐
- 从URL抓取/提取数据
- 为任务查找API(是否有用于X的API?)
如果任务需要外部付费API,请先使用 agentspend search。
操作手册(默认工作流程)
- 1. npx agentspend search <任务>
- 与用户确认费用和限制(--max-cost、预算、白名单)
- npx agentspend pay <端点> --method ... --header ... --body ... --max-cost ...
设置
bash
npx agentspend configure
打开一个URL以添加信用卡并设置每周消费限额。将凭据保存到 ~/.agentspend/credentials.json。
如果已配置,重新运行将打开仪表板以更新设置。
命令
Pay(支付)
bash
npx agentspend pay
发起付费请求。AgentSpend自动处理支付。
选项:
- - --method <方法> — HTTP方法(默认:GET)
- --body <主体> — 请求主体(JSON或文本)
- --header <标头> — 格式为 key:value 的标头(可重复)
- --max-cost <美元> — 最大可接受费用(美元,最多6位小数)
返回:
示例:
bash
npx agentspend pay \
--method POST \
--header key:value \
--body {key: value} \
--max-cost 0.05
Check(检查)
bash
npx agentspend check
在不支付的情况下发现端点的价格。
重要提示:
- - check 必须使用与计划 pay 相同的请求结构。
- 对于非GET端点,始终传递 --method。
- 如果端点需要标头/主体,请在 check 中包含相同的 --header 和 --body。
- 如果请求结构错误,端点可能返回 404/400 而不是 402,且无法提取价格。
示例:
bash
npx agentspend check \
--method POST \
--header content-type:application/json \
--body {key:value}
返回:
Search(搜索)
bash
npx agentspend search <关键词>
对目录中的服务名称和描述进行关键词搜索。返回最多5个匹配的服务。
示例:
bash
npx agentspend search 视频生成
Status(状态)
bash
npx agentspend status
显示账户支出概览。
返回:
- - 每周预算
- 本周已支出金额
- 剩余预算
- 最近的收费记录,包括金额、域名和时间戳
Configure(配置)
bash
npx agentspend configure
运行入门引导或打开仪表板以更新设置(每周预算、域名白名单、支付方式)。
支出控制
- - 每周预算 — 在配置期间设置。超出预算的请求将被拒绝。
- 每次请求最大费用 — 在 pay 中使用 --max-cost 拒绝超过价格阈值的请求。
- 域名白名单 — 可通过仪表板配置。对不在白名单中的域名的请求将被拒绝。
常见错误
- - WEEKLYBUDGETEXCEEDED — 已达到每周消费限额。运行 npx agentspend configure 以增加预算。
- DOMAINNOTALLOWLISTED — 目标域名不在白名单中。运行 npx agentspend configure 以更新允许的域名。
- PRICEEXCEEDSMAX — 端点价格高于 --max-cost。增加该值或移除该标志。