llmBreakr
API Reference

Chat Completions

The OpenAI-compatible /v1/chat/completions endpoint, streaming included.

Endpoint

POST /api/data/v1/chat/completions

Authenticated with a virtual key as a bearer token. The request and response shapes match OpenAI's Chat Completions API, so any OpenAI-compatible SDK or tool can point at this endpoint by changing only the base URL and key.

Request

curl -X POST http://localhost:4000/api/data/v1/chat/completions \
  -H "Authorization: Bearer <virtual_key>" \
  -H "Content-Type: application/json" \
  -d '{
    "model": "gpt-4o-mini",
    "messages": [
      { "role": "user", "content": "Hello" }
    ]
  }'

Using an OpenAI SDK

Because the shape is compatible, you can point the official OpenAI SDK straight at your gateway instead of api.openai.com:

import OpenAI from "openai";

const client = new OpenAI({
  baseURL: "http://localhost:4000/api/data/v1",
  apiKey: process.env.LLMBREAKR_VIRTUAL_KEY,
});

const completion = await client.chat.completions.create({
  model: "gpt-4o-mini",
  messages: [{ role: "user", content: "Hello" }],
});

This works whether model resolves to OpenAI, Anthropic, or Gemini behind the gateway — the client code doesn't change.

Streaming

Set "stream": true in the request body to receive server-sent events, exactly as OpenAI's API does:

curl -N -X POST http://localhost:4000/api/data/v1/chat/completions \
  -H "Authorization: Bearer <virtual_key>" \
  -H "Content-Type: application/json" \
  -d '{
    "model": "claude-3-5-haiku-20241022",
    "stream": true,
    "messages": [{ "role": "user", "content": "Hello" }]
  }'

What can reject a request

Before any provider is called, the gateway checks (in order):

  1. Virtual key validity — invalid or revoked keys are rejected immediately.
  2. Model access — the calling project must be explicitly allowed to use the requested model.
  3. Rate limit — requests over the project's configured rate are rejected.
  4. Budget — requests from a project past its spend cap are rejected.

See Architecture for the full request pipeline, and Rate limits & budgets for how limits are configured.

Exact error response shapes and additional admin-API endpoints (projects, keys, providers, audit logs) are documented in the repository as the admin API stabilizes — see the GitHub repo for the current route list.

On this page