Overview
CheckThat integrates with Anthropic’s Claude models, providing access to advanced AI capabilities with strong reasoning, analysis, and conversation abilities. Claude models excel at nuanced understanding, detailed explanations, and maintaining context across long conversations.Available Models
The following Claude models are available through CheckThat:Claude Sonnet 4 - Balanced performance with excellent reasoning capabilities and speed
Claude Opus 4.1 - Most capable Claude model with superior performance on complex tasks
Configuration
API Key Setup
Your Anthropic API key. Get your key from Anthropic Console.
The model identifier from the available models list above.
Request Parameters
System prompt that sets the assistant’s behavior and context.
Array of message objects. Must alternate between
user and assistant roles.Maximum number of tokens to generate. Claude models default to 8192 tokens.
Controls randomness in responses. Range: 0.0 to 1.0.
Enable streaming responses for real-time output.
Usage Examples
Basic Chat Completion
Streaming Response
Multi-turn Conversation
Structured Output (Limited Support)
Features and Capabilities
Long Context Window
Claude models support extensive context windows, making them ideal for:- Long document analysis
- Extended conversations
- Multi-turn dialogues with rich history
Conversation History Management
CheckThat automatically formats conversation history for Anthropic’s API (anthropic.py:38-42):
- Alternates user/assistant messages correctly
- Extracts system instructions properly
- Maintains conversation context across turns
Streaming Support
Real-time streaming with Anthropic’s native streaming API (anthropic.py:69-74):
OpenAI-Compatible Response Format
CheckThat transforms Anthropic responses to OpenAI-compatible format (anthropic.py:131-278), including:
- Standard message structure
- Usage statistics (prompt_tokens, completion_tokens)
- Finish reason mapping
- Stop sequence handling
Structured Outputs
Current Limitations
Anthropic structured outputs in CheckThat have limited support:- Pydantic models only: Currently supports Pydantic model formats via instructor library
- No JSON schema: Dict-based JSON schema formats not yet supported
- Error handling: Returns 400 error for unsupported formats
- claude-sonnet-4-20250514 (with Pydantic models)
anthropic.py:81-129):
Implementation Details
CheckThat’s Anthropic integration (anthropic.py:21-279) provides:
- Native Anthropic client: Uses official
anthropicPython SDK - Instructor integration: Structured outputs via instructor library
- Response transformation: Converts to OpenAI-compatible format
- Conversation formatting: Automatic message formatting for Anthropic API
Response Format Transformation
The_format_to_openai_response method ensures compatibility:
- Extracts content from Anthropic’s content blocks
- Maps finish reasons (
end_turn→stop,max_tokens→length) - Preserves usage metadata (input_tokens → prompt_tokens)
- Adds Anthropic-specific extensions for debugging
Rate Limits and Pricing
Rate limits and pricing are determined by your Anthropic API tier. CheckThat does not impose additional limits. Refer to Anthropic’s pricing page for current rates:- Claude Sonnet 4: Balanced pricing for production use
- Claude Opus 4.1: Premium pricing for highest capability
Error Handling
- 400: Invalid request or unsupported structured output format
- 401: Invalid API key
- 429: Rate limit exceeded
- 500: Anthropic service error
Best Practices
- Use system prompts effectively: Set clear context and behavior expectations
- Alternate messages properly: Ensure user/assistant message alternation
- Leverage long context: Claude excels at analyzing long documents
- Stream for UX: Enable streaming for better user experience
- Handle max_tokens: Default is 8192; adjust based on needs
- Monitor usage: Track token usage for cost optimization
- Structured outputs: Use Pydantic models when structured data is needed