页面简介
Run your own LLM behind a Retell voice agent. Retell handles telephony, transcription, and turn-taking while your WebSocket server generates each reply.
正文摘录
With a custom LLM, you own response generation. Retell handles the call itself (telephony, transcription, turn-taking, speech synthesis) and opens a WebSocket to your server for each call. Retell sends you the live transcript and asks for responses; you stream back what the agent should say. We recommend single prompt or conversation flow for most agents. They get the newest features, and they come already tuned for things like latency. When to use it Single prompt and conversation flow agents give you built-in tool calling, a knowledge base, warm transfers, and a testing playground with no server to run. They’re the right choice for most agents. Reach for a custom LLM when you need something those frameworks can’t give you: Compliance constraints. Prompts and transcripts must be processed inside your own infrastructure, or by a model you host. A model Retell doesn’t offer. A fine-tuned model, a self-hosted open-weights model, or a provider outside the supported options. Response logic beyond what Retell’s frameworks support. Your own retrieval pipeline instead of Retell’s knowledge base, a multi-step agent loop that runs before the agent speaks, or orchestration that already lives in your own code. You take on latency, uptime, and reconnection handling. You also give up the features that assume Retell generates the responses: Chat tests in the test panel can’t run on a custom LLM agent, and simulation tests reject them. Audio tests and phone calls are the only way to test. Agent transfer can’t target a custom LLM agent. Your own tool calls only appear in the transcript if you report them yourself. Retell records the actions it runs (end_call, transfer_call, press_digit) automatically. How a call flows One WebSocket is opened per call, to llm_websocket_url with the call ID appended as the last path segment. Retell drives the conversation and tells you when it needs something. Retell decides when the agent speaks, so not every response you generate gets used. If the caller keeps talking, Retell discards the response it asked for and asks again with a new response_id. What your server implements Retell tags every message it sends with interaction_type: interaction_typeYou mustWhat it carriesresponse_requiredReply with a responseThe live transcript and a response_id. Retell is waiting to speak.reminder_requiredReply with a responseSame shape, but the caller has gone quiet and Retell wants a nudge.update_onlyNothingTranscript updates and turntaking changes. Read it or ignore it.call_detailsNothingThe full call object, including dynamic variables and metadata. Only sent if you ask for it in config.ping_pongEcho it backA keepalive timestamp. Only sent if you set auto_reconnect. You tag everything you send with response_type: response_typeRequiredWhat it doesresponseYesStreams content for the agent to speak. Can also end the call, transfer, or press digits.configNoSent once on connect to turn on keepalives, call details, and tool-call transcripts.ping_pongIf auto_reconnect is onEchoes the keepalive so Retell knows you’re alive.agent_interruptNoMakes the agent speak immediately, cutting off whoever is talking. Also cancels any response still in flight.tool_call_invocation / tool_call_resultNoRecords your tool calls in the call transcript.update_agentNoChanges responsiveness, interruption sensitivity, or reminder timing mid-call.metadataNoForwards arbitrary data to a web call frontend. Always set response_type on messages you send. Retell treats a message with no response_type as a response for backward compatibility, but that fallback is the reason a malformed event fails silently instead of erroring. The LLM WebSocket reference has the full field-by-field spec for every event above. Example servers Runnable reference implementations, both with function calling: Node.js (Express) — OpenAI, Azure OpenAI, OpenRouter Python (FastAPI) — OpenAI, Claude These repos might be outdated already. Follow the guides in this section wherever the two differ. Next steps Set up your WebSocket serverGet an agent talking with a hardcoded response, before adding an LLM.Connect your LLMStream real completions back, and handle discarded responses correctly.Add function callingLet the agent book, transfer, press digits, and end the call.Best practicesKeep time-to-first-sentence low enough to sound natural.Was this page helpful?YesNo⌘I