Skip to content

API reference

One endpoint, a familiar surface.

Standard bearer authentication with OpenAI-compatible request shapes. Anthropic message bodies are accepted on the same base URL.

Base URL

All requests are made against a single host. The version segment is part of the base URL.

Base URLhttps://api.prbycode.com/v1
POST /v1/chat/completionsPOST
POST /v1/messagesPOST
GET /v1/modelsGET
GET /v1/quotaGET

Authentication

Send the key as a bearer token. The Anthropic-shaped endpoint also accepts the key in an x-api-key header.

Header
Authorization: Bearer prby_live_••••••••••••
Accepted header
Authorization: Bearer <key>
Alternative
x-api-key: <key>
Key format
prby_live_…
Rotation
Issue a new key, deploy it, then revoke the old one

Conventions

  • Request and response bodies are JSON encoded as UTF-8.
  • Timestamps in responses are ISO 8601 UTC.
  • Token counts follow the routed model's own tokenizer.
  • Every response includes an x-prbycode-request-id header.
  • Unknown fields in a request body are ignored rather than rejected.

POST /v1/chat/completions

Create a model response from a list of messages. This is the endpoint most clients use.

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": "claude-sonnet-5",
    "messages": [
      { "role": "system", "content": "You are a concise assistant." },
      { "role": "user", "content": "Summarise the request lifecycle." }
    ],
    "max_tokens": 512,
    "temperature": 0.7,
    "stream": false
  }'

POST /v1/messages

The Anthropic-compatible shape. Differences from the chat completions endpoint are the API key header, the required max_tokens field, and system as a top-level field.

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" }]
  }'

GET /v1/models

Return the models routable with the presented key.

Response
{
  "object": "list",
  "data": [
    {
      "id": "claude-sonnet-5",
      "object": "model",
      "owned_by": "anthropic",
      "context_window": 1000000
    },
    {
      "id": "glm-5.3-flash",
      "object": "model",
      "owned_by": "zhipu ai",
      "context_window": 256000
    }
  ]
}

Catalog

The same set, with pricing, in table form.

ModelModel IDContextInput / 1MOutput / 1M
Claude Sonnet 5claude-sonnet-51M$3.00$15.00
GLM 5.3 Flashglm-5.3-flash256K$0.25$1.10
GLM 5.2glm-5.2256K$0.60$2.20
DeepSeek V4 Prodeepseek-v4-pro256K$0.90$3.40
DeepSeek V4.1 Flashdeepseek-v4.1-flash256K$0.20$0.80
GPT 5.6 Lunagpt-5.6-luna1M$2.50$10.00
  • Claude Sonnet 5claude-sonnet-5 · 1M · $3.00 in / $15.00 out
  • GLM 5.3 Flashglm-5.3-flash · 256K · $0.25 in / $1.10 out
  • GLM 5.2glm-5.2 · 256K · $0.60 in / $2.20 out
  • DeepSeek V4 Prodeepseek-v4-pro · 256K · $0.90 in / $3.40 out
  • DeepSeek V4.1 Flashdeepseek-v4.1-flash · 256K · $0.20 in / $0.80 out
  • GPT 5.6 Lunagpt-5.6-luna · 1M · $2.50 in / $10.00 out

GET /v1/quota

Inspect plan status, token allowance and current rate limit standing without opening the console.

Response
{
  "object": "quota",
  "plan": "Monthly",
  "period": {
    "start": "2026-09-18",
    "renews": "2026-10-18"
  },
  "tokens": {
    "used": 412884000,
    "total": 1000000000
  },
  "rate_limit": {
    "limit": 600,
    "remaining": 574,
    "reset_at": "2026-09-20T04:00:00Z"
  }
}

Request parameters

Fields accepted by /v1/chat/completions. Availability depends on the routed model — see the parameters tab on any model page.

FieldTypeRequiredDescription
modelstringYesModel ID from the catalog. Falls back to the default route when omitted.
messagesarrayYesConversation history as { role, content } objects.
streambooleanNoReturn server-sent events instead of a single JSON body.
temperaturenumberNoSampling temperature. Model defaults apply when omitted.
top_pnumberNoNucleus sampling probability mass.
max_tokensintegerNoUpper bound on completion tokens.
toolsarrayNoFunction definitions the model may call.
tool_choicestring | objectNoWhether and which tool the model must call.
response_formatobjectNoRequest a JSON response shape.
stopstring | arrayNoSequences that terminate generation.
userstringNoStable end-user identifier for abuse attribution.
  • modelYesstring · Model ID from the catalog. Falls back to the default route when omitted.
  • messagesYesarray · Conversation history as { role, content } objects.
  • streamNoboolean · Return server-sent events instead of a single JSON body.
  • temperatureNonumber · Sampling temperature. Model defaults apply when omitted.
  • top_pNonumber · Nucleus sampling probability mass.
  • max_tokensNointeger · Upper bound on completion tokens.
  • toolsNoarray · Function definitions the model may call.
  • tool_choiceNostring | object · Whether and which tool the model must call.
  • response_formatNoobject · Request a JSON response shape.
  • stopNostring | array · Sequences that terminate generation.
  • userNostring · Stable end-user identifier for abuse attribution.

Response object

A non-streamed response is a standard completion object with usage counters attached.

JSON
{
  "id": "req_8f21c0d4a7b2",
  "object": "chat.completion",
  "created": 1789000000,
  "model": "claude-sonnet-5",
  "choices": [
    {
      "index": 0,
      "finish_reason": "stop",
      "message": {
        "role": "assistant",
        "content": "Requests enter the gateway, are validated and metered, then routed to a healthy model."
      }
    }
  ],
  "usage": {
    "prompt_tokens": 38,
    "completion_tokens": 24,
    "total_tokens": 62
  }
}

Errors

Failures use conventional status codes and a JSON body carrying a machine-readable type plus a request ID.

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

Status codes

Whether a retry is worth attempting.

  • 400invalid_request_error
    Body failed validation. Fix the payload before retrying.
  • 401authentication_error
    The key is missing, revoked or malformed.
  • 403permission_error
    The key's scope does not permit this model or endpoint.
  • 404not_found_error
    Unknown model ID or path.
  • 429rate_limit_error
    Per-key rate limit or plan allowance reached.
  • 500upstream_error
    Provider failure inside the routed model.
  • 504timeout_error
    The routed model exceeded the request timeout.

Rate limits

Limits are enforced per key. Response headers report the remaining budget so a client can back off before it is refused.

Remaining requests
x-ratelimit-remaining-requests
Remaining tokens
x-ratelimit-remaining-tokens
Reset time
x-ratelimit-reset
Back-off hint
retry-after