> ## 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.

# Authenticate requests to the Darkbloom API

> Create and manage API keys for the Darkbloom API. Keys start with sk-db- and are passed as Authorization: Bearer tokens on every request.

Every request to the Darkbloom API requires a credential in the `Authorization` header. API keys use `Bearer sk-db-...`. The coordinator reads credentials only from that header: it ignores `x-api-key`, so clients that send only that header (the Anthropic SDK's default `api_key` option) must be configured to send a bearer token instead.

## Getting an API key

**1. Sign in to the console**

Create an account at [console.darkbloom.dev](https://console.darkbloom.dev). Email is the only console login method.

**2. Open the API console**

Open the API console page (`/api-console`) and choose **Create key**.

**3. Create a key**

Copy the secret when it is shown. It is returned only by create and rotate and cannot be retrieved later. A new key looks like:

```
sk-db-xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
```

**4. Add credits**

API calls are metered. Add credits from **Billing** before sending inference requests. A request whose worst-case reservation cannot be covered returns `402`.

> [!WARNING]
>
> Store your API key in an environment variable or secrets manager. Never commit it to source control or expose it in client-side code.

## Sending the key

```
Authorization: Bearer sk-db-your-key-here
```

```bash curl theme={null}
curl https://api.darkbloom.dev/v1/models \
  -H "Authorization: Bearer sk-db-your-key-here"
```

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

client = OpenAI(
    base_url="https://api.darkbloom.dev/v1",
    api_key="sk-db-your-key-here",
)
```

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

const client = new OpenAI({
  baseURL: "https://api.darkbloom.dev/v1",
  apiKey: "sk-db-your-key-here",
});
```

> [!NOTE]
>
> Keys minted before the rename start with `eigeninference-` and remain valid, because lookups are by hash rather than by prefix. New keys start with `sk-db-`.

## Key settings

A key can carry a spend budget, request and token limits, an allowed-model list, an expiry, or `self_route_only` (for a key that may use only the account's own machines). The settings are enforced in the request prelude:

* `rpm_limit` → `429` before the account limiter.
* `allowed_models` → `403 model_not_allowed`.
* An exhausted `limit_usd` → `402`.
* `expires_at` and `disabled` → `401`.

## Manage keys

Key management requires a Privy session JWT. Calling these routes with an API key returns `403 forbidden`.

```bash theme={null}
POST   /v1/keys                  # create; response {key, data}
GET    /v1/keys                  # list
GET    /v1/keys/{id}             # inspect one
PATCH  /v1/keys/{id}             # change limits, name, models, expiry
POST   /v1/keys/{id}/rotate      # new secret, same settings
DELETE /v1/keys/{id}             # revoke
GET    /v1/key                   # inspect the calling key (accepts the API key)
```

`POST /v1/auth/keys` and `DELETE /v1/auth/keys` are the older one-key-per-account endpoints. They still work, but the `/v1/keys` family is the managed surface. A revocation or limit change can take up to the coordinator's API-key cache TTL to apply everywhere.

Create a key with limits:

```bash theme={null}
curl -X POST https://api.darkbloom.dev/v1/keys \
  -H "Authorization: Bearer <privy-access-token>" \
  -H "Content-Type: application/json" \
  -d '{"name": "ci", "limit_usd": 25, "limit_reset": "monthly", "rpm_limit": 60}'
```

`limit_usd` accepts at most six decimal places. `limit_reset` is `none`, `daily`, `weekly` or `monthly`, aligned to UTC midnight, Monday and the 1st. `GET /v1/keys` shows `usage_usd`, `limit_usd` and `remaining_usd` per key.

The older mint returns `{api_key, account_id}`; the managed create returns `{key, data}`. A key's `label` masks the secret to its prefix, first four and last four characters.

## Authentication errors

**401 authentication\_error** `error`

The `Authorization` header is missing or the key is unknown, disabled, expired or revoked. Check that you pass the full `sk-db-...` value as a bearer token.

**402 insufficient\_funds / insufficient\_quota** `error`

The balance cannot cover the request's reservation, or the key's spend cap is exhausted. Add credits in the console under **Billing**, or raise the key's `limit_usd`.

**403 forbidden** `error`

An API key was used on a route that requires a Privy session, such as key management or payout setup.

**403 model\_not\_allowed** `error`

The requested model is outside the key's `allowed_models` list.

**429 rate\_limit\_exceeded** `error`

A key, account or token limit was hit, or serving capacity is unavailable. Wait for `Retry-After`.


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