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 lowerCamelCase in TypeScript and snake_case in Python: openThread and open_thread.
  • Types have the same PascalCase name 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.
  • Expected failures are values, not exceptions: TypeScript returns { ok: true, value } or { ok: false, error: { code, message } }, Python returns Ok[T] or Err[Failure]. Only ConfigError, for a definition that can't run, is thrown.

Packages

PackageTypeScriptPython
core@threads/corethreads
host@threads/hostthreads.host
mcp@threads/mcpthreads.mcp

Model, sandbox, channel and memory providers live in their own packages (@threads/anthropic, threads.anthropic, ...). See Models, Sandboxes, Host server and Memory.

Functions

TypeScriptPythonWhat it does
agentagentDescribe an agent.
tooltoolDefine an app tool.
extensionextensionThe one extension primitive: tools, trusted instructions and hooks.
mcpmcpAn MCP server in one line.
secretsecretA reference to a host secret, resolved only in the host.
openThreadopen_threadA handle for inspection and control, independent of any in-memory run.
sqlitesqliteThe one log and artifact store.
localMemorylocal_memoryBuilt-in memory: SQLite FTS5 in the run's store.
localKnowledgelocal_knowledgeBuilt-in knowledge: SQLite FTS5 over admitted versions stored as artifacts.
scriptedModelscripted_modelTest kit.
fakeSandboxfake_sandboxTest kit.
hosthostBind agents to a store, channels and schedules.

Types

Agents and runs: Agent, RunResult, RunStream, RunContext, Tool, McpServer, Extension, Hooks, Skill, Secret, Store, ConfigError, ConfigErrorCode

Threads and evals: Thread, CaseExpectation, SavedCase

Host: Host, Schedule

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

HTTP API

The host's HTTP API is documented from its OpenAPI file in the HTTP API reference.

Edit on GitHub

On this page