diff --git a/internal/api/handlers/openai/openai_handlers.go b/internal/api/handlers/openai/openai_handlers.go index 47a5e247..579ced43 100644 --- a/internal/api/handlers/openai/openai_handlers.go +++ b/internal/api/handlers/openai/openai_handlers.go @@ -60,9 +60,33 @@ func (h *OpenAIAPIHandler) Models() []map[string]any { // It returns a list of available AI models with their capabilities // and specifications in OpenAI-compatible format. 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": h.Models(), + "data": filteredModels, }) }