Skip to main content

Constructor options

Pass configuration directly when creating a client instance. Any option you provide takes precedence over the corresponding environment variable.
import { OpenBat } from 'openbat';

const client = new OpenBat({
  apiKey: "ob_live_...",       // defaults to OPENBAT_API_KEY env var
  baseUrl: "https://...",      // defaults to OPENBAT_BASE_URL or "https://app.openbat.dev"
  enabled: true                // defaults to OPENBAT_ENABLED env var (true unless "false" or "0")
});
OptionTypeDefaultDescription
apiKeystringOPENBAT_API_KEY env varYour chatbot’s API key. Required either here or as an environment variable.
baseUrlstringOPENBAT_BASE_URL or https://app.openbat.devThe OpenBat API base URL.
enabledbooleantrue (unless env var is "false" or "0")When false, all SDK methods become no-ops.
If no arguments are passed, the SDK reads everything from environment variables:
const client = new OpenBat(); // uses OPENBAT_API_KEY, OPENBAT_BASE_URL, OPENBAT_ENABLED

Environment variables

VariableDescriptionDefault
OPENBAT_API_KEYYour chatbot’s API key (ob_live_...)Required if not in constructor
OPENBAT_BASE_URLAPI base URLhttps://app.openbat.dev
OPENBAT_ENABLEDSet to "false" or "0" to disabletrue
Constructor values always take precedence over environment variables.

API key format

API keys follow this format:
ob_live_<32 lowercase hex characters>
For example:
ob_live_a1b2c3d4e5f6a1b2c3d4e5f6a1b2c3d4
The prefix ob_live_a1b2c3 (roughly the first 14 characters) is stored in the dashboard so you can identify which key is active. The full key is hashed with SHA-256 before storage — only the hash is persisted on the server. You can only view the full key at creation or rotation time.

Disabling the SDK

There are two ways to disable the SDK: Environment variable — set OPENBAT_ENABLED to "false" or "0" in your environment:
.env.test
OPENBAT_ENABLED=false
Constructor option — pass enabled: false when creating the client:
const client = new OpenBat({ enabled: false });
When disabled, recordMessages becomes a no-op. It resolves immediately without making any network requests or throwing errors. This is useful for test and CI environments where you do not want SDK traffic.