For agents / CreditsDocs menu

Credits

Pre-fund your account with USDC on Base. Each API call debits the balance with zero gas fees.

Why credits over per-call x402

Per-call x402 payments require a wallet, USDC on Base, and gas for every signature. Credits flip that to a one-time top-up. Every call after becomes a free debit on our database. No gas, no signing, no wallet config in your client.

Priority order

  1. Free tier (if the endpoint has one and you have free quota left)
  2. Prepaid credits (used automatically if you have a balance)
  3. Per-call x402 (if you send a PAYMENT-SIGNATURE header)
  4. 402 challenge (if none of the above apply)

Top up via CLI (recommended)

Easiest path. Opens a browser to complete payment with any USDC-on-Base wallet:

bash
npx @apihubio/cli topup 10
# minimum $5, no upper cap

Top up from your AI assistant

If you have APIHub MCP connected (Claude Desktop, Cursor, etc.) just ask:

Ask the agent
"Top up $10 in APIHub credits"

# or use the tool directly
apihub_topup(amount_dollars=10)

Returns three payment paths: a browser URL, a CLI command, and raw x402 requirements. Your AI picks the right one.

Top up directly via x402

If your code already has wallet capability and you want to skip the browser, post directly to the credits endpoint. The first request returns 402 with x402 requirements; sign EIP-3009 transferWithAuthorization and re-post with the PAYMENT-SIGNATURE header.

POST/v1/credits/purchase

Buy credits via x402 payment to the platform wallet.

Parameters

amount_microdollarsnumberrequired

Amount in microdollars. 1 USD = 1,000,000. Minimum 5,000,000 ($5).

Request
# 1. Get challenge
curl -X POST https://api.apihub.io/v1/credits/purchase \
  -H "Authorization: Bearer ahk_..." \
  -H "Content-Type: application/json" \
  -d '{ "amount_microdollars": 10000000 }'

# Returns 402 with payment requirements

# 2. Sign + re-post with PAYMENT-SIGNATURE
curl -X POST https://api.apihub.io/v1/credits/purchase \
  -H "Authorization: Bearer ahk_..." \
  -H "Content-Type: application/json" \
  -H "PAYMENT-SIGNATURE: 0xsigned-eip3009" \
  -d '{ "amount_microdollars": 10000000 }'
Response200 OK
{
  "ok": true,
  "data": {
    "balance_microdollars": 10000000,
    "credited_microdollars": 10000000,
    "tx_hash": "0xabc..."
  }
}

Rate limit

Credit purchase attempts are limited to 20 per minute per API key. Prevents 402-challenge probing.

Check your balance

GET/v1/credits/balance

Returns your current credit balance and metadata about the account.

Response200 OK
{
  "ok": true,
  "data": {
    "credit_balance_microdollars": 9870000,
    "credit_balance_display": "$9.8700"
  }
}

View credit history

GET/v1/credits/history?limit=20

Returns recent credit transactions: purchases, refunds, and external x402 debits. Sorted newest first.

Parameters

limitnumber

Max rows to return. Default 20, hard cap 100.

Response200 OK
{
  "ok": true,
  "data": {
    "transactions": [
      {
        "id": "uuid",
        "amount_microdollars": 5500,
        "type": "debit",
        "payment_reference": "external:https://example.com/api",
        "balance_after": 9994500,
        "created_at": "2026-04-25T03:52:11.405Z"
      },
      {
        "id": "uuid",
        "amount_microdollars": 10000000,
        "type": "purchase",
        "payment_reference": "0xabc...",
        "balance_after": 10000000,
        "created_at": "2026-04-22T02:35:59.241Z"
      }
    ]
  }
}

Onboarded API call charges (which use the priority order above) are tracked in a separate transactions log; see the dashboard for that view.

A note on economics

External provider x402 calls (calls to APIs not onboarded to APIHub) include a small platform markup (default 10%) on top of the provider price. This funds the gas APIHub pays on your behalf to settle each call on-chain. Onboarded provider calls use credits with no per-call gas because settlement is batched daily by the payouts cron.

Practical implication: a $0.001 onboarded call charges you exactly $0.001. A $0.001 external call charges you $0.0011 ($0.001 to the provider + $0.0001 markup).

Credits (agents) - APIHub Docs - APIHub