Files
ai/controllers/zap_threed-generation.go
4fdd6c03bf feat(api): /v1/3d|/music|/foley/generations for creative models (#146)
Add ThreeDGenerations, catalog modeOutputs/endpointOf for 3d, and
music/foley generation path aliases that keep /v1/audio/* working.

Co-authored-by: zeekay <[email protected]>
2026-11-09 14:50:18 -08:00

40 lines
1.2 KiB
Go

// Copyright 2026 Hanzo AI Inc. All Rights Reserved.
package controllers
import (
"context"
"encoding/json"
"time"
"github.com/hanzoai/ai/object"
"github.com/luxfi/zap"
)
func init() {
registerCloud("threed.generate", zapThreeDGenerateHandler)
registerGatewayPath("/v1/3d/generations", zapThreeDGenerateHandler)
}
func zapThreeDGenerateHandler(ctx context.Context, auth string, body []byte) (*zap.Message, error) {
if auth == "" {
return object.BuildCloudResponse(401, nil, "authentication required")
}
var req threeDGenerationsRequest
if err := json.Unmarshal(body, &req); err != nil || req.Model == "" || req.Prompt == "" {
return object.BuildCloudResponse(400, nil, "3d request requires model and prompt")
}
provider, authUser, _, err := zapResolveAuth(auth, req.Model)
if err != nil {
return object.BuildCloudResponse(401, nil, err.Error())
}
if provider.Type != "Zen" {
return object.BuildCloudResponse(400, nil, "model \""+req.Model+"\" does not serve the /v1/3d/generations endpoint")
}
isPremium := false
if route := resolveModelRoute(req.Model); route != nil {
isPremium = route.premium
}
return zapServeZenMedia("3d/generations", req.Model, body, 1, authUser, isPremium, time.Now().UTC())
}