From 46c6fb1e7a1454c2af0c009611da2ad14f89699f Mon Sep 17 00:00:00 2001 From: Darley Date: Sat, 24 Jan 2026 04:38:13 +0330 Subject: [PATCH] fix(api): enhance ClaudeModels response to align with api.anthropic.com --- internal/registry/model_registry.go | 4 ++-- sdk/api/handlers/claude/code_handlers.go | 17 ++++++++++++++++- 2 files changed, 18 insertions(+), 3 deletions(-) diff --git a/internal/registry/model_registry.go b/internal/registry/model_registry.go index 5de0ba4a..edb1f124 100644 --- a/internal/registry/model_registry.go +++ b/internal/registry/model_registry.go @@ -1033,10 +1033,10 @@ func (r *ModelRegistry) convertModelToMap(model *ModelInfo, handlerType string) "owned_by": model.OwnedBy, } if model.Created > 0 { - result["created"] = model.Created + result["created_at"] = model.Created } if model.Type != "" { - result["type"] = model.Type + result["type"] = "model" } if model.DisplayName != "" { result["display_name"] = model.DisplayName diff --git a/sdk/api/handlers/claude/code_handlers.go b/sdk/api/handlers/claude/code_handlers.go index 30ff228d..22e10fa5 100644 --- a/sdk/api/handlers/claude/code_handlers.go +++ b/sdk/api/handlers/claude/code_handlers.go @@ -128,8 +128,23 @@ func (h *ClaudeCodeAPIHandler) ClaudeCountTokens(c *gin.Context) { // Parameters: // - c: The Gin context for the request. func (h *ClaudeCodeAPIHandler) ClaudeModels(c *gin.Context) { + models := h.Models() + firstID := "" + lastID := "" + if len(models) > 0 { + if id, ok := models[0]["id"].(string); ok { + firstID = id + } + if id, ok := models[len(models)-1]["id"].(string); ok { + lastID = id + } + } + c.JSON(http.StatusOK, gin.H{ - "data": h.Models(), + "data": models, + "has_more": false, + "first_id": firstID, + "last_id": lastID, }) }