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
- Go to the API Keys page
- Click Create Key, give it a name and slug
- 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_KEYSDKs
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.
code | Description |
|---|---|
null | No API key was provided in the request |
invalid_api_key | The 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).
| Name | Slug |
|---|---|
Production Backend | prodbk |
Staging API | stgapi |
John - Local Dev | jhndev |
CI - GitHub Actions | cigha |
Project A - Production | pjaprd |
Project A - Staging | pjastg |
Revoking Keys
If a key is compromised:
- Go to the API Keys page immediately
- Click Revoke next to the compromised key
- 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.