Docs

Installation

Use BanditDB Cloud and skip the install, or self-host the Rust engine. Either way, your code talks to it through a client SDK (Python or TypeScript/JavaScript), MCP, or plain HTTP.

Option A: BanditDB Cloud (hosted)

BanditDB Cloud runs the same engine for you. You don't install, back up or upgrade anything. Sign in, get a key, and call the API.

  1. Open the BanditDB Console and sign in with Google.
  2. Name your organization. The console creates it and sets up an isolated tenant on the engine.
  3. Create an API key under Settings → API keys, or with one click in the code panel on a campaign's page. The key appears once, in the response that creates it, so copy it then. Only a SHA-256 digest is stored.
  4. Point your code at https://api.banditdb.com, with the key in the BANDITDB_API_KEY environment variable. Keep it out of your source code.
export BANDITDB_URL=https://api.banditdb.com
export BANDITDB_API_KEY=<your API key>

curl -s $BANDITDB_URL/health
# {"status":"ok","version":"2.3.2","features":["neural"]}
import os
from banditdb import Client

db = Client(os.environ["BANDITDB_URL"], api_key=os.environ["BANDITDB_API_KEY"])
EndpointWhat it is
ConsoleSign-in, organizations, API keys, members, campaign dashboards, guides, the Playground.
https://api.banditdb.comThe API your code calls. Same endpoints and request format as a self-hosted engine (API Reference).
https://mcp.banditdb.com/mcpRemote MCP server for claude.ai, ChatGPT and other MCP clients. You sign in with OAuth through the console, so no key goes into the client config. See MCP.

Cloud tenants are always namespace-isolated: one organization can never see another organization's campaigns. The console is never in the request path. Keys are pushed to the engine and checked there, so decisions keep being served if the console is down. Limits and prices are on the pricing page. During the beta they are 10 campaigns, 10 requests/second, 64 features per context and a 1-hour reward window.

The Playground

The Playground is in the console's sidebar (Playground). You sketch a campaign in numbered cells: its choices (arms), the signals that describe each case (features, and how each is scaled to 0–1), what a good or bad outcome looks like, and optionally a budget. The code updates beside the cells as you type, in curl, Python, TypeScript and MCP. It opens on an example from the industry you picked at sign-up, and you can switch to other examples. Nothing is saved until you click Make campaign, which creates the campaign on your tenant and opens its live view.

The public sandbox at sandbox.banditdb.com has been retired. Use the Playground in BanditDB Cloud instead.

Option B: Self-host the engine

Binary (fastest, no Docker required)

curl -fsSL https://raw.githubusercontent.com/dynamicpricing-ai/banditdb/main/scripts/install.sh | sh
banditdb
curl http://localhost:8080/health   # {"status":"ok"}

Requires glibc >= 2.39 (Ubuntu 24.04+ or equivalent). On older distros — e.g. Ubuntu 22.04 (glibc 2.35) — the binary won't run. Use Docker or Build from Source below instead.

Windows: the .exe is built without the neural algorithms (NeuralLinUCB and NeuralThompsonSampling). Use Linux, macOS or Docker if you need them.

Docker

docker run -d -p 8080:8080 \
  -e BANDITDB_API_KEYS=admin-key=admin \
  -v banditdb_data:/data \
  simeonlukov/banditdb:latest

Docker Compose (recommended for production)

Includes persistence, RBAC, and auto-checkpointing:

curl -fsSL https://raw.githubusercontent.com/dynamicpricing-ai/banditdb/main/docker-compose.yml -o docker-compose.yml
# Set BANDITDB_API_KEYS=admin-key=admin;app-key=writer in .env
docker compose up -d

Key environment variables:

VariableRequiredDefaultDescription
BANDITDB_API_KEYSProduction—Multi-key RBAC: key1=admin;key2=writer;key3=reader. Without it the server runs in open mode — every caller is granted admin. Fine for local dev, never for production.
BANDITDB_REQUIRE_AUTHProductionfalseSet true so a missing key set is fatal at startup instead of silently opening the database. A mistyped secret then stops the pod rather than publishing an unauthenticated instance. Enabled by default in the Helm chart.
BANDITDB_CORS_ORIGINSOptionaldeny allComma-separated browser origins allowed to call the API. Empty denies all cross-origin requests; * permits any — avoid that if keys ever reach client-side code. Before 2.0.0 any origin was allowed.
BANDITDB_METRICS_PUBLICOptionalfalse/metrics requires a reader key by default, since its output names campaigns and arms. Set true to restore anonymous access for a scraper that cannot send headers.
BANDITDB_TENANT_MODEOptionalfalseSet true to enable multi-tenancy. Requires tenant-scoped keys in BANDITDB_API_KEYS: key=role:tenant_id, e.g. acme-key=writer:acme;globex-key=writer:globex. Each tenant's campaigns are namespaced and isolated — a key can only see/write its own tenant's data.
BANDITDB_CHECKPOINT_INTERVALOptionaloffAuto-checkpoint after N rewarded events
BANDITDB_MAX_WAL_SIZE_MBOptional128Checkpoint when the WAL exceeds N MB. 0 disables the size trigger.
DATA_DIROptional/dataWAL, checkpoint, and Parquet export directory. Set it to a persistent volume — the default in a plain binary run is the current directory.
PORTOptional8080HTTP listen port
LOG_FORMATOptionalunsetLog output format. Unset (default): human-readable text, best for terminals and docker logs. json: one structured JSON object per line — for CloudWatch, Datadog, Splunk, Loki and other log aggregators. Any other value falls back to text.
RUST_LOGOptionalinfoLog verbosity filter. Examples: debug (everything), warn (quiet), banditdb=debug,tower_http=warn (per-module). Standard Rust EnvFilter syntax.
BANDITDB_RATE_LIMIT_PER_SECOptional1000Per-key request rate limit. Raise it for load tests and bulk backfill — the default will quietly fail a tight ingest loop with 429s.
BANDITDB_MAX_PENDING_INTERACTIONSOptional100000Ceiling on predictions awaiting a reward, roughly 1 KB each. TTL alone does not bound this: at 1,000 predictions/second the 24-hour default would hold 86 million records. Eviction permanently breaks reward matching for that prediction, so alert on banditdb_interactions_evicted_total.
BANDITDB_MAX_CONTEXT_MAGNITUDEOptional1e6Largest absolute value accepted in a context vector. Guards against values that overflow the rank-one update and poison the campaign with NaN.
BANDITDB_EXPORT_RETAIN_SHARDSOptional50Parquet shards kept per campaign. 0 keeps everything, which grows until the volume fills and checkpointing starts failing.
BANDITDB_FSYNC_INTERVAL_MSOptional200Group-commit window. Measured to make almost no difference across a 20× range — the writer also syncs whenever it goes idle — so this is not a useful tuning lever. Leave it.

Kubernetes (Helm)

helm install banditdb ./helm/banditdb \
  --set auth.apiKeys="admin-key=admin;app-key=writer" \
  --set persistence.size=10Gi \
  --set ingress.enabled=true \
  --set ingress.host=banditdb.example.com

The Helm chart includes a PersistentVolumeClaim, Secret for API keys, liveness/readiness probes, and a Recreate deployment strategy — required for single-writer WAL safety.

Build from source

Requires Rust 1.97 or newer.

git clone https://github.com/dynamicpricing-ai/banditdb
cd banditdb
cargo build --release                        # standard build
# cargo build --release --features neural   # with NeuralLinUCB / NeuralThompsonSampling
./target/release/banditdb

One process per data directory. BanditDB takes an exclusive lock on DATA_DIR; a second process on the same volume refuses to start. Two writers would interleave WAL appends and corrupt both copies with no error at the time, so this is enforced rather than documented. It is also why the Helm chart pins replicaCount: 1 with the Recreate strategy.

Install the SDK

The same SDKs work with Cloud and with a self-hosted engine. Only the URL and the key change.

Python

pip install banditdb-python
from banditdb import Client
db = Client("http://localhost:8080", api_key="your-secret-key")

Smallest possible working loop — create a campaign, ask for a decision, report the outcome:

# One campaign: which button color converts best?
db.create_campaign("button-color", arms=["red", "green", "blue"], feature_dim=2)

# Ask for a decision. Context: [is_mobile, is_returning_visitor]
arm, interaction_id = db.predict("button-color", [1.0, 0.0])
print(arm)  # e.g. "green"

# Report what happened: 1.0 = clicked, 0.0 = ignored
db.reward(interaction_id, 1.0)

Normalise your context if the features are on different scales. It matters more than it looks: the exploration term scales with the vector's magnitude, and unnormalised input still converges — just far more slowly, with no error to tell you. On one benchmark this single change cut cumulative regret from 2,026 to 709.

from banditdb import normalize_context

ctx = normalize_context([age, income, sessions])   # unit L2 norm
arm, iid = db.predict("button-color", ctx)

SDK 0.2.0 requires server 2.0.0 or newer. It also validates locally before sending, so a bad context raises ValueError naming the offending index rather than costing a round trip.

That is the whole API surface you need day to day. See Quick Start for a realistic end-to-end example.

TypeScript / JavaScript

npm install banditdb-js
import { BanditDBClient } from "banditdb-js";
const db = new BanditDBClient({ url: "http://localhost:8080", apiKey: "your-secret-key" });

await db.createCampaign("button-color", { arms: ["red", "green", "blue"], feature_dim: 2 });

const { arm_id, interaction_id } = await db.predict("button-color", [1.0, 0.0]);
console.log(arm_id); // e.g. "green"

await db.reward(interaction_id, 1.0);

HTTP (no SDK)

Every SDK call is a plain JSON HTTP request. Use X-Api-Key header when auth is enabled:

curl -s http://localhost:8080/health
# {"status":"ok",...}

curl -s -X POST http://localhost:8080/predict \
  -H "Content-Type: application/json" \
  -H "X-Api-Key: your-secret-key" \
  -d '{"campaign_id":"my-campaign","context":[1.0,0.5,0.3]}'