Chatbot Operations

Query the knowledge base

This operation fetches segments pertinent to generating responses. Designed for seamless chatbot integration with the GPTs store, this API endpoint allows users to supply relevant document fragments to the GPTs. As with the /get-confidence-score endpoint, results are cached by query for efficiency.

Credit Cost: Each query costs 0.5 message credits. If reranking runs, the total cost is 1.0 message credit (0.5 base + 0.5 reranking); a cached result costs 0.5 even with reranking enabled. Requests are rejected if the available credits are insufficient.

post/query-knowledge-base/{chatbotId}

Request

  • Base URL: https://api.chat-data.com/api/v2
  • URL: https://api.chat-data.com/api/v2/query-knowledge-base/{chatbotId}
  • Auth: HTTP bearer

Path parameters

chatbotIdstring required

The unique identifier allocated to the chatbot.

Request body

querystring required

The text used to search the knowledge base by vector (cosine) similarity.

countnumber

The minimum number of context segments to select when available. More are added until a minimum token budget is met, then the list is trimmed to a maximum token budget, so the result can hold more or fewer. Only segments with a positive cosine similarity to the query are returned.

Example request

{
  "query": "What are your opening hours?"
}

Response

Successful response. The body is a JSON array of matching chunks, without a status field.

sourcestring

The name or URL of the source (document filename, website URL, etc.).

typestring

The data source type of the chunk (e.g. website, text/pdf, text/csv, product, video, notion).

snippetstring

The text content of the chunk.

relavant_scorestring

The similarity score of the chunk as a string with two decimal places (the field name is spelled relavant_score).

Example response

[
  {
    "source": "https://www.example.com/support/opening-hours",
    "type": "website",
    "snippet": "Our support team is available Monday to Friday, 9am to 6pm EST. Outside these hours you can email support@example.com.",
    "relavant_score": "0.87"
  }
]

Changes

No recorded changes to this operation across all 1 revision of this API.