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.
- 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 |
|---|---|---|
| core | @threads/core | threads |
| host | @threads/host | threads.host |
| mcp | @threads/mcp | threads.mcp |
Model, sandbox, channel and memory providers live in their own packages (@threads/anthropic, threads.anthropic, ...).
See Models, Sandboxes, Host server and Memory.
Functions
| TypeScript | Python | What it does |
|---|---|---|
agent | agent | Describe an agent. |
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. |
openThread | open_thread | A handle for inspection and control, independent of any in-memory run. |
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. |
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
HTTP API
The host's HTTP API is documented from its OpenAPI file in the HTTP API reference.