Generate Assistant Message
This endpoint allows you to generate a new message from the assistant within a specific chat session in TaskingAI.
Endpoint
- Method:
POST
- URL:
https://api.tasking.ai/v1/assistants/{assistant_id}/chats/{chat_id}/generate
Path Parameters
Parameter | Type | Description |
---|---|---|
assistant_id | string | The unique identifier for the assistant. |
chat_id | string | The unique identifier for the chat. |
Header Parameters
All TaskingAI API requests require the following headers:
Header | Type | Description |
---|---|---|
Content-Type | string | The content type of the request. Set to application/json . |
Authorization | string | API key for authorization in the format Bearer $TASKINGAI_API_KEY . The key can be obtained in the project settings in your TaskingAI console. |
Payload Parameters
Request Body (application/json)
Parameter | Type | Required | Default | Description |
---|---|---|---|---|
stream | boolean | No | false | Whether to return the assistant message in stream format. If true , the response data will be returned in SSE format. |
Examples
Normal Example
Request
{
"stream": false
}
Response Example
{
"status": "success",
"data": {
"object": "Message",
"message_id": "message_1",
"chat_id": "chat_1",
"assistant_id": "assistant_1",
"role": "assistant",
"content": {"text": "Nice to meet you"},
"metadata": {},
"updated_timestamp": 1730210035453,
"created_timestamp": 1730210035453
}
}
Stream Example
Request
{
"stream": true
}
Response Example
The response is in Server-Sent Events (SSE) format.
Message chunks are sent one by one as individual events, with the data
field containing the message content.
data: {"object": "MessageChunk", "role": "assistant", "index": 0, "delta": "Nice", "created_timestamp": 1730210033691}
data: {"object": "MessageChunk", "role": "assistant", "index": 1, "delta": " to", "created_timestamp": 1730210033735}
data: {"object": "MessageChunk", "role": "assistant", "index": 2, "delta": " meet", "created_timestamp": 1730210033735}
data: {"object": "MessageChunk", "role": "assistant", "index": 3, "delta": " you", "created_timestamp": 1730210033797}
data: {"object": "Message", "assistant_id": "assistant_1", "chat_id": "chat_1", "message_id": "message_1", "role": "assistant", "content": {"text": "Nice to meet you"}, "metadata": {}, "created_by": "user_1", "updated_by": "user_1", "created_timestamp": 1730210035453, "updated_timestamp": 1730210035453}
data: [DONE]