Skip to content

Documentation

From key to first request in minutes.

Point an OpenAI-compatible client at one base URL and keep the SDK and workflow you already use.

Quickstart

Make your first request

Three steps: create a key, set the base URL, send a request. The only thing that changes between models is the value of the model field.

  1. 1
    Create an API key

    Generate one in API Keys and store it as an environment variable.

  2. 2
    Point your client at PrByCode

    Set the base URL to https://api.prbycode.com/v1.

  3. 3
    Send a request

    Pick any model ID from the catalog and send a standard completion request.

Base URLhttps://api.prbycode.com/v1

Authentication

Send your key as a bearer token on every request. Keys are scoped to a single workspace, and each key can be revoked independently of the others.

Header
Authorization: Bearer prby_live_••••••••••••
Never ship a key in client-side code

Browser bundles, mobile apps and public repositories are all readable. Proxy requests through your own server instead.

Header
Authorization
Scheme
Bearer
Missing key
401 Unauthorized
Revoked key
401 Unauthorized — the key stops authenticating immediately

Choosing a model

Models are selected per request. A request that omits model uses the default configured in the console; if that model fails, the fallback chain is tried in order.

Fastest
deepseek-v4.1-flash
Lowest cost
deepseek-v4.1-flash
Longest context
claude-sonnet-5
Vision
gpt-5.6-luna

The model catalog lists context window, capabilities and per-token pricing for every route.

Chat completions

The primary endpoint. It accepts the standard OpenAI request body, including tools, response_format and stream.

POST /v1/chat/completions · cURL
curl https://api.prbycode.com/v1/chat/completions \
  -H "Authorization: Bearer $PRBYCODE_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "model": "glm-5.3-flash",
    "messages": [{ "role": "user", "content": "Hello" }]
  }'
EndpointPOST https://api.prbycode.com/v1/chat/completions

Anthropic messages

Clients built against the Anthropic messages shape can point at PrByCode without changes. System prompts are passed as a top-level field rather than a message.

POST /v1/messages
curl https://api.prbycode.com/v1/messages \
  -H "x-api-key: $PRBYCODE_API_KEY" \
  -H "anthropic-version: 2023-06-01" \
  -H "Content-Type: application/json" \
  -d '{
    "model": "claude-sonnet-5",
    "max_tokens": 1024,
    "system": "You are a concise assistant.",
    "messages": [{ "role": "user", "content": "Hello" }]
  }'

Streaming

Set stream to true to receive server-sent events. Each chunk carries an incremental delta, and the stream ends with a [DONE] sentinel.

Server-sent events
data: {"choices":[{"delta":{"role":"assistant","content":"Hello"}}]}

data: {"choices":[{"delta":{"content":" from"}}]}

data: {"choices":[{"delta":{"content":" PrByCode."}}]}

data: {"choices":[{"delta":{},"finish_reason":"stop"}]}

data: [DONE]

Usage counters arrive in the final chunk, so a streamed request still reports token consumption in Activity.

List models

Return the models currently routable with your key, in the standard OpenAI list shape.

GET /v1/models
curl https://api.prbycode.com/v1/models \
  -H "Authorization: Bearer $PRBYCODE_API_KEY"

Error handling

Failures use conventional HTTP status codes with a JSON body. Every response carries a request ID you can search for in the console.

JSON
{
  "error": {
    "type": "rate_limit_error",
    "message": "Rate limit reached for this API key. Retry after the window resets.",
    "request_id": "req_8f21c0d4a7b2"
  }
}

Status codes

What each class of response means for a retry strategy.

  • 200Request succeeded.
  • 400Malformed request body. Retrying unchanged will fail again.
  • 401Missing, revoked or invalid API key.
  • 404Unknown model ID. Check the catalog.
  • 429Rate limit or plan allowance exhausted. Retry after the window resets.
  • 500The upstream provider returned an internal error. Safe to retry.
  • 504The model did not respond within the timeout. Safe to retry or fall back.

Rate limits and quota

Requests are limited per key, and token consumption is metered against your plan allowance. Both are visible in the console before you hit them.

Rate limit headers
x-ratelimit-remaining-requests
Retry after
retry-after
Exhausted allowance
HTTP 429 until the period renews
Live view
Usage

Client compatibility

Any client that accepts a custom OpenAI-compatible base URL works without further changes.

  • OpenAI official SDKs for Node.js, Python, Go, Java and .NET
  • Framework integrations that accept a configurable base URL
  • Editors and CLI tools with a custom endpoint setting
  • Anthropic-compatible clients against /v1/messages
OpenAI compatibleAnthropic compatibleServer-sent events

Next steps

Where to go once a request succeeds.