Documentation

API // v1

One familiar API.
Your open model.

BrokenGPT exposes the core OpenAI Chat Completions shape, including server-sent event streaming. Point an existing client at your BrokenGPT base URL and use a BrokenGPT key.

Compatibility scopeText chat, function tools, strict structured output, Responses, persisted batches, token counting, usage reports, SSE, and typed errors are supported. Images, audio, embeddings, and hosted assistant products are outside this contract.

Prefer a guided start? Follow the Python quickstart, the Node.js quickstart, or the migration checklist.

01

Create and use a key

Create a secret from the API keys dashboard. The full value is shown once and only its SHA-256 hash is stored. Send it as a Bearer token.

Request
curl https://brokengpt.com/v1/chat/completions \
  -H "Authorization: Bearer $BROKENGPT_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "model": "broken-one",
    "messages": [
      {"role": "user", "content": "Explain continuous batching."}
    ]
  }'
02

Chat completions

POST/v1/chat/completions
modelstring · required

One of broken-one, broken-one-pro, or broken-two.

messagesarray · required

System, user, and assistant messages with string content.

streamboolean

Return incremental SSE chunks, ending with [DONE].

max_tokensinteger

Optional caller-chosen cap. Omit it to let the model finish naturally.

toolsarray

Function declarations; your application executes returned tool calls.

response_formatobject

Text, JSON object, or server-validated JSON Schema output.

seedinteger

Passed through when the selected private route supports deterministic generation.

temperature0–2

Sampling temperature passed to the configured provider.

top_p0–1

Nucleus sampling control.

03

Stream the answer

Set stream: true. Each event contains a chat.completion.chunk. Usage is included in the terminal chunk when the provider reports it; otherwise BrokenGPT records a conservative estimate.

Request
const response = await fetch(
  "https://brokengpt.com/v1/chat/completions",
  {
    method: "POST",
    headers: {
      "Authorization": `Bearer ${process.env.BROKENGPT_API_KEY}`,
      "Content-Type": "application/json"
    },
    body: JSON.stringify({
      model: "broken-one",
      messages: [{ role: "user", content: "Write a parser." }],
      stream: true
    })
  }
);
04

Responses, batches, tokens, and usage

The same scoped key can use the focused compatibility endpoints below. See the repository API reference for complete request and response schemas.

POST/v1/responses

Text/function Responses objects and lifecycle-event streaming.

POST/v1/batches

Persist and process up to 100 non-streaming chat requests.

POST/v1/tokens/count

Estimate the full serialized input envelope before inference; final billing uses model-reported usage when available.

GET/v1/usage

Read usage for a key with the usage:read scope.

05

Errors and request IDs

Every API response includes x-request-id. Keep it when contacting support. Errors use an OpenAI-style error object.

400Invalid request or context too long
401Missing, invalid, or revoked API key
404Unknown model alias
429Rate limit hit, or credit balance is empty
503Inference provider temporarily unavailable

Use the error and troubleshooting guide for retry rules, context sizing, quota failures, and streaming recovery.

06

Pricing & limits

Billing supports model-specific prepaid usage or Pro at $29/month with 10M included tokens. Unused Pro tokens expire at the end of the paid billing period; prepaid credits do not. See the pricing page for current rates and the billing dashboard to subscribe or top up.

broken-one · $0.50 input / $2.00 output per 1Mbroken-one-pro · $1.00 input / $3.00 output per 1Mbroken-two · $0.60 input / $3.00 output per 1MRequests are rate-limited per keyCredits never expire

Pro tokens are consumed before prepaid credits. When both are empty, requests return 429 until you add credits or the next paid Pro period begins. Both input and output tokens are metered.

Ready to make the first call?Create an account