> ## Documentation Index
> Fetch the complete documentation index at: https://docs.darkbloom.dev/llms.txt
> Use this file to discover all available pages before exploring further.

# Quickstart: call the Darkbloom API in 5 minutes

> Get an API key, send your first chat completion, and list available models using any OpenAI-compatible SDK. Works with Python, Node.js, and curl.

Darkbloom exposes an OpenAI-compatible API at `https://api.darkbloom.dev/v1`. If you have used the OpenAI SDK before, the main changes are the base URL and your API key. This guide gets you a key, makes your first request, and shows how to discover the current model catalog.

Have an Apple silicon Mac? You can also [run models on your own Mac](https://docs.darkbloom.dev/inference/run-on-your-own-mac.md) with a local OpenAI-compatible API, and pass only the requests it can't take to the network.

**1. Get an API key**

Sign in at [console.darkbloom.dev](https://console.darkbloom.dev) with your email address, open the API console page (`/api-console`), and create a key. The secret starts with `sk-db-` and is shown only once.

```bash theme={null}
export DARKBLOOM_API_KEY="sk-db-..."
```

> [!WARNING]
>
> Store your API key somewhere safe. You cannot view it again after closing the creation dialog; rotate it if you lose it.

**2. Find a model**

`GET /v1/models` is the authoritative catalog. It lists each model's ID, context limits, modalities and prices.

```bash theme={null}
curl -s https://api.darkbloom.dev/v1/models \
  -H "Authorization: Bearer $DARKBLOOM_API_KEY" | jq '.data[] | {id, context_length, input_modalities}'
```

Pick one ID and export it:

```bash theme={null}
export MODEL="<an id from the list>"
```

A model that is listed but has no `routable_providers` is temporarily at capacity. Requests queue or return `429` with `Retry-After`; it is not a missing model.

**3. Send your first chat completion**

```python Python theme={null}
import os
from openai import OpenAI

client = OpenAI(
    base_url="https://api.darkbloom.dev/v1",
    api_key=os.environ["DARKBLOOM_API_KEY"],
)

response = client.chat.completions.create(
    model=os.environ["MODEL"],
    messages=[
        {"role": "user", "content": "Explain the difference between a mutex and a semaphore."}
    ],
)

print(response.choices[0].message.content)
```

```javascript Node.js theme={null}
import OpenAI from "openai";

const client = new OpenAI({
  baseURL: "https://api.darkbloom.dev/v1",
  apiKey: process.env.DARKBLOOM_API_KEY,
});

const response = await client.chat.completions.create({
  model: process.env.MODEL,
  messages: [
    { role: "user", content: "Explain the difference between a mutex and a semaphore." }
  ],
});

console.log(response.choices[0].message.content);
```

```bash curl theme={null}
curl https://api.darkbloom.dev/v1/chat/completions \
  -H "Authorization: Bearer $DARKBLOOM_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "model": "'"$MODEL"'",
    "messages": [
      {"role": "user", "content": "Explain the difference between a mutex and a semaphore."}
    ]
  }'
```

**4. Stream a response**

Add `stream=True` (Python) or `stream: true` (Node.js) to receive tokens as they are generated instead of waiting for the full response.

```python Python theme={null}
stream = client.chat.completions.create(
    model=os.environ["MODEL"],
    messages=[
        {"role": "user", "content": "Write a haiku about distributed systems."}
    ],
    stream=True,
)

for chunk in stream:
    delta = chunk.choices[0].delta.content
    if delta:
        print(delta, end="", flush=True)
```

```javascript Node.js theme={null}
const stream = await client.chat.completions.create({
  model: process.env.MODEL,
  messages: [
    { role: "user", content: "Write a haiku about distributed systems." }
  ],
  stream: true,
});

for await (const chunk of stream) {
  const delta = chunk.choices[0]?.delta?.content;
  if (delta) process.stdout.write(delta);
}
```

```bash curl theme={null}
curl -N https://api.darkbloom.dev/v1/chat/completions \
  -H "Authorization: Bearer $DARKBLOOM_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "model": "'"$MODEL"'",
    "messages": [
      {"role": "user", "content": "Write a haiku about distributed systems."}
    ],
    "stream": true
  }'
```

The streaming response uses server-sent events. Each event is a `data:` field carrying a JSON chunk, and the stream ends with `data: [DONE]`. There may be no output until a provider has produced the first content; a real error status can still arrive in that window.

## Use the Responses API

`POST /v1/responses` is registered on the same handler as chat completions. Send an `input` field instead of `messages`:

```bash theme={null}
curl https://api.darkbloom.dev/v1/responses \
  -H "Authorization: Bearer $DARKBLOOM_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "model": "'"$MODEL"'",
    "input": "Say hello in one sentence."
  }'
```

## Use the Anthropic Messages API

Darkbloom also serves `POST /v1/messages`. The coordinator reads credentials only from `Authorization: Bearer`, and the Anthropic SDK's `api_key` option sends `x-api-key` instead, so pass the key as `auth_token`:

```python theme={null}
import os
import anthropic

client = anthropic.Anthropic(
    base_url="https://api.darkbloom.dev",
    auth_token=os.environ["DARKBLOOM_API_KEY"],
)

message = client.messages.create(
    model=os.environ["MODEL"],
    max_tokens=512,
    messages=[
        {"role": "user", "content": "What is the capital of France?"}
    ],
)

print(message.content[0].text)
```

## Handle errors

* `401 authentication_error` — missing or invalid bearer token.
* `402` — the balance cannot cover the request's worst-case reservation, or a key spend cap is exhausted.
* `403 model_not_allowed` — the key's `allowed_models` list excludes the model.
* `404 model_not_found` — the ID is not in `GET /v1/models`.
* `429 rate_limit_exceeded` — wait for `Retry-After`.
* `503 model_unavailable` — no provider can serve the model right now.

> [!NOTE]
>
> Darkbloom is an experimental research prototype. Do not use it in production applications.


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.