Se rendre au contenu

AI Provider Configuration

Configure connections to AI services for content generation, including API keys, model selection, and rate limiting.

Overview

AI Providers are configured through the ai.provider model. Each provider represents a connection to an AI service with associated credentials and settings.

Backend Access

Navigate to Settings > AI Workflow > Providers to manage AI provider configurations in the backend.

OpenAI Setup

OpenAI is the default and recommended provider for the AI Workflow Framework.

Step 1: Get API Key

  1. Visit platform.openai.com
  2. Sign in or create an account
  3. Navigate to API Keys section
  4. Create a new secret key
  5. Copy the key (it won't be shown again)

Step 2: Configure in RebusAI

Python
# Via RebusAI shell
provider = env['ai.provider'].create({
    'name': 'OpenAI GPT-4',
    'provider_type': 'openai',
    'api_key': 'sk-proj-xxxxx',  # Your API key
    'model': 'gpt-4-turbo-preview',
    'active': True,
})

# Or update existing provider
provider = env.ref('ai_project_workflow.openai_provider')
provider.api_key = 'sk-proj-xxxxx'

Step 3: Verify Connection

Python
# Test the provider connection
provider = env['ai.provider'].search([('provider_type', '=', 'openai')], limit=1)
result = provider.test_connection()
print(result)  # Should return True if successful

Azure OpenAI

For enterprise deployments, Azure OpenAI provides additional security and compliance features.

Python
provider = env['ai.provider'].create({
    'name': 'Azure OpenAI',
    'provider_type': 'azure_openai',
    'api_key': 'your-azure-api-key',
    'api_base': 'https://your-resource.openai.azure.com/',
    'api_version': '2024-02-01',
    'deployment_name': 'gpt-4-deployment',
    'active': True,
})

Anthropic Claude

Anthropic's Claude models can be used as an alternative to OpenAI.

Python
provider = env['ai.provider'].create({
    'name': 'Anthropic Claude',
    'provider_type': 'anthropic',
    'api_key': 'sk-ant-xxxxx',
    'model': 'claude-3-opus-20240229',
    'active': True,
})

Model Selection

Different models offer varying capabilities, costs, and performance characteristics:

Model Provider Best For Context
gpt-4-turbo-preview OpenAI Complex content, long form 128K
gpt-4o OpenAI Fast, cost-effective 128K
gpt-3.5-turbo OpenAI Simple tasks, high volume 16K
claude-3-opus Anthropic Highest quality 200K
claude-3-sonnet Anthropic Balanced quality/speed 200K

Rate Limiting

Configure rate limits to stay within API quotas and manage costs:

Python
provider.write({
    'rate_limit_rpm': 60,       # Requests per minute
    'rate_limit_tpm': 150000,   # Tokens per minute
    'max_retries': 3,           # Retry on rate limit
    'retry_delay': 5,           # Seconds between retries
})