AI models
Drop-in OpenAI- and Anthropic-compatible endpoints for every model in the catalog. Point your SDK at the gateway, use your Pikeway key, and pay per token from your balance.
OpenAI SDKs: https://gw.pikeway.ai/ai/v1 Anthropic SDKs: https://gw.pikeway.ai/ai
Authentication
Authorization: Bearer pk-… (OpenAI SDKs send this when you pass the key as apiKey) or X-API-Key: pk-…. For Claude Code set ANTHROPIC_BASE_URL=https://gw.pikeway.ai/ai and ANTHROPIC_AUTH_TOKEN=pk-…. Your balance must be above 0.
Billing
The gateway reads token usage from the model's response (or from the final events of a stream) and charges input × input price + cached input × cache price + output × output price, all per million tokens. Responses with status 400 or above are not charged. Prices per model are in GET /ai/v1/models.
X-Pikeway-Call-IdstringX-Pikeway-CostUSDX-Pikeway-Tokensprompt+completionX-Pikeway-CacheHIT | MISSChat completions
OpenAI Chat Completions format. The body is passed to the model provider as-is, except that model is mapped to the provider's model id, and streaming requests get stream_options.include_usage = true so the gateway can meter the stream.
modelstringrequired/ai/v1/models. Anthropic-style dated names are normalized, e.g. claude-sonnet-4-5-20250929 → claude-sonnet-4.5.messagesarrayrequiredstreamboolean…X-Pikeway-Cacheseconds1 = 300 s, otherwise the TTL in seconds (max 3600). Cached per account. A hit skips the model and is billed at 10% of the original token cost.curl https://gw.pikeway.ai/ai/v1/chat/completions \
-H "Authorization: Bearer $PIKEWAY_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"model": "gpt-5",
"messages": [{"role": "user", "content": "Summarize ERC-4337 in one sentence."}]
}'The response is the provider's OpenAI-format response, unchanged:
{
"id": "chatcmpl-…",
"object": "chat.completion",
"model": "openai/gpt-5",
"choices": [{
"index": 0,
"message": { "role": "assistant", "content": "ERC-4337 adds smart-contract wallets to Ethereum without protocol changes…" },
"finish_reason": "stop"
}],
"usage": { "prompt_tokens": 17, "completion_tokens": 31, "total_tokens": 48 }
}Messages (Anthropic)
Anthropic Messages format, for Claude Code and the Anthropic SDKs. anthropic-version and anthropic-beta headers are forwarded. Usage counts input_tokens plus cache reads and cache writes as input; cache reads are billed at the model's cache price.
curl https://gw.pikeway.ai/ai/v1/messages \
-H "Authorization: Bearer $PIKEWAY_API_KEY" \
-H "anthropic-version: 2023-06-01" \
-H "Content-Type: application/json" \
-d '{"model": "claude-sonnet-5", "max_tokens": 512,
"messages": [{"role": "user", "content": "Hello"}]}'export ANTHROPIC_BASE_URL=https://gw.pikeway.ai/ai export ANTHROPIC_AUTH_TOKEN=pk-... claude
Count tokens
Anthropic token counting, forwarded to the model provider. Requires a valid key and is free. Returns the provider's response.
Responses (OpenAI)
OpenAI Responses format. Usage is read from usage (or the response.completed event when streaming); input_tokens_details.cached_tokens are billed at the cache price.
curl https://gw.pikeway.ai/ai/v1/responses \
-H "Authorization: Bearer $PIKEWAY_API_KEY" \
-H "Content-Type: application/json" \
-d '{"model": "gpt-5", "input": "Write a haiku about gas fees."}'List models
All enabled models with prices and capabilities. No key needed.
curl https://gw.pikeway.ai/ai/v1/models
{
"object": "list",
"data": [
{
"id": "claude-sonnet-5",
"object": "model",
"owned_by": "anthropic",
"display_name": "Claude Sonnet 5",
"context_length": 1000000,
"pricing": { "input_per_mtok": 2, "output_per_mtok": 10 },
"capabilities": { "tools": true, "streaming": true, "thinking": true }
}
]
}idstringowned_bystringcontext_lengthinteger | nullpricing.input_per_mtok · pricing.output_per_mtoknumber (USD)capabilitiesobjectErrors
400invalid JSON body·missing 'model'401missing API key (Authorization: Bearer pk-...)·invalid or revoked API key402insufficient balance(balance is 0 or less)403key IP / origin restriction404unknown model: …405POST only502upstream LLM request failed: …- Errors from the model provider are returned with their original status and body, and are not charged.