> ## Documentation Index
> Fetch the complete documentation index at: https://docs.checkthat-ai.com/llms.txt
> Use this file to discover all available pages before exploring further.

# Chat Interface

> Endpoint to normalize a single claim from the user provided text

The primary endpoint for normalizing claims and engaging with the CheckThat AI system. This endpoint processes user queries to extract, normalize, and fact-check claims from provided text.

<Warning>
  This endpoint requires authentication via API key. Include your API key in the request body or Authorization header.
</Warning>

## Primary Use Cases

* **Claim extraction**: Identify claims within user-provided text
* **Claim normalization**: Standardize and structure extracted claims
* **Fact-checking analysis**: Evaluate the veracity of claims
* **Interactive conversations**: Maintain context across multiple interactions

## Request Parameters

<ParamField body="user_query" type="string" required>
  The text or query you want to analyze for claims. This is the main input that will be processed for claim extraction and normalization.
</ParamField>

<ParamField body="model" type="string" required>
  The AI model to use for processing. Common values include `gpt-4`, `gpt-3.5-turbo`, or other supported models.
</ParamField>

<ParamField body="api_key" type="string">
  Your API key for authentication. Can be provided here or in the Authorization header.
</ParamField>

<ParamField body="conversation_id" type="string">
  Optional identifier to maintain conversation context across multiple requests.
</ParamField>

<ParamField body="conversation_history" type="array">
  Array of previous messages to maintain context. Each message should contain `role`, `content`, and optionally `timestamp`.

  <Expandable title="Message format">
    <ResponseField name="role" type="string" required>
      The role of the message sender: "user" or "assistant"
    </ResponseField>

    <ResponseField name="content" type="string" required>
      The content of the message
    </ResponseField>

    <ResponseField name="timestamp" type="string">
      Optional ISO timestamp of when the message was sent
    </ResponseField>
  </Expandable>
</ParamField>

<ParamField body="max_history_tokens" type="integer" default="4000">
  Maximum number of tokens to include from conversation history. Helps manage context window limits.
</ParamField>

## Example Requests

<RequestExample>
  ```bash cURL theme={null}
  curl -X POST 'https://api.checkthat-ai.com/chat' \
    -H 'Content-Type: application/json' \
    -H 'Authorization: Bearer YOUR_API_KEY' \
    -d '{
      "user_query": "The COVID-19 vaccine contains microchips that track people",
      "model": "gpt-4"
    }'
  ```
</RequestExample>

<RequestExample>
  ```javascript JavaScript theme={null}
  const response = await fetch('https://api.checkthat-ai.com/chat', {
    method: 'POST',
    headers: {
      'Content-Type': 'application/json',
      'Authorization': 'Bearer YOUR_API_KEY'
    },
    body: JSON.stringify({
      user_query: 'Climate change is caused primarily by human activities',
      model: 'gpt-4',
      conversation_id: 'conv_123'
    })
  });

  const result = await response.json();
  ```
</RequestExample>

<RequestExample>
  ```python Python theme={null}
  import requests

  payload = {
      "user_query": "Drinking 8 glasses of water daily is necessary for health",
      "model": "gpt-4",
      "conversation_history": [
          {
              "role": "user",
              "content": "Hello, I want to fact-check some health claims"
          },
          {
              "role": "assistant", 
              "content": "I'd be happy to help you fact-check health claims."
          }
      ]
  }

  response = requests.post(
      'https://api.checkthat-ai.com/chat',
      headers={'Authorization': 'Bearer YOUR_API_KEY'},
      json=payload
  )
  ```
</RequestExample>

## Response Format

The endpoint returns a structured response with the analysis results:

<ResponseExample>
  ```json Success Response theme={null}
  {
    "conversation_id": "conv_456", 
    "response": "Based on current scientific evidence, this claim requires nuance...",
    "claims_identified": [
      {
        "claim": "COVID-19 vaccine contains microchips",
        "confidence": 0.95,
        "category": "health_misinformation"
      }
    ],
    "fact_check_result": {
      "verdict": "false",
      "evidence_sources": ["CDC", "WHO", "peer_reviewed_studies"],
      "explanation": "No credible evidence supports the presence of microchips..."
    }
  }
  ```
</ResponseExample>

<AccordionGroup>
  <Accordion title="Error Response Examples">
    **Missing Required Fields (422)**

    ```json theme={null}
    {
      "detail": [
        {
          "loc": ["body", "model"],
          "msg": "field required",
          "type": "value_error.missing"
        }
      ]
    }
    ```

    **Authentication Error (401)**

    ```json theme={null}
    {
      "detail": "Invalid or missing API key"
    }
    ```
  </Accordion>
</AccordionGroup>

<Tip>
  For better context retention, include `conversation_id` and relevant `conversation_history` in follow-up requests within the same fact-checking session.
</Tip>


## OpenAPI

````yaml POST /chat
openapi: 3.1.0
info:
  title: CheckThat AI - Advanced Claim Normalization & Fact-Checking Platform
  description: API for the CheckThat AI Platform - https://www.checkthat-ai.com
  version: 1.0.0
servers: []
security: []
paths:
  /chat:
    post:
      tags:
        - chat
      summary: Chat Interface
      description: Endpoint to normalize a single claim from the user provided text
      operationId: chat_interface_chat_post
      requestBody:
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/ChatRequest'
        required: true
      responses:
        '200':
          description: Successful Response
          content:
            application/json:
              schema: {}
        '422':
          description: Validation Error
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/HTTPValidationError'
components:
  schemas:
    ChatRequest:
      properties:
        user_query:
          type: string
          title: User Query
        model:
          type: string
          title: Model
        conversation_id:
          anyOf:
            - type: string
            - type: 'null'
          title: Conversation Id
        conversation_history:
          anyOf:
            - items:
                $ref: '#/components/schemas/ChatMessage'
              type: array
            - type: 'null'
          title: Conversation History
        api_key:
          anyOf:
            - type: string
            - type: 'null'
          title: Api Key
        max_history_tokens:
          anyOf:
            - type: integer
            - type: 'null'
          title: Max History Tokens
          default: 4000
      type: object
      required:
        - user_query
        - model
      title: ChatRequest
    HTTPValidationError:
      properties:
        detail:
          items:
            $ref: '#/components/schemas/ValidationError'
          type: array
          title: Detail
      type: object
      title: HTTPValidationError
    ChatMessage:
      properties:
        role:
          type: string
          title: Role
        content:
          type: string
          title: Content
        timestamp:
          anyOf:
            - type: string
            - type: 'null'
          title: Timestamp
      type: object
      required:
        - role
        - content
      title: ChatMessage
    ValidationError:
      properties:
        loc:
          items:
            anyOf:
              - type: string
              - type: integer
          type: array
          title: Location
        msg:
          type: string
          title: Message
        type:
          type: string
          title: Error Type
      type: object
      required:
        - loc
        - msg
        - type
      title: ValidationError

````