Reference
SDK reference
Every function, type and field of @voicelayer/sdk, with its signature, typed parameters, defaults, errors and an example.
This is the reference for @voicelayer/sdk, the TypeScript package you use to define agents, serve them, test them and build channels. It lists each export with its signature, the type of every field or parameter, whether it is required, its default, the errors it throws and a small example. For a walk-through of how the pieces fit, start with the how-to pages; come here to look up a name.
The reference is generated from the package's TypeScript types and their comments each time the package changes, so it cannot drift from the code. For the REST calls (@voicelayer/api), see the API reference.
What is here
| Page | What it covers | Import from |
|---|---|---|
| Defining an agent | defineAgent, every AgentConfig field, defineProcess, startAgents and agent.start() | @voicelayer/sdk |
| The handler context | ctx: say, ask, handoff, endCall, memory, and the errors they throw | @voicelayer/sdk |
| Tools | defineTool, httpTool, tool and their options | @voicelayer/sdk |
| Models | openai, anthropic, google, deepgram, cartesia, elevenlabs, assemblyai and the models slots | @voicelayer/sdk |
| Direct mode | serveDirect, onMessage and the message context | @voicelayer/sdk/direct |
| Custom channels | defineChannel, actions, the store and serveChannel | @voicelayer/sdk/channel |
| Hosted agents | serveRoom and the request your published endpoints receive | @voicelayer/sdk |
| Brains | onQuery, framework adapters and brain tools | @voicelayer/sdk, @voicelayer/sdk/brain |
| The testing kit | testContext, invoke, checkAgent, runBrain, testChannel | @voicelayer/sdk/testing |
How to read an entry
- Signature: the call as TypeScript prints it. A
?marks an optional parameter or field. - Required and Default: whether you must pass it, and what you get when you do not.
- Nested fields appear indented under their parent with a dotted name, for example
endCall.idleHangupMs. - Throws: the errors a call rejects with. Calls back to the platform reject with a
HandlerContextError; branch on itscode, never on its message. - Example: a small piece of code that works as written.
Next steps
- Voice agents in code: build an agent step by step.
- Testing agents and channels
- Build your own channel