API Reference

Overview

Every Pikeway endpoint lives on one gateway host: the API proxy, capability routing, the OpenAI/Anthropic-compatible AI gateway, and the Agent API that agents use to find, inspect and run endpoints.

Base URL

Gateway
https://gw.pikeway.ai

All paths in this reference are relative to the gateway base URL. The main route families:

  • /gw/{slug}/{path} calls any marketplace API (any method), billed per successful call.
  • /cap/{slug} one action served by several providers, with automatic failover.
  • /ai/v1/… OpenAI- and Anthropic-compatible LLM endpoints, billed per token.
  • /v1/… the Agent API: discover, inspect, run, runs, wallet.
  • /mock/{slug}/{path} free example responses, no key, never hits the upstream.
  • /ws/{slug}/{path} WebSocket proxy (key required; see the WebSocket guide).

Authentication

API key

Create a key in Console → Keys. Keys start with pk-. Send it as a Bearer token; the X-API-Key header is accepted as well.

bash
curl https://gw.pikeway.ai/v1/auth/whoami \
  -H "Authorization: Bearer pk-..."

# equivalent
curl https://gw.pikeway.ai/v1/auth/whoami -H "X-API-Key: pk-..."

The gateway strips its own auth headers before forwarding, so your Pikeway key never reaches the upstream provider. Each key can carry its own restrictions, set in the console:

  • Spend limit: once reached, paid calls return 402 api key spend limit reached.
  • IP allowlist (CIDR): other IPs get 403 client IP not allowed for this API key.
  • Expiry: an expired key behaves like a revoked one (401 invalid or revoked API key).

Browser keys

A browser key is a key with an origin allowlist. The gateway checks the Origin header (falling back to Referer) against the list; entries are hostnames and *.example.com matches subdomains. Requests with no Origin/Referer, such as server-side calls, are rejected with 403 request origin not allowed for this API key. See Browser keys.

Endpoints that need no key

POST /v1/discover, POST /v1/inspect, GET /v1/examples, GET /v1/rankings, GET /ai/v1/models and /mock/… are free and work without a key.

Billing and response headers

Paid calls are charged only when they succeed. On /gw that means the upstream answered 2xx (and, where the provider configured it, the body's business code says success). Upstream errors, network failures, timeouts and every gateway-side rejection are free. Before forwarding, the gateway holds the price on your balance and releases it if the call is not billed.

Response headers
X-Pikeway-Call-Idstring
Unique id of this call. It is the runId for GET /v1/runs/{id} and shows up in your request logs.
X-Pikeway-Costdecimal (USD)
Amount charged for this call, e.g. 0.001. 0 when the call was not billed. On /ai/v1 it is set only on non-streaming responses.
X-Pikeway-CacheHIT | MISS
Present when the response cache applies (provider-enabled on /gw GET requests; opt-in via the X-Pikeway-Cache request header on /ai/v1/chat/completions). Cache hits on /gw are billed at the normal price.
X-Pikeway-Planstring
Name of the subscription plan used for this call, when you have an active plan for the API.
X-Pikeway-Quota-Remaininginteger
Calls left in the plan's included quota after this call.
X-Pikeway-Volume-Discountpercent
Volume-tier discount applied to this pay-per-call request.
X-Pikeway-Byok1
The call ran on your own provider key (Console → Connections) and was not charged.
X-Pikeway-Upstream-Attemptsinteger
Number of upstream targets tried, when the gateway failed over to a backup.
X-Pikeway-Upstream-Errorstring
Why a 2xx upstream response was treated as a failure and not billed: business-code, graphql-errors or grpc-status-N.
X-Pikeway-Tokensprompt+completion
Token usage on non-streaming /ai/v1 responses, e.g. 812+64.
X-Pikeway-Capability / -Routed-To / -Attemptsstring
On /cap responses: the capability, the provider that served it, and every attempt as api:status.
X-Pikeway-Mocktrue
The response is a free mock from /mock (cost 0).

Browser code can read them through CORS, except X-Pikeway-Byok, X-Pikeway-Upstream-Attempts and X-Pikeway-Upstream-Error, which are not in the exposed list.

Requests and responses

  • Pass-through. /gw and /cap return the provider's status code, headers and body unchanged (plus the headers above). Request bodies, query strings and headers are forwarded as-is, minus Pikeway's auth headers.
  • Agent API. /v1/* takes and returns JSON. Prices and costs are objects like {"value": 0.001, "currency": "USD"}; timestamps are RFC 3339 in UTC.
  • Idempotency. Send Idempotency-Key (up to 255 characters) on a paid /gw call and the gateway forwards and charges it at most once per key. Reusing the key returns 409.
  • Errors. Gateway errors are JSON with error + statusCode; Agent API errors use code + message. See Errors.

Pagination

GET /v1/runs and GET /v1/wallet/activities use cursor pagination, newest first. Pass limit (default 20, max 100) and the cursor from the previous page. The response is {"items": [...], "cursor": "..."}; cursor is null on the last page. Cursors are opaque strings.

bash
curl "https://gw.pikeway.ai/v1/runs?limit=50" -H "Authorization: Bearer pk-..."
curl "https://gw.pikeway.ai/v1/runs?limit=50&cursor=MjAyNi0xMC0yNFQwOToxMjo..." -H "Authorization: Bearer pk-..."

Endpoints

Gateway

AI gateway

Agent API

Other public endpoints

GET/v1/examples
Ready-made agent tasks with the endpoints they use and an estimated cost; /v1/examples/{slug} for one.
GET/v1/rankings
Most-used APIs. Query: window (24h | 7d | 30d, default 7d), category, limit (default 30, max 100).
GET/health
Gateway status and edition.
GET/SKILL.md
The agent skill file (also /skill.md).
GET/llms.txt
Machine-readable catalog summary for LLMs.
POST/mcp
MCP server, authenticated with Authorization: Bearer pk-…; /mcp/agent uses OAuth sign-in.
Self-hosted (community edition) gateways don't bill: every cost is 0 and balance checks are skipped.