Agent API

钱包与账户

查看一把 key 还能花多少钱、读取余额流水,以及 key 属于哪个账户。

鉴权

本页所有接口都需要 Authorization: Bearer pk-…。金额单位为美元。充值请在控制台完成,没有充值 API。

查询余额

GET/v1/wallet/balance
bash
curl https://gw.pikeway.ai/v1/wallet/balance -H "Authorization: Bearer $PIKEWAY_API_KEY"
200 OK
{
  "balance":   { "value": 12.4831, "currency": "USD" },
  "earnings":  { "value": 0, "currency": "USD" },
  "keyBudget": { "limit": 5, "used": 1.25, "remaining": 3.75, "currency": "USD" },
  "spendable": { "value": 3.75, "currency": "USD" }
}
字段
balancemoney
账户的预付余额。
earningsmoney
作为提供者的收益(与消费余额分开)。
keyBudgetobject
仅当这把 key 设置了消费上限时返回:limit、used、remaining。
spendablemoney
这把 key 当前可花的金额:余额,且不超过 key 的剩余预算。

余额流水

GET/v1/wallet/activities

余额账本的流水,按时间倒序:充值、调用扣费、套餐费用、退款及其他余额变动。

查询参数
limitinteger
每页条数。默认 20,最大 100。
cursorstring
上一页返回的 cursor。
bash
curl "https://gw.pikeway.ai/v1/wallet/activities?limit=50" -H "Authorization: Bearer $PIKEWAY_API_KEY"
200 OK
{
  "items": [
    {
      "id": "6a1f0c52-8d3e-4b7a-9f21-0e4c5d6b7a89",
      "type": "CONSUMPTION",
      "amount": { "value": -0.001, "currency": "USD" },
      "balanceAfter": 12.4831,
      "description": "call Birdeye",
      "createdAt": "2026-10-24T09:12:03Z",
      "runId": "0192f6b0-5e2a-7d40-b1c3-8f9e2a4d6c11"
    },
    {
      "id": "3c9b1e7d-2f4a-4c8e-b5d6-7a8f9e0d1c2b",
      "type": "TOPUP",
      "amount": { "value": 10, "currency": "USD" },
      "balanceAfter": 12.4841,
      "description": "Top-up",
      "createdAt": "2026-10-23T18:40:11Z"
    }
  ],
  "cursor": null
}
字段
typestring
例如 TOPUP、CONSUMPTION、SUBSCRIPTION、REFUND、BONUS、ADJUST。
amountmoney
入账为正,出账为负。
balanceAfternumber
该笔流水之后的余额。
runIdstring
该流水对应的调用(如有),可用于 /v1/runs/{runId}。

当前身份

GET/v1/auth/whoami

校验 key 并返回其所属账户。适合用来检查已配置的 key 是否有效(CLI 的 setup 命令就用它)。

bash
curl https://gw.pikeway.ai/v1/auth/whoami -H "Authorization: Bearer $PIKEWAY_API_KEY"
200 OK
{
  "userId": "cm2x8k1qz0000abcd1234efgh",
  "email": "[email protected]",
  "walletAddress": null,
  "twitterHandle": null,
  "key": {
    "id": "cm2x9p4rt0001abcd5678ijkl",
    "name": "agent",
    "preview": "pk-AbCd****xYz9",
    "budget": { "limit": 5, "used": 1.25, "currency": "USD" }
  }
}

账户未设置时,email、walletAddress 和 twitterHandle 为 null。key.budget 只在 key 设置了消费上限时出现。

错误

  • 401 missing API key (Authorization: Bearer pk-...) · invalid or revoked API key
  • 403 key 的 IP / 来源限制
  • 404 not found (/v1/wallet/ 下不存在的路径)· account not found
  • 405 use GET