Skip to main content

Documentation Index

Fetch the complete documentation index at: https://docs.karta.sh/llms.txt

Use this file to discover all available pages before exploring further.

karta-python is the data plane as a library. It’s how you embed a harness application in your own Python process, stand up the HTTP server, and run the karta CLI.

Install

pip install karta-python

# optional session backends:
pip install karta-python[postgres]   # PostgreSQL
pip install karta-python[s3]         # S3
You also need a harness installed — Claude Code (npm install -g @anthropic-ai/claude-code) or OpenCode.

The three entry points

Karta

The orchestrator. Detects your harness, discovers agents, and sends/streams turns.

Session

A multi-turn handle with participants and agent handoff.

KartaHub

Multi-tenant orchestrator — one isolated Karta per (tenant, user).

Three lines to a response

from karta import Karta

app = Karta()                              # auto-detects the harness here
print(app.send_sync("Hello!").text)
Karta detects the harness from the current directory — .claude//CLAUDE.md → Claude Code, .opencode/ → OpenCode.

Sync and async, send and stream

Every send has four shapes — sync/async × accumulated/streamed:
# accumulated (a final Response)
resp = app.send_sync("...")              # sync
resp = await app.send("...")             # async

# streamed (typed events)
for event in app.stream_sync("..."):     # sync
    ...
async for event in app.stream("..."):    # async
    if event.type == "text":
        print(event.text, end="")
See Streaming events for the event model.

Serve over HTTP

from karta import Karta
from karta.server import create_fastapi_app
import uvicorn

uvicorn.run(create_fastapi_app(Karta()), host="0.0.0.0", port=8000)
This exposes the HTTP API.

Where to go

Karta reference

Constructor, properties, and every method.

Hooks & policies

React to lifecycle events; gate messages with policies.