Chat completions

Generate a completion

Ask for a completion and stores the prompt in the chat history.

Replica chat supports two response formats: streamed and JSON. To switch between these formats, use the 'Accept' header, specifying either 'text/event-stream' for streaming or 'application/json' for JSON. The streamed response honours the Stream Protocol, allowing the use of a number of SDKs, including Vercel AI SDK.

The streamed variant is not specified in the OpenAPI Schema because it is not an OpenAPI endpoint.

post/v1/replicas/{replicaUUID}/chat/completions

Request

  • Base URL: https://api.sensay.io
  • URL: https://api.sensay.io/v1/replicas/{replicaUUID}/chat/completions
  • Auth: one of:
    • API key in header X-ORGANIZATION-SECRET and API key in header X-USER-ID and API key in header X-USER-ID-TYPE
    • API key in header X-ORGANIZATION-SECRET

Path parameters

replicaUUIDstring uuid required

The replica unique identifier (UUID)

Example:03db5651-cb61-4bdf-9ef0-89561f7c9c53

Headers

X-API-Versionstring
Example:2025-03-25
Content-Encoding'gzip'

Content encoding for request body compression. Optional - when used, client is responsible for gzipping and sending binary data.

Request body

contentstring required

The prompt to generate completions for, encoded as a string.

skip_chat_historyboolean

When set to true, historical messages are not used in the context, and the message is not appended to the conversation history, thus it is excluded from all future chat context.

source'discord' | 'telegram' | 'embed' | 'web' | 'telegram_autopilot'

The place where the conversation is happening, which informs where the message should be saved in the chat history.

Example request

{
  "content": "How did you handle the immense pressure during the Civil War?"
}

Response

List of chat messages had with a replica by the current user, including the completion

successboolean required
contentstring required

Example response

{
  "success": true,
  "content": "I handled the immense pressure during the Civil War by..."
}

Changes

No recorded changes to this operation across all 1 revision of this API.