BLACKFUEL
Getting Started

Authentication

How to authenticate requests to the Blackfuel API

Pass your API key as a bearer token in the Authorization header of every request.

Getting Your API Key

  1. Go to the API Keys page
  2. Click Create Key, give it a name and slug
  3. Copy and store the key — it's only shown once; beneath it sits a ready-to-run cURL, Python or TypeScript snippet for a first call straight away, showing the key abridged and copying it whole so the pasted command runs unedited. Where the catalog holds no model the snippet can demonstrate, none appears

Keys are not shown again after creation. Store them in a secrets manager or environment variable immediately.

Key Format

Keys follow the pattern bf_<slug>_<random>, for example bf_mykey_xxxxxx:

  • <slug> — a label you choose when creating the key (1–6 lowercase letters or numbers)
  • <random> — 32 hex characters generated by Blackfuel

The slug is just a label. Blackfuel has a single API environment, so a slug like test or prod does not select an environment — it only helps you identify the key in logs.

Using Your API Key

Set your key as an environment variable:

export BLACKFUEL_API_KEY="bf_mykey_xxxxxx"

Include it in every request via the Authorization header:

Authorization: Bearer $BLACKFUEL_API_KEY

SDKs

import os
import openai

client = openai.OpenAI(
    base_url="https://api.blackfuel.ai/v1",
    api_key=os.environ["BLACKFUEL_API_KEY"],
)
import OpenAI from 'openai';

const client = new OpenAI({
  baseURL: 'https://api.blackfuel.ai/v1',
  apiKey: process.env.BLACKFUEL_API_KEY,
});
curl -X POST https://api.blackfuel.ai/v1/chat/completions \
  -H "Authorization: Bearer $BLACKFUEL_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{"model": "deepseek-ai/DeepSeek-V4-Flash-0731", "messages": [{"role": "user", "content": "Hello"}]}'

Authentication Errors

A missing key and an invalid key both return 401; error.code distinguishes them.

codeDescription
nullNo API key was provided in the request
invalid_api_keyThe key is incorrect or has been revoked

Missing key (401):

{
  "error": {
    "message": "No API key provided. Provide your key in the Authorization header as 'Bearer <YOUR_API_KEY>'. Manage your keys at https://console.blackfuel.ai.",
    "type": "invalid_request_error",
    "param": null,
    "code": null
  }
}

Invalid key (401):

{
  "error": {
    "message": "Incorrect API key provided. Check the key for typos or whether it has been revoked. Manage your keys at https://console.blackfuel.ai.",
    "type": "invalid_request_error",
    "param": null,
    "code": "invalid_api_key"
  }
}

Insufficient balance (402) — a valid key on an account without credit:

{
  "error": {
    "message": "Your account has insufficient balance to process this request. Add credit at https://console.blackfuel.ai or contact [email protected].",
    "type": "insufficient_quota",
    "code": "insufficient_quota",
    "param": null
  }
}

All of these errors use the same structured error object as the rest of the API, so you can branch on error.code — see the Error Handling guide for the full error shape and every status code the API returns.

Key Management

Naming Keys

Each key has a name (descriptive label) and a slug (up to 6 characters, shown in logs).

NameSlug
Production Backendprodbk
Staging APIstgapi
John - Local Devjhndev
CI - GitHub Actionscigha
Project A - Productionpjaprd
Project A - Stagingpjastg

Revoking Keys

If a key is compromised:

  1. Go to the API Keys page immediately
  2. Click Revoke next to the compromised key
  3. Create a new key and update your applications

Security

  • Store in environment variables or a secrets manager — never in source code or client-side bundles.
  • One key per environment and service — limits the blast radius if a key is leaked.
  • Monitor for anomalies — check usage by API key for unexpected activity.

On this page