diff --git a/apps/gateway/internal/adapters/http/handlers/handlers_test.go b/apps/gateway/internal/adapters/http/handlers/handlers_test.go index 642877f..e8704eb 100644 --- a/apps/gateway/internal/adapters/http/handlers/handlers_test.go +++ b/apps/gateway/internal/adapters/http/handlers/handlers_test.go @@ -8,6 +8,7 @@ import ( "reflect" "strings" "testing" + "time" "github.com/dappnode/dappnode-nexus-gateway/apps/gateway/internal/adapters/http/handlers" "github.com/dappnode/dappnode-nexus-gateway/apps/gateway/internal/application/services" @@ -107,11 +108,13 @@ func TestModelsHandler_NoAuthRequired(t *testing.T) { } func TestModelsHandler_ListsModels(t *testing.T) { + createdAt := time.Date(2026, 11, 15, 12, 0, 0, 0, time.UTC) desc := "GPT-4.1 Mini model" catalog := &mockModelCatalog{ models: []domain.PublicModel{ { PublicModelID: "openai/gpt-4.1-mini", + CreatedAt: createdAt, DisplayName: "GPT-4.1 Mini", Description: &desc, ProviderConfig: domain.ProviderConfig{ProviderName: "openai"}, @@ -154,6 +157,7 @@ func TestModelsHandler_ListsModels(t *testing.T) { Object string `json:"object"` Data []struct { ID string `json:"id"` + Created int64 `json:"created"` Object string `json:"object"` OwnedBy string `json:"owned_by"` DisplayName string `json:"display_name"` @@ -178,6 +182,12 @@ func TestModelsHandler_ListsModels(t *testing.T) { t.Fatalf("data len = %d, want 2", len(body.Data)) } first := body.Data[0] + if first.Created != createdAt.Unix() { + t.Errorf("created = %d, want %d", first.Created, createdAt.Unix()) + } + if body.Data[1].Created != 0 { + t.Errorf("missing creation date = %d, want 0", body.Data[1].Created) + } if first.ID != "openai/gpt-4.1-mini" { t.Errorf("data[0].id = %s, want openai/gpt-4.1-mini", first.ID) } diff --git a/apps/gateway/internal/adapters/http/handlers/models_handler.go b/apps/gateway/internal/adapters/http/handlers/models_handler.go index ce1ff6d..9660379 100644 --- a/apps/gateway/internal/adapters/http/handlers/models_handler.go +++ b/apps/gateway/internal/adapters/http/handlers/models_handler.go @@ -53,13 +53,17 @@ func toPublicModelData(m domain.PublicModel, eurToUSDRate float64) dto.ModelData inputPrice := eurToCents(m.InputPricePerMillion) outputPrice := eurToCents(m.OutputPricePerMillion) proofMode := m.EffectiveProofMode() + created := int64(0) + if !m.CreatedAt.IsZero() { + created = m.CreatedAt.Unix() + } data := dto.ModelData{ ID: m.PublicModelID, Object: "model", Kind: string(domain.CatalogKindPublicModel), BaseModel: privateBaseModel(m.PublicModelID, m.UpstreamModelName), OwnedBy: "nexus", - Created: 0, + Created: created, DisplayName: m.DisplayName, Description: m.Description, ContextSize: &m.MaxContextWindow, diff --git a/apps/gateway/internal/adapters/metering/runtime_client.go b/apps/gateway/internal/adapters/metering/runtime_client.go index 8b80fea..58d19be 100644 --- a/apps/gateway/internal/adapters/metering/runtime_client.go +++ b/apps/gateway/internal/adapters/metering/runtime_client.go @@ -353,6 +353,7 @@ func (m runtimePublicModel) capabilities() json.RawMessage { func (m runtimePublicModel) toDomain() domain.PublicModel { model := domain.PublicModel{ + CreatedAt: m.CreatedAt, ID: m.ID, PublicModelID: m.PublicModelID, DisplayName: m.DisplayName, @@ -450,6 +451,7 @@ type runtimeAPIKey struct { } type runtimePublicModel struct { + CreatedAt time.Time `json:"created_at"` ID string `json:"id"` PublicModelID string `json:"public_model_id"` DisplayName string `json:"display_name"` diff --git a/apps/gateway/internal/adapters/metering/runtime_client_test.go b/apps/gateway/internal/adapters/metering/runtime_client_test.go index 5f20ce8..84ae2a9 100644 --- a/apps/gateway/internal/adapters/metering/runtime_client_test.go +++ b/apps/gateway/internal/adapters/metering/runtime_client_test.go @@ -434,7 +434,7 @@ func TestRuntimeClientMapsModelPricesWithoutPrecisionLoss(t *testing.T) { "input_price_per_1m_tokens_microcents":75000000, "output_price_per_1m_tokens_microcents":450000000, "cache_read_price_per_1m_tokens_microcents":12500000, - "currency":"EUR","active":true + "created_at":"2026-11-15T12:00:00Z","currency":"EUR","active":true }`)) })) defer server.Close() @@ -443,6 +443,9 @@ func TestRuntimeClientMapsModelPricesWithoutPrecisionLoss(t *testing.T) { if err != nil { t.Fatalf("GetPublicModel: %v", err) } + if !model.CreatedAt.Equal(time.Date(2026, 11, 15, 12, 0, 0, 0, time.UTC)) { + t.Fatalf("created_at = %v", model.CreatedAt) + } if model.InputPricePerMillion.String() != "0.75" || model.OutputPricePerMillion.String() != "4.5" { t.Fatalf("prices = (%s, %s)", model.InputPricePerMillion, model.OutputPricePerMillion) } diff --git a/pkg/domain/model.go b/pkg/domain/model.go index 6cc17f4..63f14df 100644 --- a/pkg/domain/model.go +++ b/pkg/domain/model.go @@ -3,6 +3,7 @@ package domain import ( "encoding/json" "strings" + "time" "github.com/shopspring/decimal" ) @@ -32,6 +33,7 @@ type ProviderTarget struct { // PublicModel is the fully-resolved model exposed by the gateway. type PublicModel struct { + CreatedAt time.Time ID string PublicModelID string DisplayName string