Skip to main content

Install the package

npm install openbat

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
The SDK reads these automatically, so you can create a client with no arguments if the environment variables are set:
const client = new OpenBat(); // picks up OPENBAT_API_KEY from env

Getting your API key

1

Open the Settings page

Go to your chatbot’s Settings page in the OpenBat dashboard.
2

Find the API key

Open the General tab. The API key prefix is displayed there.
3

Rotate if needed

If you have lost the full key, click Rotate Key to generate a new one. The full key is shown only at creation or rotation.
4

Set the environment variable

Copy the key and add it to your environment:
OPENBAT_API_KEY=ob_live_your_key_here
Your API key is shown only once when you create or rotate it. Copy it immediately and store it securely. The full key cannot be recovered after you leave the page.

Disabling in test or CI

Set OPENBAT_ENABLED to false in your test environment so the SDK silently skips all API calls. No code changes required.
.env.test
OPENBAT_ENABLED=false
You can also disable the client programmatically in the constructor:
const client = new OpenBat({ enabled: false });

Quick verification

Run a test call to confirm your API key and connection are working:
import { OpenBat } from 'openbat';

const client = new OpenBat();

await client.recordMessages({
  conversationId: "test_123",
  messages: [
    { role: "user", content: "Hello" },
    { role: "assistant", content: "Hi there!" }
  ]
});
If the call completes without error, your SDK is configured correctly. You can now move on to recording messages or integrate with the Vercel AI SDK.