Generate a Telegram completion

POST /v1/replicas/{replicaUUID}/chat/completions/telegram

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.

Path parameters

application/json

Body

  • content string Required

    Content of the message must be between 1 and 10000 characters.

    Minimum length is 1, maximum length is 10000.

  • 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.

    Default value is false.

  • telegram_data object Required

    Telegram information about the message

    Additional properties are NOT allowed.

    Hide telegram_data attributes Show telegram_data attributes object
    • chat_type string Required

      Type of the chat, can be either private, group, supergroup or channel.

    • chat_id number Required

      Unique identifier for this chat.

    • user_id number

      Sender of the message's userID; may be empty for messages sent to channels. For backward compatibility, if the message was sent on behalf of a chat, the field contains a fake sender user in non-channel chats.

    • username string

      Sender of the message's username; may be empty for messages sent to channels. For backward compatibility, if the message was sent on behalf of a chat, the field contains a fake sender user in non-channel chats.

    • message_id number Required

      Unique message identifier inside this chat. In specific instances (e.g., message containing a video sent to a big chat).

    • Unique identifier of a message thread or a forum topic to which the message belongs; for supergroups only.

Responses

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

    Hide response attributes Show response attributes object
    Hide response attributes Show response attributes object
  • 400 application/json

    Bad Request

    Hide response attributes Show response attributes object
    • success boolean Required

      Indicates the status of the request

    • error string Required

      A text representation of the error

    • A unique identifier of the event, useful for reporting

    • request_id string Required

      A unique identifier of the request, useful for reporting

  • 401 application/json

    Unauthorized

    Hide response attributes Show response attributes object
    • success boolean Required

      Indicates the status of the request

    • error string Required

      A text representation of the error

    • A unique identifier of the event, useful for reporting

    • request_id string Required

      A unique identifier of the request, useful for reporting

  • 404 application/json

    Not Found

    Hide response attributes Show response attributes object
    • success boolean Required

      Indicates the status of the request

    • error string Required

      A text representation of the error

    • request_id string Required

      A unique identifier of the request, useful for reporting

  • 415 application/json

    Unsupported Media Type

    Hide response attributes Show response attributes object
    • success boolean Required

      Indicates the status of the request

    • error string Required

      A text representation of the error

    • A unique identifier of the event, useful for reporting

    • request_id string Required

      A unique identifier of the request, useful for reporting

  • 500 application/json

    Internal Server Error

    Hide response attributes Show response attributes object
    • success boolean Required

      Indicates the status of the request

    • error string Required

      A text representation of the error

    • A unique identifier of the event, useful for reporting

    • request_id string Required

      A unique identifier of the request, useful for reporting

    • The inner exception

      Hide inner_exception attributes Show inner_exception attributes object
POST /v1/replicas/{replicaUUID}/chat/completions/telegram
curl \
 --request POST 'https://api.sensay.io/v1/replicas/03db5651-cb61-4bdf-9ef0-89561f7c9c53/chat/completions/telegram' \
 --header "X-ORGANIZATION-SECRET: $API_KEY" \
 --header "X-USER-ID: $API_KEY" \
 --header "Content-Type: application/json" \
 --data '{"content":"How did you handle the immense pressure during the Civil War?","skip_chat_history":false,"telegram_data":{"chat_type":"string","chat_id":42.0,"user_id":42.0,"username":"string","message_id":42.0,"message_thread_id":42.0}}'
Request examples
{
  "content": "How did you handle the immense pressure during the Civil War?",
  "skip_chat_history": false,
  "telegram_data": {
    "chat_type": "string",
    "chat_id": 42.0,
    "user_id": 42.0,
    "username": "string",
    "message_id": 42.0,
    "message_thread_id": 42.0
  }
}
Response examples (200)
{
  "content": "I handled the immense pressure during the Civil War by...",
  "success": true
}
Response examples (200)
{"content"=>"I handled the immense pressure during the Civil War by...", "success"=>true}
Response examples (400)
{
  "success": true,
  "error": "string",
  "fingerprint": "14fceadd84e74ec499afe9b0f7952d6b",
  "request_id": "xyz1::reg1:reg1::ab3c4-1234567890123-0123456789ab"
}
Response examples (401)
{
  "success": true,
  "error": "string",
  "fingerprint": "14fceadd84e74ec499afe9b0f7952d6b",
  "request_id": "xyz1::reg1:reg1::ab3c4-1234567890123-0123456789ab"
}
Response examples (404)
{
  "success": true,
  "error": "string",
  "request_id": "xyz1::reg1:reg1::ab3c4-1234567890123-0123456789ab"
}
Response examples (415)
{
  "success": true,
  "error": "string",
  "fingerprint": "14fceadd84e74ec499afe9b0f7952d6b",
  "request_id": "xyz1::reg1:reg1::ab3c4-1234567890123-0123456789ab"
}
Response examples (500)
{
  "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"
  }
}