LLMBase | Docs

Authentication

How to authenticate requests to the LLMBase API using Bearer tokens.

Updated


All requests to https://api.llmbase.ai/v1/* must include a valid API key in the Authorization header using the Bearer scheme.

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": "zai-org/glm-5", "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.

import OpenAI from "openai";

const client = new OpenAI({
  baseURL: "https://api.llmbase.ai/v1",
  apiKey: process.env.LLMBASE_API_KEY, // never hard-code keys
});

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"
  }
}
CodeMeaning
missing_api_keyNo Authorization header was sent
invalid_api_keyThe key was not recognised