mirror of
https://github.com/router-for-me/CLIProxyAPI.git
synced 2026-02-02 20:40:52 +08:00
fix(api): enhance ClaudeModels response to align with api.anthropic.com
This commit is contained in:
@@ -1033,10 +1033,10 @@ func (r *ModelRegistry) convertModelToMap(model *ModelInfo, handlerType string)
|
|||||||
"owned_by": model.OwnedBy,
|
"owned_by": model.OwnedBy,
|
||||||
}
|
}
|
||||||
if model.Created > 0 {
|
if model.Created > 0 {
|
||||||
result["created"] = model.Created
|
result["created_at"] = model.Created
|
||||||
}
|
}
|
||||||
if model.Type != "" {
|
if model.Type != "" {
|
||||||
result["type"] = model.Type
|
result["type"] = "model"
|
||||||
}
|
}
|
||||||
if model.DisplayName != "" {
|
if model.DisplayName != "" {
|
||||||
result["display_name"] = model.DisplayName
|
result["display_name"] = model.DisplayName
|
||||||
|
|||||||
@@ -128,8 +128,23 @@ func (h *ClaudeCodeAPIHandler) ClaudeCountTokens(c *gin.Context) {
|
|||||||
// Parameters:
|
// Parameters:
|
||||||
// - c: The Gin context for the request.
|
// - c: The Gin context for the request.
|
||||||
func (h *ClaudeCodeAPIHandler) ClaudeModels(c *gin.Context) {
|
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{
|
c.JSON(http.StatusOK, gin.H{
|
||||||
"data": h.Models(),
|
"data": models,
|
||||||
|
"has_more": false,
|
||||||
|
"first_id": firstID,
|
||||||
|
"last_id": lastID,
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user