Providers¶
Providers are LLM (Large Language Model) services that power your agents. AG2Trust supports multiple providers, allowing you to choose the best model for each use case.
Supported Providers¶
| Provider | Models | Best For |
|---|---|---|
| OpenAI | GPT-4o, GPT-4o-mini, GPT-4 Turbo | General purpose, fast responses |
| Anthropic | Claude Opus 4, Claude Sonnet 4 | Complex reasoning, longer context |
Adding a Provider¶
Via Dashboard¶
- Navigate to Settings > Providers
- Click Add Provider
- Select the provider type
- Enter your API key
- Give it a name (e.g., "OpenAI Production")
- Click Save
Provider Configuration¶
| Field | Required | Description |
|---|---|---|
| Name | Yes | Identifier for this provider config |
| Type | Yes | OpenAI or Anthropic |
| API Key | Yes | Your provider API key |
Security¶
Credential Encryption¶
Provider API keys are encrypted using AWS KMS envelope encryption:
┌─────────────────────────────────────────────────┐
│ Encryption Process │
│ │
│ 1. Generate random DEK (Data Encryption Key) │
│ 2. Encrypt API key with DEK (AES-256-GCM) │
│ 3. Encrypt DEK with KMS master key │
│ 4. Store: encrypted_key + encrypted_DEK │
└─────────────────────────────────────────────────┘
Key Points¶
- API keys are never stored in plain text
- Keys are decrypted only when starting an agent
- Decrypted keys passed to containers via environment variables (in-memory only)
- No .env files containing credentials
Credential Flow¶
sequenceDiagram
participant D as Dashboard
participant B as Backend
participant K as AWS KMS
participant A as Agent Container
D->>B: Save provider (API key)
B->>K: Encrypt API key
K-->>B: Encrypted credential
B->>B: Store encrypted
Note over B,A: Later: Agent Start
B->>K: Decrypt credential
K-->>B: Plain API key
B->>A: Pass via env var
A->>A: Use for LLM calls Model Selection¶
OpenAI Models¶
| Model | Speed | Intelligence | Cost | Use Case |
|---|---|---|---|---|
gpt-4o | Fast | High | $$ | General purpose |
gpt-4o-mini | Very Fast | Good | $ | High volume, simple tasks |
gpt-4-turbo | Medium | High | $$$ | Complex reasoning |
Anthropic Models¶
| Model | Speed | Intelligence | Cost | Use Case |
|---|---|---|---|---|
claude-sonnet-4-20250514 | Fast | High | $$ | Balanced performance |
claude-opus-4-20250514 | Medium | Very High | $$$ | Complex analysis |
Choosing a Model¶
High volume + Simple tasks → gpt-4o-mini
General purpose → gpt-4o
Complex reasoning → claude-opus-4
Code generation → claude-sonnet-4
Cost sensitive → gpt-4o-mini
Multiple Providers¶
You can configure multiple providers for different purposes:
Example Setup¶
| Provider Name | Type | Use Case |
|---|---|---|
| openai-production | OpenAI | Production agents |
| openai-development | OpenAI | Testing (separate quota) |
| anthropic-complex | Anthropic | Complex reasoning tasks |
Benefits¶
- Quota separation: Don't let dev testing affect prod limits
- Model specialization: Use the right model for each task
- Failover: Switch providers if one has issues
- Cost management: Track spending per use case
Rate Limits¶
Provider Rate Limits¶
Each LLM provider has their own rate limits:
| Provider | Typical Limits |
|---|---|
| OpenAI | Varies by tier (TPM, RPM) |
| Anthropic | Varies by tier |
AG2Trust Rate Limits¶
AG2Trust adds additional rate limiting for protection:
| Limit Type | Value |
|---|---|
| Agent tool calls | 5/minute |
| HTTP requests | 3/minute |
Monitoring Usage¶
Dashboard Metrics¶
Track provider usage in the Dashboard:
- Tokens consumed per agent
- Response times
- Error rates
- Cost estimates
Per-Agent Statistics¶
Returns: - Total tokens used - Average response time - Messages processed - Errors encountered
Best Practices¶
1. Use Separate Keys for Environments¶
Provider: openai-production
└── Production API key with higher limits
Provider: openai-development
└── Development API key for testing
2. Monitor Token Usage¶
Set up alerts for: - Unusual token consumption spikes - High error rates - Slow response times
3. Choose Models Wisely¶
| Task Complexity | Recommended |
|---|---|
| Simple Q&A | gpt-4o-mini |
| Customer support | gpt-4o |
| Code review | claude-sonnet-4 |
| Complex analysis | claude-opus-4 |
4. Rotate Keys Periodically¶
- Generate new API key at provider
- Add new provider config in AG2Trust
- Update agent types to use new provider
- Restart affected agents
- Delete old provider config
Troubleshooting¶
"Invalid API Key"¶
- Verify key is correct (no extra spaces)
- Check key hasn't been revoked at provider
- Ensure key has required permissions
"Rate Limit Exceeded"¶
- Check your provider's rate limit tier
- Reduce agent activity or add more agents
- Consider upgrading your provider plan
"Model Not Available"¶
- Verify model name is correct
- Check model is available in your region
- Some models require special access
Provider API¶
List Providers¶
Add Provider¶
POST /api/providers
Content-Type: application/json
{
"name": "OpenAI Production",
"type": "openai",
"api_key": "sk-..."
}
Delete Provider¶
Cannot Delete In-Use Providers
Providers with active agents cannot be deleted. Stop or reassign agents first.