LogoLogo
Home
  • Introduction
  • Quickstart
    • Starter guide
    • Core Concepts
      • Stack Type
      • Data Loader
      • Inputs/Outputs
      • Text Splitters
      • Embedding Model
      • Vector Store
      • Large Language Model
      • Memory
      • Chain
    • Testing Stack
    • Deployment
    • Knowledge Base
    • Organization and Teams
    • Secret Keys
    • Logs
  • Components
    • Inputs
    • Outputs
    • Document Loaders
    • Prompts
    • Text Splitters
    • Embeddings
    • Vector Store
    • Retrievers
    • Multi Modals
    • Agents
    • Large Language Models
    • Memories
    • Chains
    • Output Parsers
  • Customization
    • Writing Custom Components in GenAI Stack
    • Build your own custom component
    • Define parameters used for required components
  • Usecases
    • Simple QA using Open Source Large Language Models
    • Multilingual Indic Language Translation
    • Document Search and Chat
    • Chat with Multiple Documents
  • Terminologies
    • RAG - Retrieval Augmented Generation
    • Hybrid Search - Ensemble Retriever
  • REST APIs
    • GenAI Stack REST APIs
    • Chat API Reference
    • Text Generation API Reference
    • Rate Limiting and Sleep Mode
  • Troubleshooting
    • How to verify what is loaded and chunked from the loader?
  • Acknowledgements
    • Special Mentions
Powered by GitBook
On this page

Was this helpful?

  1. REST APIs

Chat API Reference

PreviousGenAI Stack REST APIsNextText Generation API Reference

Last updated 1 year ago

Was this helpful?

Following are the steps to use Test it feature.

  • Replace the {{url}} with the deployed url.

  • Get the from the GenAI Stack for authentication.

  • Now you're ready to test the APIs.

api key

Health

get
Responses
200
Successful Response
application/json
Responseany
get
GET /health HTTP/1.1
Host: {{url}}
Accept: */*
200

Successful Response

No content

Get Stack App

get

Retrieve the stack app instance.

This endpoint fetches the stack app, including its associated chat sessions or text generations based on the interface type selected, using the provided token/api key.

Parameters:

  • authorization: str - Provide your API key as a Bearer token in the Authorization header to authenticate requests.

Responses:

  • 200 OK: Returns a detailed view of the stack app including chat sessions and text generations.
  • 404 Not Found: If no stack app is found for the given criteria.

Exceptions:

  • Raises a 404 HTTPException if no stack app is found.
Query parameters
tokenstringOptional
Header parameters
authorizationstringOptional
Responses
200
Successful Response
application/json
422
Validation Error
application/json
get
GET /api/v1/apps HTTP/1.1
Host: {{url}}
Accept: */*
{
  "id": "123e4567-e89b-12d3-a456-426614174000",
  "data": {},
  "form_keys_data": {},
  "stack_type": "chat",
  "chat_sessions": [
    {
      "id": "123e4567-e89b-12d3-a456-426614174000",
      "title": "text",
      "data": [
        {
          "is_bot": true,
          "message": "text",
          "chatKey": "text",
          "type": "text",
          "intermediate_steps": "text",
          "files": []
        }
      ]
    }
  ],
  "text_generations": [
    {
      "id": "123e4567-e89b-12d3-a456-426614174000",
      "inputs": {},
      "outputs": {},
      "logs": "text",
      "meta_data": {},
      "status": "pending"
    }
  ]
}

Get Chat Session

get

Retrieve details of a specific chat session by its ID and associated stack app ID.

Parameters:

  • stack_app_id: UUID - Path parameter to specify the stack app ID.
  • chat_session_id: str - Path parameter to specify the chat session ID.
  • authorization: str - Provide your API key as a Bearer token in the Authorization header to authenticate requests.

Responses:

  • 200 OK: Successfully retrieves and returns the details of the chat session.
  • 400 Bad Request: If the chat_session_id is not a valid UUID.
  • 401 Unauthorized: If user authentication fails.
  • 404 Not Found: If no chat session is found matching the criteria.

Exceptions:

  • Raises 400 HTTPException if chat_session_id is invalid.
  • Raises 401 HTTPException for unauthorized access.
  • Raises 404 HTTPException if the chat session is not found.
  • Raises 404 HTTPException if stack app doesn't exist
Path parameters
stack_app_idstring · uuidRequired
chat_session_idstringRequired
Query parameters
tokenstringOptional
Header parameters
authorizationstringOptional
Responses
200
Successful Response
application/json
422
Validation Error
application/json
get
GET /api/v1/{stack_app_id}/chat-sessions/{chat_session_id} HTTP/1.1
Host: {{url}}
Accept: */*
{
  "id": "123e4567-e89b-12d3-a456-426614174000",
  "title": "text",
  "data": [
    {
      "is_bot": true,
      "message": "text",
      "chatKey": "text",
      "type": "text",
      "intermediate_steps": "text",
      "files": []
    }
  ],
  "data_pipelines": [
    {
      "id": "123e4567-e89b-12d3-a456-426614174000",
      "input_key": "text",
      "meta_data": {},
      "created_at": "2025-05-15T10:41:27.950Z",
      "files": [
        {
          "id": "123e4567-e89b-12d3-a456-426614174000",
          "file": "text",
          "url": "text",
          "text": "text",
          "created_at": "2025-05-15T10:41:27.950Z",
          "data_pipeline_status": "queued",
          "meta_data": {}
        }
      ]
    }
  ],
  "can_chat": true
}

Data Pipeline List

get

This endpoint lists all files, URLs, or text snippets associated with a chat session, allowing for a comprehensive view of the resources related to a conversation.

Parameters:

  • stack_app_id: str - The unique identifier of the stack app associated with the chat session.
  • chat_session_id: str - The unique identifier of the chat session for which to list uploads.
  • authorization: str - Provide your API key as a Bearer token in the Authorization header to authenticate requests.

Responses:

  • 200 OK: Successfully returns a list of uploads for the chat session.
  • 401 Unauthorized: User authentication failed.
  • Raises 404 HTTPException if stack app doesn't exist

This endpoint provides an overview of all resources uploaded or linked in the context of a specific chat session.

Path parameters
stack_app_idstring · uuidRequired
chat_session_idstringRequired
Query parameters
tokenstringOptional
Header parameters
authorizationstringOptional
Responses
200
Successful Response
application/json
422
Validation Error
application/json
get
GET /api/v1/{stack_app_id}/chat-sessions/{chat_session_id}/uploads HTTP/1.1
Host: {{url}}
Accept: */*
[
  {
    "id": "123e4567-e89b-12d3-a456-426614174000",
    "file": "text",
    "url": "text",
    "text": "text",
    "chat_session_id": "123e4567-e89b-12d3-a456-426614174000",
    "created_at": "2025-05-15T10:41:27.950Z",
    "meta_data": {},
    "data_pipeline_status": "queued",
    "data_pipeline": {
      "id": "123e4567-e89b-12d3-a456-426614174000",
      "input_key": "text",
      "meta_data": {},
      "created_at": "2025-05-15T10:41:27.950Z"
    }
  }
]

Get Data Pipeline

get

Retrieve the status and details of a specific file upload, URL, or text associated with a chat session. This allows for detailed tracking and management of resources within a chat context.

Parameters:

  • stack_app_id: str - The unique identifier of the stack app associated with the chat session.
  • upload_id: str - The unique identifier of the upload whose details are being retrieved.
  • chat_session_id: str - The unique identifier of the chat session associated with the upload.
  • authorization: str - Provide your API key as a Bearer token in the Authorization header to authenticate requests.

Responses:

  • 200 OK: Successfully returns the details of the specified upload.
  • 401 Unauthorized: User authentication failed.
  • Raises 404 HTTPException if stack app doesn't exist
Path parameters
stack_app_idstring · uuidRequired
upload_idstringRequired
chat_session_idstringRequired
Query parameters
tokenstringOptional
Header parameters
authorizationstringOptional
Responses
200
Successful Response
application/json
422
Validation Error
application/json
get
GET /api/v1/{stack_app_id}/chat-sessions/{chat_session_id}/uploads/{upload_id} HTTP/1.1
Host: {{url}}
Accept: */*
{
  "id": "123e4567-e89b-12d3-a456-426614174000",
  "file": "text",
  "url": "text",
  "text": "text",
  "chat_session_id": "123e4567-e89b-12d3-a456-426614174000",
  "created_at": "2025-05-15T10:41:27.950Z",
  "meta_data": {},
  "data_pipeline_status": "queued",
  "data_pipeline": {
    "id": "123e4567-e89b-12d3-a456-426614174000",
    "input_key": "text",
    "meta_data": {},
    "created_at": "2025-05-15T10:41:27.950Z"
  }
}
  • GETHealth
  • GETGet Stack App
  • POSTCreate Chat Session
  • GETGet Chat Session
  • POSTChat
  • PATCHUpdate Chat Session
  • GETData Pipeline List
  • POSTData Pipeline
  • GETGet Data Pipeline

Create Chat Session

post

Create a new chat session associated with a specific stack app.

Parameters:

  • stack_app_id: UUID - Path parameter to specify the stack app ID the chat session will be associated with.
  • title: Optional[str] - A custom title for the chat session. If not provided, a default title "New Chat" is used.
  • authorization: str - Provide your API key as a Bearer token in the Authorization header to authenticate requests.

Responses:

  • 200 OK: Returns the created chat session's details.
  • 401 Unauthorized: If user authentication fails.
  • 429 Too Many Requests: If the request is throttled based on rate limiting.

Exceptions:

  • Raises 401 HTTPException for unauthorized access.
  • Raises 429 HTTPException for exceeding rate limit, with retry information.
  • Raises 404 HTTPException if stack app doesn't exist
Path parameters
stack_app_idstring · uuidRequired
Query parameters
tokenstringOptional
Header parameters
authorizationstringOptional
Body
titleany ofOptional
stringOptional
or
nullOptional
Responses
200
Successful Response
application/json
422
Validation Error
application/json
post
POST /api/v1/{stack_app_id}/chat-sessions HTTP/1.1
Host: {{url}}
Content-Type: application/json
Accept: */*
Content-Length: 16

{
  "title": "text"
}
{
  "id": "123e4567-e89b-12d3-a456-426614174000",
  "title": "text",
  "data": [
    {
      "is_bot": true,
      "message": "text",
      "chatKey": "text",
      "type": "text",
      "intermediate_steps": "text",
      "files": []
    }
  ]
}

Chat

post

Initiates or continues a chat session by sending a payload to the specified chat session.

This endpoint allows users to interact with a chat session by sending a payload. The payload will be processed according to the chat session's logic, and a response will be streamed back. This endpoint requires user authentication and is subject to rate limiting to ensure fair usage.

Parameters:

  • stack_app_id: str - The unique identifier of the stack app associated with the chat session. It is a path parameter.
  • chat_session_id: str - The unique identifier of the chat session to which the message is being sent. It is a path parameter.
  • payload: dict - A JSON object containing the chatKey & inputs. The values of chatKey & inputs will be dynamic check the form_keys_data object in stack app data in which chatKey is key given in input_keys & inputs is object containing all the required inputs. When there are multiple input_keys chatKey can be the key which you want to make it primary.
  • authorization: str - Provide your API key as a Bearer token in the Authorization header to authenticate requests.

Successful Response:

  • Returns a streaming response, which streams the response from the chat session back to the client. The response is in the text/event-stream format.

Errors:

  • HTTP 401 Unauthorized: Returned if the user cannot be authenticated or authorized, indicating either missing, invalid, or expired credentials.
  • HTTP 429 Too Many Requests: Returned if the request is throttled based on rate limiting. The response includes a Retry-After header indicating how long the client should wait before retrying.
  • HTTP 500 Internal Server Error: Returned if an unexpected error occurs during the processing of the chat message.
  • Raises 404 HTTPException if stack app doesn't exist

Notes:

  • The endpoint is designed for real-time chat interactions and uses Server-Sent Events (SSE) to stream responses back to the client.
  • Clients must be prepared to handle streaming responses and display them to the user in real-time.
  • The rate limiting mechanism is in place to ensure that all users have a smooth experience.
Path parameters
stack_app_idstring · uuidRequired
chat_session_idstringRequired
Query parameters
tokenstringOptional
Header parameters
authorizationstringOptional
Body
chatKeystringRequired
inputsobject · InputsRequired
Responses
200
Successful Response
application/json
Responseany of
or
or
422
Validation Error
application/json
post
POST /api/v1/{stack_app_id}/chat-sessions/{chat_session_id} HTTP/1.1
Host: {{url}}
Content-Type: application/json
Accept: */*
Content-Length: 30

{
  "chatKey": "text",
  "inputs": {}
}
{
  "is_bot": true,
  "message": "text",
  "chatKey": "text",
  "type": "text",
  "intermediate_steps": "text",
  "files": []
}

Update Chat Session

patch

Update details of an existing chat session, such as its title.

Parameters:

  • stack_app_id: UUID - Path parameter for the associated stack app.
  • chat_session_id: UUID - Path parameter for the chat session to update.
  • update_request: ChatSessionUpdate - The request body containing the update details.
  • authorization: str - Provide your API key as a Bearer token in the Authorization header to authenticate requests.

Responses:

  • 200 OK: Returns the updated chat session details.
  • 401 Unauthorized: If user authentication fails.
  • 404 Not Found: If no chat session is found matching the criteria.

Exceptions:

  • Raises 401 HTTPException for unauthorized access.
  • Raises 404 HTTPException if the chat session not found
  • Raises 404 HTTPException if stack app doesn't exist
Path parameters
stack_app_idstring · uuidRequired
chat_session_idstring · uuidRequired
Query parameters
tokenstringOptional
Header parameters
authorizationstringOptional
Body
titleany ofOptional
stringOptional
or
nullOptional
Responses
200
Successful Response
application/json
422
Validation Error
application/json
patch
PATCH /api/v1/{stack_app_id}/chat-sessions/{chat_session_id} HTTP/1.1
Host: {{url}}
Content-Type: application/json
Accept: */*
Content-Length: 16

{
  "title": "text"
}
{
  "id": "123e4567-e89b-12d3-a456-426614174000",
  "title": "text",
  "data": [
    {
      "is_bot": true,
      "message": "text",
      "chatKey": "text",
      "type": "text",
      "intermediate_steps": "text",
      "files": []
    }
  ],
  "data_pipelines": [
    {
      "id": "123e4567-e89b-12d3-a456-426614174000",
      "input_key": "text",
      "meta_data": {},
      "created_at": "2025-05-15T10:41:27.950Z",
      "files": [
        {
          "id": "123e4567-e89b-12d3-a456-426614174000",
          "file": "text",
          "url": "text",
          "text": "text",
          "created_at": "2025-05-15T10:41:27.950Z",
          "data_pipeline_status": "queued",
          "meta_data": {}
        }
      ]
    }
  ],
  "can_chat": true
}

Data Pipeline

post

Upload a file, or provide a URL or text to be associated with a chat session. This endpoint supports file uploads for further processing and inclusion in the chat session's context or data pipelines.

Parameters:

  • stack_app_id: str - The unique identifier for the stack app associated with this chat session.
  • chat_session_id: str - The unique identifier for the chat session where the file or text is to be uploaded.
  • input_key: str - A key identifying the type of input or the specific pipeline this upload is associated with.
  • url: str (optional) - A URL pointing to a resource to be associated with the chat session.
  • file: UploadFile (optional) - The file to be uploaded. Files should be less than 50MB in size.
  • text: str (optional) - Text content to be associated with the chat session.
  • authorization: str - Provide your API key as a Bearer token in the Authorization header to authenticate requests.

Responses:

  • 200 OK: Returns the details of the uploaded file or the provided URL/text including any metadata.
  • 401 Unauthorized: User authentication failed.
  • 400 Bad Request: Data pipeline for the provided input_key not found or the file size exceeds the limit.
  • 429 Too Many Requests: The request is throttled based on rate limiting.
  • Raises 404 HTTPException if stack app doesn't exist

Usage:

  • To upload a file, include it in the request's form-data.
  • To associate a URL or text with the chat session, provide them in the form-data without a file.

This endpoint is subject rate limiting to ensure smooth experience for all the users.

Path parameters
stack_app_idstring · uuidRequired
chat_session_idstringRequired
Query parameters
tokenstringOptional
Header parameters
authorizationstringOptional
Body
input_keystringRequired
urlany ofOptional
stringOptional
or
nullOptional
fileany ofOptional
string · binaryOptional
or
nullOptional
textany ofOptional
stringOptional
or
nullOptional
Responses
200
Successful Response
application/json
422
Validation Error
application/json
post
POST /api/v1/{stack_app_id}/chat-sessions/{chat_session_id}/uploads HTTP/1.1
Host: {{url}}
Content-Type: multipart/form-data
Accept: */*
Content-Length: 63

{
  "input_key": "text",
  "url": "text",
  "file": "binary",
  "text": "text"
}
{
  "id": "123e4567-e89b-12d3-a456-426614174000",
  "file": "text",
  "url": "text",
  "text": "text",
  "chat_session_id": "123e4567-e89b-12d3-a456-426614174000",
  "created_at": "2025-05-15T10:41:27.950Z",
  "meta_data": {},
  "data_pipeline_status": "queued",
  "data_pipeline": {
    "id": "123e4567-e89b-12d3-a456-426614174000",
    "input_key": "text",
    "meta_data": {},
    "created_at": "2025-05-15T10:41:27.950Z"
  }
}