Generate a completion (OpenAI-compatible, non-streaming)
Beta
Limited OpenAI Chat Completions API compatibility. Supports basic chat completion with standard message roles and JSON responses. Not supported: OpenAI-style streaming, tool calls, stop sequences, logprobs, and most request parameters.
Creates a chat completion response from a list of messages comprising a conversation.
Path parameters
-
replicaUUID
string(uuid) Required The UUID of the Replica
Body
-
messages
array[object] Required A list of messages that make up the conversation context. Only the last message is used for completion.
-
store
boolean When set to false, historical messages are not used in the context, and the message is not appended to the conversation history.
Default value is
true
. -
source
string The place where the conversation is happening, which informs where the message should be saved in the chat history if
store
is true.Values are
discord
,embed
, orweb
. Default value isweb
. -
discord_data
object Discord information about the message
Additional properties are NOT allowed.
curl \
--request POST 'https://api.sensay.io/v1/experimental/replicas/03db5651-cb61-4bdf-9ef0-89561f7c9c53/chat/completions' \
--header "X-ORGANIZATION-SECRET: $API_KEY" \
--header "X-USER-ID: $API_KEY" \
--header "Content-Type: application/json" \
--data '{"messages":[{"role":"system","content":"You are a helpful assistant."},{"role":"user","content":"How did you handle the immense pressure during the Civil War?"}],"store":true,"source":"web","discord_data":{"channel_id":"string","channel_name":"string","author_id":"string","author_name":"string","message_id":"string","created_at":"string","server_id":"string","server_name":"string"}}'
{
"messages": [
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "How did you handle the immense pressure during the Civil War?"
}
],
"store": true,
"source": "web",
"discord_data": {
"channel_id": "string",
"channel_name": "string",
"author_id": "string",
"author_name": "string",
"message_id": "string",
"created_at": "string",
"server_id": "string",
"server_name": "string"
}
}
{
"id": "chatcmpl-abc123",
"created": 1677858242,
"object": "chat.completion",
"model": "o1",
"choices": [
{
"index": 0,
"message": {
"role": "assistant",
"content": "During the Civil War, I faced tremendous pressure...",
"tool_calls": []
},
"finish_reason": "stop"
}
],
"usage": {
"prompt_tokens": 56,
"completion_tokens": 31,
"total_tokens": 87
}
}
{
"success": true,
"error": "string",
"fingerprint": "14fceadd84e74ec499afe9b0f7952d6b",
"request_id": "xyz1::reg1:reg1::ab3c4-1234567890123-0123456789ab"
}
{
"success": true,
"error": "string",
"fingerprint": "14fceadd84e74ec499afe9b0f7952d6b",
"request_id": "xyz1::reg1:reg1::ab3c4-1234567890123-0123456789ab"
}
{
"success": true,
"error": "string",
"request_id": "xyz1::reg1:reg1::ab3c4-1234567890123-0123456789ab"
}
{
"success": true,
"error": "string",
"fingerprint": "14fceadd84e74ec499afe9b0f7952d6b",
"request_id": "xyz1::reg1:reg1::ab3c4-1234567890123-0123456789ab"
}
{
"success": true,
"error": "string",
"fingerprint": "14fceadd84e74ec499afe9b0f7952d6b",
"request_id": "xyz1::reg1:reg1::ab3c4-1234567890123-0123456789ab",
"inner_exception": {
"name": "Server overheated",
"cause": "Request too complicated",
"stack": "Error: Server overheated due to an unexpected situation\n at Object.eval (eval at <anonymous>...",
"message": "The server overheated due to an unexpected situation"
}
}