@@ -220,105 +220,62 @@ func (s *ChatServerV2) ListSupportedModels(
220220 return nil , err
221221 }
222222
223- hasOwnAPIKey := strings .TrimSpace (settings .OpenAIAPIKey ) != ""
224-
225223 var models []* chatv2.SupportedModel
226224 for _ , config := range allModels {
225+ // Check if user has set API key for this particular model
226+ hasOwnAPIKey := false
227+ for _ , model := range settings .CustomModels {
228+ if model .Slug == config .slugOpenRouter {
229+ // User has API key for this model, use slugOpenAI instead of slugOpenRouter if applicable
230+ slug := config .slugOpenRouter
231+ if strings .TrimSpace (config .slugOpenAI ) != "" {
232+ slug = config .slugOpenAI
233+ }
234+
235+ models = append (models , & chatv2.SupportedModel {
236+ Name : model .Name ,
237+ Slug : slug ,
238+ TotalContext : int64 (model .ContextWindow ),
239+ MaxOutput : int64 (model .MaxOutput ),
240+ InputPrice : int64 (model .InputPrice ),
241+ OutputPrice : int64 (model .OutputPrice ),
242+ CustomModelId : model .ID .Hex (),
243+ })
244+ hasOwnAPIKey = true
245+ continue
246+ }
247+ }
248+
249+ if hasOwnAPIKey {
250+ continue
251+ }
252+
227253 // Choose the appropriate slug based on whether user has their own API key.
228254 //
229255 // Some models are only available via OpenRouter; for those, slugOpenAI may be empty.
230256 // In that case, keep using the OpenRouter slug to avoid returning an empty model slug.
231- slug := config .slugOpenRouter
232- if hasOwnAPIKey && strings .TrimSpace (config .slugOpenAI ) != "" {
233- slug = config .slugOpenAI
234- }
235-
236- // model := &chatv2.SupportedModel{
237- // Name: config.name,
238- // Slug: slug,
239- // TotalContext: config.totalContext,
240- // MaxOutput: config.maxOutput,
241- // InputPrice: config.inputPrice,
242- // OutputPrice: config.outputPrice,
243- // }
244-
245- // // If model requires own key but user hasn't provided one, mark as disabled
246- // if config.requireOwnKey && !hasOwnAPIKey {
247- // model.Disabled = true
248- // model.DisabledReason = stringPtr("Requires your own OpenAI API key. Configure it in Settings.")
249- // }
257+ // slug := config.slugOpenRouter
258+ // if hasOwnAPIKey && strings.TrimSpace(config.slugOpenAI) != "" {
259+ // slug = config.slugOpenAI
260+ // }
250261
251- // models = append(models, model)
262+ model := & chatv2.SupportedModel {
263+ Name : config .name ,
264+ Slug : config .slugOpenRouter ,
265+ TotalContext : config .totalContext ,
266+ MaxOutput : config .maxOutput ,
267+ InputPrice : config .inputPrice ,
268+ OutputPrice : config .outputPrice ,
269+ }
252270
253- // models = []*chatv2.SupportedModel{
254- // {
255- // Name: "GPT-4.1",
256- // Slug: "openai/gpt-4.1",
257- // TotalContext: 1050000,
258- // MaxOutput: 32800,
259- // InputPrice: 200,
260- // OutputPrice: 800,
261- // CustomModelId: "",
262- // },
263- // {
264- // Name: "GPT-4.1-mini",
265- // Slug: "openai/gpt-4.1-mini",
266- // TotalContext: 128000,
267- // MaxOutput: 16400,
268- // InputPrice: 15,
269- // OutputPrice: 60,
270- // CustomModelId: "",
271- // },
272- // {
273- // Name: "Qwen Plus (balanced)",
274- // Slug: "qwen/qwen-plus",
275- // TotalContext: 131100,
276- // MaxOutput: 8200,
277- // InputPrice: 40,
278- // OutputPrice: 120,
279- // CustomModelId: "",
280- // },
281- // {
282- // Name: "Qwen Turbo (fast)",
283- // Slug: "qwen/qwen-turbo",
284- // TotalContext: 1000000,
285- // MaxOutput: 8200,
286- // InputPrice: 5,
287- // OutputPrice: 20,
288- // CustomModelId: "",
289- // },
290- // {
291- // Name: "Gemini 2.5 Flash (fast)",
292- // Slug: "google/gemini-2.5-flash",
293- // TotalContext: 1050000,
294- // MaxOutput: 65500,
295- // InputPrice: 30,
296- // OutputPrice: 250,
297- // CustomModelId: "",
298- // },
299- // {
300- // Name: "Gemini 3 Flash Preview",
301- // Slug: "google/gemini-3-flash-preview",
302- // TotalContext: 1050000,
303- // MaxOutput: 65500,
304- // InputPrice: 50,
305- // OutputPrice: 300,
306- // CustomModelId: "",
307- // },
308- // }
271+ // If model requires own key but user hasn't provided one, mark as disabled
272+ if config .requireOwnKey {
273+ model .Disabled = true
274+ model .DisabledReason = stringPtr ("Requires your own OpenAI API key. Configure it in Settings." )
275+ }
309276
310- // for _, m := range settings.CustomModels {
311- // models = slices.Insert(models, 0, &chatv2.SupportedModel{
312- // Name: m.Name,
313- // Slug: m.Slug,
314- // TotalContext: int64(m.ContextWindow),
315- // MaxOutput: int64(m.MaxOutput),
316- // InputPrice: int64(m.InputPrice),
317- // OutputPrice: int64(m.OutputPrice),
318- // CustomModelId: m.ID.Hex(),
319- // })
277+ models = append (models , model )
320278 }
321-
322279 return & chatv2.ListSupportedModelsResponse {
323280 Models : models ,
324281 }, nil
0 commit comments