Authentication
How to authenticate requests to the LLMBase API using Bearer tokens.
Updated
Authenticated requests to https://api.llmbase.ai/v1/* must include a valid
API key in the Authorization header using the Bearer scheme.
Inference API keys use the llmbase_... prefix and work at
https://api.llmbase.ai/v1. They spend prepaid inference credits. Chat-agent
keys use the llmbase_chat_... prefix, work only at
https://llmbase.ai/api/v1/agents, and use the included Pro Chat/Agent
subscription budget. Do not use a chat-agent key with
https://api.llmbase.ai/v1.
| Key prefix | Valid base URL | Product | Notes |
|---|---|---|---|
llmbase_... | https://api.llmbase.ai/v1 | Inference API | Prepaid credits only |
llmbase_chat_... | https://llmbase.ai/api/v1/agents | Agent integrations | Uses the included Pro Chat/Agent subscription budget |
Per-key monthly spend caps apply only to llmbase_... inference API keys.
Chat-agent keys are subscription access credentials: they can be individually
revoked, but their included subscription budget is account-level.
The legacy chat-agent base URL, https://llmbase.ai/api/chat-agent/v1, remains
available for existing clients. New OpenClaw, Hermes, and OpenAI-compatible
agent setups should use https://llmbase.ai/api/v1/agents.
Send the Bearer header on every API request, including model discovery, so the request uses the documented API authentication flow consistently.
Sending your API key
Authorization: Bearer <your-api-key>
curl
curl https://api.llmbase.ai/v1/chat/completions \
-H "Authorization: Bearer $LLMBASE_API_KEY" \
-H "Content-Type: application/json" \
-d '{ "model": "<model-id-from-/v1/models>", "messages": [{ "role": "user", "content": "Hi" }] }'
OpenAI SDK
Pass the key as apiKey when constructing the client.
The SDK automatically adds the Authorization: Bearer header to every request,
so SDK requests use the same authentication flow as the curl example.
import OpenAI from "openai";
const client = new OpenAI({
baseURL: "https://api.llmbase.ai/v1",
apiKey: process.env.LLMBASE_API_KEY, // never hard-code keys
});
Credits and balance
Inference API keys spend prepaid USD credits. Chat-agent keys use the included
Pro Chat/Agent subscription budget and do not spend prepaid inference credits.
If an inference request needs prepaid credits and no balance is available,
LLMBase returns 402 with insufficient_quota before running the model
request.
Check the live API balance programmatically:
curl https://api.llmbase.ai/v1/balance \
-H "Authorization: Bearer $LLMBASE_API_KEY"
Response
{
"balance_usd_cents": 500
}
Add credits and configure auto top-up from Dashboard -> API Keys / Balance. Chat subscriptions and chat-agent keys do not add or spend prepaid inference credits.
Keeping your key safe
- Store keys in environment variables or a secrets manager — never commit them to source control.
- Rotate keys immediately if you suspect they have been exposed.
- Use one key per application so you can revoke them independently.
Error responses
A missing or invalid key returns a 401 response:
{
"error": {
"message": "Invalid API key",
"type": "invalid_request_error",
"code": "invalid_api_key"
}
}
| Code | Meaning |
|---|---|
missing_api_key | No Authorization header was sent |
invalid_api_key | The key was not recognised |