API reference
Every public function and type, in TypeScript and Python.
This reference is generated from spec/api.json, the contract both implementations follow. Members
that exist in the contract but are not built yet are left out; members built in one language only
say so.
Naming
- Functions and methods are
lowerCamelCasein TypeScript andsnake_casein Python:openThreadandopen_thread. - Types have the same
PascalCasename in both. - Required inputs are positional. Everything else is one trailing options object in TypeScript and keyword-only arguments in Python, with the same names and defaults. The one exception is a test seam: a provider factory may take an optional TypeScript-only positional, such as the
transportofexa, marked "Seam:". - Expected failures are values, not exceptions: TypeScript returns
{ ok: true, value }or{ ok: false, error: { code, message } }, Python returnsOk[T]orErr[Failure]. OnlyConfigError, for a definition that can't run, is thrown.
Packages
| Package | TypeScript | Python |
|---|---|---|
| otel | @threads/otel | threads.otel |
| core | @threads/core | threads |
| host | @threads/host | threads.host |
| mcp | @threads/mcp | threads.mcp |
| supermemory | @threads/supermemory | threads.supermemory |
| zep | @threads/zep | threads.zep |
| anthropic | @threads/anthropic | threads.anthropic |
| openai | @threads/openai | threads.openai |
| ai-sdk | @threads/ai-sdk | — |
| litellm | — | threads.litellm |
| e2b | @threads/e2b | threads.e2b |
| daytona | @threads/daytona | threads.daytona |
| modal | @threads/modal | threads.modal |
| dev | @threads/core | threads.dev |
| postgres | @threads/postgres | threads.postgres |
| mem0 | @threads/mem0 | threads.mem0 |
| slack | @threads/slack | threads.slack |
| github | @threads/github | threads.github |
@threads/whatsapp | threads.whatsapp | |
| search | @threads/core | threads.search |
Functions
| TypeScript | Python | What it does |
|---|---|---|
agent | agent | Describe an agent. |
dynamicAgent | dynamic_agent | Describe a dynamic agent: a template in a lead's team whose members the lead (or team.start) defines at runtime within what this code pins. |
tool | tool | Define an app tool. |
extension | extension | The one extension primitive: tools, trusted instructions and hooks. |
mcp | mcp | An MCP server in one line. |
secret | secret | A reference to a host secret, resolved only in the host. |
usd | usd | A US-dollar amount as the integer nano-dollars budgets and prices use: usd(0.5) is 500000000. |
openThread | open_thread | A handle for inspection and control, independent of any in-memory run. |
importThread | import_thread | Stores a bundle written by thread.export, or a bare .jsonl export, and returns a handle on its leaf branch. |
sqlite | sqlite | The one log and artifact store. |
localMemory | local_memory | Built-in memory: SQLite FTS5 in the run's store. |
localKnowledge | local_knowledge | Built-in knowledge: SQLite FTS5 over admitted versions stored as artifacts. |
scriptedModel | scripted_model | Test kit. |
fakeSandbox | fake_sandbox | Test kit. |
host | host | Bind agents to a store, channels and schedules. |
openTeam | open_team | A Team handle for a team another process ran, or to act as another principal. |
runEvals | run_evals | Runs every saved case under cases through the checks, cheapest first: replay (the recorded requests re-render byte for byte with the code running now), rerun (the recorded turn reruns offline to the same events, with no model call and every effect stubbed), drift (with agents: the case's recorded config against each agent as it is pinned now, by a dry pin that runs no setup, reads no secret and connects to no MCP server) and, only with live, a judged run of the current agent. |
assertNever | assert_never | Ends a switch over a union, so a variant nobody handles is a type error. |
Providers
A provider factory connects an agent to an outside service and returns one of the protocol types below. Its page lists every option in both languages and the ConfigError codes it can raise. Options whose description starts with "Seam:" exist in one language to swap a transport or clock in tests.
| TypeScript | Python | What it does |
|---|---|---|
otel | otel | An Exporter that sends each span of every thread in the store once, when it closes, to an OpenTelemetry collector over OTLP/HTTP JSON. |
postgres | postgres | The log and artifact store on Postgres: every host process on every machine points at the same database. |
supermemory | supermemory | A MemoryProvider that stores records in Supermemory. |
zep | zep | A MemoryProvider that stores records in Zep. |
anthropic | anthropic | A Claude model through the Messages API. |
openai | openai | An OpenAI model through the Responses API (stateless: store is false). |
aiSdk | aiSdk | Any AI SDK v4 language model as a threads Model, for the providers with no adapter of their own. |
litellm | litellm | A model behind LiteLLM's openai/ route: any OpenAI-compatible endpoint, named through base_url. |
exa | exa | A web_search backend that searches with Exa (exa.ai). |
tavily | tavily | A web_search backend that searches with Tavily (tavily.com). |
brave | brave | A web_search backend that searches with Brave (search.brave.com). |
e2b | e2b | A Sandbox on an E2B cloud VM. |
daytona | daytona | A Sandbox on Daytona. |
modal | modal | A Sandbox on Modal. |
devSandbox | dev_sandbox | A Sandbox in a local directory on the host, inside an OS confinement (bubblewrap on Linux, sandbox-exec on macOS). |
mem0 | mem0 | Mem0 memory: refused, since the mem0ai SDK sends outside any transport threads can fence (its constructor checks the key and it posts telemetry on its own). |
slack | slack | A Slack channel. |
github | github | A GitHub channel. |
whatsapp | whatsapp | A WhatsApp Cloud API channel. |
These providers exist but are not in the reference yet; their guides describe them: Models, Sandboxes, Host server and Memory.
Types
Agents and runs: Agent, RunResult, RunStream, RunContext, Tool, McpServer, Extension, Hooks, Skill, Secret, Store, ConfigError, ConfigErrorCode
Threads and evals: Thread, CaseExpectation, SavedCase
Model adapters: Model, ModelContext, ModelInfo, ModelRequest, ModelResponse, ModelChunk, LookupResult, LookupCapability
Sandbox adapters: Sandbox, SandboxAuthority, SandboxContext, SandboxInfo, SandboxSession, ExecOutput, ExecResult
Memory and knowledge adapters: MemoryProvider, KnowledgeProvider, Scope, Binding, MemoryRecord, RecordRef, MemoryHit, KnowledgeSource, DocVersion, KnowledgeHit, Doc, SearchBackend, SearchHit
Channel adapters: ChannelAdapter, ChannelCapabilities, RawRequest, RawResponse, VerifiedDelivery, Inbound, DeliveryOutcome
Other types: Exporter, SyncReport, SkippedBranch, TeamAgent, DynamicAgent, TeamRunResult, TeamRunStream, ExportedBundle, Live, EvalReport, EvalCaseResult, Verdict, ModelBlockedError, Principal, Workspace, TeamRef, MemberRef, Team, StartRefusal, InvalidDefinition, SendRefusal, AskRefusal, ReplyRefusal, ObserveRefusal, CancelRefusal, OperatorRefusal, MemberState, MemberResult, StoredMemberResult, StartResult, SendResult, AskOutcome, AskResult, ReplyResult, Waited, WaitResult, MonitorResult, CancelResult, TeamStartResult, TeamSendResult, TeamAskResult, TeamWaitResult, TeamCancelResult, TeamMember, AskStatus, TeamCursor, TeamSource, TeamItem, StoreCorruptError, MessagePolicyRule
HTTP API
The host's HTTP API is documented from its OpenAPI file in the HTTP API reference.