Use a computer to access this page
The Developer API portal is designed for desktop use. Please switch to a larger screen.
API Reference

The Coder Copilot Developer API lets you call AI models directly using an API key. No session cookie required — just pass your key and a prompt.

⚠️ The Developer API is in public beta. Token limits and model availability may change.

Base URL

https://codercopilot.firesmasher.workers.dev

Authentication

All inference endpoints require your API key. Pass it as a query parameter or as an HTTP header.

Query parameter (easiest)

POST /v1/model/orbus-low?apikey=dak_your_key_here

Header

x-api-key: dak_your_key_here

Keys start with dak_ and are 52 characters long. You can create up to 3 keys per account on the API Keys page.

OAuth / Database Auth

Beyond per-key authentication, the server can enforce an additional layer of OAuth-style request authentication configured via require.jsonc stored in D1 (managed on the Database tab). When config.enableAuthentication is true, every inference request must pass the check defined by oauth.authenticationType — either "Key" or "Password".

When config.allowRequests is false, all inference requests are rejected with 503 regardless of auth.

Key method

Pass ?apikey= in the URL as usual, and include oauthKey and oauthType in the JSON body. The worker reads the stored 64-character key from D1 and compares.

POST /v1/model/orbus-low?apikey=dak_your_key
Content-Type: application/json

{
  "message": "Your prompt here",
  "oauthKey": "64-character-secret-key-here",
  "oauthType": "key"
}

oauthType must be the string "key" (case-insensitive). The oauthKey must exactly match the 64-character value set in oauth.oauthKey inside require.jsonc.

Password method

Pass the password as the ?pswd= query parameter. The worker fetches oauth.oauthPassword from D1 and compares.

POST /v1/model/orbus-low?apikey=dak_your_key&pswd=my_password
StatusMeaning
401OAuth key or password mismatch / missing fields.
503config.allowRequests is false.

Available Models

Four models are available. They all draw from your single shared token pool — no model has its own individual budget. Pick the model that fits your task; the tokens you spend always come from the same 15,000-token account-level pool.

Slug Msgs/min Best for
flux-plus 10 Short, precise tasks
orbus-low 10 General use, longer responses
nova-standard 10 Balanced quality and token efficiency
astra-plus 10 Complex reasoning and code generation

Token counts are approximate (≈ 1 token per 4 characters for input + output). All models return text only — file creation is not supported via the Dev API.

POST /v1/model/:model

POST /v1/model/{modelSlug} Send a prompt, receive a reply

Request body (JSON)

FieldTypeRequiredDescription
messagestringYes*The prompt / user message to send to the model.
promptstringYes*Alias for message.

* Either message or prompt is required.

Example request

curl -X POST \
  "https://codercopilot.firesmasher.workers.dev/v1/model/orbus-low?apikey=dak_your_key" \
  -H "Content-Type: application/json" \
  -d '{"message": "What is a Cloudflare Worker?"}'

Example response (200 OK)

{
  "ok": true,
  "model": "orbus-low",
  "reply": "A Cloudflare Worker is a serverless JavaScript runtime…",
  "usage": {
    "tokensConsumed": 47,
    "tokensUsed": 47,
    "tokensRemaining": 14953,
    "tokensLimit": 15000
  }
}

Error responses

StatusErrorMeaning
401Invalid API keyKey is missing, wrong, or revoked.
400Missing 'message'No prompt was provided in the request body.
404Unknown modelThe model slug in the URL doesn't exist.
429Rate limit / Token limitYou've hit the per-minute message limit or exhausted your token budget. Check retryIn / resetInMinutes in the response.
502AI errorThe upstream AI provider returned an error.

GET /v1/models

GET /v1/models List all available models (no auth required)

Example response

{
  "models": [
    { "slug": "flux-plus",     "msgsPerMinute": 10, "sharedPoolLimit": 15000, "sharedPoolResetH": 12 },
    { "slug": "orbus-low",     "msgsPerMinute": 10, "sharedPoolLimit": 15000, "sharedPoolResetH": 12 },
    { "slug": "nova-standard", "msgsPerMinute": 10, "sharedPoolLimit": 15000, "sharedPoolResetH": 12 },
    { "slug": "astra-plus",    "msgsPerMinute": 10, "sharedPoolLimit": 15000, "sharedPoolResetH": 12 }
  ],
  "pool": { "tokenLimit": 15000, "resetHours": 12 }
}

Key Management Endpoints

These endpoints require a valid session cookie (you must be logged in via the main Coder Copilot app), not an API key.

GET /api/dev/keys List your API keys
POST /api/dev/keys Create a new API key (body: { "label": "…" })
DELETE /api/dev/keys/:keyId Revoke an API key
GET /api/dev/usage Get token usage for all your keys

Database Config Endpoints

These endpoints read and write require.jsonc in D1. They require a valid session cookie — the same login session used by the Developer Portal. They are also accessible via the Database tab in the UI.

GET /api/dev/db/config Fetch the stored require.jsonc

Example response

{
  "content": "{\n    \"config\": { ... },\n    \"oauth\": { ... }\n}"
}

Returns 404 if the config has never been saved to D1 yet.

POST /api/dev/db/config Save / overwrite require.jsonc in D1

Request body (JSON)

FieldTypeRequiredDescription
contentstringYesThe full JSONC text to store. Comments (// …) are allowed; the worker strips them and validates with JSON.parse before saving.

Example request

curl -X POST \
  "https://codercopilot.firesmasher.workers.dev/api/dev/db/config" \
  -H "Content-Type: application/json" \
  --cookie "cc_session=your_session_cookie" \
  -d '{
    "content": "{\n  \"config\": { \"allowRequests\": true, \"enableAuthentication\": false },\n  \"oauth\": { \"oauthPassword\": \"my_password\", \"oauthKey\": \"64-string\", \"authenticationType\": \"Key\" }\n}"
  }'

Example response (200 OK)

{ "ok": true }

Rate Limits

Token usage is tracked at the account level, not per key or per model. All your API keys and all models share one 15,000-token pool that resets every 12 hours. For example: Key A uses 120 tokens on orbus-low, and Key B uses 80 tokens on flux-plus — your pool now shows 200 tokens used, 14,800 remaining.

LimitValueScope
Messages10 per minutePer API key, per model
Token pool15,000 / 12 hoursPer user account (all keys + all models)
API keys3 per accountPer user

When you hit a limit, the API returns HTTP 429 with retryIn (seconds, for message rate limit) or resetInMinutes (for token pool exhaustion) in the response body.

Quick Start

JavaScript / fetch

const res = await fetch(
  "https://codercopilot.firesmasher.workers.dev/v1/model/orbus-low?apikey=dak_your_key",
  {
    method: "POST",
    headers: { "Content-Type": "application/json" },
    body: JSON.stringify({ message: "Hello, what can you help me with?" }),
  }
);
const data = await res.json();
console.log(data.reply);       // AI response text
console.log(data.usage);       // token consumption details

Python

import requests

res = requests.post(
    "https://codercopilot.firesmasher.workers.dev/v1/model/orbus-low",
    params={"apikey": "dak_your_key"},
    json={"message": "Hello, what can you help me with?"}
)
data = res.json()
print(data["reply"])
print(data["usage"])