mirror of
https://gh-proxy.org/https://github.com/klinsmaya/CLIProxyAPI.git
synced 2026-11-10 10:26:48 +08:00
fix(registry): Emit Claude model created_at as RFC 3339 string
Anthropic's List Models schema types created_at as an RFC 3339 datetime string, but the Claude case of convertModelToMap emitted model.Created as a Unix-timestamp integer. Format it with time.RFC3339 so the listing matches the documented schema.
This commit is contained in:
@@ -1161,7 +1161,7 @@ func (r *ModelRegistry) convertModelToMap(model *ModelInfo, handlerType string)
|
||||
"owned_by": model.OwnedBy,
|
||||
}
|
||||
if model.Created > 0 {
|
||||
result["created_at"] = model.Created
|
||||
result["created_at"] = time.Unix(model.Created, 0).UTC().Format(time.RFC3339)
|
||||
}
|
||||
if model.Type != "" {
|
||||
result["type"] = "model"
|
||||
|
||||
@@ -25,7 +25,7 @@ func TestGetAvailableModelsReturnsClonedSnapshots(t *testing.T) {
|
||||
func TestGetAvailableModelsClaudeIncludesTokenLimits(t *testing.T) {
|
||||
r := newTestModelRegistry()
|
||||
r.RegisterClient("client-1", "Claude", []*ModelInfo{
|
||||
{ID: "claude-sonnet-4-6", OwnedBy: "anthropic", Type: "claude", ContextLength: 200000, MaxCompletionTokens: 64000},
|
||||
{ID: "claude-sonnet-4-6", OwnedBy: "anthropic", Type: "claude", Created: 1771372800, ContextLength: 200000, MaxCompletionTokens: 64000},
|
||||
{ID: "claude-no-limits", OwnedBy: "anthropic", Type: "claude"},
|
||||
})
|
||||
|
||||
@@ -46,6 +46,9 @@ func TestGetAvailableModelsClaudeIncludesTokenLimits(t *testing.T) {
|
||||
if got := withLimits["max_tokens"]; got != 64000 {
|
||||
t.Fatalf("expected max_tokens 64000, got %v", got)
|
||||
}
|
||||
if got := withLimits["created_at"]; got != "2026-02-18T00:00:00Z" {
|
||||
t.Fatalf("expected created_at as RFC 3339 string, got %v", got)
|
||||
}
|
||||
|
||||
withDefaults, ok := byID["claude-no-limits"]
|
||||
if !ok {
|
||||
|
||||
Reference in New Issue
Block a user