Overview
CheckThat integrates with xAI’s Grok models, providing access to advanced AI capabilities with unique characteristics optimized for reasoning, analysis, and real-time information processing. Grok models are built by xAI with OpenAI-compatible APIs.Available Models
The following Grok models are available through CheckThat:Grok 3 - Previous generation model with strong reasoning capabilities
Grok 4 - Latest generation model with enhanced performance and reasoning
Grok 3 Mini - Compact model optimized for speed and efficiency
Configuration
API Key Setup
Your xAI API key. Get your key from xAI Console.
The model identifier from the available models list above.
Request Parameters
Grok models use OpenAI-compatible parameters:Array of message objects with
role and content fields.Controls randomness in responses. Range: 0.0 to 2.0.
Maximum number of tokens to generate in the response.
Enable streaming responses for real-time output.
Structured output format specification (JSON schema).
Usage Examples
Basic Chat Completion
Streaming Response
Structured Output
Multi-turn Conversation
Features and Capabilities
OpenAI-Compatible API
xAI’s Grok models use OpenAI-compatible endpoints (xai.py:20-164):
- Familiar OpenAI SDK interface
- Standard message formatting
- Compatible response structures
- Easy migration from OpenAI
Structured Output Support
All Grok models support structured outputs via JSON schema (xai.py:109-157):
JSON Schema Support:
- grok-3
- grok-4-0709
- grok-3-mini
Conversation History Management
Automatic conversation formatting using OpenAI format (xai.py:69-87):
Streaming Support
Real-time streaming with OpenAI-compatible chunks (xai.py:51-67):
Stream[ChatCompletionChunk] for seamless integration.
Direct Parameter Pass-Through
Flexible parameter handling (xai.py:34-49):
Implementation Details
CheckThat’s xAI integration (xai.py:20-164) provides:
- OpenAI SDK: Uses official OpenAI Python SDK with xAI base URL
- Full compatibility: Supports all OpenAI-style parameters and features
- Structured outputs: Both JSON schema and Pydantic model formats
- Streaming: Native streaming support with chunks
- Conversation management: Automatic message formatting
Structured Response Object
For JSON schema responses, CheckThat returns aStructuredResponse object:
Response Format Options
Dict-based JSON Schema:Rate Limits and Pricing
Rate limits and pricing are determined by your xAI API tier. CheckThat does not impose additional limits. Refer to xAI pricing for current rates:- Grok 4: Latest model with premium pricing
- Grok 3: Previous generation with standard pricing
- Grok 3 Mini: Cost-optimized for high-volume use
Error Handling
- 400: Invalid request format or parameters
- 401: Invalid API key
- 429: Rate limit exceeded
- 500: xAI service error
Best Practices
- Choose the right model: Use Grok 4 for best performance, Grok 3 Mini for speed
- Leverage structured outputs: Use JSON schema for reliable data extraction
- Implement streaming: Enable streaming for better UX on long responses
- System prompts: Grok responds well to clear, specific system instructions
- Error handling: Implement retry logic with exponential backoff for 429 errors
- Conversation context: Include relevant history for coherent multi-turn dialogues
- Monitor usage: Track token usage to optimize costs
- Test thoroughly: Validate structured output schemas before production use
Model Comparison
Grok 4 (grok-4-0709)
- Best for: Complex reasoning, analysis, latest capabilities
- Performance: Highest quality responses
- Speed: Standard inference time
- Pricing: Premium tier
Grok 3
- Best for: General-purpose tasks, balanced performance
- Performance: High-quality responses
- Speed: Standard inference time
- Pricing: Standard tier
Grok 3 Mini
- Best for: High-volume applications, speed-critical tasks
- Performance: Good quality with optimizations
- Speed: Faster inference
- Pricing: Cost-optimized
Unique Characteristics
- Real-time awareness: Grok models are designed with focus on current information
- OpenAI compatibility: Seamless migration from OpenAI with same SDK
- Full structured output support: Both JSON schema and Pydantic models
- Conversation management: Built-in conversation history formatting
- xAI ecosystem: Integration with xAI’s broader platform and tools