Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
27 changes: 4 additions & 23 deletions sdk/api/handlers/openai/openai_handlers.go
Original file line number Diff line number Diff line change
Expand Up @@ -59,34 +59,15 @@ func (h *OpenAIAPIHandler) Models() []map[string]any {
// OpenAIModels handles the /v1/models endpoint.
// It returns a list of available AI models with their capabilities
// and specifications in OpenAI-compatible format.
// All metadata from the model registry is included so that downstream
// consumers (dashboards, IDEs, proxy UIs) can group and display models
// without maintaining a separate static list.
func (h *OpenAIAPIHandler) OpenAIModels(c *gin.Context) {
// Get all available models
allModels := h.Models()

// Filter to only include the 4 required fields: id, object, created, owned_by
filteredModels := make([]map[string]any, len(allModels))
for i, model := range allModels {
filteredModel := map[string]any{
"id": model["id"],
"object": model["object"],
}

// Add created field if it exists
if created, exists := model["created"]; exists {
filteredModel["created"] = created
}

// Add owned_by field if it exists
if ownedBy, exists := model["owned_by"]; exists {
filteredModel["owned_by"] = ownedBy
}

filteredModels[i] = filteredModel
}

c.JSON(http.StatusOK, gin.H{
"object": "list",
"data": filteredModels,
"data": allModels,
})
}

Expand Down