Pkay/docs
DEVELOPER DOCUMENTATION

Build at the speed
of thought.

One API. Every model. Zero vendor lock-in.
Go from zero to your first completion in minutes.

01

Quickstart

All requests go through one public base URL. Create a key in your dashboard, then send your first request.

REQUEST
curl https://api.pkay.dev/v1/chat/completions \
  -H "Authorization: Bearer $PKAY_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{"model":"your-model","messages":[{"role":"user","content":"Hello!"}]}'

Or use any OpenAI-compatible SDK — only the base URL and key change.

TYPESCRIPT
import OpenAI from "openai";

const client = new OpenAI({
  apiKey: process.env.PKAY_API_KEY,
  baseURL: "https://api.pkay.dev/v1",
});

const res = await client.chat.completions.create({
  model: "your-model",
  messages: [{ role: "user", content: "Summarize this changelog" }],
});
02

Authentication

Every request needs an Authorization header with your API key. Keys are generated from your dashboard and can be revoked or replaced at any time without downtime.

HEADER
Authorization: Bearer pkay_********
03

Agentic AI configuration

Pkay works with the most popular agentic coding CLIs. Every tool speaks either the OpenAI or Anthropic protocol, so configuration is just a base URL and your key.

OpenCode

OpenCode

OpenCode speaks the OpenAI protocol — point base URL at Pkay and pick any model with /models.

Environment variable
CONFIG
export OPENAI_API_KEY=pkay_********
export OPENAI_BASE_URL=https://api.pkay.dev/v1
opencode
Claude Code

Claude Code

Pkay exposes an Anthropic-compatible endpoint, so Claude Code works without a proxy.

Anthropic-compatible env
CONFIG
export ANTHROPIC_AUTH_TOKEN=pkay_********
export ANTHROPIC_BASE_URL=https://api.pkay.dev
claude --model claude-sonnet-5
Codex CLI

Codex CLI

Add Pkay as a custom provider, then launch codex normally.

Config file (~/.codex/config.toml)
CONFIG
model = "gpt-5.6-sol"
model_provider = "pkay"

[model_providers.pkay]
base_url = "https://api.pkay.dev/v1"
env_key = "PKAY_API_KEY"
Aider

Aider

Prefix any catalog model with openai/ to route it through Pkay.

Launch flags / .env
CONFIG
export OPENAI_API_BASE=https://api.pkay.dev/v1
export OPENAI_API_KEY=pkay_********
aider --model openai/deepseek-v4-pro
Qwen Code

Qwen Code

Any model in the catalog is selectable — not just Qwen models.

OpenAI-compatible env
CONFIG
export OPENAI_API_KEY=pkay_********
export OPENAI_BASE_URL=https://api.pkay.dev/v1
qwen --model kimi-k3
04

Streaming

Set stream: true to receive server-sent events. Each chunk carries a delta you can append directly to your UI.

STREAM
for await (const chunk of stream) {
  process.stdout.write(chunk.choices[0].delta.content ?? "");
}
05

Errors

Errors return a stable JSON shape with a machine-readable code, so retries and alerting stay simple.

JSON
{ "error": { "type": "rate_limit_error", "message": "Too many requests", "request_id": "req_9f2a..." } }
401
authentication_errorMissing, invalid or revoked API key.
Fix: Send Authorization: Bearer pkay_******** with an active key from your dashboard.
400
invalid_request_errorThe request body is malformed or missing a required field.
Fix: Check the message field — usually a missing model or messages parameter.
404
model_not_foundNo provider in the pool serves the requested model.
Fix: List available models with GET /v1/models and use one of those ids.
429
rate_limit_errorToo many requests in the current window for your key.
Fix: Back off and retry — the response includes retryable: true when safe to retry.
502
provider_unavailableEvery provider that serves this model failed or is circuit-open.
Fix: Safe to retry with backoff. The gateway automatically fails over between providers.
06

Rate limits

Requests are metered per API key and per model. When a limit is exceeded the gateway returns rate_limit_error with HTTP 429 — back off and retry. Need higher limits? Contact support and we'll raise them for your key.