Chat
/routes/chat/completion
POST
https://api.answerly.io/routes/chat/completion
Generates a response to a chat conversation. This endpoint is OpenAI spec safe, allowing for seamless integration with existing OpenAI-compatible libraries and tools.
Note: Models and any other AI configurations cannot be passed in the API request body. All AI configuration must be done directly to the agent from the Answerly dashboard.
Request Body
APIKey
string
Required
Your API key. You can read more about how to get an API Key by clicking here.
agentId
string
Required
The ID of your specific agent.
You can find the Agent ID in your Agent Settings -> Settings tab, located all the way at the bottom of the page.
You can find the Agent ID in your Agent Settings -> Settings tab, located all the way at the bottom of the page.
input
array
Required
A list of messages comprising the conversation so far, formatted to standard OpenAI specifications.
input[].role
string
Required
The role of the messages author. Typically
user, assistant, or system.
input[].content
string
Required
The contents of the message.
curl --request POST \
--url 'https://api.answerly.io/routes/chat/completion' \
--header 'Content-Type: application/json' \
--data '{
"APIKey": "YOUR_API_KEY",
"agentId": "YOUR_AGENT_ID",
"input": [
{
"role": "user",
"content": "What is your name?"
}
]
}'
Return (success)
choices
array
A list of chat completion choices containing the generated assistant role and content.
{
"choices": [
{
"role": "assistant",
"content": "I am an AI assistant created by Answerly."
}
]
}
Return (failure)
error
object
The error object containing failure details.
error.code
string
An error code returned by the server. Possible values:
error
completions-error
unknown-error
error.message
string
A human-readable message providing more details about the error.
{
"error": {
"code": "completions-error",
"message": "The specified agentId could not be located."
}
}