Examples
Real-world examples and practical use cases for ModelRed SDK
Practical Examples
Learn ModelRed SDK through real-world examples and practical use cases that you can implement directly in your projects.
Featured Examples
Quick Security Assessment
Get started in 5 minutes with a complete security assessment workflow
Multi-Provider Setup
Configure and test multiple AI providers in a single application
What You'll Learn
Core Concepts in Action
Each example demonstrates key ModelRed patterns and best practices you can apply to your own projects.
✅ Authentication
API key management and secure authentication patterns
🤖 Model Registration
Register models from OpenAI, Anthropic, Azure, and more
🧪 Security Testing
Run comprehensive security assessments with test suites
📊 Result Analysis
Parse and analyze security assessment results
⚠️ Error Handling
Robust error handling and recovery strategies
⚡ Best Practices
Production-ready patterns and optimization techniques
Prerequisites
📋 Before You Start
ModelRed API Key
Get your API key from the ModelRed dashboard
Python 3.8+
ModelRed SDK requires Python 3.8 or higher
ModelRed SDK Installed
pip install modelred
AI Provider API Keys (Optional)
OpenAI, Anthropic, Azure, etc. for multi-provider examples
Quick Setup
⚡ Environment Setup
pip install modelred
export MODELRED_API_KEY="mr_your_api_key_here"
import asyncio
from modelred import ModelRed
async def test_setup():
async with ModelRed() as client:
account = await client.validate_api_key()
print(f"✅ Connected to ModelRed!")
print(f"Organization: {account.get('organization', 'N/A')}")
asyncio.run(test_setup())
Example Categories
Getting Started
Perfect for beginners new to ModelRed
- •Quick Security Assessment - Your first 5-minute security test
Multi-Provider Integration
Work with multiple AI providers simultaneously
- •Multi-Provider Setup - OpenAI, Anthropic, Azure in one app
Code Style
📝 Example Code Standards
Need Help?
📚 Additional Resources
• Review
Error Handling
for troubleshooting common issues
• Explore
Provider Configuration
for specific setup guides