# SDK reference

> Every function, type and field of @voicelayer/sdk, with its signature, typed parameters, defaults, errors and an example.

Source: https://docs.vlayers.ai/developers/sdks/reference

Kind: Reference

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](https://docs.vlayers.ai/reference).

## What is here

| Page | What it covers | Import from |
|---|---|---|
| [Defining an agent](https://docs.vlayers.ai/developers/sdks/reference/define-agent) | `defineAgent`, every `AgentConfig` field, `defineProcess`, `startAgents` and `agent.start()` | `@voicelayer/sdk` |
| [The handler context](https://docs.vlayers.ai/developers/sdks/reference/handler-context) | `ctx`: `say`, `ask`, `handoff`, `endCall`, `memory`, and the errors they throw | `@voicelayer/sdk` |
| [Tools](https://docs.vlayers.ai/developers/sdks/reference/tools) | `defineTool`, `httpTool`, `tool` and their options | `@voicelayer/sdk` |
| [Models](https://docs.vlayers.ai/developers/sdks/reference/models) | `openai`, `anthropic`, `google`, `deepgram`, `cartesia`, `elevenlabs`, `assemblyai` and the `models` slots | `@voicelayer/sdk` |
| [Direct mode](https://docs.vlayers.ai/developers/sdks/reference/direct) | `serveDirect`, `onMessage` and the message context | `@voicelayer/sdk/direct` |
| [Custom channels](https://docs.vlayers.ai/developers/sdks/reference/channels) | `defineChannel`, actions, the store and `serveChannel` | `@voicelayer/sdk/channel` |
| [Hosted agents](https://docs.vlayers.ai/developers/sdks/reference/hosting) | `serveRoom` and the request your published endpoints receive | `@voicelayer/sdk` |
| [Brains](https://docs.vlayers.ai/developers/sdks/reference/brains) | `onQuery`, framework adapters and brain tools | `@voicelayer/sdk`, `@voicelayer/sdk/brain` |
| [The testing kit](https://docs.vlayers.ai/developers/sdks/reference/testing) | `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 its `code`, never on its message.
- **Example**: a small piece of code that works as written.

## Next steps

- [Voice agents in code](https://docs.vlayers.ai/developers/sdks/voice-agents): build an agent step by step.
- [Testing agents and channels](https://docs.vlayers.ai/developers/sdks/testing)
- [Build your own channel](https://docs.vlayers.ai/developers/sdks/custom-channels)
