Quick start
The public contract is OpenAI-compatible. Point any OpenAI SDK at /v1 and authenticate with your API key.
curl https://pkay-api-freee.up.railway.app/v1/chat/completions \
-H "Authorization: Bearer YOUR_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"model": "auto",
"messages": [{"role": "user", "content": "Hello!"}]
}'
Authentication
Every request is authenticated with a user API key (pkay_…) sent in the Authorization: Bearer header. Keys are stored only as salted hashes — the raw key is shown once when it is issued to you, so save it immediately.
If you get a 401 or 403 error
These are the two auth errors you may hit. The response body always tells you the exact reason — here is how to read and fix each one.
- The
Authorization: Bearerheader is missing entirely. - The key is typed/embedded incorrectly (extra spaces, copied prefix only, or truncated).
- The key has been revoked by an admin.
- The key has expired (it had an expiry date set).
Authorization: Bearer header, and — if it was revoked or expired — ask for a fresh key. You can verify a key is still valid with the key usage checker: a 401 there means the key is dead.
- You call
/v1/chat/completionsbut the key lacks thechatpermission. - You call
/v1/embeddingsbut the key lacks theembeddingspermission.
chat / embeddings) to that key. A 403 is never caused by a wrong password or expiry.
Endpoints
| Method | Path | Description |
|---|---|---|
| GET | /healthz | Health check. |
| GET | /v1/models | List the models available to your key. |
| POST | /v1/chat/completions | OpenAI-compatible chat completion (supports stream:true). |
| POST | /v1/embeddings | OpenAI-compatible embeddings. |
Check your API key usage
Want to know which models your key has used, on what dates, how many tokens it has spent, and whether it has hit 401, 403, 404, or other errors? Call the self-service usage endpoint below — authenticated with your own key, so you only ever see your own data.
curl https://pkay-api-freee.up.railway.app/v1/key/usage \
-H "Authorization: Bearer YOUR_API_KEY"
| Field | Meaning |
|---|---|
models | Per-model breakdown: request count, prompt/completion/total tokens, and first/last used timestamps. |
by_date | Total requests and tokens grouped by calendar date (UTC). |
status_breakdown | Counts of ok, error, and aborted responses. |
http_breakdown | Counts by HTTP status — including 401 (missing/invalid/expired key), 403 (missing permission), and 404 (unknown route/model). |
error_breakdown | Counts by internal error type (e.g. provider_error, rate_limit_error). |
chat or embeddings). 404 means the route or model name was not found. Any other error is a provider or gateway failure.Available models
Send "model" as the exact model name shown below. The gateway routes each request to the best available backend automatically — you never need to know (or trust) which upstream service is serving it. Use auto to let the gateway pick the best available model.
Kimi-K2.6DeepSeek-V4-FlashMiniMax-M3claude-opus-4-8claude-opus-5deepseek-v4-progpt-5.6-solKimi-K2.6-azurellama-4-maverickgemma-4-26bglm-5.2claudeaicodexaigemini-3.6-flashclaude-sonnet-5kimi-k3minimax-m3claude-haiku-4.5