---
title: "Get confidence scores"
method: POST
path: "/get-confidence-score"
tags: ["Chatbot Operations"]
---

# Get confidence scores

`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

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.

## Request body

- SendConfidenceScoreReq
  - `messages` MessageInput[], required: The messages of the conversation, oldest first. On this endpoint, non-image `files` are not downloaded or parsed (only a provided `content` is used), and extra files are not dropped.
    - `role` 'user' | 'assistant', required: The role of the message sender (`user` or `assistant`).
    - `content` string, required: The text content of the message.
    - `files` object[]: An optional array of file objects attached to the message. Only the chatbot's allowed number of files is kept on the last message (3 by default); extra files are dropped.
      - `name` string, required: The name of the attached file.
      - `type` string, required: The MIME type of the file, for example `image/png` or `application/pdf`. Images (`image/*`) are passed to the model as images. Other files are downloaded and parsed to text by the type the file host reports; PDF, DOCX, HTML, plain text and CSV are supported.
      - `url` string, uri, required: The publicly accessible URL where the file is hosted by you.
      - `content` string: The text content of a non-image file. If this field is non-empty, it is used directly without downloading or parsing the file. If it is empty, the file is downloaded and parsed to text when the file type is supported. Files larger than the chatbot's file size limit (3 MB by default) cannot be downloaded, so parse them yourself and provide their content in this field.
  - `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.
  - `chatbotId` string, required: The ID of the chatbot.

## Response `200`

Successful response.

- object: When the chatbot uses `custom-model` or ignores its data source, the body is only `{ "status": "success", "score": 0 }`.
  - `status` 'success', required
  - `score` 0: Only returned, instead of the other fields, when the chatbot uses `custom-model` or `ignoreDataSource` is on. Always 0.
  - `averageScore` number: 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.
  - `scoresArray` number[]: The confidence score of each context chunk used to generate the answer.
  - `sources` object[]: The context chunks used to generate the answer, with their sources.
    - `score` number, required: Confidence score (cosine similarity) of the associated context chunk.
    - `question` string: The question text if this is a 'q&a' type source.
    - `answer` string: The answer text if this is a 'q&a' type source.
    - `url` string: The URL of the website if this is a 'website' type source.
    - `title` string: The title of the document or website.
    - `text` string: Original chunk text used to generate the answer in the `custom-data-upload` model chatbot. Text is not truncated for chatbots based on the `custom-data-upload` model.
    - `truncatedText` string: Truncated text from the `medical-chat-human` or `medical-chat-vet` model used to generate the answer. To protect the intellectual property of our database, only the first 100 characters are shown.
    - `table` string: Text representation of the table.
    - `topic` string: The topic of the medical chat model text.
    - `subtopic` string: The subtopic of the medical chat model text.
    - `type` string, required: The document type of the source.
  - `embeddingText` string: 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.

## Other responses

- `400`: The scores could not be computed. For example: `chatbotId` is missing, `baseModel` is not an allowed value, `messages` is not an array, is empty, ends with an empty message, or its last message is too long.
- `401`: Authentication failed: the `Authorization` header is missing or not in the `Bearer <key>` format, the API key does not exist, its workspace is unavailable or has no owner, or the workspace's plan does not include API access. `message` says which.
- `403`: The API key cannot access the requested chatbot. A chatbot-scoped key used with another chatbot's ID gets `Access denied to this chatbot`. A workspace key gets `Chatbot <id> was not found in this API key's workspace. It may have been deleted or moved to another workspace.` when the chatbot does not exist or belongs to another workspace.
- `429`: The workspace sent more than 600 API requests in the last minute. Wait the number of seconds given in the `Retry-After` header (and in `message`) before retrying.

---

[API](https://skmtc.dev/chat-data/apis/chat-data-api-schema-guide.md) · [All operations](https://skmtc.dev/chat-data/apis/chat-data-api-schema-guide/llms.txt) · [OpenAPI document](https://skmtc.dev/chat-data/apis/chat-data-api-schema-guide/revisions/72871007f7f0?raw)
