Skip to main content

Overview

The CheckThat AI Python SDK provides a seamless interface to access 11+ models from leading AI providers through a single, unified API. Built as a drop-in replacement for the OpenAI SDK, it includes integrated fact-checking and claim normalization capabilities.

PyPI Package

PyPI version

GitHub Repository

View source code and contribute

Features

  • 🔄 Unified LLM Access: Access all the latest models from OpenAI, Anthropic, Google Gemini, xAI, and Together AI through a single API
  • 🔍 Claim Normalization: Standardize and structure claims for analysis
  • Fact-Checking: Built-in claim verification and evidence sourcing
  • 🔌 OpenAI Compatible: Drop-in replacement for OpenAI Python SDK
  • Async Support: Full async/await support for high-performance applications
  • 🛡️ Type Safety: Complete type hints for better development experience
  • 🎯 Claim Refinement: Iterative improvement of response accuracy with configurable quality thresholds
  • 📊 Evaluation Metrics: Built-in support for G-Eval, bias detection, hallucination detection, and more
  • 🆕 Always Up-to-Date: Access to the newest models as soon as they’re released

Installation

Requirements: Python 3.8+ with full type hint support

Quick Start

Basic Usage

The simplest way to get started is using your OpenAI API key:

Environment Setup

Set up your environment variables for the providers you want to use:

Client Configuration

Synchronous Client

Asynchronous Client

Chat Completions

Basic Chat

Streaming Responses

Async Streaming

Multi-Provider Usage

Using Different Providers

You can switch between providers seamlessly by using different API keys and model identifiers:

Model Discovery

Structured Output Generation

Generate structured, type-safe responses using Pydantic models with the dedicated parse() method:

Evaluation Metrics

The SDK supports various quality evaluation metrics:
  • G-Eval: General evaluation framework
  • Bias: Bias detection and analysis
  • Hallucinations: Hallucination detection
  • Hallucination Coverage: Coverage analysis of hallucinations
  • Factual Accuracy: Fact-checking accuracy
  • Relevance: Content relevance assessment
  • Coherence: Response coherence evaluation

Supported Models

The SDK provides access to all the latest models from multiple providers:
  • OpenAI: GPT-5, GPT-5 nano, o3, o4-mini, GPT-4o, and more
  • Anthropic: Claude Sonnet 4, Sonnet Opus 4.1, Claude 3.5 Sonnet, and more
  • Google: Gemini 2.5 Pro, Gemini 2.5 Flash, Gemini 1.5 Pro, and more
  • xAI: Grok 4, Grok 3, Grok 3 Mini, and more
  • Together AI: Llama 3.3 70B, Deepseek R1 Distill Llama 70B, and more
⚠️ Important: Always Check Available ModelsBefore using any model, query the /v1/models endpoint to get the current list of available models:
Model availability depends on:
  • Your API keys and provider access
  • Current provider service status
  • Regional availability
  • Your subscription tier with each provider

Advanced Usage

Model Discovery

Advanced Usage

Context Management

Custom Headers and Metadata

Conversation Management

Error Handling

The SDK uses the same exception types as the OpenAI SDK for compatibility, plus custom CheckThat AI exceptions:

Custom Exceptions

  • InvalidModelError: Raised when trying to use an unsupported or unavailable model
  • InvalidResponseFormatError: Raised when there’s an issue with structured output format

Best Practices

1. Resource Management

2. API Key Security

3. Model Selection

4. Monitoring and Logging

Migration from OpenAI SDK

If you’re already using the OpenAI SDK, migration is straightforward:
Zero Breaking Changes: The API is 100% compatible with OpenAI SDK patterns.

Support and Contributing

Issues & Bugs

Report bugs or request features on GitHub

Contributing

Contribute to the CheckThat AI Python SDK

Getting Help

When reporting issues, please include your Python version, SDK version, and a minimal reproducible example.