API Documentation

Model Database is a single, OpenAI-compatible API for hundreds of large language models. If you've used the OpenAI API, you already know how to use this one — just change the base URL.

Introduction

All requests go to a single base URL. Endpoints mirror the OpenAI API shape, so existing SDKs and tools work with a one-line change.

BASEhttps://modeldatabase.com/v1
  • Authenticate with a Bearer API key (prefix mdb_live_).
  • Send and receive JSON; streaming uses server-sent events.
  • Pick any model by passing its identifier in the model field.
  • Every billable response reports its cost and your balance in headers.

Quickstart

1. Create an account and grab your key from the dashboard. 2. Add credit. 3. Make your first call:

request.sh
curl https://modeldatabase.com/v1/chat/completions \
  -H "Authorization: Bearer $MDB_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "model": "anthropic/claude-opus-4-8",
    "messages": [{"role": "user", "content": "Hello!"}]
  }'
app.py
# pip install openai
from openai import OpenAI

client = OpenAI(
    base_url="https://modeldatabase.com/v1",
    api_key="mdb_live_...",
)

resp = client.chat.completions.create(
    model="anthropic/claude-opus-4-8",
    messages=[{"role": "user", "content": "Hello!"}],
)
print(resp.choices[0].message.content)
app.mjs
// npm install openai
import OpenAI from "openai";

const client = new OpenAI({
  baseURL: "https://modeldatabase.com/v1",
  apiKey: "mdb_live_...",
});

const resp = await client.chat.completions.create({
  model: "anthropic/claude-opus-4-8",
  messages: [{ role: "user", content: "Hello!" }],
});
console.log(resp.choices[0].message.content);

Authentication

Every request to /v1/* must include your API key as a Bearer token. Keys are created — and can be labelled, rotated, or revoked — from your dashboard. A key is shown only once at creation; store it securely.

header
Authorization: Bearer mdb_live_xxxxxxxxxxxxxxxxxxxx
Tip Keep keys server-side. If a key leaks, revoke it from the dashboard and mint a new one — existing keys keep working until you revoke them.

Chat completions

The core endpoint. Request and response bodies match the OpenAI Chat Completions schema.

POST/v1/chat/completions

Request body

FieldTypeDescription
modelrequiredstring Model identifier, e.g. anthropic/claude-opus-4-8. See List models.
messagesrequiredarray Conversation so far — objects with role (system/user/assistant) and content.
streamboolean When true, tokens stream back as server-sent events. Default false.
temperaturenumberSampling temperature. Optional, passed through to the model.
max_tokensintegerCap on generated tokens. Optional, passed through.

Other standard OpenAI parameters (top_p, stop, presence_penalty, …) are passed through to the underlying model when supported.

Example response

200 OK
{
  "id": "chatcmpl-...",
  "object": "chat.completion",
  "model": "anthropic/claude-opus-4-8",
  "choices": [{
    "index": 0,
    "message": { "role": "assistant", "content": "Hello! How can I help?" },
    "finish_reason": "stop"
  }],
  "usage": { "prompt_tokens": 9, "completion_tokens": 7, "total_tokens": 16 }
}

Streaming

Set "stream": true to receive the response token-by-token as server-sent events. Each event is a data: line carrying a JSON chunk; the stream ends with data: [DONE].

stream.sh
curl -N https://modeldatabase.com/v1/chat/completions \
  -H "Authorization: Bearer $MDB_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "model": "anthropic/claude-opus-4-8",
    "messages": [{"role":"user","content":"Stream a haiku"}],
    "stream": true
  }'

# data: {"choices":[{"delta":{"content":"Silent"}}]}
# data: {"choices":[{"delta":{"content":" code"}}]}
# data: [DONE]

List models

Returns the catalog of models you can call, in OpenAI list format.

GET/v1/models
models.sh
curl https://modeldatabase.com/v1/models \
  -H "Authorization: Bearer $MDB_API_KEY"

Health

A public, unauthenticated liveness check — useful for uptime monitors.

GET/v1/health

Response headers

Every successful billable call returns three headers so you can track spend in real time — no extra API call required.

HeaderMeaning
X-MDB-Upstream-Cost-USDRaw provider cost for the request.
X-MDB-Charged-USDAmount deducted from your balance for this request.
X-MDB-Balance-USDYour remaining credit balance after the request.

Errors

Errors use standard HTTP status codes with a JSON body containing a detail field.

StatusMeaning
400Malformed JSON, or a missing required field such as model.
401Missing, empty, or invalid API key.
402Insufficient credit — top up your balance to continue. Body includes your current balance_usd.
5xxTransient upstream or server error — safe to retry with backoff.
Note A per-request cost cap rejects any single call whose cost would exceed a safe threshold, protecting you from accidental large spends on runaway prompts.

Billing & credits

Model Database is prepaid and usage-based. Buy a credit pack ($10, $50, or $200) from your dashboard; each request draws down your balance at the model's token rates. Credit never expires, and you can top up at any time.

See Pricing for the full breakdown, or head to your dashboard to add credit and view usage history.

Get your API key →