Chatbot Operations

Get confidence scores

This operation retrieves the confidence scores (defined as cosine similarity) of the related chunks used to generate answers. You can use it to obtain confidence scores before calling the /chat API endpoint, providing an estimate of the chatbot's ability to deliver high-quality answers based on the context. Chunks are cached based on the messages array, so subsequent calls to the /chat API with the same messages array will incur minimal latency in retrieving related vector embeddings from the database. Therefore, calling this API endpoint before /chat should not significantly impact overall chat performance.

post/get-confidence-score

Request

  • Base URL: https://api.chat-data.com/api/v2
  • URL: https://api.chat-data.com/api/v2/get-confidence-score
  • Auth: HTTP bearer

Request body

baseModel'gpt-4o-mini' | 'gpt-4o' | 'gpt-4' | 'gpt-4.1-nano' | 'gpt-4.1-mini' | 'gpt-4.1' | 'gpt-5-nano' | 'gpt-5-mini' | 'gpt-5' | 'gpt-5.1' | 'gpt-5.2' | 'gpt-5.6-sol' | 'gpt-5.6-terra' | 'gpt-5.6-luna' | 'gpt-6-astra' | 'gpt-6.1-sol' | 'gpt-6-luna' | 'gpt-5.5' | 'gpt-5.4' | 'gpt-5.4-nano' | 'gpt-5.4-mini' | 'gpt-o1' | 'gpt-o3-mini' | 'gpt-o3' | 'gpt-o4-mini' | 'claude-4-5-sonnet' | 'claude-4-6-sonnet' | 'claude-4-5-haiku' | 'claude-4-opus' | 'claude-4.1-opus' | 'claude-4.5-opus' | 'claude-4.6-opus' | 'claude-5-opus' | 'claude-5-sonnet' | 'claude-5-5-opus' | 'claude-5-5-sonnet' | 'claude-5-5-haiku' | 'gemini-3.0-flash' | 'gemini-3.1-flash' | 'gemini-3.5-flash-lite' | 'gemini-3.7-flash' | 'gemini-2.5-pro' | 'gemini-3.0-pro' | 'gemini-3.1-pro' | 'deepseek-r1' | 'deepseek-v3.2' | 'mancer-deepseek-v4-flash'

Overrides the chatbot's baseModel setting when processing the RAG context for this request.

chatbotIdstring required

The ID of the chatbot.

Example request

{
  "messages": [
    {
      "role": "assistant",
      "content": "How can I help you?"
    },
    {
      "role": "user",
      "content": "How does Chat Data work?"
    }
  ],
  "chatbotId": "6650f1c2a9e4b83d2c7a1f05"
}

Response

Successful response.

status'success' required
score0

Only returned, instead of the other fields, when the chatbot uses custom-model or ignoreDataSource is on. Always 0.

averageScorenumber

The average confidence score of all context chunks. Confidence score is defined as cosine similarity, and only context chunks with positive cosine similarities are included.

scoresArraynumber[]

The confidence score of each context chunk used to generate the answer.

embeddingTextstring

The actual text used to generate the embedding. To take the chat history into account, more than the last query may be used to generate embeddingText, depending on the messages array.

Example response

{
  "averageScore": 0.8,
  "scoresArray": [
    0.85,
    0.75
  ],
  "sources": [
    {
      "score": 0.85,
      "url": "https://www.chat-data.com/",
      "title": "Chat Data | Build AI chatbots with your own data",
      "text": "Chat Data lets you build an AI chatbot trained on your own documents, websites and Q&As, then embed it on your site or connect it to WhatsApp, Slack, Discord and more.",
      "type": "website"
    },
    {
      "score": 0.75,
      "question": "How do I train my chatbot?",
      "answer": "Add documents, website links, plain text or Q&As as sources, then retrain the chatbot. Training usually finishes in 1-2 minutes.",
      "type": "q&a"
    }
  ],
  "embeddingText": "How does Chat Data work?"
}

Changes

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