API Reference
Use this page when you already understand the concepts and need the current public surface at a glance.
Runnables
| API | Use |
|---|---|
Runnable<I, O> | base contract with invoke and pipe |
RunnableLambda<I, O> | wrap sync or async custom logic |
RunnableSequence<I, O> | run steps in order |
RunnableParallel<I, TMap> | run branches from the same input concurrently |
RunnableMap<I, TMap> | build a named object from one input |
RunnablePassthrough<T> | return input unchanged |
ModelRunnable | adapt Model into a string -> string runnable |
Prompts
PromptTemplate<TVars>
- input: object of template variables
- output: formatted prompt string
- throws:
PromptTemplateErrorwhen required variables are missing
Output Parsers
| API | Behavior |
|---|---|
StringOutputParser | returns raw text unchanged |
JsonOutputParser<T> | parses JSON text into typed output |
JsonOutputParser<T> throws OutputParserError on invalid JSON.
Agent Runtime
Agent
new Agent({ model, tools, passes?, hooks?, maxSteps? })
agent.run(input: string): Promise<string>
Runtime behavior:
- iterative model loop
- tool execution when requested
- memory context injection
- max-step enforcement
Config details:
toolsare registered by unique tool namepassescan transform interpreted instructions before executionhooks.onStart(state)andhooks.onEnd(state, result)allow lifecycle instrumentationmaxStepsdefaults to20runtimePolicyconfig:modelTimeoutMs: max time for a model callmodelRetry.maxAttempts: number of model attempts (default1)modelRetry.backoffMs: linear backoff base between retries
Tools
tool(...)
tool({
name,
description,
schema, // zod schema
execute // async handler
})
Behavior:
- args are validated against
schemabefore execution - unknown tool names raise
ToolNotFoundError - schema mismatch raises
ToolValidationError
Workflows
Workflow
new Workflow({ steps })
workflow.run(input, { resumeFrom? })
Types:
WorkflowStep:{ id, run, when? }WorkflowSnapshot: captured per-step input/output metadataWorkflowResumeState: replayable state withnextStepIndex,data,snapshotsWorkflowRunResult:{ output, snapshots, resumeState }
Errors
ToolNotFoundErrorToolValidationErrorModelErrorMaxStepsExceededErrorPromptTemplateErrorOutputParserError
Canonical code mapping and compatibility policy: error-codes.md
Versioned runtime contract: core-contract-v0.1.md