|
- package aiping
-
- import "net/http"
-
- const (
- ActionText2Video = "kling-text2video"
- ActionImage2Video = "kling-image2video"
- ActionMotionControl = "kling-motion-control"
- ActionOmniVideo = "kling-omni-video"
- ActionMultiImage2Video = "kling-multi-image2video"
- ActionVideoExtend = "kling-video-extend"
- ActionAdvancedElements = "kling-advanced-elements-create"
- ActionVoicesCreate = "kling-voices-create"
- ActionDeleteElements = "kling-delete-elements"
- ActionDeleteVoices = "kling-voices-delete"
- )
-
- const (
- RouteKindSubmit = "submit"
- RouteKindFetch = "fetch"
- RouteKindList = "list"
- RouteKindProxy = "proxy"
- )
-
- const (
- ModelKlingAdvancedElements = "kling-advanced-elements"
- ModelCustomVoices = "custom-voices"
- )
-
- type Route struct {
- Method string
- PathPattern string
- Action string
- UpstreamPath string
- Kind string
- BillingModel string
- }
-
- var Routes = []Route{
- // 视频能力:文生视频
- {http.MethodPost, "/v1/videos/text2video", ActionText2Video, "/api/v1/multimodal/kling/videos/text2video", RouteKindSubmit, ""},
- {http.MethodGet, "/v1/videos/text2video/:task_id", ActionText2Video, "/api/v1/multimodal/kling/videos/text2video/:task_id", RouteKindFetch, ""},
- {http.MethodGet, "/v1/videos/text2video", ActionText2Video, "/api/v1/multimodal/kling/videos/text2video", RouteKindList, ""},
- // 视频能力:图生视频
- {http.MethodPost, "/v1/videos/image2video", ActionImage2Video, "/api/v1/multimodal/kling/videos/image2video", RouteKindSubmit, ""},
- {http.MethodGet, "/v1/videos/image2video/:task_id", ActionImage2Video, "/api/v1/multimodal/kling/videos/image2video/:task_id", RouteKindFetch, ""},
- {http.MethodGet, "/v1/videos/image2video", ActionImage2Video, "/api/v1/multimodal/kling/videos/image2video", RouteKindList, ""},
- // 视频能力:动作控制(model_name 可指定 Kling-V3 / Kling-V2.6)
- {http.MethodPost, "/v1/videos/motion-control", ActionMotionControl, "/api/v1/multimodal/kling/videos/motion-control", RouteKindSubmit, ""},
- {http.MethodGet, "/v1/videos/motion-control/:task_id", ActionMotionControl, "/api/v1/multimodal/kling/videos/motion-control/:task_id", RouteKindFetch, ""},
- {http.MethodGet, "/v1/videos/motion-control", ActionMotionControl, "/api/v1/multimodal/kling/videos/motion-control", RouteKindList, ""},
- // 视频能力:Omni / 多镜头
- {http.MethodPost, "/v1/videos/omni-video", ActionOmniVideo, "/api/v1/multimodal/kling/videos/omni-video", RouteKindSubmit, ""},
- {http.MethodGet, "/v1/videos/omni-video/:task_id", ActionOmniVideo, "/api/v1/multimodal/kling/videos/omni-video/:task_id", RouteKindFetch, ""},
- {http.MethodGet, "/v1/videos/omni-video", ActionOmniVideo, "/api/v1/multimodal/kling/videos/omni-video", RouteKindList, ""},
- // 视频能力:多图参考生视频
- {http.MethodPost, "/v1/videos/multi-image2video", ActionMultiImage2Video, "/api/v1/multimodal/kling/videos/multi-image2video", RouteKindSubmit, ""},
- {http.MethodGet, "/v1/videos/multi-image2video/:task_id", ActionMultiImage2Video, "/api/v1/multimodal/kling/videos/multi-image2video/:task_id", RouteKindFetch, ""},
- {http.MethodGet, "/v1/videos/multi-image2video", ActionMultiImage2Video, "/api/v1/multimodal/kling/videos/multi-image2video", RouteKindList, ""},
- // 视频能力:视频延长
- {http.MethodPost, "/v1/videos/video-extend", ActionVideoExtend, "/api/v1/multimodal/kling/videos/video-extend", RouteKindSubmit, ""},
- {http.MethodGet, "/v1/videos/video-extend/:task_id", ActionVideoExtend, "/api/v1/multimodal/kling/videos/video-extend/:task_id", RouteKindFetch, ""},
- {http.MethodGet, "/v1/videos/video-extend", ActionVideoExtend, "/api/v1/multimodal/kling/videos/video-extend", RouteKindList, ""},
-
- // 主体能力:自定义主体
- {http.MethodPost, "/v1/general/advanced-custom-elements", ActionAdvancedElements, "/api/v1/multimodal/kling/general/advanced-custom-elements", RouteKindSubmit, ModelKlingAdvancedElements},
- {http.MethodGet, "/v1/general/advanced-custom-elements/:task_id", ActionAdvancedElements, "/api/v1/multimodal/kling/general/advanced-custom-elements/:task_id", RouteKindFetch, ModelKlingAdvancedElements},
- {http.MethodGet, "/v1/general/advanced-custom-elements", "kling-advanced-elements-list", "/api/v1/multimodal/kling/general/advanced-custom-elements", RouteKindProxy, ModelKlingAdvancedElements},
- // 主体能力:官方主体列表
- {http.MethodGet, "/v1/general/advanced-presets-elements", "kling-advanced-elements-presets", "/api/v1/multimodal/kling/general/advanced-presets-elements", RouteKindProxy, ModelKlingAdvancedElements},
- // 主体能力:删除自定义主体
- {http.MethodPost, "/v1/general/delete-advanced-elements", ActionDeleteElements, "/api/v1/multimodal/kling/general/delete-advanced-elements", RouteKindProxy, ModelKlingAdvancedElements},
-
- // 音色能力:自定义音色
- {http.MethodPost, "/v1/general/custom-voices", ActionVoicesCreate, "/api/v1/multimodal/kling/general/custom-voices", RouteKindSubmit, ModelCustomVoices},
- {http.MethodGet, "/v1/general/custom-voices/:task_id", ActionVoicesCreate, "/api/v1/multimodal/kling/general/custom-voices/:task_id", RouteKindFetch, ModelCustomVoices},
- {http.MethodGet, "/v1/general/custom-voices", "kling-voices-list", "/api/v1/multimodal/kling/general/custom-voices", RouteKindProxy, ModelCustomVoices},
- // 音色能力:官方音色列表
- {http.MethodGet, "/v1/general/presets-voices", "kling-voices-presets", "/api/v1/multimodal/kling/general/presets-voices", RouteKindProxy, ModelCustomVoices},
- // 音色能力:删除自定义音色
- {http.MethodPost, "/v1/general/delete-voices", ActionDeleteVoices, "/api/v1/multimodal/kling/general/delete-voices", RouteKindProxy, ModelCustomVoices},
- }
-
- func FindRoute(method, pathPattern, kind string) (Route, bool) {
- for _, route := range Routes {
- if route.Method == method && route.PathPattern == pathPattern && route.Kind == kind {
- return route, true
- }
- }
- return Route{}, false
- }
-
- func FindRouteByAction(action string) (Route, bool) {
- for _, route := range Routes {
- if route.Action == action && route.Kind == RouteKindSubmit {
- return route, true
- }
- }
- return Route{}, false
- }
-
- func FindFetchRouteByAction(action string) (Route, bool) {
- for _, route := range Routes {
- if route.Action == action && route.Kind == RouteKindFetch {
- return route, true
- }
- }
- return Route{}, false
- }
-
- func Models() []string {
- return []string{
- "kling-v1",
- "kling-v1-6",
- "kling-v2-6",
- "kling-v3",
- "kling-video-o1",
- "kling-v3-omni",
- ModelKlingAdvancedElements,
- ModelCustomVoices,
- }
- }
|