SDKs & recipes

There is no SDK to install — the API is a single authenticated POST, so a plain HTTP client in any language works. Below are drop-in recipes.

Node / TypeScript

TypeScript
export async function analyze(message: string) {
  const res = await fetch("https://api.bactlabs.africa/v1/analyze", {
    method: "POST",
    headers: {
      Authorization: `Bearer ${process.env.BACT_API_KEY}`,
      "Content-Type": "application/json",
    },
    body: JSON.stringify({ message }),
  });
  if (!res.ok) throw new Error(`bact ${res.status}`);
  return res.json();
}

Python

Python
import os, requests

def analyze(message: str) -> dict:
    r = requests.post(
        "https://api.bactlabs.africa/v1/analyze",
        headers={"Authorization": f"Bearer {os.environ['BACT_API_KEY']}"},
        json={"message": message},
        timeout=10,
    )
    r.raise_for_status()
    return r.json()

Routing recipe

A common pattern: analyze the inbound message, and if the engine flags a crisis or critical urgency, escalate before calling your LLM.

TypeScript
const { annotation, routing } = await analyze(userMessage);

if (routing.response_posture === "CRISIS_SUPPORT") {
  return escalateToHuman(userMessage);
}

const tone = routing.recommended_tone; // feed into your model's system prompt
return callYourModel(userMessage, { tone });