244 lines
8.4 KiB
Go
244 lines
8.4 KiB
Go
package httpapi
|
|
|
|
import (
|
|
"github.com/easyai/easyai-ai-gateway/apps/api/internal/auth"
|
|
"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 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"`
|
|
}
|
|
|
|
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 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 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 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 TaskParamPreprocessingLogListResponse struct {
|
|
Items []store.TaskParamPreprocessingLog `json:"items"`
|
|
}
|
|
|
|
type TaskEventListResponse struct {
|
|
Items []store.TaskEvent `json:"items"`
|
|
}
|
|
|
|
type ReplacePlatformModelsRequest struct {
|
|
Models []store.CreatePlatformModelInput `json:"models"`
|
|
}
|
|
|
|
type TaskAcceptedResponse struct {
|
|
TaskID string `json:"taskId" example:"9f4d8f3d-5f5f-4bb7-a4be-344a9f930e25"`
|
|
Task store.GatewayTask `json:"task"`
|
|
Next TaskNextLinks `json:"next"`
|
|
}
|
|
|
|
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"`
|
|
}
|
|
|
|
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-v1"`
|
|
}
|
|
|
|
type TaskRequest struct {
|
|
Model string `json:"model" example:"gpt-4o-mini"`
|
|
Messages []ChatMessage `json:"messages,omitempty"`
|
|
Input string `json:"input,omitempty" example:"Tell me a short story"`
|
|
Prompt string `json:"prompt,omitempty" example:"A watercolor robot reading a book"`
|
|
Stream bool `json:"stream,omitempty" example:"false"`
|
|
RunMode string `json:"runMode,omitempty" example:"simulation"`
|
|
MaxTokens int `json:"max_tokens,omitempty" example:"512"`
|
|
Size string `json:"size,omitempty" example:"1024x1024"`
|
|
Duration int `json:"duration,omitempty" example:"5"`
|
|
Resolution string `json:"resolution,omitempty" example:"720p"`
|
|
}
|
|
|
|
type ChatCompletionRequest struct {
|
|
Model string `json:"model" example:"gpt-4o-mini"`
|
|
Messages []ChatMessage `json:"messages"`
|
|
Temperature float64 `json:"temperature,omitempty" example:"0.7"`
|
|
MaxTokens int `json:"max_tokens,omitempty" example:"512"`
|
|
Stream bool `json:"stream,omitempty" example:"false"`
|
|
RunMode string `json:"runMode,omitempty" example:"simulation"`
|
|
}
|
|
|
|
type ChatMessage struct {
|
|
Role string `json:"role" example:"user"`
|
|
Content string `json:"content" example:"Hello"`
|
|
}
|
|
|
|
type ResponsesRequest struct {
|
|
Model string `json:"model" example:"gpt-4o-mini"`
|
|
Input interface{} `json:"input" example:"Tell me a short story"`
|
|
Stream bool `json:"stream,omitempty" example:"false"`
|
|
RunMode string `json:"runMode,omitempty" example:"simulation"`
|
|
}
|
|
|
|
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:"standard"`
|
|
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"`
|
|
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"`
|
|
ResponseFormat string `json:"response_format,omitempty" example:"url"`
|
|
RunMode string `json:"runMode,omitempty" example:"simulation"`
|
|
}
|
|
|
|
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 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"`
|
|
}
|