Skip to main content
Create a Retell voice agent with the TypeScript SDK by creating a Retell LLM response engine and attaching it to a voice configuration. This example builds an after-hours receptionist, returns the resource IDs, and leaves the first agent version as a draft for testing.

When to use this workflow

Use this workflow when you manage agent configuration in source code or provision agents for multiple customers. If you already have an agent and only need to place calls, use the create phone call API instead. The example creates an after-hours receptionist for a heating company. It collects the caller’s name, callback number, address, and reason for calling without promising a price or appointment time.

Before you start

You need:

Create the agent

1

Install the SDK and TypeScript runner

Create a Node.js project and install the dependencies:
2

Set environment variables

Export the API key and voice ID you copied from the dashboard. Set the webhook URL only if your endpoint is ready to receive call events.
Keep the API key in your server environment or secret manager. Do not expose it in browser code or commit it to source control.
3

Create the response engine and agent

Save this file as create-agent.ts:
The example sets English explicitly, caps calls at 15 minutes, and ends a call after 2 minutes of silence. As of July 2026, max_call_duration_ms accepts 1 minute to 2 hours, while end_call_after_silence_ms has a 10-second minimum and a 10-minute default. Because model is omitted, the Retell LLM uses the endpoint’s default text model.If RETELL_WEBHOOK_URL is set, the agent-level webhook replaces the account-level webhook for this agent.
4

Run the script

Run the TypeScript file:
A successful run prints the Retell LLM ID, agent ID, and draft version:

Test and publish the agent

Open the new agent in the dashboard and run a web call test. A draft can be tested without publishing or assigning a phone number. When the draft is ready, publish it from the dashboard version panel or call the publish agent API with the agent_id and version printed by the script. Published versions are immutable. See agent versioning before you attach a version or environment tag to a phone number. If you configured a webhook, verify its signature before processing call events.

Common questions

The response engine and voice agent are separate resources. client.llm.create() defines what the agent says and which tools it can use. client.agent.create() attaches that response engine to voice and call settings.
The Retell LLM remains available because the two create calls are not atomic. Reuse its llm_id on the next attempt, or remove it with the delete Retell LLM API.
No. Test the draft with a browser web call first. Publish it when you are ready to use an immutable version for a phone number or environment tag.