Documentation

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.

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

1. INSTALL SDK
pip install modelred
2. SET API KEY
export MODELRED_API_KEY="mr_your_api_key_here"
3. VERIFY INSTALLATION
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

All examples are production-ready and include proper error handling
Code is well-commented with explanations of key concepts
Examples follow Python best practices and async/await patterns
Each example is self-contained and can be run independently

Need Help?

📚 Additional Resources

• Review

Error Handling

for troubleshooting common issues

• Explore

Provider Configuration

for specific setup guides

Next Steps