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.
KartaHub is for embedding Karta in a multi-tenant application. It gives each
(tenant, user) pair a fully isolated filesystem workspace and its own
Karta instance and harness — the embedded isolation model described in
Multi-tenancy.
from karta import KartaHub
Construct
KartaHub(project_path: str | Path = ".")
Workspaces are materialized under {project_path}/workspaces/, cloned from
{project_path}/project/ as the template.
hub = KartaHub("/path/to/karta-root")
Per-tenant access
def karta(self, tenant_id: str, user_id: str) -> Karta
def session(self, tenant_id: str, user_id: str, metadata=None) -> Session
def has_instance(self, tenant_id: str, user_id: str) -> bool
# Each call resolves (or creates) an isolated workspace + Karta + harness:
session = hub.session("acme", "alice", metadata={"topic": "billing"})
response = session.send_sync("Help with invoice #789")
other = hub.session("globex", "bob") # entirely separate workspace
Lifecycle
async def evict(self, tenant_id: str, user_id: str) -> bool # disconnect harness, release workspace
async def aclose(self) -> None # full async cleanup
def close(self) -> None # release workspaces (no harness disconnect)
await hub.evict("acme", "alice") # free one tenant's resources
await hub.aclose() # tear everything down
KartaHub is the embedded multi-tenancy model — strong per-user
filesystem isolation, heavier per-tenant overhead. For a shared cloud service,
prefer a single karta serve instance with auth-enforced org
scoping. See Multi-tenancy for the trade-off.