Skip to main content
POST
/
create-chat-completion
JavaScript
import Retell from 'retell-sdk';

const client = new Retell({
  apiKey: process.env['RETELL_API_KEY'], // This is the default and can be omitted
});

const response = await client.chat.createChatCompletion({
  chat_id: 'oBeDLoLOeuAbiuaMFXRtDOLriTJ5tSxD',
  content: 'hi how are you doing?',
});

console.log(response.messages);
{
  "messages": [
    {
      "message_id": "Jabr9TXYYJHfvl6Syypi88rdAHYHmcq6",
      "role": "agent",
      "content": "hi how are you doing?",
      "created_timestamp": 1703302428855
    }
  ]
}

Documentation Index

Fetch the complete documentation index at: https://docs.retellai.com/llms.txt

Use this file to discover all available pages before exploring further.

Authorizations

Authorization
string
header
required

Authentication header containing API key (find it in dashboard). The format is "Bearer YOUR_API_KEY"

Body

application/json
chat_id
string
required

Unique id of the chat to create completion.

Example:

"oBeDLoLOeuAbiuaMFXRtDOLriTJ5tSxD"

content
string
required

user message to generate agent chat completion.

Example:

"hi how are you doing?"

Response

Successfully created chat completion.

messages
object[]
required

New messages generated by the agent during this completion, including any tool call invocations and their results. Does not include the original input messages.