Chat with file by File ID

Send a query related to a specific file.

POST https://api.knowbase.ai/api/v1/chat

Headers

Name
Type
Description

access-token*

string

Required. Your API access token

Request Body

Name
Type
Description

file_id*

string

Required. The ID of the file related to the query

query*

string

The query text

{
  "result": "string",
  "source": {},
  "documentType": "string"
}

Example usage

import requests
import json

# The URL for the chat endpoint
url = 'https://api.knowbase.ai/api/v1/chat'

# Replace 'your_access_token_here' with the actual access token you received from the API
headers = {
    'access-token': 'your_access_token_here',
    'Content-Type': 'application/json'  # Specify the content type as JSON
}

# Replace 'your_file_id_here' with the actual file ID you want to query
# Replace 'your_query_here' with the actual query text
data = {
    'file_id': 'your_file_id_here',
    'query': 'your_query_here'
}

# Make the POST request to send the query
response = requests.post(url, headers=headers, data=json.dumps(data))

# Check the response
if response.status_code == 200:
    print("Query processed successfully.")
    print(response.text)  # This will print the response to the query
elif response.status_code == 404:
    print("File not found or has not been processed yet.")
    print(response.json())  # This will print the error message
elif response.status_code == 429:
    print("Rate limit reached.")
    print(response.json())  # This will print the error message
else:
    print("Failed to process the query.")
    print(response.json())  # This will print the error message

Last updated