Skip to main content
The Rust SDK is the primary interface. The Python/TypeScript SDKs and all API servers are thin wrappers over this same engine. A production Rust host composes PersistentSessionService with MeerkatMachine; the service is the session substrate and the machine owns runtime transitions. The direct EphemeralSessionService path remains useful for small embedded programs and tests that intentionally do not need runtime-backed persistence or delivery.

Method overview

Mob orchestration is layered on this facade by the separate meerkat-mob crate. The live feature composes meerkat-live into the runtime; direct adapter types remain owned by meerkat-live.

Installation

1

Add the dependency

2

Choose feature flags

The default feature set enables the Anthropic, OpenAI, and Gemini clients plus GitHub Copilot OAuth/backend support; add optional gates as needed:

Quick start

Production surfaces (CLI, REST, RPC, MCP) use the runtime-backed path where PersistentSessionService is substrate and MeerkatMachine owns keep-alive, Queue/Steer routing, interruption, terminal publication, and archive. Start a native host with both halves: Use this dependency set for the persistent example. The explicit meerkat-store dependency supplies RealmBackend and realm_paths_in; transitive dependencies are not available as direct crate imports.
build_persistent_service() returns only the persistent service half. Its direct start_turn, interrupt, and archive methods intentionally return SessionError::Unsupported; a runtime-backed host must use the machine commit, interrupt, and retire protocols. Use the public helpers in meerkat::surface when building a native host, or use the ready-made RPC, REST, CLI, or MCP host.
For a direct embedded or testing flow that does not need machine-owned runtime semantics, use the ephemeral service: Before running the model turn below, make credentials available for its Claude model through a compatible configured auth binding or an Anthropic environment key. For a clean API-key setup:
A compatible existing binding can be used instead; another provider’s key does not authenticate this Claude request. Merely constructing the persistent host above does not make a model call or require this credential step.

Sessions

The examples below use the direct EphemeralSessionService lifecycle. The same request and result types are used inside production hosts, but persistent follow-up turns, interruption, and archive are machine-owned transitions and must not call these trait methods directly.

Multi-turn conversations

Append a System message at a turn boundary

system_prompt appends one ordinary ordered System message immediately before that turn. It may be used on any turn; prior System messages and the rest of the transcript remain unchanged.

Error handling


Direct agent APIs

Agent::run(...) and AgentBuilder are expert-level escape hatches. Prefer the persistent service plus machine composition for a production host, or the ephemeral session service for a deliberately direct embedded flow.

Running agents directly

Basic run

Run with event streaming

turn_completed carries optional usage for one provider call while run_completed carries the session-cumulative total, and their input_tokens fields use different denominators. usage: None means no accounting exists for that turn, not zero usage. Read Usage accounting before aggregating either.

Agent methods

Error handling


Events


Core types

Message and ContentBlock

ContentInput

ContentInput is the prompt type accepted by CreateSessionRequest and StartTurnRequest. It supports both text-only and multimodal prompts:

ToolCall and ToolResult

RunResult


See also

  • Tools and stores - tool system, session stores, MCP integration
  • Advanced - expert-only direct agent construction, providers, budgets, and hooks
  • API reference - quick-lookup type index