Skip to content
This repository was archived by the owner on Jul 29, 2025. It is now read-only.

Commit fb53885

Browse files
[feature/openrouter-provider] Add OpenRouter provider support and integrate new models
- Updated README.md to include OpenRouter as a supported provider and its configuration details. - Added `OPENROUTER_API_KEY` to environment variable configuration. - Introduced OpenRouter-specific models in `internal/llm/models/openrouter.go` with mappings to existing cost and token configurations. - Updated `internal/config/config.go` to set default models for OpenRouter agents. - Extended `opencode-schema.json` to include OpenRouter models in the schema definitions. - Refactored model IDs and names to align with OpenRouter naming conventions.
1 parent 0f10b17 commit fb53885

File tree

4 files changed

+208
-158
lines changed

4 files changed

+208
-158
lines changed

README.md

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ OpenCode is a Go-based CLI application that brings AI assistance to your termina
1111
## Features
1212

1313
- **Interactive TUI**: Built with [Bubble Tea](https://github.com/charmbracelet/bubbletea) for a smooth terminal experience
14-
- **Multiple AI Providers**: Support for OpenAI, Anthropic Claude, Google Gemini, AWS Bedrock, Groq, and Azure OpenAI
14+
- **Multiple AI Providers**: Support for OpenAI, Anthropic Claude, Google Gemini, AWS Bedrock, Groq, Azure OpenAI, and OpenRouter
1515
- **Session Management**: Save and manage multiple conversation sessions
1616
- **Tool Integration**: AI can execute commands, search files, and modify code
1717
- **Vim-like Editor**: Integrated editor with text input capabilities
@@ -97,8 +97,12 @@ You can configure OpenCode using environment variables:
9797
"disabled": false
9898
},
9999
"groq": {
100-
"apiKey": "your-api-key",
101-
"disabled": false
100+
"apiKey": "your-api-key",
101+
"disabled": false
102+
},
103+
"openrouter": {
104+
"apiKey": "your-api-key",
105+
"disabled": false
102106
}
103107
},
104108
"agents": {

internal/config/config.go

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -270,9 +270,9 @@ func setProviderDefaults() {
270270
// OpenRouter configuration
271271
if apiKey := os.Getenv("OPENROUTER_API_KEY"); apiKey != "" {
272272
viper.SetDefault("providers.openrouter.apiKey", apiKey)
273-
viper.SetDefault("agents.coder.model", models.GPT41)
274-
viper.SetDefault("agents.task.model", models.GPT41Mini)
275-
viper.SetDefault("agents.title.model", models.GPT41Mini)
273+
viper.SetDefault("agents.coder.model", models.OpenRouterGPT41)
274+
viper.SetDefault("agents.task.model", models.OpenRouterGPT41Mini)
275+
viper.SetDefault("agents.title.model", models.OpenRouterGPT41Mini)
276276
return
277277
}
278278

@@ -596,12 +596,12 @@ func setDefaultModelForAgent(agent AgentName) bool {
596596

597597
switch agent {
598598
case AgentTitle:
599-
model = models.GPT41Mini
599+
model = models.OpenRouterGPT41Mini
600600
maxTokens = 80
601601
case AgentTask:
602-
model = models.GPT41Mini
602+
model = models.OpenRouterGPT41Mini
603603
default:
604-
model = models.GPT41
604+
model = models.OpenRouterGPT41
605605
}
606606

607607
// Check if model supports reasoning

0 commit comments

Comments
 (0)