Serverless AI Text Conversation
AI powered conversational service that generates responses to user messages, supporting conversation history and context.
Endpoint
Generate conversational AI responses with context and history
POSThttps://api.xtartapp.com/text/conversation
*Authentication
You must use a Bearer token provided by the dashboard to use for authentication. Add the token to the Authorization header.
Request body
| Name | Type | Required | Max | Description |
|---|---|---|---|---|
| ask | string | Yes | 1000 | The user input message. |
| behavior | string | No | - | Custom behavior instruction for the assistant (defaults to 'You are a helpful AI assistant.') |
| history | array of objects | No | 25 | Previous conversation history between user and assistant. |
| history[].role | string | Yes | - | The role of the message sender (user or assistant) |
| history[].content | string | Yes | 500 | The message content. |
| context | string | No | 25000 | Optional context information that helps the assistant generate better responses (max 25 000 characters). |
| language | string | No | - | The language code for the assistant response. |
Response
| Name | Type | Description |
|---|---|---|
| data | object | The assistant response data. |
| data.response | string | The assistant response text. |
| metadata | object | Metadata about the execution process. |
| metadata.cost | number | The cost of the execution request. |
Errors
{
"error": "string",
"code": "string"
}| HTTP Status | Error Code | Message |
|---|---|---|
| 400 | INVALID_PAYLOAD | Occurs when the payload is invalid. |
| 400 | INVALID_REQUEST | The request is invalid. |
| 400 | TEXT_CONVERSATION_ERROR | Could not generate response | parsing error. |
| 400 | HARM_CONTENT | The content is harmful and cannot be processed. |
| 400 | INSUFFICIENT_BALANCE | The user has insufficient balance. |
| 400 | INPUT_TOO_LONG | The input text exceeds the maximum length. |
| 401 | UNAUTHORIZED | The token is invalid. |
| 429 | TOO_MANY_REQUESTS | The request limit has been reached. |