Set up Direct
Create a key, lock it to your servers, and call any API from your backend. Give each agent or tenant its own budget so one runaway loop can't drain your balance.
Create a server key
Top up in Console → Billing, then create a key in Console → API Keys. Keys start with pk- and are shown once. Store it as a secret, for example PIKEWAY_API_KEY, in your server's environment or secret manager.
Send it as Authorization: Bearer pk-…. The X-API-Key header is accepted too.
Lock the key down
Open the key in Console → API Keys and set the restrictions that fit where it runs. Restrictions are checked by the gateway before anything is charged.
LimitUSD402 api key spend limit reached. You can raise it, remove it, or reset the spent amount at any time.IP allowlistIP / CIDR403 client IP not allowed for this API key. Use it for every server key with a stable egress IP.SiteshostnamesCall an API from your backend
Find an endpoint with /v1/discover and check its inputs and price with /v1/inspect (both free), then run it. /v1/run builds the upstream request from structured input and returns a run object.
curl -X POST https://gw.pikeway.ai/v1/run \
-H "Authorization: Bearer $PIKEWAY_API_KEY" \
-H "Content-Type: application/json" \
-H "Idempotency-Key: order-1842-price" \
-d '{
"provider": "birdeye",
"endpoint": "/defi/price",
"input": { "address": "So11111111111111111111111111111111111111112" }
}'HTTP/1.1 200 OK
X-Pikeway-Call-Id: 0192f6b0-5e2a-7d40-b1c3-8f9e2a4d6c11
X-Pikeway-Cost: 0.001
{
"runId": "0192f6b0-5e2a-7d40-b1c3-8f9e2a4d6c11",
"provider": "birdeye",
"endpoint": "/defi/price",
"method": "GET",
"status": "COMPLETED",
"output": { "data": { "value": 171.42 }, "success": true },
"providerResponse": { "httpStatus": 200, "contentType": "application/json", "cache": "" },
"cost": { "value": 0.001, "currency": "USD" },
"durationMs": 312
}Prefer to send the provider's own request shape? Use the raw gateway instead. Full parameters are in the /v1/run and gateway references.
# Same call through the raw gateway: your request is forwarded as-is curl "https://gw.pikeway.ai/gw/birdeye/defi/price?address=So11111111111111111111111111111111111111112" \ -H "Authorization: Bearer $PIKEWAY_API_KEY"
Give each agent or tenant its own budget
In Console → Team, issue an agent key for each agent, worker or customer. Each has its own budget (up to $100,000) and spends from your balance. The console shows each key's spend and call count for the last 30 days and when it was last used, and you can revoke one without touching the others.
- One key per agent means a stuck retry loop stops at its budget, not at your balance.
- One key per tenant gives you per-customer spend without building metering.
- Name keys after the agent or tenant: the name shows up in your logs and usage views.
Watch spend and handle errors
Any key can read its account balance and, if it has a limit, its own remaining budget. Check it before long jobs or alert on it.
curl https://gw.pikeway.ai/v1/wallet/balance -H "Authorization: Bearer $PIKEWAY_API_KEY"
{
"balance": { "value": 48.21, "currency": "USD" },
"earnings": { "value": 0, "currency": "USD" },
"keyBudget": { "limit": 20, "used": 3.47, "remaining": 16.53, "currency": "USD" },
"spendable": { "value": 16.53, "currency": "USD" }
}| Status | Message | What to do |
|---|---|---|
401 | invalid or revoked API key | The key was revoked, expired or mistyped. Load the current key. |
402 | insufficient balance | Top up, or enable auto top-up in Console → Billing. |
402 | api key spend limit reached | This key hit its limit. Raise it, or let the agent stop. |
403 | client IP not allowed for this API key | The call came from an IP outside the allowlist. |
429 | rate limit exceeded | Back off and retry. |
None of these are charged. When you retry a paid call after a timeout, send the same Idempotency-Key header so the call is never charged twice. See Errors for the full list.
Rotate keys without downtime
Rotate a key from Console → API Keys. The new key copies every setting and the spend so far; the old key keeps working for a grace period (24 hours by default, up to 7 days, or 0 to cut it off immediately) while you deploy the new one.
Security checklist
- Keys live only on servers, in a secret manager or environment variables, never in source control.
- Every key has a limit; server keys also have an IP allowlist.
- Separate keys per environment (dev, staging, prod) and per agent.
- Rate-limit your own users before their requests reach Pikeway: you pay for what they trigger.