Developers
Alalvera SDK
Connect any custom AI agent to Alalvera, whatever model it runs on and whichever coding assistant built it. Add one call where a conversation ends: the SDK sends it in the background, and your Alalvera account audits it and reports proven errors with their evidence.
Version 0.1.0JavaScript and TypeScript, and Python.Available
The packages are not published to npm and PyPI yet. The install commands on this page work once they are.
Your server
Where a conversation ends, one call: sendConversation()
- Chat closed
- Ticket resolved
- Timed out
Your bot
Answers without waiting.
Alalvera SDK
- Removes emails, cards and phones
- Sends in the background
- Retries by itself
- Never throws into your code
Your Alalvera account
Audits every conversation against your own rules.
- Proven errors
- Evidence
- Alerts
Overview
The SDK is a small library for your server. Call it once when a conversation with a customer is finished. It checks the conversation against one schema, removes email addresses, card numbers and phone numbers, and sends it to Alalvera in the background. Your bot never waits for it, and it never throws an error into your code.
It is how any custom chatbot gets monitored from your Alalvera account: whatever model writes the answers, and whether you, your team or a coding assistant wrote the code. It sends text and nothing else.
- JavaScript and TypeScript:
@alalvera/sdk. No dependencies. An ES module for Node 18 or newer, Bun, Deno and edge runtimes, anything withfetch. - Python:
alalvera. The standard library only, Python 3.8 or newer. The client is thread safe.
Before you start
- An active Alalvera subscription. Keys are issued only to one. Connecting a custom AI agent is not part of the 100 free audits. Subscriptions are activated by our team for now: talk to us.
- Server code where a conversation ends. The key belongs on your server, never in a browser or an app on a customer's device.
- Your own conversation ids. Each conversation is sent once, under an id that does not change.
Install
Not published yet: these commands work once the packages are on npm and PyPI, and the status at the top of this page changes when they are.
npm install @alalvera/sdk@0.1.0
pip install alalvera==0.1.0
CommonJS projects: require("@alalvera/sdk") works on Node 20.19 and 22.12 or newer. On older Node, use await import("@alalvera/sdk").
Your API key
Create a key in your Alalvera account, under Custom AI agent. A key is issued only while your subscription is active, and it is shown once: it cannot be shown again, so store it straight away.
Store it as the ALALVERA_API_KEY environment variable wherever your bot's server runs, in your secret manager or your hosting settings. Never put it in code, in git, in a browser or in a chat with a coding assistant. Without a key every SDK call does nothing, so local development and tests need none.
Rotate
Rotating gives you a new key for the same integration. The old one keeps working for 24 hours while you swap it, then stops.
Revoke
Revoking stops a key at once. The SDK then stops sending and your bot keeps working. You can revoke a key at any time, also without a subscription.
Create the client
One client per server process, created at module level and shared. The key comes only from the environment.
import { Alalvera } from "@alalvera/sdk";
// One client per process. Without ALALVERA_API_KEY every call does nothing.
export const alalvera = new Alalvera({ apiKey: process.env.ALALVERA_API_KEY });
import os
from alalvera import Alalvera
# One client per process. Without ALALVERA_API_KEY every call does nothing.
alalvera = Alalvera(api_key=os.environ.get("ALALVERA_API_KEY"))
Send a finished conversation
Call it once per conversation, when the conversation is finished: the customer closed the chat, a person on your team resolved it, or it timed out, for example after 30 minutes without a new message. Call it after the bot's last reply has been sent.
// Returns at once: it sends in the background and never throws.
alalvera.sendConversation({
externalId: "conv-1042",
endedAt: new Date(),
messages: [
{ id: "m1", role: "customer", text: "How long is delivery?", sentAt: "2026-11-02T10:12:00Z" },
{ id: "m2", role: "bot", text: "Delivery takes 3 to 5 business days.", sentAt: "2026-11-02T10:12:05Z" },
],
});
from datetime import datetime, timezone
# Returns at once: a background thread sends it, and it never raises.
alalvera.send_conversation(
external_id="conv-1042",
ended_at=datetime.now(timezone.utc),
messages=[
{"id": "m1", "role": "customer", "text": "How long is delivery?", "sent_at": "2026-11-02T10:12:00Z"},
{"id": "m2", "role": "bot", "text": "Delivery takes 3 to 5 business days.", "sent_at": "2026-11-02T10:12:05Z"},
],
)
- Three roles:
customer,botandhuman_agent. Map yourusertocustomerandassistanttobot. Never send system prompts, tool calls or tool results. - Once, with every message. The same id sent again is ignored as a duplicate, so sending after every reply would audit only the first reply.
- Never await it on the code path that answers the customer. It returns at once.
- Defaults: message ids are m1, m2 and so on by position, a message's time is the conversation's end, and the end is now. Times are a
Date, an ISO 8601 string or epoch milliseconds in JavaScript, and adatetime, an ISO 8601 string or epoch seconds in Python. - A conversation with no messages sends nothing.
Record as it happens
If it is easier, record the conversation message by message and end it when it is finished. Ids and times are filled in.
const recording = alalvera.conversation("conv-1042");
recording.customer("How long is delivery?");
recording.bot(reply); // after your bot's reply is produced
recording.end(); // when the conversation is finished
recording = alalvera.conversation("conv-1042")
recording.customer("How long is delivery?")
recording.bot(reply) # after your bot's reply is produced
recording.end() # when the conversation is finished
A person on your team writes with recording.humanAgent(text) in JavaScript and recording.human_agent(text) in Python. A second end() does nothing.
Test the connection
test() is the one call you wait for on purpose. It sends a two message sample conversation that is checked and never stored, audited or counted. Your Alalvera account then shows the integration as connected. Run it once, with ALALVERA_API_KEY set in your shell.
node --input-type=module -e "import { Alalvera } from '@alalvera/sdk'; console.log(await new Alalvera({ apiKey: process.env.ALALVERA_API_KEY }).test())"
# Expected: { ok: true, status: 200 }
python -c "import os; from alalvera import Alalvera; print(Alalvera(api_key=os.environ.get('ALALVERA_API_KEY')).test())"
# Expected: {'ok': True, 'status': 200, 'error': None, 'message': None}
| error | What it means |
|---|---|
invalid_api_key | The key is wrong or revoked. |
subscription_inactive | Your Alalvera subscription is not active. |
disabled | ALALVERA_API_KEY is not set, or the SDK is switched off. |
network_error, timeout | No answer reached your server. Check that it can make outgoing HTTPS requests. |
The conversation schema
Every way in, the SDK, the REST API and file uploads, takes the same body: alalvera.conversation.v1. The SDK builds it for you. This is what it sends.
{
"schema": "alalvera.conversation.v1",
"platform": "my-bot",
"external_id": "conv-1042",
"ended_at": "2026-11-02T10:15:00Z",
"messages": [
{ "id": "m1", "role": "customer", "text": "How long is delivery?", "sent_at": "2026-11-02T10:12:00Z" },
{ "id": "m2", "role": "bot", "text": "Delivery takes 3 to 5 business days.", "sent_at": "2026-11-02T10:12:05Z" }
]
}
| Field | What it is |
|---|---|
schema | alalvera.conversation.v1. Optional; any other value is refused. |
platform | Names the bot: sdk by default. Set your own when you run more than one bot. |
external_id | Your id for the conversation. With platform it identifies the conversation: the same pair sent again is stored, audited and counted once. |
ended_at | When the conversation finished, ISO 8601 in UTC. Only finished conversations are audited. |
messages[].id | Unique inside the conversation. |
messages[].role | customer, bot or human_agent. |
messages[].text | What was said, after redaction. |
messages[].sent_at | When the message was sent, ISO 8601 in UTC. |
Anything else in the body is ignored and not stored. One request carries at most 1 MB. A conversation that has not ended, or in which the bot said nothing, is answered as skipped and is not stored: send it again once it is finished.
How the SDK behaves
It is built around one rule: it must never block or break your bot.
- Your bot never waits. Every call returns at once. Sending happens in the background, on a background thread in Python.
- It never throws into your code. No method throws, rejects or raises. Every problem goes to your
onErrorhandler (on_errorin Python), or is printed as a warning at most once a minute for each kind. - It retries by itself. Network errors, timeouts, 429 (after the wait its Retry-After asks for) and 5xx answers are tried again with growing pauses, up to 6 attempts per conversation.
- It stops on a refused key. A 401 means no later request can work, so the client stops sending and says so once.
- It removes personal details first. Email addresses become
[email], card numbers[card]and phone numbers of 9 or more digits[phone], before anything leaves your server. - It never sends a conversation unredacted. If your own redact function fails, that conversation is dropped.
- It keeps the key to itself. The key goes only in the Authorization header to the Alalvera API. It is never logged, and a redirect is never followed with the key attached.
- It cannot fill your memory. At most 1,000 conversations wait by default. When that is full, new ones are dropped and reported.
Options
Passed to the constructor. In Python the names are in snake case and times are in seconds.
| Option | Default | What it does |
|---|---|---|
apiKey | ALALVERA_API_KEY | Without a key every call does nothing. |
baseUrl | ALALVERA_API_URL | Otherwise https://api.alalvera.net. |
platform | "sdk" | Names each bot when you run more than one. |
redact | "default" | false sends the text as is; your own function replaces the default. |
maxQueue | 1000 | Conversations held at most. When full, new ones are dropped and reported. |
maxAttempts | 6 | Tries per conversation. |
timeoutMs | 10000 | Per request. In Python, timeout in seconds. |
onError | prints a warning | Called once for each conversation that will not be delivered. |
disabled | ALALVERA_DISABLED | true turns every call into a no-op. |
fetch | global fetch | JavaScript only, for runtimes without one. |
Scripts and serverless functions
A long running server needs nothing more. A script, a queue worker or a serverless function can end before the background send is done, so let it finish.
flush(timeout)resolves totrueonce everything queued is delivered, orfalseat the timeout, 5 seconds by default. It never rejects.close()flushes, then stops the client: later calls do nothing.- Python also waits up to 2 seconds by itself at a normal interpreter exit.
- Next.js 15.1 or newer:
after(() => alalvera.flush(5000))fromnext/server. Older versions:await alalvera.flush(5000)before returning. - Cloudflare Workers: pass the key explicitly and use
ctx.waitUntil(alalvera.flush()).
Errors and status codes
The API answers every error as { "error": "<code>", "message": "<one sentence>" }. The code is stable; the message may change. This is what the SDK does with each answer, so you do not have to.
| Status | Code | What the SDK does |
|---|---|---|
| 202 | queued, skipped | Done. A skipped conversation was not finished: send it again when it is. |
| 200 | test_ok | The answer to test(). |
| 400 | invalid_conversation, unsupported_schema, invalid_json | Drops it and reports it. |
| 401 | invalid_api_key | Drops it, reports it and stops sending. |
| 402 | subscription_inactive | Drops it and reports it. Keys work only while the subscription is active. |
| 413 | too_large | Drops it and reports it. The limit is 1 MB. |
| 415 | unsupported_media_type | Drops it and reports it. |
| 429 | rate_limited | Waits as long as Retry-After says, then tries again. |
| 5xx | internal_error | Tries again with growing pauses. |
| none | network error, timeout | Tries again with growing pauses. |
Limits: 600 requests a minute per key, and 1 MB per request. In your account, creating a key without an active subscription is refused with 402 subscription_required.
Your onError handler receives one error per conversation that will not be delivered, with a code: disabled, invalid_conversation, redact_failed, too_large, queue_full, network_error, timeout, rate_limited, server_error, invalid_api_key, subscription_inactive or another API code. It also carries the HTTP status when there was one, your conversation id and the number of attempts.
Frameworks
The code your account gives you for each stack. It is the same for every customer and never contains a key: it reads ALALVERA_API_KEY from the environment.
// alalvera.ts: one Alalvera client for the whole server process.
import { Alalvera, type Role } from "@alalvera/sdk";
// The key comes only from the environment. Without it every call does
// nothing, so local development and tests need no key.
export const alalvera = new Alalvera({ apiKey: process.env.ALALVERA_API_KEY });
// Your stored messages use your own roles; map them to Alalvera's three.
// System prompts, tool calls and tool results are never sent.
function toAlalveraRole(role: string): Role | null {
if (role === "user") return "customer";
if (role === "assistant") return "bot";
if (role === "agent") return "human_agent";
return null;
}
interface StoredConversation {
id: string;
messages: { id: string; role: string; text: string; createdAt: Date }[];
}
// Call once per conversation, when it is finished (closed, resolved or timed
// out), after the bot's last reply. Returns at once: it sends in the
// background, retries on its own and never throws. Never await it on the path
// that answers the customer.
export function conversationFinished(conversation: StoredConversation): void {
alalvera.sendConversation({
externalId: conversation.id,
endedAt: new Date(),
messages: conversation.messages.flatMap((message) => {
const role = toAlalveraRole(message.role);
return role === null ? [] : [{ id: message.id, role, text: message.text, sentAt: message.createdAt }];
}),
});
}
// Or record the conversation as it happens:
// const recording = alalvera.conversation(conversationId);
// recording.customer(customerText); // when the customer writes
// recording.bot(replyText); // after your bot's reply is produced
// recording.end(); // when the conversation is finished
// Scripts, queue workers and serverless functions, before the process ends:
// await alalvera.flush();
import express from "express";
import { Alalvera, type Role } from "@alalvera/sdk";
import { loadConversation } from "./conversations.js"; // your own storage
// One client per process, created at startup. The key comes only from the
// environment; without it every call does nothing.
const alalvera = new Alalvera({ apiKey: process.env.ALALVERA_API_KEY });
// Your stored messages use your own roles; map them to Alalvera's three.
// System prompts, tool calls and tool results are never sent.
function toAlalveraRole(role: string): Role | null {
if (role === "user") return "customer";
if (role === "assistant") return "bot";
if (role === "agent") return "human_agent";
return null;
}
const app = express();
app.use(express.json());
// Your chat route stays exactly as it is: the bot answers without waiting
// for Alalvera.
// Called when the conversation is finished: the widget's "close chat", a
// resolved ticket, or your job that ends idle sessions.
app.post("/chat/:id/end", async (req, res) => {
const conversation = await loadConversation(req.params.id);
if (conversation) {
// Returns at once: it sends in the background and never throws.
alalvera.sendConversation({
externalId: conversation.id,
endedAt: new Date(),
messages: conversation.messages.flatMap((message) => {
const role = toAlalveraRole(message.role);
return role === null ? [] : [{ id: message.id, role, text: message.text, sentAt: message.createdAt }];
}),
});
}
res.sendStatus(204);
});
app.listen(3000);
// lib/alalvera.ts: server code only; never import it from a "use client" file.
import { Alalvera, type Role } from "@alalvera/sdk";
// One client per server instance. The key comes only from the environment;
// never name it NEXT_PUBLIC_..., which would publish it to every visitor.
export const alalvera = new Alalvera({ apiKey: process.env.ALALVERA_API_KEY });
// Your stored messages use your own roles; map them to Alalvera's three.
// System prompts, tool calls and tool results are never sent.
export function toAlalveraRole(role: string): Role | null {
if (role === "user") return "customer";
if (role === "assistant") return "bot";
if (role === "agent") return "human_agent";
return null;
}
// app/api/chat/[id]/end/route.ts: called when the conversation is finished
// (the widget's "close chat", a resolved ticket, or your idle-session job).
import { after } from "next/server";
import { alalvera, toAlalveraRole } from "@/lib/alalvera";
import { loadConversation } from "@/lib/conversations"; // your own storage
export async function POST(_request: Request, { params }: { params: Promise<{ id: string }> }) {
const { id } = await params;
const conversation = await loadConversation(id);
if (conversation) {
// Returns at once: it sends in the background and never throws.
alalvera.sendConversation({
externalId: conversation.id,
endedAt: new Date(),
messages: conversation.messages.flatMap((message) => {
const role = toAlalveraRole(message.role);
return role === null ? [] : [{ id: message.id, role, text: message.text, sentAt: message.createdAt }];
}),
});
// A serverless function can be frozen once the response is sent; after()
// keeps it alive until the conversation is delivered (at most 5 s).
// Before Next.js 15.1: await alalvera.flush(5000) here instead.
after(() => alalvera.flush(5000));
}
return new Response(null, { status: 204 });
}
# alalvera_client.py: one Alalvera client for the whole process.
import os
from datetime import datetime, timezone
from alalvera import Alalvera
# The key comes only from the environment. Without it every call does
# nothing, so local development and tests need no key.
alalvera = Alalvera(api_key=os.environ.get("ALALVERA_API_KEY"))
# Your stored messages use your own roles; map them to Alalvera's three.
# System prompts, tool calls and tool results are never sent.
ROLES = {"user": "customer", "assistant": "bot", "agent": "human_agent"}
def conversation_finished(conversation):
"""Call once per conversation, when it is finished (closed, resolved or
timed out), after the bot's last reply. Returns at once: a background
thread sends it, retries on its own and never raises."""
alalvera.send_conversation(
external_id=conversation.id,
ended_at=datetime.now(timezone.utc),
messages=[
{"id": m.id, "role": ROLES[m.role], "text": m.text, "sent_at": m.created_at}
for m in conversation.messages
if m.role in ROLES
],
)
# Or record the conversation as it happens:
# recording = alalvera.conversation(conversation_id)
# recording.customer(customer_text) # when the customer writes
# recording.bot(reply_text) # after your bot's reply is produced
# recording.end() # when the conversation is finished
# Scripts, task workers and serverless functions, before the process ends:
# alalvera.flush()
import os
from contextlib import asynccontextmanager
from datetime import datetime, timezone
from fastapi import FastAPI
from alalvera import Alalvera
from .conversations import load_conversation # your own storage
# One client per process. The key comes only from the environment; without
# it every call does nothing.
alalvera = Alalvera(api_key=os.environ.get("ALALVERA_API_KEY"))
# Your stored messages use your own roles; map them to Alalvera's three.
# System prompts, tool calls and tool results are never sent.
ROLES = {"user": "customer", "assistant": "bot", "agent": "human_agent"}
@asynccontextmanager
async def lifespan(app: FastAPI):
yield
# At shutdown, send what is still queued (waits at most 5 seconds).
alalvera.close()
app = FastAPI(lifespan=lifespan)
# Your chat endpoint stays exactly as it is: the bot answers without waiting
# for Alalvera.
# Called when the conversation is finished: the widget's "close chat", a
# resolved ticket, or your job that ends idle sessions.
@app.post("/chat/{conversation_id}/end")
async def end_chat(conversation_id: str):
conversation = await load_conversation(conversation_id)
if conversation is not None:
# Returns at once (safe in async def): a background thread sends it.
alalvera.send_conversation(
external_id=conversation.id,
ended_at=datetime.now(timezone.utc),
messages=[
{"id": m.id, "role": ROLES[m.role], "text": m.text, "sent_at": m.created_at}
for m in conversation.messages
if m.role in ROLES
],
)
return {"status": "ended"}
import os
from datetime import datetime, timezone
from flask import Flask
from alalvera import Alalvera
from conversations import load_conversation # your own storage
# One client per process; under gunicorn each worker starts its own sender
# thread on first use. The key comes only from the environment; without it
# every call does nothing.
alalvera = Alalvera(api_key=os.environ.get("ALALVERA_API_KEY"))
# Your stored messages use your own roles; map them to Alalvera's three.
# System prompts, tool calls and tool results are never sent.
ROLES = {"user": "customer", "assistant": "bot", "agent": "human_agent"}
app = Flask(__name__)
# Your chat route stays exactly as it is: the bot answers without waiting
# for Alalvera.
# Called when the conversation is finished: the widget's "close chat", a
# resolved ticket, or your job that ends idle sessions.
@app.post("/chat/<conversation_id>/end")
def end_chat(conversation_id):
conversation = load_conversation(conversation_id)
if conversation is not None:
# Returns at once: a background thread sends it, and it never raises.
alalvera.send_conversation(
external_id=conversation.id,
ended_at=datetime.now(timezone.utc),
messages=[
{"id": m.id, "role": ROLES[m.role], "text": m.text, "sent_at": m.created_at}
for m in conversation.messages
if m.role in ROLES
],
)
return {"status": "ended"}
The key is not in it. Each version calls the SDK from the place a conversation ends, never from the code that answers the customer.
Notes for each stack
- Express: call it from the route or job that ends a conversation. If your app already handles SIGTERM,
await alalvera.flush(5000)there. - Next.js: keep the client in server code only, never in a
"use client"file, and never name the keyNEXT_PUBLIC_ALALVERA_API_KEY: that would publish it to every visitor. - FastAPI:
send_conversationnever blocks, so it is safe insideasync def. Callalalvera.close()in the app's lifespan shutdown. - Flask: create the client at module level. Under gunicorn each worker starts its own sender thread on first use.
With a coding assistant
Your account gives you a prompt for the stack you pick. Paste it into the coding assistant you already use. It asks for the smallest change: add the SDK, find where a conversation ends, and call it once there. It tells the assistant not to touch your bot's model, prompts or settings, never to handle the key, and to show you the full diff before anything is committed.
I want to connect my customer-service chatbot to Alalvera, an independent service that audits what the bot tells customers. Make the smallest change that does this, then stop and show me the full diff. I will review it myself before anything is committed or deployed.
What to do:
1. Add the official SDK, version 0.1.0: npm install @alalvera/sdk@0.1.0. It has no dependencies and works in TypeScript and JavaScript (ES modules, Node 18 or newer, Bun, Deno and edge runtimes).
2. Create one client per server process, at module level: new Alalvera({ apiKey: process.env.ALALVERA_API_KEY }). The key is read only from the ALALVERA_API_KEY environment variable. If the project has an example env file (such as .env.example), add ALALVERA_API_KEY to it with an empty value.
3. Find where a customer conversation ends in this code: the customer closes the chat, a human agent resolves it, or the session expires. If there is no such point, add one that fits the existing design, for example ending a conversation after 30 minutes without a new message.
4. At that point, after the bot's last reply has been produced and sent, call alalvera.sendConversation({ externalId, endedAt, messages }) once, with every message of the conversation in order: the customer's messages as role "customer", the bot's replies as "bot", a human agent's as "human_agent", each with its id, text and time (sentAt). Use the conversation's own stable id as externalId.
5. Do not await the call and do not put it on the code path that answers the customer: it returns at once, sends in the background, retries on its own and never throws.
6. Send each conversation once. Sending the same id again is ignored as a duplicate, so sending after every reply would audit only the first part of the conversation.
7. If this code runs as a script, a queue worker or a serverless function, await alalvera.flush() before it ends. If the app already handles SIGTERM, await alalvera.flush(5000) there; do not add a new signal handler otherwise.
Do not:
- change the bot's AI model, provider, prompts, system prompt, tools, temperature or any other model setting, or how replies are produced;
- send system prompts, tool calls, tool results, internal notes, customer profiles or any field other than the conversation's messages;
- print, log, hard-code or commit the key, or expose it to browser code;
- wrap the SDK in your own retries, queues or error handling; it already handles failures and never throws;
- change unrelated code or formatting.
When you are done:
- list the files you changed and why;
- tell me how to check it: with ALALVERA_API_KEY set in the shell, run node --input-type=module -e "import { Alalvera } from '@alalvera/sdk'; console.log(await new Alalvera({ apiKey: process.env.ALALVERA_API_KEY }).test())". Expected: { ok: true, status: 200 }. "invalid_api_key" means the key is wrong or revoked, "subscription_inactive" that the Alalvera subscription is not active, "disabled" that ALALVERA_API_KEY is not set.
I want to connect my customer-service chatbot to Alalvera, an independent service that audits what the bot tells customers. Make the smallest change that does this, then stop and show me the full diff. I will review it myself before anything is committed or deployed.
What to do:
1. Add the official SDK, version 0.1.0: pip install alalvera==0.1.0. It uses only the Python standard library (Python 3.8 or newer).
2. Create one client per server process, at module level: Alalvera(api_key=os.environ.get("ALALVERA_API_KEY")). The key is read only from the ALALVERA_API_KEY environment variable. If the project has an example env file (such as .env.example), add ALALVERA_API_KEY to it with an empty value.
3. Find where a customer conversation ends in this code: the customer closes the chat, a human agent resolves it, or the session expires. If there is no such point, add one that fits the existing design, for example ending a conversation after 30 minutes without a new message.
4. At that point, after the bot's last reply has been produced and sent, call alalvera.send_conversation(external_id, ended_at, messages) once, with every message of the conversation in order: the customer's messages as role "customer", the bot's replies as "bot", a human agent's as "human_agent", each with its id, text and time (sent_at). Use the conversation's own stable id as external_id.
5. Do not await the call and do not put it on the code path that answers the customer: it returns at once, sends in the background, retries on its own and never throws.
6. Send each conversation once. Sending the same id again is ignored as a duplicate, so sending after every reply would audit only the first part of the conversation.
7. If this code runs as a script, a task worker or a serverless function, call alalvera.flush() before it ends.
Do not:
- change the bot's AI model, provider, prompts, system prompt, tools, temperature or any other model setting, or how replies are produced;
- send system prompts, tool calls, tool results, internal notes, customer profiles or any field other than the conversation's messages;
- print, log, hard-code or commit the key, or expose it to browser code;
- wrap the SDK in your own retries, queues or error handling; it already handles failures and never throws;
- change unrelated code or formatting.
When you are done:
- list the files you changed and why;
- tell me how to check it: with ALALVERA_API_KEY set in the shell, run python -c "import os; from alalvera import Alalvera; print(Alalvera(api_key=os.environ.get('ALALVERA_API_KEY')).test())". Expected: {'ok': True, 'status': 200, 'error': None, 'message': None}. "invalid_api_key" means the key is wrong or revoked, "subscription_inactive" that the Alalvera subscription is not active, "disabled" that ALALVERA_API_KEY is not set.
The key is not in it. The prompt names the environment variable; the value stays on your server.
The steps in your account, from key to first audited conversation, are on the custom AI agent page.
Privacy
- Sent, for each finished conversation: your conversation id, when it ended, and each message's id, role, text and time. Nothing else: no metadata, customer profile, IP address, hostname, environment variable, system prompt or model setting.
- Removed first. Before anything leaves your server, email addresses become
[email], card numbers[card]and phone numbers[phone], in every message. Prices, percentages, day counts and order thresholds stay, because the audit checks exactly those. - Your own rule. Pass your own
redactfunction to replace the default, or turn redaction off withredact: false(redact=Falsein Python). If your function fails, the conversation is dropped, never sent unredacted. - In transit. Conversations go over HTTPS to the Alalvera API, with your key in the Authorization header.
- What we keep. Transcripts are deleted after 90 days by default; you can choose from 7 to 3,650 days. See data and privacy.
Disconnect
Revoke the key
In your Alalvera account. It stops working at once; the SDK stops sending for the life of the process, and your bot keeps working.
Remove the variable
Take
ALALVERA_API_KEYout of your environment and secret store. Without a key the SDK does nothing.Remove the code
Delete the Alalvera calls and the package:
npm uninstall @alalvera/sdkorpip uninstall alalvera.
To pause sending without a code change, set ALALVERA_DISABLED=1 and restart.
Other languages: the REST API
No SDK for your language? Send the same body yourself, from server code, with the same key.
POSThttps://api.alalvera.net/v1/conversations
curl https://api.alalvera.net/v1/conversations \
-H "Authorization: Bearer $ALALVERA_API_KEY" \
-H "Content-Type: application/json" \
-d @conversation.json
- Add
"test": trueto the body to check the connection: the key, the subscription and the body are checked, and nothing is stored, audited or counted. - Try again after a 429 once Retry-After has passed, and after a 5xx or a network error with growing pauses. Drop and log anything else. Use the table under errors and status codes.
- Never call it from a browser. The key belongs on your server, and the API sends no CORS headers.
Keys come with the Alalvera subscription.
$99 a month plus $0.15 per conversation for the first 1,000 and $0.05 after that. You subscribe from your account, through the checkout of Paddle, our reseller. Until online payment opens, talk to us and we set yours up.