repairspecialty_64579
10/09/2025, 4:19 PMAI Evy
10/09/2025, 4:19 PMAI Evy
10/09/2025, 4:19 PMcreate-chat-completion API endpoint . The API returns the agent's response in the messages array . All conversation history is automatically stored in Retell's database, so you don't need to manage conversation context yourself .
Here's how the chat functionality works:
1. Create a Chat Session - Use the create-chat API endpoint to start a chat session, which returns a chat_id for subsequent requests
2. Create a Chat Completion - Use the create-chat-completion API endpoint to generate responses from the chat agent
3. Retrieve Chat Details - You can retrieve details about a chat session using the get-chat API endpoint, or list all chat sessions using the list-chat endpoint
4. End Chat Session - When the conversation is complete, end the chat session using the end-chat API endpoint
Retell also supports SMS integration through Twilio, allowing you to deploy chat agents to receive and respond to text messages [(1) ]() [(2) ]() .AI Evy
10/09/2025, 4:19 PMAI Evy
10/09/2025, 4:19 PMrepairspecialty_64579
10/09/2025, 4:21 PMAI Evy
10/09/2025, 4:21 PMAI Evy
10/09/2025, 4:22 PMcreate-chat-completion endpoint is the same for all chat agents [(1) ]() . You use your existing agent by first creating a chat session with your agent_id, then sending messages to that chat [(1) ]() [(2) ]() .
Here's the process:
1. Create a chat session with your agent:
javascript
import Retell from 'retell-sdk';
const client = new Retell({
apiKey: 'YOUR_RETELL_API_KEY',
}) ;
const chatResponse = await client.chat.create({ agent_id: 'oBeDLoLOeuAbiuaMFXRtDOLriTJ5tSxD' }) ;
console.log(chatResponse.agent_id) ;
[(2) ]()
2. Use the returned chat_id to send messages:
javascript
import Retell from 'retell-sdk';
const client = new Retell({
apiKey: 'YOUR_RETELL_API_KEY',
}) ;
const response = await client.chat.createChatCompletion({
chat_id: 'oBeDLoLOeuAbiuaMFXRtDOLriTJ5tSxD',
content: 'hi how are you doing?',
}) ;
console.log(response.messages) ;
[(1) ]()
The endpoint itself is POST /create-chat-completion . You don't need to find a different endpoint for each agent - you specify which agent to use when creating the chat session, and all subsequent messages use that same chat_id [(1) ]() [(2) ]() .AI Evy
10/09/2025, 4:22 PMAI Evy
10/09/2025, 4:22 PM