Provider trait interface, enabling seamless switching between models and vendors.
Provider Trait Interface
All providers implement theProvider trait from ~/workspace/source/clients/agent-runtime/src/providers/traits.rs:230, which defines:
Supported Providers
Corvus supports 30+ providers organized into several categories:Primary Providers
Providers with custom implementations for optimal performance:| Provider | Config Name | API Key Variable | Tool Support | Notes |
|---|---|---|---|---|
| OpenRouter | openrouter | OPENROUTER_API_KEY | ✅ Native | Access to 100+ models |
| Anthropic | anthropic | ANTHROPIC_API_KEY, ANTHROPIC_OAUTH_TOKEN | ✅ Native | Claude models with prompt caching |
| OpenAI | openai | OPENAI_API_KEY | ✅ Native | GPT-4o, o1, o3-mini |
| OpenAI Codex | openai-codex | OAuth flow | ✅ Native | Authenticated via OAuth |
| Ollama | ollama | OLLAMA_API_KEY (optional) | ✅ Native | Local model hosting |
| Gemini | gemini, google, google-gemini | Auto-detected | ✅ Native | Google’s Gemini models |
| GitHub Copilot | copilot, github-copilot | GITHUB_TOKEN, GH_TOKEN | ✅ Native | Copilot Chat models |
OpenAI-Compatible Providers
Providers using the OpenAI chat completions API format:| Provider | Config Name | API Key Variable | Base URL |
|---|---|---|---|
| Venice | venice | VENICE_API_KEY | https://api.venice.ai |
| Vercel AI Gateway | vercel, vercel-ai | VERCEL_API_KEY | https://api.vercel.ai |
| Cloudflare AI | cloudflare, cloudflare-ai | CLOUDFLARE_API_KEY | https://gateway.ai.cloudflare.com/v1 |
| Groq | groq | GROQ_API_KEY | https://api.groq.com/openai |
| Mistral | mistral | MISTRAL_API_KEY | https://api.mistral.ai/v1 |
| xAI (Grok) | xai, grok | XAI_API_KEY | https://api.x.ai |
| DeepSeek | deepseek | DEEPSEEK_API_KEY | https://api.deepseek.com |
| Together AI | together, together-ai | TOGETHER_API_KEY | https://api.together.xyz |
| Fireworks AI | fireworks, fireworks-ai | FIREWORKS_API_KEY | https://api.fireworks.ai/inference/v1 |
| Perplexity | perplexity | PERPLEXITY_API_KEY | https://api.perplexity.ai |
| Cohere | cohere | COHERE_API_KEY | https://api.cohere.com/compatibility |
| Amazon Bedrock | bedrock, aws-bedrock | AWS credentials | https://bedrock-runtime.us-east-1.amazonaws.com |
| NVIDIA NIM | nvidia, nvidia-nim, build.nvidia.com | NVIDIA_API_KEY | https://integrate.api.nvidia.com/v1 |
| LM Studio | lmstudio, lm-studio | Optional | http://localhost:1234/v1 |
Chinese AI Providers
Providers with region-specific endpoints:| Provider | Config Names | API Key Variable | Regions |
|---|---|---|---|
| Moonshot (Kimi) | moonshot, moonshot-cn, moonshot-intl, kimi, kimi-cn, kimi-global | MOONSHOT_API_KEY | CN, International |
| GLM (Zhipu) | glm, glm-cn, glm-global, zhipu, zhipu-cn, bigmodel | GLM_API_KEY | CN, Global |
| MiniMax | minimax, minimax-cn, minimax-intl, minimax-io, minimaxi | MINIMAX_API_KEY | CN, International |
| Qwen (DashScope) | qwen, qwen-cn, qwen-intl, qwen-us, dashscope, dashscope-intl, dashscope-us | DASHSCOPE_API_KEY | CN, International, US |
| Z.AI | zai, z.ai, zai-cn, zai-global, z.ai-cn, z.ai-global | ZAI_API_KEY | CN, Global |
| Qianfan (Baidu) | qianfan, baidu | QIANFAN_API_KEY | CN |
Other Providers
| Provider | Config Name | API Key Variable | Base URL |
|---|---|---|---|
| Astrai | astrai | ASTRAI_API_KEY | https://as-trai.com/v1 |
| Synthetic | synthetic | SYNTHETIC_API_KEY | https://api.synthetic.com |
| OpenCode Zen | opencode, opencode-zen | OPENCODE_API_KEY | https://opencode.ai/zen/v1 |
Provider Capabilities
Providers declare their capabilities through theProviderCapabilities struct:
- OpenRouter
- Anthropic (Claude)
- OpenAI (GPT-4o, o1, o3-mini)
- Gemini
- Ollama (with compatible models)
- OpenAI-compatible providers
How to Switch Providers
In Configuration File
Edit~/.config/corvus/config.toml:
Via Environment Variables
Set provider-specific API key:Programmatically
Using the factory function from~/workspace/source/clients/agent-runtime/src/providers/mod.rs:382:
Provider Comparison
| Feature | OpenRouter | Anthropic | OpenAI | Ollama | Gemini |
|---|---|---|---|---|---|
| Native Tools | ✅ | ✅ | ✅ | ✅ | ✅ |
| Streaming | ✅ | ✅ | ✅ | ✅ | ✅ |
| Prompt Caching | Via upstream | ✅ Auto | ❌ | N/A | ✅ |
| Local Hosting | ❌ | ❌ | ❌ | ✅ | ❌ |
| Model Access | 100+ | Claude only | GPT only | Any GGUF | Gemini only |
| Cost | Varies | ~$3-15/M tokens | ~$2.50-15/M tokens | Free | Free tier |
| Setup Complexity | Low | Low | Low | Medium | Medium |
Resilient Provider Chain
Corvus supports automatic failover with thecreate_resilient_provider factory from ~/workspace/source/clients/agent-runtime/src/providers/mod.rs:573:
- Tries primary provider (Anthropic)
- On failure, tries fallback providers in order
- Retries with exponential backoff
- Logs failures for observability
Model Routing
Route specific models to different providers:Best Practices
- Use environment variables for API keys instead of config files
- Enable fallback providers for production deployments
- Use OpenRouter for access to multiple models with one API key
- Use Ollama for local development and privacy-sensitive workloads
- Enable prompt caching (Anthropic) for long system prompts
- Set appropriate timeouts for slow providers (default: 120s)
- Call
warmup()during initialization to pre-establish connections