-
Notifications
You must be signed in to change notification settings - Fork 71
Expand file tree
/
Copy pathlist_supported_models_v2.go
More file actions
293 lines (277 loc) · 7.72 KB
/
list_supported_models_v2.go
File metadata and controls
293 lines (277 loc) · 7.72 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
package chat
import (
"context"
"strings"
"paperdebugger/internal/libs/contextutil"
chatv2 "paperdebugger/pkg/gen/api/chat/v2"
"github.com/openai/openai-go/v3"
)
// modelConfig holds model configuration including whether it requires user's own API key
type modelConfig struct {
name string
slugOpenRouter string // Slug for OpenRouter API (used when user doesn't provide own key)
slugOpenAI string // Slug for OpenAI API (used when user provides own key)
totalContext int64
maxOutput int64
inputPrice int64
outputPrice int64
requireOwnKey bool // If true, this model requires user to provide their own API key
}
// allModels defines all available models in the system
var allModels = []modelConfig{
{
name: "GPT-5.1",
slugOpenRouter: "openai/gpt-5.1",
slugOpenAI: openai.ChatModelGPT5_1,
totalContext: 400000,
maxOutput: 128000,
inputPrice: 125, // $1.25
outputPrice: 1000, // $10.00
requireOwnKey: false,
},
{
name: "GPT-5.2",
slugOpenRouter: "openai/gpt-5.2",
slugOpenAI: openai.ChatModelGPT5_2,
totalContext: 400000,
maxOutput: 128000,
inputPrice: 175, // $1.75
outputPrice: 1400, // $14.00
requireOwnKey: true,
},
{
name: "GPT-5 Mini",
slugOpenRouter: "openai/gpt-5-mini",
slugOpenAI: openai.ChatModelGPT5Mini,
totalContext: 400000,
maxOutput: 128000,
inputPrice: 25,
outputPrice: 200,
requireOwnKey: false,
},
{
name: "GPT-5 Nano",
slugOpenRouter: "openai/gpt-5-nano",
slugOpenAI: openai.ChatModelGPT5Nano,
totalContext: 400000,
maxOutput: 128000,
inputPrice: 5, // $0.20
outputPrice: 40, // $0.80
requireOwnKey: false,
},
{
name: "GPT-4.1",
slugOpenRouter: "openai/gpt-4.1",
slugOpenAI: openai.ChatModelGPT4_1,
totalContext: 1050000,
maxOutput: 32800,
inputPrice: 200, // $2.00
outputPrice: 800,
requireOwnKey: false,
},
{
name: "GPT-4.1-mini",
slugOpenRouter: "openai/gpt-4.1-mini",
slugOpenAI: openai.ChatModelGPT4_1Mini,
totalContext: 128000,
maxOutput: 16400,
inputPrice: 15,
outputPrice: 60,
requireOwnKey: false,
},
{
name: "GPT-4o",
slugOpenRouter: "openai/gpt-4o",
slugOpenAI: openai.ChatModelGPT4o,
totalContext: 128000,
maxOutput: 16400,
inputPrice: 250,
outputPrice: 1000,
requireOwnKey: true,
},
{
name: "OpenAI: gpt-oss-120b (free)",
slugOpenRouter: "openai/gpt-oss-120b:free",
slugOpenAI: "",
totalContext: 131072,
maxOutput: 131072,
inputPrice: 0,
outputPrice: 0,
requireOwnKey: false,
},
{
name: "Qwen Plus (balanced)",
slugOpenRouter: "qwen/qwen-plus",
slugOpenAI: "", // OpenAI doesn't support Qwen, use OpenRouter slug
totalContext: 131100,
maxOutput: 8200,
inputPrice: 40,
outputPrice: 120,
requireOwnKey: false,
},
{
name: "Qwen Turbo (fast)",
slugOpenRouter: "qwen/qwen-turbo",
slugOpenAI: "", // OpenAI doesn't support Qwen, use OpenRouter slug
totalContext: 1000000,
maxOutput: 8200,
inputPrice: 5,
outputPrice: 20,
requireOwnKey: false,
},
{
name: "Qwen3 Coder 480B A35B (free)",
slugOpenRouter: "qwen/qwen3-coder:free",
slugOpenAI: "",
totalContext: 262000,
maxOutput: 262000,
inputPrice: 0,
outputPrice: 0,
requireOwnKey: false,
},
{
name: "GLM 4.5 Air (free)",
slugOpenRouter: "z-ai/glm-4.5-air:free",
slugOpenAI: "",
totalContext: 131072,
maxOutput: 131072,
inputPrice: 0,
outputPrice: 0,
requireOwnKey: false,
},
{
name: "Gemini 2.5 Flash (fast)",
slugOpenRouter: "google/gemini-2.5-flash",
slugOpenAI: "", // OpenAI doesn't support Gemini, use OpenRouter slug
totalContext: 1050000,
maxOutput: 65500,
inputPrice: 30,
outputPrice: 250,
requireOwnKey: false,
},
{
name: "Gemini 3 Flash Preview",
slugOpenRouter: "google/gemini-3-flash-preview",
slugOpenAI: "", // OpenAI doesn't support Gemini, use OpenRouter slug
totalContext: 1050000,
maxOutput: 65500,
inputPrice: 50,
outputPrice: 300,
requireOwnKey: false,
},
{
name: "MiniMax M2.7",
slugOpenRouter: "minimax/MiniMax-M2.7",
slugOpenAI: "MiniMax-M2.7",
totalContext: 1000000,
maxOutput: 128000,
inputPrice: 100, // $1.00
outputPrice: 400, // $4.00
requireOwnKey: false,
},
{
name: "MiniMax M2.7 Highspeed",
slugOpenRouter: "minimax/MiniMax-M2.7-highspeed",
slugOpenAI: "MiniMax-M2.7-highspeed",
totalContext: 1000000,
maxOutput: 128000,
inputPrice: 50, // $0.50
outputPrice: 200, // $2.00
requireOwnKey: false,
},
{
name: "o1 Mini",
slugOpenRouter: "openai/o1-mini",
slugOpenAI: openai.ChatModelO1Mini,
totalContext: 128000,
maxOutput: 65536,
inputPrice: 300, // $3.00
outputPrice: 1200, // $12.00
requireOwnKey: true,
},
{
name: "o3",
slugOpenRouter: "openai/o3",
slugOpenAI: openai.ChatModelO3,
totalContext: 200000,
maxOutput: 100000,
inputPrice: 200,
outputPrice: 800,
requireOwnKey: true,
},
{
name: "o3 Mini",
slugOpenRouter: "openai/o3-mini",
slugOpenAI: openai.ChatModelO3Mini,
totalContext: 200000,
maxOutput: 100000,
inputPrice: 110,
outputPrice: 440,
requireOwnKey: true,
},
{
name: "o4 Mini",
slugOpenRouter: "openai/o4-mini",
slugOpenAI: openai.ChatModelO4Mini,
totalContext: 128000,
maxOutput: 65536,
inputPrice: 110,
outputPrice: 440,
requireOwnKey: true,
},
}
func (s *ChatServerV2) ListSupportedModels(
ctx context.Context,
req *chatv2.ListSupportedModelsRequest,
) (*chatv2.ListSupportedModelsResponse, error) {
actor, err := contextutil.GetActor(ctx)
if err != nil {
return nil, err
}
settings, err := s.userService.GetUserSettings(ctx, actor.ID)
if err != nil {
return nil, err
}
hasOwnAPIKey := strings.TrimSpace(settings.OpenAIAPIKey) != ""
hasMiniMaxAPIKey := strings.TrimSpace(s.cfg.MiniMaxAPIKey) != ""
var models []*chatv2.SupportedModel
for _, config := range allModels {
// Choose the appropriate slug based on whether user has their own API key.
//
// Some models are only available via OpenRouter; for those, slugOpenAI may be empty.
// In that case, keep using the OpenRouter slug to avoid returning an empty model slug.
slug := config.slugOpenRouter
if hasOwnAPIKey && strings.TrimSpace(config.slugOpenAI) != "" {
slug = config.slugOpenAI
}
// For MiniMax models, use direct API slug when server has MiniMax API key
if hasMiniMaxAPIKey && isMiniMaxModelConfig(config) && strings.TrimSpace(config.slugOpenAI) != "" {
slug = config.slugOpenAI
}
model := &chatv2.SupportedModel{
Name: config.name,
Slug: slug,
TotalContext: config.totalContext,
MaxOutput: config.maxOutput,
InputPrice: config.inputPrice,
OutputPrice: config.outputPrice,
}
// If model requires own key but user hasn't provided one, mark as disabled
if config.requireOwnKey && !hasOwnAPIKey {
model.Disabled = true
model.DisabledReason = stringPtr("Requires your own OpenAI API key. Configure it in Settings.")
}
models = append(models, model)
}
return &chatv2.ListSupportedModelsResponse{
Models: models,
}, nil
}
// isMiniMaxModelConfig checks if a model config belongs to MiniMax.
func isMiniMaxModelConfig(config modelConfig) bool {
return strings.Contains(strings.ToLower(config.slugOpenRouter), "minimax")
}
// stringPtr returns a pointer to the given string
func stringPtr(s string) *string {
return &s
}