feat: expose model groups in /v1/models endpoint
CI / Lint (push) Has been cancelled
CI / Test (push) Has been cancelled
CI / Build (push) Has been cancelled

Add Groups() method to Router so handleListModels can append model
group IDs (e.g. 'deepseek-auto', 'openai-auto') to the model list,
marked with owned_by: 'gophergate'. This lets clients discover and
use groups via the standard OpenAI /v1/models endpoint.
This commit is contained in:
2026-05-07 11:26:05 -04:00
parent 3021e4b2b4
commit 79dd122b56
2 changed files with 23 additions and 0 deletions
+9
View File
@@ -36,6 +36,15 @@ func New(groups []db.ModelGroup, classify ClassifierFunc) *Router {
return r
}
// Groups returns all registered model group IDs.
func (r *Router) Groups() []string {
ids := make([]string, 0, len(r.groups))
for id := range r.groups {
ids = append(ids, id)
}
return ids
}
// IsGroup returns true if the model name is a group ID.
func (r *Router) IsGroup(modelID string) bool {
_, ok := r.groups[modelID]
+14
View File
@@ -467,6 +467,20 @@ func (s *Server) handleListModels(c *gin.Context) {
}
}
// Add model groups so clients can discover them
if s.modelRouter != nil {
for _, gid := range s.modelRouter.Groups() {
if _, exists := modelMap[gid]; !exists {
modelMap[gid] = OpenAIModel{
ID: gid,
Object: "model",
Created: 1700000000,
OwnedBy: "gophergate",
}
}
}
}
var data []OpenAIModel
for _, m := range modelMap {
data = append(data, m)