Overview
The/chat endpoint provides a streaming chat interface optimized for claim normalization. It applies CheckThat AI’s specialized prompts and returns real-time streaming responses.
Endpoint
Authentication
Include your LLM provider’s API key in the request body:Request Parameters
The user’s input text containing claims to normalize or verify.Cannot be empty or contain only whitespace.
The LLM model to use for processing. Must be one of the supported models.Examples:
gpt-4o, claude-sonnet-4-20250514, grok-4-0709, gemini-2.5-proAPI key for the LLM provider. Required for most models.Not required for free models like
meta-llama/Llama-3.3-70B-Instruct-Turbo-Free or Gemini models.Optional conversation ID to retrieve conversation history from storage.When provided, the system retrieves previous messages to maintain context.
Optional array of previous conversation messages.Used as a fallback if
conversation_id is not provided or history is not found.Maximum number of tokens to include from conversation history.Helps manage context window limits for different models.
Supported Models
The endpoint accepts models from the following providers:OpenAI Models
gpt-5-2025-08-07(GPT-5)gpt-5-nano-2025-08-07(GPT-5 nano)o3-2025-04-16(o3)o4-mini-2025-04-16(o4-mini)
Anthropic Models
claude-sonnet-4-20250514(Claude Sonnet 4)claude-opus-4-1-20250805(Claude Opus 4.1)
Google Gemini Models
gemini-2.5-pro(Gemini 2.5 Pro)gemini-2.5-flash(Gemini 2.5 Flash)
xAI Models
grok-3(Grok 3)grok-4-0709(Grok 4)grok-3-mini(Grok 3 Mini)
Together AI Models (Free)
meta-llama/Llama-3.3-70B-Instruct-Turbo-Free(Llama 3.3 70B)deepseek-ai/DeepSeek-R1-Distill-Llama-70B-free(DeepSeek R1)
Response Format
The endpoint returns a streaming response withContent-Type: text/plain; charset=utf-8.
Response Headers
Streaming Response
The response streams text chunks as they’re generated:Example Requests
Basic Request
With Conversation History
Using Free Model
With Anthropic Claude
Python Example with Streaming
JavaScript Example with Streaming
Error Responses
Invalid Model
Status Code:400 Bad Request
Empty Query
Status Code:400 Bad Request
Invalid API Key
Status Code:403 Forbidden
Streaming response:
Rate Limit Exceeded
Status Code:429 Too Many Requests
Server Error
Status Code:500 Internal Server Error
Streaming response:
System Prompts
The/chat endpoint automatically applies CheckThat AI’s specialized prompts:
System Prompt
Defines the AI’s role as a claim normalization and fact-checking assistant.Few-Shot CoT Prompt
Provides examples of proper claim normalization using Chain-of-Thought reasoning.Chat Guide
Instructions for handling conversational context and maintaining consistency.These prompts are applied automatically. You don’t need to include them in your
user_query.Conversation Management
The endpoint supports conversation continuity through two mechanisms:1. Conversation ID
Provide aconversation_id to retrieve stored conversation history:
max_history_tokens worth of messages.
2. Explicit History
Provide conversation history directly:Rate Limiting
The/chat endpoint has the following limits:
- 10 requests per 60 seconds per IP address
- Rate limit headers included in all responses
429status code when limit exceeded- Automatic retry after the specified wait time
Implementation Details
LLM Router
The endpoint usesLLMRouter to automatically select the correct client based on the model:
Streaming Generator
Responses are generated using a streaming generator function:Error Handling
The endpoint provides detailed error messages in the stream:ValueError→[Error 400: Bad Request - ...]PermissionError→[Error 403: Forbidden - ...]- Other exceptions →
[<error message>]
Best Practices
Handle Streaming Responses
Handle Streaming Responses
Always process streaming responses incrementally rather than waiting for completion. This provides better user experience and handles long responses efficiently.
Manage Conversation Context
Manage Conversation Context
Use
max_history_tokens to limit context size and avoid exceeding model token limits. Different models have different context windows.Validate User Input
Validate User Input
Ensure
user_query is not empty and contains meaningful content before sending requests. This avoids unnecessary API calls.Choose Appropriate Models
Choose Appropriate Models
Select models based on your needs:
- Free models for testing and development
- GPT-4o for high-quality claim normalization
- Claude for nuanced reasoning
- Gemini for multimodal tasks (future support)
Related Endpoints
Chat Completions
OpenAI-compatible completions with advanced features
Models
List all available models and providers