https://retellai.com/?utm_source=discord&utm_medium=seo logo
Does retell AI povide a text chat API endpoint tha...
# ❓・ai-evy-support
r
Does retell AI povide a text chat API endpoint that can recieve messages and return responses? @AI Evy
a
Thanks for tagging me @repairspecialty_64579. I'll look through relevant sources and get back to you shortly.
### Answer Yes, Retell AI provides a chat API endpoint that can receive messages and return responses [(1) ]() . To generate a response from the chat agent, you use the
create-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) ]() .
​ To learn more, see the sources I considered: [[1] Create Chat Completion](https://docs.retellai.com/deploy/create-chat-completion) [[2] Create Outbound SMS](https://docs.retellai.com/api-references/create-sms-chat) ​
Feel free to tag @AI Evy with additional questions. I also appreciate feedback, it helps me improve.
r
How can i find the create-chat-completion API endpoint for the chat agent i already have created @AI Evy
a
Thanks for the follow-up, @repairspecialty_64579. I'll get back to you soon.
### Answer --- The
create-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:
Copy code
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:
Copy code
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) ]() .
​ To learn more, see the sources I considered: [[1] Create Chat Completion](https://docs.retellai.com/api-references/create-chat-completion) [[2] Create Chat](https://docs.retellai.com/api-references/create-chat) ​
Feel free to tag @AI Evy with additional questions. I also appreciate feedback, it helps me improve.