Install the package
Environment variables
| Variable | Description | Default |
|---|
OPENBAT_API_KEY | Your chatbot’s API key (ob_live_...) | Required if not in constructor |
OPENBAT_BASE_URL | API base URL | https://app.openbat.dev |
OPENBAT_ENABLED | Set to "false" or "0" to disable | true |
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
Find the API key
Open the General tab. The API key prefix is displayed there.
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.
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.
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.