suno

package
v0.5.2 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Mar 14, 2026 License: Apache-2.0 Imports: 10 Imported by: 0

Documentation

Index

Constants

View Source
const (
	SunoActionMusic  = "MUSIC"
	SunoActionLyrics = "LYRICS"
)

Variables

This section is empty.

Functions

func ErrorHandle

func ErrorHandle(err *types.TaskResponse[any]) *types.OpenAIError

错误处理

func RequestErrorHandle

func RequestErrorHandle(resp *http.Response) *types.OpenAIError

请求错误处理

Types

type FetchReq

type FetchReq struct {
	IDs []string `json:"ids"`
}

type GoAPIFetchResponseData

type GoAPIFetchResponseData struct {
	TaskID string              `json:"task_id"`
	Status string              `json:"status"`
	Input  string              `json:"input"`
	Clips  map[string]SunoSong `json:"clips"`
}

type GoAPITaskResponse

type GoAPITaskResponse[T any] struct {
	Code         int    `json:"code"`
	Message      string `json:"message"`
	Data         T      `json:"data"`
	ErrorMessage string `json:"error_message,omitempty"`
}

type GoAPITaskResponseData

type GoAPITaskResponseData struct {
	TaskID string `json:"task_id"`
}

type SunoAccount

type SunoAccount struct {
	SessionId    string `json:"session_id"`
	Cookie       string `json:"cookie"`
	Jwt          string `json:"jwt"`
	LastUpdate   int64  `json:"last_update"`
	CreditsLeft  int    `json:"credits_left"`
	MonthlyLimit int    `json:"monthly_limit"`
	MonthlyUsage int    `json:"monthly_usage"`
	Period       string `json:"period"`
	IsActive     bool   `json:"is_active"`
}

type SunoDataResponse

type SunoDataResponse struct {
	TaskID     string         `json:"task_id" gorm:"type:varchar(50);index"`
	Action     string         `json:"action" gorm:"type:varchar(40);index"` // 任务类型, song, lyrics, description-mode
	Status     string         `json:"status" gorm:"type:varchar(20);index"` // 任务状态, submitted, queueing, processing, success, failed
	FailReason string         `json:"fail_reason"`
	SubmitTime int64          `json:"submit_time" gorm:"index"`
	StartTime  int64          `json:"start_time" gorm:"index"`
	FinishTime int64          `json:"finish_time" gorm:"index"`
	Data       datatypes.JSON `json:"data" gorm:"type:json"`
}

type SunoGoAPISubmitReq

type SunoGoAPISubmitReq struct {
	CustomMode bool `json:"custom_mode"`

	Input SunoGoAPISubmitReqInput `json:"input"`

	NotifyHook string `json:"notify_hook,omitempty"`
}

type SunoGoAPISubmitReqInput

type SunoGoAPISubmitReqInput struct {
	GptDescriptionPrompt string  `json:"gpt_description_prompt"`
	Prompt               string  `json:"prompt"`
	Mv                   string  `json:"mv"`
	Title                string  `json:"title"`
	Tags                 string  `json:"tags"`
	ContinueAt           float64 `json:"continue_at"`
	TaskID               string  `json:"task_id"`
	ContinueClipId       string  `json:"continue_clip_id"`
	MakeInstrumental     bool    `json:"make_instrumental"`
}

type SunoLyrics

type SunoLyrics struct {
	ID     string `json:"id"`
	Status string `json:"status"`
	Title  string `json:"title"`
	Text   string `json:"text"`
}

type SunoMetadata

type SunoMetadata struct {
	Tags                 string      `json:"tags"`
	Prompt               string      `json:"prompt"`
	GPTDescriptionPrompt interface{} `json:"gpt_description_prompt"`
	AudioPromptID        interface{} `json:"audio_prompt_id"`
	Duration             interface{} `json:"duration"`
	ErrorType            interface{} `json:"error_type"`
	ErrorMessage         interface{} `json:"error_message"`
}

type SunoProvider

type SunoProvider struct {
	openai.OpenAIProvider
	Account      string
	Fetchs       string
	Fetch        string
	SubmitMusic  string
	SubmitLyrics string
}

func (*SunoProvider) GetAccount

func (s *SunoProvider) GetAccount() (data *types.TaskResponse[SunoAccount], err error)

func (*SunoProvider) GetFetch

func (s *SunoProvider) GetFetch(id string) (data *types.TaskResponse[SunoDataResponse], errWithCode *types.OpenAIErrorWithStatusCode)

func (*SunoProvider) GetFetchs

func (s *SunoProvider) GetFetchs(ids []string) (data *types.TaskResponse[[]SunoDataResponse], errWithCode *types.OpenAIErrorWithStatusCode)

func (*SunoProvider) GetRequestHeaders

func (p *SunoProvider) GetRequestHeaders() (headers map[string]string)

func (*SunoProvider) Submit

func (s *SunoProvider) Submit(action string, request *SunoSubmitReq) (data *types.TaskResponse[string], errWithCode *types.OpenAIErrorWithStatusCode)

type SunoProviderFactory

type SunoProviderFactory struct{}

定义供应商工厂

func (SunoProviderFactory) Create

创建 SunoProvider

type SunoSong

type SunoSong struct {
	ID                string       `json:"id"`
	VideoURL          string       `json:"video_url"`
	AudioURL          string       `json:"audio_url"`
	ImageURL          string       `json:"image_url"`
	ImageLargeURL     string       `json:"image_large_url"`
	MajorModelVersion string       `json:"major_model_version"`
	ModelName         string       `json:"model_name"`
	Status            string       `json:"status"`
	Title             string       `json:"title"`
	Text              string       `json:"text"`
	Metadata          SunoMetadata `json:"metadata"`
}

type SunoSubmitReq

type SunoSubmitReq struct {
	GptDescriptionPrompt string  `json:"gpt_description_prompt,omitempty"`
	Prompt               string  `json:"prompt,omitempty"`
	Mv                   string  `json:"mv,omitempty"`
	Title                string  `json:"title,omitempty"`
	Tags                 string  `json:"tags,omitempty"`
	ContinueAt           float64 `json:"continue_at,omitempty"`
	TaskID               string  `json:"task_id,omitempty"`
	ContinueClipId       string  `json:"continue_clip_id,omitempty"`
	MakeInstrumental     bool    `json:"make_instrumental"`
}

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL