Skip to main content

zizkadb-sdk

PyPI: zizkadb-sdk 0.7.0

Python SDK for ZizkaDB — Why did your agent do that? Call db.why(event_id) or zizkadb why <id> after logging with parent_id.

Setup (managed cloud)

  1. Sign up at db.zizka.ai
  2. Dashboard → Create agent (e.g. my-bot) — you get an API key for that agent
  3. Use the same agent name in every db.log() call
  4. Set ZIZKADB_API_KEY (or pass the key to the constructor)

Important: The agent in db.log(agent="...", ...) must match the agent you created in the dashboard. A mismatch returns 403 AgentScopeError.

Install

pip install zizkadb-sdk

Note: There is an unrelated package called agentdb on PyPI. Install zizkadb-sdk. Import: from zizkadb import ZizkaDB.

Scaffold a project

pip install zizkadb-sdk
zizkadb init my-agent --template basic
cd my-agent && cp .env.example .env   # paste your key into ZIZKADB_API_KEY
pip install -r requirements.txt
python agent.py

Templates: basic, openai, langchain, crewai, mcp-cursor.

Framework packages (optional)

Package Install Use case
zizkadb-langchain pip install zizkadb-langchain LangChain callbacks
zizkadb-crewai pip install zizkadb-crewai CrewAI crew logger
zizkadb-livekit pip install zizkadb-livekit LiveKit voice → Sessions + Events

See integrations/ and docs/integrations/livekit.md.

Quickstart

from zizkadb import ZizkaDB

# Key from Dashboard → Settings → API keys → create "my-bot" → copy key
db = ZizkaDB("zizkadb_live_xxxx")

async with db:
    result = await db.log(
        agent="my-bot",  # must match dashboard agent name
        event="tool_call",
        data={"tool": "search", "query": "billing"},
    )
    chain = await db.why(result.event_id)
    chain.print()

Auto-capture LLM calls (one line)

import zizkadb
from zizkadb import ZizkaDB

db = ZizkaDB("zizkadb_live_xxxx")
zizkadb.instrument(db, agent="my-bot")

Then call your model as usual (sync or async). Each call is recorded as causally linked events, so db.why() works without any db.log():

user_message → llm_end (model, output, token_usage) → tool_call → tool_result → llm_end …

You call models through Covered
openai (chat completions, Responses API) OpenAI, Azure OpenAI, and every OpenAI-compatible API: DeepSeek, GLM (Zhipu), Kimi (Moonshot), Qwen, Mistral, Groq, Together, Fireworks, OpenRouter, xAI, and local servers (Ollama, vLLM, LM Studio, llama.cpp, TGI)
anthropic (messages, messages.stream) Claude, including on AWS Bedrock and Google Vertex
google-genai (models.generate_content, generate_content_stream, chats) Gemini
ollama (native package: ollama.chat, Client, AsyncClient) any local Ollama model
zai-sdk / zhipuai GLM through Zhipu's own SDK
mistralai (chat.complete, chat.stream, async) Mistral
cohere (ClientV2.chat, chat_stream, async) Cohere Command
boto3 bedrock-runtime (converse, converse_stream) every model on AWS Bedrock (Claude, Llama, Mistral, Nova, ...)
litellm 100+ providers behind LiteLLM (Vertex, Hugging Face, ...)
llama-cpp-python (Llama.create_chat_completion) GGUF models run in your process
transformers (pipeline("text-generation")) Hugging Face models run in your process

Reasoning models are covered too: the thinking text (reasoning_content from DeepSeek, GLM and Kimi; Gemini thoughts; Ollama thinking) lands in llm_end as reasoning, and cached and reasoning tokens are read from each provider's own usage fields. In-process models are recorded when their library is imported before instrument() runs (it never imports PyTorch or llama.cpp itself, so startup stays fast). Calls below those entry points (a raw model.generate() on tensors) are not recorded: log them with db.log().

  • Tool results are linked to the tool call that asked for them (OpenAI role="tool" or Responses API function_call_output, Anthropic tool_result), each recorded once even though chat APIs resend the history.
  • Inside async with db.track(agent="my-bot") the events share that session.
  • capture_content=False stores only models, tool names, token usage and the links, no prompt or output text. Text is otherwise clipped to 4,000 characters.
  • Tools without call ids (the native ollama package, some Gemini calls) are matched to their call by tool name.
  • Streaming (stream=True) is recorded too: you get the provider's stream unchanged, and once it ends the events carry the full output, tool calls and token usage (for OpenAI chat, usage needs stream_options={"include_usage": True}). A stream closed early is marked "truncated": true; one that fails mid-way becomes llm_error with the partial output. The .stream() helpers are recorded too: OpenAI chat.completions.stream() / responses.stream() and Anthropic messages.stream() (recorded when its with block exits).
  • A failed write is logged as a warning; your LLM call is never affected. inst.uninstrument() restores the original methods.

Turn a bad session into a test

zizkadb test from-session <session_id> --agent my-bot --entry my_app.agent:answer
pytest tests/test_session_<id>.py

Writes a snapshot of the session (tests/zizkadb_sessions/<name>.json: user inputs, tool path, final answer, errors) and a pytest test that replays the user inputs through your agent and checks it calls the same tools, in the same order, without errors. Without --entry, connect run_agent() in the generated file to your agent. If the recorded run was the bug, edit EXPECTED_TOOL_CALLS to the path the agent should take.

The test runs inside zizkadb.testing.capture(), which records OpenAI / Anthropic / LiteLLM calls in memory (no ZizkaDB server needed). Use it in your own tests too:

from zizkadb.testing import capture

def test_refund_question():
    with capture() as run:
        my_agent("How long do refunds take?")
    assert run.tool_calls == ["search_policies"] and not run.errors

Multi-agent apps (ZizkaDB Cloud)

An API key works for one agent name. Running several agents — and agent-to-agent messaging between them — is a ZizkaDB Cloud feature; create each agent and its key in the dashboard.

Self-hosted ZizkaDB is single-agent: log everything under one agent name and use session_id to separate users or conversations. A second agent name is rejected with 409 agent_limit_reached.

More than logging

Method What it does
log(..., idempotency_key=, supersedes=, importance=) Safe retries; replace an outdated fact; weight it in memory
log_batch(events) Up to 500 events in one request
search(query, mode=) Keyword out of the box, hybrid with embeddings
context_for(agent, task) Relevant past as a prompt block (no OpenAI key needed)
verify_chain(agent, after_seq=, anchor=) Prove no event was edited, removed or reordered
iter_events(agent) Every event, cursor-paged
export_events(agent) / import_events(lines) Portable NDJSON copy and import

Needs a server from release 0.5.0. Full guide: CONNECT.md.

Errors

Exception Meaning
AuthError Invalid or revoked API key
AgentScopeError Key is for agent A but you logged to agent B
NotFoundError Event or agent not found

Environment variables

Variable Purpose
ZIZKADB_API_KEY Your cloud API key (preferred)
AGENTDB_API_KEY Legacy alias for ZIZKADB_API_KEY
ZIZKADB_AGENT Default agent name (used in templates/examples)
ZIZKADB_HOST Self-hosted API URL. Used when the client gets no host argument, so with an API key it sends requests here instead of ZizkaDB Cloud (legacy alias AGENTDB_HOST)
ZIZKADB_TELEMETRY Set false to opt out (anonymous ping on client construct)

Self-host dashboard

  1. bash scripts/setup-local.sh (API + dashboard on port 3001)
  2. Open http://localhost:3001/login → Open my dashboard →

Metadata

Release files for zizkadb-sdk 0.7.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for zizkadb-sdk 0.7.0
File Size Uploaded Provenance Actions
zizkadb_sdk-0.7.0.tar.gz 81.5 kB Without provenance Details for zizkadb_sdk-0.7.0.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for zizkadb-sdk 0.7.0
File Interpreter ABI Platform Actions
zizkadb_sdk-0.7.0-py3-none-any.whl Python 3 none any Details for zizkadb_sdk-0.7.0-py3-none-any.whl

Total release size: 142.6 kB

Release files / zizkadb_sdk-0.7.0.tar.gz

Download URL zizkadb_sdk-0.7.0.tar.gz
Size 81.5 kB
Tags Source
SHA-256 checksum
How to use checksums
132fcaa701f6f59a7b4540534c5475ed4ea5eea6507b13d5b027b898f096cb77
BLAKE2b-256 checksum
How to use checksums
d173483dea2e83a871d3db4f10f831570491ec19673b30b3da63bd19d07dcc26
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.13.9

Release files / zizkadb_sdk-0.7.0-py3-none-any.whl

Download URL zizkadb_sdk-0.7.0-py3-none-any.whl
Size 61.1 kB
Tags Python 3
SHA-256 checksum
How to use checksums
7b0900c0ebec7ac7a4b3c9b117fe25b8d6eb0083310716cdddefc5808abcc0d1
BLAKE2b-256 checksum
How to use checksums
ba846213ce772f84a107a38103bbb04fdf25f4b8d4187edb15ff456d0c918f4c
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.13.9

Security for zizkadb-sdk 0.7.0

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page