OpenRouter Integration
Codebuff routes requests through OpenRouter by default, which provides access to a wide variety of models. The framework automatically handles:- Model routing and fallbacks
- Cost tracking and optimization
- Provider selection based on availability
- Authentication and API key management
How It Works
When you make a request, Codebuff:- Receives your API key via the
Authorizationheader - Routes the request to the Codebuff backend
- Forwards to OpenRouter with proper authentication
- Tracks usage and costs automatically
sdk/src/impl/model-provider.ts:298-320:
Available Models
Codebuff provides access to leading models through OpenRouter. Here are the most commonly used:Claude Models (Anthropic)
OpenAI Models
Google Models
Other Providers
Model Selection in Agents
When creating an agent, specify the model using OpenRouter’s format:Model Aliases
Codebuff supports convenient aliases for common models:Model Configuration
Provider Routing
Codebuff automatically configures provider routing for optimal performance and reliability:Custom Provider Options
For advanced use cases, configure provider routing in your agent:Claude OAuth (Advanced)
For Claude models, Codebuff supports direct OAuth authentication with Anthropic, bypassing OpenRouter:Benefits
- Direct API access to Anthropic
- Potentially lower latency
- Use your Claude subscription directly
- No OpenRouter intermediary
How It Works
Rate Limiting
ClaudeCoduff automatically handles Claude OAuth rate limits:- Detects 429 rate limit errors
- Fetches reset time from Anthropic API
- Automatically falls back to OpenRouter
- Resumes OAuth when rate limit expires
Cost Tracking
Codebuff tracks model usage costs automatically:Next Steps
- Learn about Credentials Management
- Explore Error Handling
- See Agent Definition for full configuration options

