package httpapi

import (
	"github.com/easyai/easyai-ai-gateway/apps/api/internal/auth"
	"github.com/easyai/easyai-ai-gateway/apps/api/internal/publicerror"
	"github.com/easyai/easyai-ai-gateway/apps/api/internal/store"
)

type HealthResponse struct {
	OK           bool   `json:"ok" example:"true"`
	Service      string `json:"service" example:"easyai-ai-gateway"`
	Env          string `json:"env" example:"development"`
	IdentityMode string `json:"identityMode" example:"standalone"`
}

type ReadyResponse struct {
	OK bool `json:"ok" example:"true"`
}

type SkillBundleMetadataResponse struct {
	Name            string   `json:"name" example:"ai-gateway-ops-management"`
	Version         string   `json:"version" example:"1.0.2"`
	DisplayName     string   `json:"displayName" example:"AI Gateway 运维管理"`
	Modules         []string `json:"modules" example:"model-runtime"`
	FileName        string   `json:"fileName" example:"ai-gateway-ops-management-v1.0.2.zip"`
	DownloadPath    string   `json:"downloadPath" example:"/api/v1/public/skills/ai-gateway-ops-management/download"`
	APIDocsJSONPath string   `json:"apiDocsJsonPath" example:"/api/v1/openapi.json"`
	APIDocsYAMLPath string   `json:"apiDocsYamlPath" example:"/api/v1/openapi.yaml"`
}

type ErrorEnvelope struct {
	Error ErrorPayload `json:"error"`
}

type ErrorPayload struct {
	Message           string `json:"message" example:"invalid json body"`
	Status            int    `json:"status" example:"400"`
	Code              string `json:"code,omitempty" example:"rate_limit"`
	Category          string `json:"category,omitempty" example:"rate_limit"`
	HTTPStatus        int    `json:"httpStatus,omitempty" example:"429"`
	Retryable         bool   `json:"retryable" example:"true"`
	Action            string `json:"action,omitempty" example:"retry_after"`
	Version           string `json:"version,omitempty" example:"v1"`
	RetryAfterSeconds int    `json:"retryAfterSeconds,omitempty" example:"2"`
	RequestID         string `json:"requestId,omitempty"`
	TaskID            string `json:"taskId,omitempty"`
	Type              string `json:"type,omitempty" example:"invalid_request_error"`
	Param             any    `json:"param,omitempty"`
}

type OpenAIErrorEnvelope struct {
	Error OpenAIErrorPayload `json:"error"`
}

type OpenAIErrorPayload struct {
	Message string `json:"message" example:"Invalid parameter"`
	Type    string `json:"type" example:"invalid_request_error"`
	Param   string `json:"param,omitempty" example:"model"`
	Code    string `json:"code,omitempty" example:"invalid_parameter"`
}

type GeminiErrorEnvelope struct {
	Error GeminiErrorStatus `json:"error"`
}

type GeminiErrorStatus struct {
	Code    int              `json:"code" example:"400"`
	Message string           `json:"message" example:"Invalid argument"`
	Status  string           `json:"status" example:"INVALID_ARGUMENT"`
	Details []map[string]any `json:"details"`
}

type VolcesErrorEnvelope struct {
	Error publicerror.Error `json:"error"`
}

type VolcesContentsGenerationTaskResponse struct {
	ID        string         `json:"id" example:"cgt-202607221234"`
	Model     string         `json:"model,omitempty"`
	Status    string         `json:"status,omitempty" enums:"queued,running,succeeded,failed,cancelled"`
	Content   map[string]any `json:"content,omitempty"`
	CreatedAt int64          `json:"created_at,omitempty"`
	UpdatedAt int64          `json:"updated_at,omitempty"`
	Usage     map[string]any `json:"usage,omitempty"`
	Error     map[string]any `json:"error,omitempty"`
}

type KlingErrorEnvelope struct {
	Code        int                `json:"code" example:"1001"`
	Message     string             `json:"message" example:"invalid parameter"`
	RequestID   string             `json:"request_id"`
	Error       string             `json:"error,omitempty" example:"invalid_parameter"`
	PublicError *publicerror.Error `json:"public_error,omitempty"`
}

type AuthResponse struct {
	AccessToken string     `json:"accessToken" example:"eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9..."`
	TokenType   string     `json:"tokenType" example:"Bearer"`
	ExpiresIn   int        `json:"expiresIn" example:"86400"`
	User        *auth.User `json:"user"`
}

type ItemListResponse struct {
	Items []map[string]interface{} `json:"items"`
}

type PlatformListResponse struct {
	Items []store.Platform `json:"items"`
}

type PlatformModelListResponse struct {
	Items []store.PlatformModel `json:"items"`
}

type APIKeyAssignableModelsResponse struct {
	Items           []store.PlatformModel              `json:"items"`
	RuleDiagnostics []store.APIKeyAccessRuleDiagnostic `json:"ruleDiagnostics"`
}

type OpenAIModel struct {
	ID      string `json:"id" example:"gpt-4o-mini"`
	Object  string `json:"object" example:"model"`
	Created int64  `json:"created" example:"1710000000"`
	OwnedBy string `json:"owned_by" example:"easyai"`
}

type OpenAIModelListResponse struct {
	Object string        `json:"object" example:"list"`
	Data   []OpenAIModel `json:"data"`
}

type CatalogProviderListResponse struct {
	Items []store.CatalogProvider `json:"items"`
}

type BaseModelListResponse struct {
	Items []store.BaseModel `json:"items"`
}

type TenantListResponse struct {
	Items []store.GatewayTenant `json:"items"`
}

type UserListResponse struct {
	Items []store.GatewayUser `json:"items"`
}

type UserGroupListResponse struct {
	Items []store.UserGroup `json:"items"`
}

type IdentityBatchResponse struct {
	Action         string   `json:"action" example:"disable"`
	RequestedCount int      `json:"requestedCount" example:"2"`
	AffectedCount  int      `json:"affectedCount" example:"2"`
	IDs            []string `json:"ids"`
}

type AccessRuleListResponse struct {
	Items []store.AccessRule `json:"items"`
}

type APIKeyListResponse struct {
	Items []store.APIKey `json:"items"`
}

type PlayableAPIKeyListResponse struct {
	Items []store.PlayableAPIKey `json:"items"`
}

type PricingRuleListResponse struct {
	Items []store.PricingRule `json:"items"`
}

type PricingRuleSetListResponse struct {
	Items []store.PricingRuleSet `json:"items"`
}

type RuntimePolicySetListResponse struct {
	Items []store.RuntimePolicySet `json:"items"`
}

type RateLimitWindowListResponse struct {
	Items []store.RateLimitWindow `json:"items"`
}

type ModelRateLimitStatusListResponse struct {
	Items []store.ModelRateLimitStatus `json:"items"`
}

type AuditLogListResponse struct {
	Items []store.AuditLog `json:"items"`
}

type BillingSettlementListResponse struct {
	Items    []store.BillingSettlement `json:"items"`
	Total    int                       `json:"total" example:"42"`
	Page     int                       `json:"page" example:"1"`
	PageSize int                       `json:"pageSize" example:"50"`
}

type BillingSettlementRetryResponse struct {
	Settlement store.BillingSettlement `json:"settlement"`
	AuditLog   store.AuditLog          `json:"auditLog"`
}

type WalletTransactionListResponse struct {
	Items    []store.GatewayWalletTransaction `json:"items"`
	Total    int                              `json:"total" example:"42"`
	Page     int                              `json:"page" example:"1"`
	PageSize int                              `json:"pageSize" example:"50"`
}

type TaskListResponse struct {
	Items    []store.GatewayTask `json:"items"`
	Total    int                 `json:"total" example:"42"`
	Page     int                 `json:"page" example:"1"`
	PageSize int                 `json:"pageSize" example:"50"`
}

type AdminTaskListResponse struct {
	Items    []store.AdminGatewayTask `json:"items"`
	Total    int                      `json:"total" example:"42"`
	Page     int                      `json:"page" example:"1"`
	PageSize int                      `json:"pageSize" example:"50"`
}

type TaskParamPreprocessingLogListResponse struct {
	Items []store.TaskParamPreprocessingLog `json:"items"`
}

type TaskEventListResponse struct {
	Items []store.TaskEvent `json:"items"`
}

type FileStorageChannelListResponse struct {
	Items []store.FileStorageChannel `json:"items"`
}

type FileStorageChannelTestResponse struct {
	Provider         string `json:"provider"`
	PutSucceeded     bool   `json:"putSucceeded"`
	HeadSucceeded    bool   `json:"headSucceeded"`
	DeleteSucceeded  bool   `json:"deleteSucceeded"`
	LifecycleReady   bool   `json:"lifecycleReady"`
	ExpirationPolicy string `json:"expirationPolicy"`
	DurationMS       int64  `json:"durationMs"`
}

type FileUploadResponse struct {
	ID           string                 `json:"id,omitempty" example:"file_abc123"`
	URL          string                 `json:"url,omitempty" example:"/static/uploaded/upload-abc123.png"`
	Filename     string                 `json:"filename,omitempty" example:"image.png"`
	ContentType  string                 `json:"contentType,omitempty" example:"image/png"`
	Size         int                    `json:"size,omitempty" example:"1024"`
	AssetStorage map[string]interface{} `json:"assetStorage,omitempty"`
	Status       string                 `json:"status" example:"success"`
	Data         FileUploadData         `json:"data"`
}

type FileUploadData struct {
	ID           string                 `json:"id,omitempty" example:"file_abc123"`
	URL          string                 `json:"url,omitempty" example:"/static/uploaded/upload-abc123.png"`
	Filename     string                 `json:"filename,omitempty" example:"image.png"`
	ContentType  string                 `json:"contentType,omitempty" example:"image/png"`
	Size         int                    `json:"size,omitempty" example:"1024"`
	AssetStorage map[string]interface{} `json:"assetStorage,omitempty"`
}

type ReplacePlatformModelsRequest struct {
	Models []store.CreatePlatformModelInput `json:"models"`
}

type TaskAcceptedResponse struct {
	Status       string            `json:"status" example:"submitted"`
	LegacyTaskID string            `json:"task_id" example:"9f4d8f3d-5f5f-4bb7-a4be-344a9f930e25"`
	TaskID       string            `json:"taskId" example:"9f4d8f3d-5f5f-4bb7-a4be-344a9f930e25"`
	QueryURL     string            `json:"query_url" example:"/api/v1/ai/result/9f4d8f3d-5f5f-4bb7-a4be-344a9f930e25"`
	Task         store.GatewayTask `json:"task"`
	Next         TaskNextLinks     `json:"next"`
}

type TaskCancelResponse struct {
	TaskID      string `json:"taskId" example:"9f4d8f3d-5f5f-4bb7-a4be-344a9f930e25"`
	Cancelled   bool   `json:"cancelled" example:"false"`
	Cancellable bool   `json:"cancellable" example:"false"`
	Submitted   bool   `json:"submitted" example:"true"`
	Message     string `json:"message" example:"任务已提交上游，当前不可取消，请继续查询结果"`
}

type TaskNextLinks struct {
	Events string `json:"events" example:"/api/v1/tasks/9f4d8f3d-5f5f-4bb7-a4be-344a9f930e25/events"`
	Detail string `json:"detail" example:"/api/v1/tasks/9f4d8f3d-5f5f-4bb7-a4be-344a9f930e25"`
	Result string `json:"result" example:"/api/v1/ai/result/9f4d8f3d-5f5f-4bb7-a4be-344a9f930e25"`
}

type EasyAIGeneratedResponse struct {
	Status         string              `json:"status" example:"success" enums:"submitted,process,success,failed"`
	TaskID         string              `json:"task_id" example:"9f4d8f3d-5f5f-4bb7-a4be-344a9f930e25"`
	CamelTaskID    string              `json:"taskId,omitempty" example:"9f4d8f3d-5f5f-4bb7-a4be-344a9f930e25"`
	UpstreamTaskID string              `json:"upstream_task_id,omitempty" example:"provider-task-123"`
	QueryURL       string              `json:"query_url,omitempty" example:"/api/v1/ai/result/9f4d8f3d-5f5f-4bb7-a4be-344a9f930e25"`
	Created        int64               `json:"created" example:"1784772000000"`
	Message        string              `json:"message,omitempty"`
	Code           string              `json:"code,omitempty"`
	Data           []EasyAIMediaOutput `json:"data"`
	Output         []string            `json:"output"`
	// OutputContent is a one-release URL-only compatibility alias for Data.
	OutputContent []EasyAIMediaOutput `json:"output_content"`
	Cancellable   bool                `json:"cancellable"`
	Submitted     bool                `json:"submitted"`
	// Result is a one-release URL-only compatibility alias and is deprecated.
	Result map[string]interface{} `json:"result,omitempty"`
	Usage  map[string]interface{} `json:"usage,omitempty"`
}

type EasyAIMediaOutput struct {
	Type string `json:"type,omitempty" example:"video" enums:"image,video,audio,file,text"`
	URL  string `json:"url,omitempty" example:"https://cdn.example.com/output.mp4"`
	// B64JSON is available only to bounded synchronous OpenAI image responses.
	B64JSON          string                 `json:"b64_json,omitempty"`
	ImageURL         string                 `json:"image_url,omitempty"`
	VideoURL         string                 `json:"video_url,omitempty"`
	AudioURL         string                 `json:"audio_url,omitempty"`
	Content          string                 `json:"content,omitempty"`
	Text             string                 `json:"text,omitempty"`
	MimeType         string                 `json:"mime_type,omitempty"`
	Format           string                 `json:"format,omitempty"`
	Duration         float64                `json:"duration,omitempty"`
	Width            int                    `json:"width,omitempty"`
	Height           int                    `json:"height,omitempty"`
	SourceResolution string                 `json:"source_resolution,omitempty"`
	TargetResolution string                 `json:"target_resolution,omitempty"`
	Metadata         map[string]interface{} `json:"metadata,omitempty"`
}

type OpenAIImagesResponse struct {
	Created int64             `json:"created" example:"1710000000"`
	Data    []OpenAIImageData `json:"data"`
}

type OpenAIImageData struct {
	URL           string `json:"url,omitempty" example:"https://cdn.example.com/output.png"`
	B64JSON       string `json:"b64_json,omitempty"`
	RevisedPrompt string `json:"revised_prompt,omitempty"`
}

type TaskAcceptedEvent struct {
	TaskID string `json:"taskId" example:"9f4d8f3d-5f5f-4bb7-a4be-344a9f930e25"`
	Status string `json:"status" example:"pending"`
}

type PricingEstimateRequest struct {
	Kind      string        `json:"kind" example:"chat.completions"`
	Model     string        `json:"model" example:"gpt-4o-mini"`
	Messages  []ChatMessage `json:"messages,omitempty"`
	Prompt    string        `json:"prompt,omitempty" example:"A small orange cat"`
	MaxTokens int           `json:"max_tokens,omitempty" example:"512"`
	N         int           `json:"n,omitempty" example:"1"`
	RunMode   string        `json:"runMode,omitempty" example:"simulation"`
}

type PricingEstimateResponse struct {
	Items              []map[string]interface{} `json:"items"`
	Resolver           string                   `json:"resolver" example:"effective-pricing-v2"`
	TotalAmount        float64                  `json:"totalAmount" example:"1.25"`
	ReservationAmount  float64                  `json:"reservationAmount" example:"2.75"`
	Currency           string                   `json:"currency" example:"resource"`
	CandidateCount     int                      `json:"candidateCount" example:"2"`
	PricingVersion     string                   `json:"pricingVersion" example:"effective-pricing-v2"`
	RequestFingerprint string                   `json:"requestFingerprint" example:"76ef6a537de8e71bd1ca93acadc078dbdbfa9f17e45224e4f9df59f535d2886f"`
}

type DailyTokenUsageResponse struct {
	Items     []store.DailyTokenUsage `json:"items"`
	TokenDays []store.DailyTokenUsage `json:"tokenDays"`
	Summary   dailyTokenUsageSummary  `json:"summary"`
	Range     map[string]string       `json:"range"`
}

type TaskRequest struct {
	Model          string        `json:"model" example:"gpt-4o-mini"`
	Messages       []ChatMessage `json:"messages,omitempty"`
	Input          interface{}   `json:"input,omitempty"`
	Query          string        `json:"query,omitempty" example:"Which document mentions EasyAI Gateway?"`
	Documents      []string      `json:"documents,omitempty"`
	Prompt         string        `json:"prompt,omitempty" example:"A watercolor robot reading a book"`
	Text           string        `json:"text,omitempty" example:"Hello from EasyAI audio synthesis."`
	TextFileID     string        `json:"text_file_id,omitempty" example:""`
	VoiceID        string        `json:"voice_id,omitempty" example:"female-shaonv"`
	AudioURL       string        `json:"audio_url,omitempty" example:"https://example.com/source-voice.mp3"`
	DisplayName    string        `json:"display_name,omitempty" example:"EasyAI DEV acceptance"`
	PromptAudioURL string        `json:"prompt_audio_url,omitempty" example:"https://example.com/prompt-voice.mp3"`
	PromptText     string        `json:"prompt_text,omitempty" example:"EasyAI voice clone prompt."`
	PreviewModel   string        `json:"preview_model,omitempty" example:"speech-2.8-hd"`
	Stream         *bool         `json:"stream,omitempty" example:"false"`
	RunMode        string        `json:"runMode,omitempty" example:"simulation"`
	MaxTokens      *int          `json:"max_tokens,omitempty" example:"512"`
	// MaxCompletionTokens includes visible output and reasoning tokens.
	MaxCompletionTokens *int `json:"max_completion_tokens,omitempty" example:"512"`
	MaxOutputTokens     *int `json:"max_output_tokens,omitempty" example:"512"`
	// ReasoningEffort 推理强度，OpenAI-compatible 请求字段；支持 none、minimal、low、medium、high、xhigh、max。供应商自定义取值由网关按平台适配。
	ReasoningEffort     string  `json:"reasoning_effort,omitempty" example:"medium" enums:"none,minimal,low,medium,high,xhigh,max"`
	Size                string  `json:"size,omitempty" example:"1024x1024"`
	Duration            int     `json:"duration,omitempty" example:"5"`
	Resolution          string  `json:"resolution,omitempty" example:"720p"`
	AspectRatio         string  `json:"aspect_ratio,omitempty" example:"16:9"`
	Audio               *bool   `json:"audio,omitempty" example:"false"`
	Watermark           *bool   `json:"watermark,omitempty" example:"false"`
	MakeInstrumental    bool    `json:"makeInstrumental,omitempty" example:"false"`
	CustomMode          bool    `json:"customMode,omitempty" example:"false"`
	Style               string  `json:"style,omitempty" example:"city pop, bright synth"`
	Title               string  `json:"title,omitempty" example:"Useful Tools"`
	Tags                string  `json:"tags,omitempty" example:"city pop, synth"`
	NegativeTags        string  `json:"negativeTags,omitempty" example:"noise"`
	VocalGender         string  `json:"vocalGender,omitempty" example:"f"`
	StyleWeight         float64 `json:"styleWeight,omitempty" example:"0.65"`
	WeirdnessConstraint float64 `json:"weirdnessConstraint,omitempty" example:"0.35"`
	AudioWeight         float64 `json:"audioWeight,omitempty" example:"0.65"`
	Speed               float64 `json:"speed,omitempty" example:"1"`
	Vol                 float64 `json:"vol,omitempty" example:"1"`
	Pitch               float64 `json:"pitch,omitempty" example:"0"`
	Emotion             string  `json:"emotion,omitempty" example:"happy"`
}

type ChatCompletionRequest struct {
	Model                string                   `json:"model" example:"gpt-4o-mini"`
	Messages             []ChatMessage            `json:"messages"`
	Audio                map[string]interface{}   `json:"audio,omitempty"`
	FrequencyPenalty     *float64                 `json:"frequency_penalty,omitempty" example:"0"`
	FunctionCall         interface{}              `json:"function_call,omitempty"`
	Functions            []map[string]interface{} `json:"functions,omitempty"`
	LogitBias            map[string]interface{}   `json:"logit_bias,omitempty"`
	Logprobs             *bool                    `json:"logprobs,omitempty"`
	MaxCompletionTokens  *int                     `json:"max_completion_tokens,omitempty" example:"512"`
	MaxTokens            *int                     `json:"max_tokens,omitempty" example:"512"`
	Metadata             map[string]interface{}   `json:"metadata,omitempty"`
	Modalities           []string                 `json:"modalities,omitempty"`
	Moderation           interface{}              `json:"moderation,omitempty"`
	N                    *int                     `json:"n,omitempty" example:"1"`
	ParallelToolCalls    *bool                    `json:"parallel_tool_calls,omitempty"`
	Prediction           interface{}              `json:"prediction,omitempty"`
	PresencePenalty      *float64                 `json:"presence_penalty,omitempty" example:"0"`
	PromptCacheKey       string                   `json:"prompt_cache_key,omitempty"`
	PromptCacheOptions   map[string]interface{}   `json:"prompt_cache_options,omitempty"`
	PromptCacheRetention string                   `json:"prompt_cache_retention,omitempty" enums:"in_memory,24h"`
	// ReasoningEffort 推理强度，OpenAI-compatible 请求字段；支持 none、minimal、low、medium、high、xhigh、max。供应商自定义取值由网关按平台适配。
	ReasoningEffort  string                   `json:"reasoning_effort,omitempty" example:"medium" enums:"none,minimal,low,medium,high,xhigh,max"`
	ResponseFormat   interface{}              `json:"response_format,omitempty"`
	SafetyIdentifier string                   `json:"safety_identifier,omitempty"`
	Seed             *int                     `json:"seed,omitempty"`
	ServiceTier      string                   `json:"service_tier,omitempty"`
	Stop             interface{}              `json:"stop,omitempty"`
	Store            *bool                    `json:"store,omitempty"`
	Stream           *bool                    `json:"stream,omitempty" example:"false"`
	StreamOptions    map[string]interface{}   `json:"stream_options,omitempty"`
	Temperature      *float64                 `json:"temperature,omitempty" example:"0.7"`
	ToolChoice       interface{}              `json:"tool_choice,omitempty"`
	Tools            []map[string]interface{} `json:"tools,omitempty"`
	TopLogprobs      *int                     `json:"top_logprobs,omitempty"`
	TopP             *float64                 `json:"top_p,omitempty" example:"1"`
	User             string                   `json:"user,omitempty"`
	Verbosity        string                   `json:"verbosity,omitempty"`
	WebSearchOptions map[string]interface{}   `json:"web_search_options,omitempty"`
	RunMode          string                   `json:"runMode,omitempty" example:"simulation"`
}

type ChatMessage struct {
	Role         string      `json:"role" example:"user"`
	Content      interface{} `json:"content,omitempty"`
	Name         string      `json:"name,omitempty"`
	ToolCallID   string      `json:"tool_call_id,omitempty"`
	ToolCalls    interface{} `json:"tool_calls,omitempty"`
	FunctionCall interface{} `json:"function_call,omitempty"`
	Audio        interface{} `json:"audio,omitempty"`
	Refusal      string      `json:"refusal,omitempty"`
}

type ResponsesRequest struct {
	Model                string                   `json:"model" example:"Doubao Seed 2.0 Pro"`
	Background           *bool                    `json:"background,omitempty"`
	ContextManagement    interface{}              `json:"context_management,omitempty"`
	Conversation         interface{}              `json:"conversation,omitempty"`
	Include              []string                 `json:"include,omitempty"`
	Input                interface{}              `json:"input"`
	Instructions         string                   `json:"instructions,omitempty" example:"Answer concisely"`
	MaxOutputTokens      *int                     `json:"max_output_tokens,omitempty" example:"512"`
	MaxToolCalls         *int                     `json:"max_tool_calls,omitempty"`
	Metadata             map[string]interface{}   `json:"metadata,omitempty"`
	Moderation           interface{}              `json:"moderation,omitempty"`
	ParallelToolCalls    *bool                    `json:"parallel_tool_calls,omitempty" example:"true"`
	PreviousResponseID   string                   `json:"previous_response_id,omitempty" example:"resp_0123456789abcdef0123456789abcdef"`
	Prompt               interface{}              `json:"prompt,omitempty"`
	PromptCacheKey       string                   `json:"prompt_cache_key,omitempty"`
	PromptCacheOptions   map[string]interface{}   `json:"prompt_cache_options,omitempty"`
	PromptCacheRetention string                   `json:"prompt_cache_retention,omitempty" enums:"in_memory,24h"`
	Reasoning            map[string]interface{}   `json:"reasoning,omitempty"`
	SafetyIdentifier     string                   `json:"safety_identifier,omitempty"`
	ServiceTier          string                   `json:"service_tier,omitempty"`
	Store                *bool                    `json:"store,omitempty"`
	Stream               *bool                    `json:"stream,omitempty" example:"false"`
	StreamOptions        map[string]interface{}   `json:"stream_options,omitempty"`
	Temperature          *float64                 `json:"temperature,omitempty" example:"0.7"`
	Text                 map[string]interface{}   `json:"text,omitempty"`
	ToolChoice           interface{}              `json:"tool_choice,omitempty"`
	Tools                []map[string]interface{} `json:"tools,omitempty"`
	TopLogprobs          *int                     `json:"top_logprobs,omitempty"`
	TopP                 *float64                 `json:"top_p,omitempty" example:"1"`
	Truncation           string                   `json:"truncation,omitempty"`
	User                 string                   `json:"user,omitempty"`
}

type ResponsesCompatibleResponse struct {
	ID                   string                   `json:"id" example:"resp_0123456789abcdef0123456789abcdef"`
	Object               string                   `json:"object" example:"response"`
	CreatedAt            int64                    `json:"created_at" example:"1710000000"`
	Status               string                   `json:"status" example:"completed" enums:"queued,in_progress,completed,incomplete,failed,cancelled"`
	CompletedAt          *int64                   `json:"completed_at"`
	Error                interface{}              `json:"error"`
	IncompleteDetails    interface{}              `json:"incomplete_details"`
	Instructions         interface{}              `json:"instructions"`
	Metadata             map[string]interface{}   `json:"metadata"`
	Model                string                   `json:"model" example:"Doubao Seed 2.0 Pro"`
	Output               []map[string]interface{} `json:"output"`
	ParallelToolCalls    bool                     `json:"parallel_tool_calls"`
	Temperature          interface{}              `json:"temperature"`
	ToolChoice           interface{}              `json:"tool_choice"`
	Tools                []map[string]interface{} `json:"tools"`
	TopP                 interface{}              `json:"top_p"`
	Background           bool                     `json:"background"`
	Conversation         interface{}              `json:"conversation"`
	MaxOutputTokens      interface{}              `json:"max_output_tokens"`
	MaxToolCalls         interface{}              `json:"max_tool_calls"`
	Moderation           interface{}              `json:"moderation"`
	OutputText           string                   `json:"output_text" example:"Hello"`
	PreviousResponseID   interface{}              `json:"previous_response_id"`
	Prompt               interface{}              `json:"prompt"`
	PromptCacheKey       interface{}              `json:"prompt_cache_key"`
	PromptCacheOptions   interface{}              `json:"prompt_cache_options"`
	PromptCacheRetention interface{}              `json:"prompt_cache_retention"`
	Reasoning            interface{}              `json:"reasoning"`
	SafetyIdentifier     interface{}              `json:"safety_identifier"`
	ServiceTier          interface{}              `json:"service_tier"`
	Text                 interface{}              `json:"text"`
	TopLogprobs          interface{}              `json:"top_logprobs"`
	Truncation           interface{}              `json:"truncation"`
	Usage                map[string]interface{}   `json:"usage"`
	User                 interface{}              `json:"user"`
}

type ImageGenerationRequest struct {
	Model          string `json:"model" example:"gpt-image-1"`
	Prompt         string `json:"prompt" example:"A watercolor robot reading a book"`
	N              int    `json:"n,omitempty" example:"1"`
	Size           string `json:"size,omitempty" example:"1024x1024"`
	Quality        string `json:"quality,omitempty" example:"auto"`
	ResponseFormat string `json:"response_format,omitempty" example:"url"`
	RunMode        string `json:"runMode,omitempty" example:"simulation"`
}

type ImageEditRequest struct {
	Model          string   `json:"model" example:"gpt-image-1"`
	Prompt         string   `json:"prompt" example:"Add a sunset background"`
	Image          string   `json:"image,omitempty" example:"https://example.com/image.png"`
	Images         []string `json:"images,omitempty" example:"https://example.com/image-a.png,https://example.com/image-b.png"`
	Mask           string   `json:"mask,omitempty" example:"https://example.com/mask.png"`
	N              int      `json:"n,omitempty" example:"1"`
	Size           string   `json:"size,omitempty" example:"1024x1024"`
	Quality        string   `json:"quality,omitempty" example:"auto"`
	ResponseFormat string   `json:"response_format,omitempty" example:"url"`
	RunMode        string   `json:"runMode,omitempty" example:"simulation"`
}

type ImageVectorizeSource struct {
	URL              string `json:"url,omitempty" example:"https://example.com/source.png"`
	VectorizerTaskID string `json:"vectorizerTaskId,omitempty" example:"9f4d8f3d-5f5f-4bb7-a4be-344a9f930e25"`
}

type ImageVectorizeRequest struct {
	Model        string               `json:"model,omitempty" example:"easy-image-vectorizer-1"`
	Source       ImageVectorizeSource `json:"source"`
	Format       string               `json:"format,omitempty" example:"svg" enums:"svg,eps,pdf,dxf,png"`
	MaxColors    int                  `json:"maxColors,omitempty" example:"16" enums:"0,2,4,8,16,32"`
	CleanupLevel string               `json:"cleanupLevel,omitempty" example:"standard" enums:"low,standard,strong"`
}

type VideoUpscaleRequest struct {
	Model            string  `json:"model,omitempty" example:"easy-proteus-standard-4"`
	VideoURL         string  `json:"video_url" example:"https://example.com/source.mp4"`
	Operation        string  `json:"operation,omitempty" example:"upscale" enums:"upscale"`
	TargetResolution string  `json:"target_resolution,omitempty" example:"1080p"`
	OutputWidth      int     `json:"output_width,omitempty" example:"1920"`
	OutputHeight     int     `json:"output_height,omitempty" example:"1080"`
	PreserveAudio    *bool   `json:"preserve_audio,omitempty" example:"true"`
	Duration         float64 `json:"duration,omitempty" example:"3"`
	SourceResolution string  `json:"source_resolution,omitempty" example:"480p"`
	SourceFrameRate  float64 `json:"source_frame_rate,omitempty" example:"24"`
	TargetFrameRate  float64 `json:"target_frame_rate,omitempty" example:"24"`
	SlowMotionRate   float64 `json:"slow_motion_rate,omitempty" example:"1"`
}

type VideoGenerationRequest struct {
	Model      string `json:"model" example:"video-model"`
	Prompt     string `json:"prompt" example:"A cinematic drone shot over mountains"`
	Duration   int    `json:"duration,omitempty" example:"5"`
	Resolution string `json:"resolution,omitempty" example:"720p"`
	RunMode    string `json:"runMode,omitempty" example:"simulation"`
}

type CompatibleResponse struct {
	ID      string                   `json:"id" example:"chatcmpl-123"`
	Object  string                   `json:"object" example:"chat.completion"`
	Model   string                   `json:"model" example:"gpt-4o-mini"`
	Choices []map[string]interface{} `json:"choices,omitempty"`
	Usage   map[string]interface{}   `json:"usage,omitempty"`
}

type ChatCompletionCompatibleResponse struct {
	ID                string                 `json:"id" example:"chatcmpl-123"`
	Object            string                 `json:"object" example:"chat.completion"`
	Created           int64                  `json:"created,omitempty" example:"1710000000"`
	Model             string                 `json:"model" example:"gpt-4o-mini"`
	Choices           []ChatCompletionChoice `json:"choices"`
	Usage             *ChatCompletionUsage   `json:"usage,omitempty"`
	ServiceTier       string                 `json:"service_tier,omitempty"`
	SystemFingerprint string                 `json:"system_fingerprint,omitempty"`
}

type ChatCompletionChoice struct {
	Index        int                         `json:"index" example:"0"`
	Message      ChatCompletionChoiceMessage `json:"message"`
	FinishReason string                      `json:"finish_reason,omitempty" example:"stop"`
	Logprobs     interface{}                 `json:"logprobs,omitempty"`
}

type ChatCompletionChoiceMessage struct {
	Role         string      `json:"role" example:"assistant"`
	Content      interface{} `json:"content"`
	Refusal      string      `json:"refusal,omitempty"`
	Audio        interface{} `json:"audio,omitempty"`
	Annotations  interface{} `json:"annotations,omitempty"`
	ToolCalls    interface{} `json:"tool_calls,omitempty"`
	FunctionCall interface{} `json:"function_call,omitempty"`
}

type ChatCompletionUsage struct {
	PromptTokens        int                      `json:"prompt_tokens,omitempty" example:"12"`
	CompletionTokens    int                      `json:"completion_tokens,omitempty" example:"8"`
	TotalTokens         int                      `json:"total_tokens,omitempty" example:"20"`
	PromptTokensDetails *ChatPromptTokensDetails `json:"prompt_tokens_details,omitempty"`
	InputTokensDetails  *ChatInputTokensDetails  `json:"input_tokens_details,omitempty"`
}

type ChatPromptTokensDetails struct {
	CachedTokens int `json:"cached_tokens,omitempty" example:"4"`
}

type ChatInputTokensDetails struct {
	CachedTokens int `json:"cached_tokens,omitempty" example:"4"`
}

type NetworkProxyConfigResponse struct {
	GlobalHTTPProxy       string `json:"globalHttpProxy" example:"http://127.0.0.1:7890"`
	GlobalHTTPProxySet    bool   `json:"globalHttpProxySet" example:"true"`
	GlobalHTTPProxySource string `json:"globalHttpProxySource" example:"env"`
}

type WalletAdjustmentResponse struct {
	Account     store.GatewayWalletAccount     `json:"account"`
	Before      store.GatewayWalletAccount     `json:"before"`
	Transaction store.GatewayWalletTransaction `json:"transaction"`
	AuditLog    store.AuditLog                 `json:"auditLog"`
}
