Available Models
Retrieve a list of available models using theclient.models.list() method:
from checkthat_ai import CheckThatAI
import os
# Initialize client with your provider API key
client = CheckThatAI(api_key=os.getenv("OPENAI_API_KEY"))
# Get all available models
models = client.models.list()
# Print models by provider
for provider in models.models_list:
print(f"\n{provider['provider']} Models:")
for model in provider['available_models']:
print(f" - {model['name']}: {model['model_id']}")
curl -X GET 'https://api.checkthat-ai.com/v1/models' \
-H 'Content-Type: application/json' \
-d '{
"api_key": "your-provider-api-key"
}'
Models List Response
{
"models_list": [
{
"provider": "OpenAI",
"available_models": [
{
"name": "GPT-4o",
"model_id": "gpt-4o",
"description": "Most capable GPT-4 model, optimized for chat and code"
},
{
"name": "GPT-5",
"model_id": "gpt-5",
"description": "Latest GPT-5 model with enhanced reasoning"
}
]
}
]
}
Non-Streaming Responses
Use non-streaming responses for standard chat interactions where you want to receive the complete response at once:from checkthat_ai import CheckThatAI
import os
client = CheckThatAI(api_key=os.getenv("OPENAI_API_KEY"))
response = client.chat.completions.create(
model="gpt-4o",
messages=[
{"role": "user", "content": "Fact-check this claim: Coffee consumption is linked to increased longevity"}
],
temperature=0.1, # Lower temperature for factual responses
max_tokens=1000
)
print(response.choices[0].message.content)
from checkthat_ai import CheckThatAI
import os
client = CheckThatAI(api_key=os.getenv("ANTHROPIC_API_KEY"))
# Multi-turn conversation with context
messages = [
{"role": "system", "content": "You are a helpful fact-checking assistant."},
{"role": "user", "content": "Is climate change caused by human activities?"},
{"role": "assistant", "content": "Yes, scientific consensus confirms that current climate change is primarily caused by human activities, particularly greenhouse gas emissions from burning fossil fuels."},
{"role": "user", "content": "What evidence supports this conclusion?"}
]
response = client.chat.completions.create(
model="claude-sonnet-4-2025-03-10",
messages=messages,
temperature=0.2,
max_tokens=1500
)
print(response.choices[0].message.content)
curl -X POST 'https://api.checkthat-ai.com/v1/chat/completions' \
-H 'Content-Type: application/json' \
-d '{
"api_key": "your-provider-api-key",
"model": "gpt-4o",
"messages": [
{
"role": "user",
"content": "Explain the health benefits of regular exercise"
}
],
"temperature": 0.7,
"max_tokens": 1000
}'
Response Structure
{
"id": "chatcmpl-abc123",
"object": "chat.completion",
"created": 1704067200,
"model": "gpt-4o",
"choices": [
{
"index": 0,
"message": {
"role": "assistant",
"content": "Regular exercise provides numerous health benefits including improved cardiovascular health and enhanced mental well-being."
},
"finish_reason": "stop"
}
],
"usage": {
"prompt_tokens": 25,
"completion_tokens": 18,
"total_tokens": 43
}
}
Streaming Responses
Use streaming responses for real-time chat experiences where you want to display text as it’s generated:Synchronous Streaming
from checkthat_ai import CheckThatAI
import os
client = CheckThatAI(api_key=os.getenv("OPENAI_API_KEY"))
# Enable streaming with stream=True
response = client.chat.completions.create(
model="gpt-4o",
messages=[
{"role": "user", "content": "Tell me about the latest developments in renewable energy"}
],
stream=True,
temperature=0.7,
max_tokens=1500
)
# Process streaming chunks
print("Streaming response: ", end="", flush=True)
for chunk in response:
if chunk.choices[0].delta.content:
print(chunk.choices[0].delta.content, end="", flush=True)
print("\n") # New line when complete
curl -X POST 'https://api.checkthat-ai.com/v1/chat/completions' \
-H 'Content-Type: application/json' \
-d '{
"api_key": "your-provider-api-key",
"model": "gpt-4o",
"messages": [
{
"role": "user",
"content": "Explain quantum computing in simple terms"
}
],
"stream": true,
"temperature": 0.7
}'
Asynchronous Streaming
import asyncio
from checkthat_ai import AsyncCheckThatAI
async def stream_chat():
client = AsyncCheckThatAI(api_key="your-api-key")
try:
stream = await client.chat.completions.create(
model="claude-sonnet-4-2025-03-10",
messages=[
{"role": "user", "content": "Discuss the impact of artificial intelligence on society"}
],
stream=True,
temperature=0.8
)
print("AI Response: ", end="", flush=True)
async for chunk in stream:
if chunk.choices[0].delta.content:
print(chunk.choices[0].delta.content, end="", flush=True)
print("\n")
finally:
await client.close()
# Run the async function
asyncio.run(stream_chat())
import asyncio
from checkthat_ai import AsyncCheckThatAI
async def stream_with_context():
async with AsyncCheckThatAI(api_key="your-api-key") as client:
stream = await client.chat.completions.create(
model="gpt-4o",
messages=[
{"role": "user", "content": "What are the pros and cons of nuclear energy?"}
],
stream=True,
temperature=0.3
)
# Handle streaming with error recovery
try:
async for chunk in stream:
if chunk.choices[0].delta.content:
content = chunk.choices[0].delta.content
print(content, end="", flush=True)
# Check for completion
if chunk.choices[0].finish_reason:
print(f"\n\nStream finished: {chunk.choices[0].finish_reason}")
break
except Exception as e:
print(f"\nStreaming error: {e}")
asyncio.run(stream_with_context())
import asyncio
from checkthat_ai import AsyncCheckThatAI
import os
async def compare_model_responses():
"""Compare responses from different models simultaneously"""
models_and_keys = [
("gpt-4o", "OPENAI_API_KEY"),
("claude-sonnet-4-2025-03-10", "ANTHROPIC_API_KEY"),
("gemini-2.5-pro-002", "GEMINI_API_KEY")
]
async def get_model_response(model, api_key_env):
api_key = os.getenv(api_key_env)
if not api_key:
return f"{model}: API key not found"
async with AsyncCheckThatAI(api_key=api_key) as client:
stream = await client.chat.completions.create(
model=model,
messages=[
{"role": "user", "content": "What is the future of space exploration?"}
],
stream=True,
max_tokens=500
)
response = ""
async for chunk in stream:
if chunk.choices[0].delta.content:
response += chunk.choices[0].delta.content
return f"{model}: {response[:100]}..."
# Run all models concurrently
tasks = [get_model_response(model, key) for model, key in models_and_keys]
results = await asyncio.gather(*tasks, return_exceptions=True)
for result in results:
print(result)
print("-" * 50)
asyncio.run(compare_model_responses())
Streaming Response Format
Streaming Chunk Example
{
"id": "chatcmpl-abc123",
"object": "chat.completion.chunk",
"created": 1704067200,
"model": "gpt-4o",
"choices": [
{
"index": 0,
"delta": {
"content": "Renewable energy has seen remarkable"
},
"finish_reason": null
}
]
}
// Final chunk
{
"id": "chatcmpl-abc123",
"object": "chat.completion.chunk",
"created": 1704067200,
"model": "gpt-4o",
"choices": [
{
"index": 0,
"delta": {},
"finish_reason": "stop"
}
]
}
Streaming Benefits: Streaming responses provide better user experience for long-form content, allow for real-time interaction, and can reduce perceived latency in chat applications.
Memory Management: When using streaming, especially with async operations, ensure you properly close clients and handle exceptions to prevent memory leaks.

