dto

package
v0.2.0 Latest Latest
Warning

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

Go to latest
Published: Sep 3, 2026 License: AGPL-3.0 Imports: 12 Imported by: 0

Documentation

Index

Constants

View Source
const (
	BillingUsageSourceClaudeMessages = "claude_messages"
	BillingUsageSourceGeminiChat     = "gemini_chat"
	BillingUsageSourceOAIChat        = "oai_chat"
	BillingUsageSourceOAIResponses   = "oai_responses"

	BillingUsageSemanticAnthropic = "anthropic"
	BillingUsageSemanticGemini    = "gemini"
	BillingUsageSemanticOpenAI    = "openai"
)
View Source
const (
	HTTPProtocolAuto         = "auto"
	HTTPProtocolHTTP1        = "http1"
	MaxHTTP2ConnectionShards = 8
)
View Source
const (
	AdvancedCustomAuthTypeNone   = "none"
	AdvancedCustomAuthTypeHeader = "header"
	AdvancedCustomAuthTypeQuery  = "query"
)
View Source
const (
	// AdvancedCustomModelListPath identifies the optional OpenAI Models discovery route.
	AdvancedCustomModelListPath = "/v1/models"
	// AdvancedCustomBalancePath identifies the optional balance lookup route used by channel management.
	AdvancedCustomBalancePath = "/v1/dashboard/billing/credit_grants"
)
View Source
const (
	NotifyTypeQuotaExceed   = "quota_exceed"
	NotifyTypeChannelUpdate = "channel_update"
	NotifyTypeChannelTest   = "channel_test"
)
View Source
const (
	ContentTypeText       = "text"
	ContentTypeImageURL   = "image_url"
	ContentTypeInputAudio = "input_audio"
	ContentTypeFile       = "file"
	ContentTypeVideoUrl   = "video_url" // 阿里百炼视频识别

)
View Source
const (
	BuildInToolWebSearchPreview = "web_search_preview"
	BuildInToolWebSearch        = "web_search"
	BuildInToolFileSearch       = "file_search"
	BuildInToolGoogleSearch     = "google_search"
	BuildInToolImageGeneration  = "image_generation"
)
View Source
const (
	BuildInCallWebSearchCall  = "web_search_call"
	BuildInCallFileSearchCall = "file_search_call"
	BuildInCallFunctionCall   = "function_call"
	BuildInCallToolUse        = "tool_use"
)
View Source
const (
	ResponsesOutputTypeItemAdded = "response.output_item.added"
	ResponsesOutputTypeItemDone  = "response.output_item.done"
)
View Source
const (
	VideoStatusUnknown    = "unknown"
	VideoStatusQueued     = "queued"
	VideoStatusInProgress = "in_progress"
	VideoStatusCompleted  = "completed"
	VideoStatusFailed     = "failed"
)
View Source
const (
	RealtimeEventTypeError              = "error"
	RealtimeEventTypeSessionUpdate      = "session.update"
	RealtimeEventTypeConversationCreate = "conversation.item.create"
	RealtimeEventTypeResponseCreate     = "response.create"
	RealtimeEventInputAudioBufferAppend = "input_audio_buffer.append"
)
View Source
const (
	RealtimeEventTypeResponseDone                   = "response.done"
	RealtimeEventTypeSessionUpdated                 = "session.updated"
	RealtimeEventTypeSessionCreated                 = "session.created"
	RealtimeEventResponseAudioDelta                 = "response.audio.delta"
	RealtimeEventResponseAudioTranscriptionDelta    = "response.audio_transcript.delta"
	RealtimeEventResponseFunctionCallArgumentsDelta = "response.function_call_arguments.delta"
	RealtimeEventResponseFunctionCallArgumentsDone  = "response.function_call_arguments.done"
	RealtimeEventConversationItemCreated            = "conversation.item.created"
)
View Source
const ContentValueParam = "{{value}}"
View Source
const CustomType = "custom"
View Source
const MaxImageN = 128

MaxImageN caps the image generation count. Without this bound a huge or wrapped-negative n overflows quota calculation into a negative charge.

View Source
const (
	ResponsesOutputTypeImageGenerationCall = "image_generation_call"
)

Variables

View Source
var (
	NotifyTypeEmail   = "email"   // Email 邮件
	NotifyTypeWebhook = "webhook" // Webhook
	NotifyTypeBark    = "bark"    // Bark 推送
	NotifyTypeGotify  = "gotify"  // Gotify 推送
)

Functions

func GetJSONFieldNames

func GetJSONFieldNames(t reflect.Type) map[string]struct{}

func GetOpenAIError

func GetOpenAIError(errorField any) *types.OpenAIError

GetOpenAIError 从动态错误类型中提取OpenAIError结构

func HasClaudeUsageTokens

func HasClaudeUsageTokens(usage *ClaudeUsage) bool

HasClaudeUsageTokens mirrors HasOpenAIUsageTokens/HasGeminiUsageMetadataTokens: an all-zero ClaudeUsage must not become a BillingUsage, otherwise it would take precedence during settlement and zero out a non-zero top-level usage.

func HasGeminiUsageMetadataTokens

func HasGeminiUsageMetadataTokens(metadata *GeminiUsageMetadata) bool

func HasOpenAIUsageTokens

func HasOpenAIUsageTokens(usage *Usage) bool

func IsAdvancedCustomConverterAllowed

func IsAdvancedCustomConverterAllowed(converter string) bool

func IsOpenAIGPT5Model

func IsOpenAIGPT5Model(modelName string) bool

func IsOpenAIReasoningOModel

func IsOpenAIReasoningOModel(modelName string) bool

func IsQwenThinkingBudgetModel added in v0.2.0

func IsQwenThinkingBudgetModel(modelName string) bool

func NormalizeResponsesWebSearchAction added in v0.2.0

func NormalizeResponsesWebSearchAction(raw json.RawMessage) (json.RawMessage, error)

NormalizeResponsesWebSearchAction validates and canonicalizes the current Responses web_search_call action union. Claude emits {"query": ...}; the Responses representation additionally requires a discriminator.

func ProcessTools

func ProcessTools(tools []any) ([]*Tool, []*ClaudeWebSearchTool)

ProcessTools 处理工具列表,支持类型断言

func ResponsesArgumentsString

func ResponsesArgumentsString(arguments json.RawMessage) string

ResponsesArgumentsString returns function call arguments in the string form expected by Chat Completions.

Types

type AdvancedCustomConfig

type AdvancedCustomConfig struct {
	Routes []AdvancedCustomRoute `json:"advanced_routes,omitempty"`
}

func (*AdvancedCustomConfig) BalanceRoute added in v0.2.0

func (c *AdvancedCustomConfig) BalanceRoute() (AdvancedCustomRoute, bool)

BalanceRoute returns the explicitly configured channel-management balance route.

func (*AdvancedCustomConfig) MatchPath

func (c *AdvancedCustomConfig) MatchPath(requestPath string) (AdvancedCustomRoute, bool)

MatchPath returns the first route whose IncomingPath matches requestPath. Matching mirrors the relay adaptor: exact match, {model} placeholder, and :generateContent <-> :streamGenerateContent equivalence.

func (*AdvancedCustomConfig) MatchPathForModel

func (c *AdvancedCustomConfig) MatchPathForModel(requestPath string, model string) (AdvancedCustomRoute, bool)

MatchPathForModel returns the first route whose IncomingPath and Models match. An empty Models list is a catch-all fallback for that incoming path.

func (*AdvancedCustomConfig) ModelListRoute

func (c *AdvancedCustomConfig) ModelListRoute() (AdvancedCustomRoute, bool)

ModelListRoute returns the explicitly configured OpenAI Models discovery route. Template routes that merely happen to match /v1/models are not discovery routes.

func (*AdvancedCustomConfig) SupportedEndpointTypesForModel

func (c *AdvancedCustomConfig) SupportedEndpointTypesForModel(model string) []types.EndpointType

func (*AdvancedCustomConfig) SupportsPath

func (c *AdvancedCustomConfig) SupportsPath(requestPath string) bool

SupportsPath reports whether any route matches requestPath.

func (*AdvancedCustomConfig) SupportsPathForModel

func (c *AdvancedCustomConfig) SupportsPathForModel(requestPath string, model string) bool

SupportsPathForModel reports whether any route matches requestPath and model.

func (*AdvancedCustomConfig) Validate

func (c *AdvancedCustomConfig) Validate() error

type AdvancedCustomRoute

type AdvancedCustomRoute struct {
	IncomingPath string                   `json:"incoming_path,omitempty"`
	UpstreamPath string                   `json:"upstream_path,omitempty"`
	Converter    string                   `json:"converter,omitempty"`
	Models       []string                 `json:"models,omitempty"`
	Auth         *AdvancedCustomRouteAuth `json:"auth,omitempty"`
}

type AdvancedCustomRouteAuth

type AdvancedCustomRouteAuth struct {
	Type  string `json:"type,omitempty"`
	Name  string `json:"name,omitempty"`
	Value string `json:"value,omitempty"`
}

type AlphaSearchRequest

type AlphaSearchRequest struct {
	Model   string          `json:"model"`
	Id      string          `json:"id,omitempty"`
	Stream  *bool           `json:"stream,omitempty"`
	RawBody json.RawMessage `json:"-"`
}

AlphaSearchRequest is the Codex standalone web search request. RawBody preserves the original JSON so unknown fields are forwarded intact.

func (*AlphaSearchRequest) GetTokenCountMeta

func (r *AlphaSearchRequest) GetTokenCountMeta() *types.TokenCountMeta

func (*AlphaSearchRequest) IsStream

func (r *AlphaSearchRequest) IsStream(_ *http.Request) bool

func (*AlphaSearchRequest) SetModelName

func (r *AlphaSearchRequest) SetModelName(modelName string)

type AnthropicModel

type AnthropicModel struct {
	ID          string `json:"id"`
	CreatedAt   string `json:"created_at"`
	DisplayName string `json:"display_name"`
	Type        string `json:"type"`
}

type AudioRequest

type AudioRequest struct {
	Model          string          `json:"model"`
	Input          string          `json:"input"`
	Voice          string          `json:"voice"`
	Instructions   string          `json:"instructions,omitempty"`
	ResponseFormat string          `json:"response_format,omitempty"`
	Speed          *float64        `json:"speed,omitempty"`
	StreamFormat   string          `json:"stream_format,omitempty"`
	Metadata       json.RawMessage `json:"metadata,omitempty"`
	// vllm-omini
	TaskType                json.RawMessage `json:"task_type,omitempty"`
	Language                json.RawMessage `json:"language,omitempty"`
	RefAudio                json.RawMessage `json:"ref_audio,omitempty"`
	RefText                 json.RawMessage `json:"ref_text,omitempty"`
	XVectorOnlyMode         json.RawMessage `json:"x_vector_only_mode,omitempty"`
	MaxNewTokens            json.RawMessage `json:"max_new_tokens,omitempty"`
	InitialCodecChunkFrames json.RawMessage `json:"initial_codec_chunk_frames,omitempty"`
}

func (*AudioRequest) GetTokenCountMeta

func (r *AudioRequest) GetTokenCountMeta() *types.TokenCountMeta

func (*AudioRequest) IsStream

func (r *AudioRequest) IsStream(c *http.Request) bool

func (*AudioRequest) SetModelName

func (r *AudioRequest) SetModelName(modelName string)

type AudioResponse

type AudioResponse struct {
	Text string `json:"text"`
}

type AwsKeyType

type AwsKeyType string
const (
	AwsKeyTypeAKSK   AwsKeyType = "ak_sk" // 默认
	AwsKeyTypeApiKey AwsKeyType = "api_key"
)

type BaseRequest

type BaseRequest struct {
}

func (*BaseRequest) GetTokenCountMeta

func (b *BaseRequest) GetTokenCountMeta() *types.TokenCountMeta

func (*BaseRequest) IsStream

func (b *BaseRequest) IsStream(c *http.Request) bool

func (*BaseRequest) SetModelName

func (b *BaseRequest) SetModelName(modelName string)

type BillingUsage

type BillingUsage struct {
	Source              string               `json:"source,omitempty"`
	Semantic            string               `json:"semantic,omitempty"`
	Estimated           bool                 `json:"estimated,omitempty"`
	OpenAIUsage         *Usage               `json:"openai_usage,omitempty"`
	ClaudeUsage         *ClaudeUsage         `json:"claude_usage,omitempty"`
	GeminiUsageMetadata *GeminiUsageMetadata `json:"gemini_usage_metadata,omitempty"`
}

func CloneBillingUsage

func CloneBillingUsage(usage *BillingUsage) *BillingUsage

func CloneBillingUsageWithEstimatedCompletion added in v0.2.0

func CloneBillingUsageWithEstimatedCompletion(usage *BillingUsage, completionTokens int) *BillingUsage

CloneBillingUsageWithEstimatedCompletion preserves the original upstream billing dialect and fills a missing completion count without rebuilding the payload from a converted, potentially lossy Usage value.

func MergeBillingUsageNonZero added in v0.2.0

func MergeBillingUsageNonZero(current *BillingUsage, incoming *BillingUsage) *BillingUsage

MergeBillingUsageNonZero preserves non-zero provider-native fields across partial stream snapshots. A snapshot from a different billing dialect remains authoritative and replaces the previous payload.

func NewClaudeMessagesBillingUsage

func NewClaudeMessagesBillingUsage(usage *ClaudeUsage) *BillingUsage

func NewEstimatedGeminiChatBillingUsage

func NewEstimatedGeminiChatBillingUsage(usage *Usage) *BillingUsage

func NewGeminiChatBillingUsage

func NewGeminiChatBillingUsage(metadata *GeminiUsageMetadata) *BillingUsage

func NewOpenAIChatBillingUsage

func NewOpenAIChatBillingUsage(usage *Usage) *BillingUsage

func NewOpenAIResponsesBillingUsage

func NewOpenAIResponsesBillingUsage(usage *Usage) *BillingUsage

func (*BillingUsage) CanonicalUsage added in v0.2.0

func (usage *BillingUsage) CanonicalUsage() (*Usage, bool)

CanonicalUsage decodes the original provider usage carried across relay hops into the shared accounting shape. The BillingUsage snapshot remains the source of truth and is cloned onto the returned value for further relays.

type BoolValue

type BoolValue bool

func (BoolValue) MarshalJSON

func (b BoolValue) MarshalJSON() ([]byte, error)

func (*BoolValue) UnmarshalJSON

func (b *BoolValue) UnmarshalJSON(data []byte) error

type ChannelOtherSettings

type ChannelOtherSettings struct {
	AzureResponsesVersion                 string                `json:"azure_responses_version,omitempty"`
	VertexKeyType                         VertexKeyType         `json:"vertex_key_type,omitempty"` // "json" or "api_key"
	OpenRouterEnterprise                  *bool                 `json:"openrouter_enterprise,omitempty"`
	ClaudeBetaQuery                       bool                  `json:"claude_beta_query,omitempty"`          // Claude 渠道是否强制追加 ?beta=true
	AllowServiceTier                      bool                  `json:"allow_service_tier,omitempty"`         // 是否允许 service_tier 透传(默认过滤以避免额外计费)
	AllowInferenceGeo                     bool                  `json:"allow_inference_geo,omitempty"`        // 是否允许 inference_geo 透传(仅 Claude,默认过滤以满足数据驻留合规
	AllowSpeed                            bool                  `json:"allow_speed,omitempty"`                // 是否允许 speed 透传(仅 Claude,默认过滤以避免意外切换推理速度模式)
	AllowSafetyIdentifier                 bool                  `json:"allow_safety_identifier,omitempty"`    // 是否允许 safety_identifier 透传(默认过滤以保护用户隐私)
	DisableStore                          bool                  `json:"disable_store,omitempty"`              // 是否禁用 store 透传(默认允许透传,禁用后可能导致 Codex 无法使用)
	AllowIncludeObfuscation               bool                  `json:"allow_include_obfuscation,omitempty"`  // 是否允许 stream_options.include_obfuscation 透传(默认过滤以避免关闭流混淆保护)
	DisableTaskPollingSleep               bool                  `json:"disable_task_polling_sleep,omitempty"` // 是否跳过异步任务轮询间隔
	AwsKeyType                            AwsKeyType            `json:"aws_key_type,omitempty"`
	UpstreamModelUpdateCheckEnabled       bool                  `json:"upstream_model_update_check_enabled,omitempty"`        // 是否检测上游模型更新
	UpstreamModelUpdateAutoSyncEnabled    bool                  `json:"upstream_model_update_auto_sync_enabled,omitempty"`    // 是否自动同步上游模型更新
	UpstreamModelUpdateLastCheckTime      int64                 `json:"upstream_model_update_last_check_time,omitempty"`      // 上次检测时间
	UpstreamModelUpdateLastDetectedModels []string              `json:"upstream_model_update_last_detected_models,omitempty"` // 上次检测到的可加入模型
	UpstreamModelUpdateLastRemovedModels  []string              `json:"upstream_model_update_last_removed_models,omitempty"`  // 上次检测到的可删除模型
	UpstreamModelUpdateIgnoredModels      []string              `json:"upstream_model_update_ignored_models,omitempty"`       // 手动忽略的模型
	AdvancedCustom                        *AdvancedCustomConfig `json:"advanced_custom,omitempty"`
	// ToolLossPolicy is a channel-level opt-in for request-phase conversion
	// rejection. Empty follows the default allow policy. Accepted values:
	// "", "allow", "safe", "strict".
	ToolLossPolicy string `json:"tool_loss_policy,omitempty"`
}

func (*ChannelOtherSettings) IsOpenRouterEnterprise

func (s *ChannelOtherSettings) IsOpenRouterEnterprise() bool

func (*ChannelOtherSettings) ValidateToolLossPolicy added in v0.2.0

func (s *ChannelOtherSettings) ValidateToolLossPolicy() error

ValidateToolLossPolicy validates the channel-level request-phase tool-loss policy. Empty keeps the default allow policy.

type ChannelSettings

type ChannelSettings struct {
	TaskPluginKey          string `json:"task_plugin_key,omitempty"`
	ForceFormat            bool   `json:"force_format,omitempty"`
	ThinkingToContent      bool   `json:"thinking_to_content,omitempty"`
	Proxy                  string `json:"proxy"`
	PassThroughBodyEnabled bool   `json:"pass_through_body_enabled,omitempty"`
	SystemPrompt           string `json:"system_prompt,omitempty"`
	SystemPromptOverride   bool   `json:"system_prompt_override,omitempty"`
	// HTTPProtocol controls outbound HTTP version negotiation for this channel.
	// Accepted values: "", "auto" (default), "http1".
	HTTPProtocol string `json:"http_protocol,omitempty"`
	// HTTP2ConnectionShards spreads HTTP/2 traffic across N independent transports
	// (1-8). Zero/unset means 1. Ignored when HTTPProtocol is "http1".
	HTTP2ConnectionShards int `json:"http2_connection_shards,omitempty"`
}

func (*ChannelSettings) ValidateHTTPTransport added in v0.2.0

func (s *ChannelSettings) ValidateHTTPTransport() error

ValidateHTTPTransport validates save-time HTTP transport channel settings.

type ChatCompletionsStreamResponse

type ChatCompletionsStreamResponse struct {
	Id                string                                `json:"id"`
	Object            string                                `json:"object"`
	Created           int64                                 `json:"created"`
	Model             string                                `json:"model"`
	SystemFingerprint *string                               `json:"system_fingerprint"`
	Choices           []ChatCompletionsStreamResponseChoice `json:"choices"`
	Usage             *Usage                                `json:"usage"`
}

func (*ChatCompletionsStreamResponse) ClearToolCalls

func (c *ChatCompletionsStreamResponse) ClearToolCalls()

func (*ChatCompletionsStreamResponse) Copy

func (*ChatCompletionsStreamResponse) GetFirstToolCall

func (c *ChatCompletionsStreamResponse) GetFirstToolCall() *ToolCallResponse

func (*ChatCompletionsStreamResponse) GetSystemFingerprint

func (c *ChatCompletionsStreamResponse) GetSystemFingerprint() string

func (*ChatCompletionsStreamResponse) IsFinished

func (c *ChatCompletionsStreamResponse) IsFinished() bool

func (*ChatCompletionsStreamResponse) IsToolCall

func (c *ChatCompletionsStreamResponse) IsToolCall() bool

func (*ChatCompletionsStreamResponse) SetSystemFingerprint

func (c *ChatCompletionsStreamResponse) SetSystemFingerprint(s string)

type ChatCompletionsStreamResponseChoice

type ChatCompletionsStreamResponseChoice struct {
	Delta        ChatCompletionsStreamResponseChoiceDelta `json:"delta,omitempty"`
	Logprobs     *any                                     `json:"logprobs"`
	FinishReason *string                                  `json:"finish_reason"`
	Index        int                                      `json:"index"`
}

type ChatCompletionsStreamResponseChoiceDelta

type ChatCompletionsStreamResponseChoiceDelta struct {
	Content          *string            `json:"content,omitempty"`
	ReasoningContent *string            `json:"reasoning_content,omitempty"`
	Reasoning        *string            `json:"reasoning,omitempty"`
	Role             string             `json:"role,omitempty"`
	ToolCalls        []ToolCallResponse `json:"tool_calls,omitempty"`
	// Annotations is an OpenAI-compatible streaming extension supported by
	// providers such as OpenRouter. Relaykit uses it to preserve streaming URL
	// citations, including Claude round-trip metadata.
	Annotations json.RawMessage `json:"annotations,omitempty"`
}

func (*ChatCompletionsStreamResponseChoiceDelta) GetContentString

func (c *ChatCompletionsStreamResponseChoiceDelta) GetContentString() string

func (*ChatCompletionsStreamResponseChoiceDelta) GetReasoningContent

func (c *ChatCompletionsStreamResponseChoiceDelta) GetReasoningContent() string

func (*ChatCompletionsStreamResponseChoiceDelta) SetContentString

func (c *ChatCompletionsStreamResponseChoiceDelta) SetContentString(s string)

func (*ChatCompletionsStreamResponseChoiceDelta) SetReasoningContent

func (c *ChatCompletionsStreamResponseChoiceDelta) SetReasoningContent(s string)

type ChatCompletionsStreamResponseSimple

type ChatCompletionsStreamResponseSimple struct {
	Choices []ChatCompletionsStreamResponseChoice `json:"choices"`
	Usage   *Usage                                `json:"usage"`
}

type ClaudeCacheCreationUsage

type ClaudeCacheCreationUsage struct {
	Ephemeral5mInputTokens int `json:"ephemeral_5m_input_tokens,omitempty"`
	Ephemeral1hInputTokens int `json:"ephemeral_1h_input_tokens,omitempty"`
}

type ClaudeErrorWithStatusCode

type ClaudeErrorWithStatusCode struct {
	Error      types.ClaudeError `json:"error"`
	StatusCode int               `json:"status_code"`
	LocalError bool
}

type ClaudeMediaMessage

type ClaudeMediaMessage struct {
	Type         string               `json:"type,omitempty"`
	Text         *string              `json:"text,omitempty"`
	Model        string               `json:"model,omitempty"`
	Source       *ClaudeMessageSource `json:"source,omitempty"`
	Usage        *ClaudeUsage         `json:"usage,omitempty"`
	StopReason   *string              `json:"stop_reason,omitempty"`
	PartialJson  *string              `json:"partial_json,omitempty"`
	Role         string               `json:"role,omitempty"`
	Thinking     *string              `json:"thinking,omitempty"`
	Data         string               `json:"data,omitempty"`
	Signature    string               `json:"signature,omitempty"`
	Delta        string               `json:"delta,omitempty"`
	CacheControl json.RawMessage      `json:"cache_control,omitempty"`

	// Text blocks and citations_delta events.
	Citations json.RawMessage `json:"citations,omitempty"`
	Citation  json.RawMessage `json:"citation,omitempty"`

	// Server-tool and tool-result blocks.
	Caller     json.RawMessage `json:"caller,omitempty"`
	ServerName string          `json:"server_name,omitempty"`
	IsError    *bool           `json:"is_error,omitempty"`
	// ErrorCode is a relaykit compatibility extension. Claude places provider
	// error codes inside nested tool-result error content.
	ErrorCode string `json:"error_code,omitempty"`

	// Tool-use and tool-result blocks.
	Id        string `json:"id,omitempty"`
	Name      string `json:"name,omitempty"`
	Input     any    `json:"input,omitempty"`
	Content   any    `json:"content,omitempty"`
	ToolUseId string `json:"tool_use_id,omitempty"`
}

func (*ClaudeMediaMessage) GetJsonRowString

func (c *ClaudeMediaMessage) GetJsonRowString() string

func (*ClaudeMediaMessage) GetStringContent

func (c *ClaudeMediaMessage) GetStringContent() string

func (*ClaudeMediaMessage) GetText

func (c *ClaudeMediaMessage) GetText() string

func (*ClaudeMediaMessage) IsStringContent

func (c *ClaudeMediaMessage) IsStringContent() bool

func (*ClaudeMediaMessage) ParseMediaContent

func (c *ClaudeMediaMessage) ParseMediaContent() []ClaudeMediaMessage

func (*ClaudeMediaMessage) SetContent

func (c *ClaudeMediaMessage) SetContent(content any)

func (*ClaudeMediaMessage) SetText

func (c *ClaudeMediaMessage) SetText(s string)

func (*ClaudeMediaMessage) ToFileSource

func (m *ClaudeMediaMessage) ToFileSource() types.FileSource

type ClaudeMessage

type ClaudeMessage struct {
	Role    string `json:"role"`
	Content any    `json:"content"`
}

func (*ClaudeMessage) GetStringContent

func (c *ClaudeMessage) GetStringContent() string

func (*ClaudeMessage) IsStringContent

func (c *ClaudeMessage) IsStringContent() bool

func (*ClaudeMessage) ParseContent

func (c *ClaudeMessage) ParseContent() ([]ClaudeMediaMessage, error)

func (*ClaudeMessage) SetContent

func (c *ClaudeMessage) SetContent(content any)

func (*ClaudeMessage) SetStringContent

func (c *ClaudeMessage) SetStringContent(content string)

type ClaudeMessageSource

type ClaudeMessageSource struct {
	Type      string `json:"type"`
	MediaType string `json:"media_type,omitempty"`
	Data      any    `json:"data,omitempty"`
	Url       string `json:"url,omitempty"`
}

type ClaudeMetadata

type ClaudeMetadata struct {
	UserId string `json:"user_id"`
}

type ClaudeRequest

type ClaudeRequest struct {
	Model        string          `json:"model"`
	Prompt       string          `json:"prompt,omitempty"`
	System       any             `json:"system,omitempty"`
	Messages     []ClaudeMessage `json:"messages,omitempty"`
	CacheControl json.RawMessage `json:"cache_control,omitempty"`
	// InferenceGeo controls Claude data residency region.
	// This field is filtered by default and can be enabled via channel setting allow_inference_geo.
	InferenceGeo      string          `json:"inference_geo,omitempty"`
	MaxTokens         *uint           `json:"max_tokens,omitempty"`
	MaxTokensToSample *uint           `json:"max_tokens_to_sample,omitempty"`
	StopSequences     []string        `json:"stop_sequences,omitempty"`
	Temperature       *float64        `json:"temperature,omitempty"`
	TopP              *float64        `json:"top_p,omitempty"`
	TopK              *int            `json:"top_k,omitempty"`
	Stream            *bool           `json:"stream,omitempty"`
	Tools             any             `json:"tools,omitempty"`
	ContextManagement json.RawMessage `json:"context_management,omitempty"`
	OutputConfig      json.RawMessage `json:"output_config,omitempty"`
	OutputFormat      json.RawMessage `json:"output_format,omitempty"`
	Container         json.RawMessage `json:"container,omitempty"`
	ToolChoice        any             `json:"tool_choice,omitempty"`
	Thinking          *Thinking       `json:"thinking,omitempty"`
	McpServers        json.RawMessage `json:"mcp_servers,omitempty"`
	Metadata          json.RawMessage `json:"metadata,omitempty"`
	// Speed specifies the Claude inference speed mode.
	// This field is filtered by default and can be enabled via channel setting allow_speed.
	Speed json.RawMessage `json:"speed,omitempty"`
	// ServiceTier specifies upstream service level and may affect billing.
	// This field is filtered by default and can be enabled via channel setting allow_service_tier.
	ServiceTier string `json:"service_tier,omitempty"`
}

func (*ClaudeRequest) AddTool

func (c *ClaudeRequest) AddTool(tool any)

AddTool 添加工具到请求中

func (*ClaudeRequest) GetEfforts

func (c *ClaudeRequest) GetEfforts() string

func (*ClaudeRequest) GetStringSystem

func (c *ClaudeRequest) GetStringSystem() string

func (*ClaudeRequest) GetTokenCountMeta

func (c *ClaudeRequest) GetTokenCountMeta() *types.TokenCountMeta

func (*ClaudeRequest) GetTools

func (c *ClaudeRequest) GetTools() []any

GetTools 获取工具列表

func (*ClaudeRequest) IsStream

func (c *ClaudeRequest) IsStream(ctx *http.Request) bool

func (*ClaudeRequest) IsStringSystem

func (c *ClaudeRequest) IsStringSystem() bool

func (*ClaudeRequest) ParseSystem

func (c *ClaudeRequest) ParseSystem() []ClaudeMediaMessage

func (*ClaudeRequest) SearchToolNameByToolCallId

func (c *ClaudeRequest) SearchToolNameByToolCallId(toolCallId string) string

func (*ClaudeRequest) SetModelName

func (c *ClaudeRequest) SetModelName(modelName string)

func (*ClaudeRequest) SetStringSystem

func (c *ClaudeRequest) SetStringSystem(system string)

type ClaudeResponse

type ClaudeResponse struct {
	Id           string               `json:"id,omitempty"`
	Type         string               `json:"type"`
	Role         string               `json:"role,omitempty"`
	Content      []ClaudeMediaMessage `json:"content,omitempty"`
	Completion   string               `json:"completion,omitempty"`
	StopReason   string               `json:"stop_reason,omitempty"`
	Model        string               `json:"model,omitempty"`
	Error        any                  `json:"error,omitempty"`
	Usage        *ClaudeUsage         `json:"usage,omitempty"`
	Index        *int                 `json:"index,omitempty"`
	ContentBlock *ClaudeMediaMessage  `json:"content_block,omitempty"`
	Delta        *ClaudeMediaMessage  `json:"delta,omitempty"`
	Message      *ClaudeMediaMessage  `json:"message,omitempty"`
}

func (*ClaudeResponse) GetClaudeError

func (c *ClaudeResponse) GetClaudeError() *types.ClaudeError

GetClaudeError 从动态错误类型中提取ClaudeError结构

func (*ClaudeResponse) GetIndex

func (c *ClaudeResponse) GetIndex() int

get index

func (*ClaudeResponse) SetIndex

func (c *ClaudeResponse) SetIndex(i int)

set index

type ClaudeServerToolUse

type ClaudeServerToolUse struct {
	WebSearchRequests     int `json:"web_search_requests,omitempty"`
	WebFetchRequests      int `json:"web_fetch_requests,omitempty"`
	CodeExecutionRequests int `json:"code_execution_requests,omitempty"`
	ToolSearchRequests    int `json:"tool_search_requests,omitempty"`
}

type ClaudeToolChoice

type ClaudeToolChoice struct {
	Type                   string `json:"type"`
	Name                   string `json:"name,omitempty"`
	DisableParallelToolUse bool   `json:"disable_parallel_tool_use,omitempty"`
}

type ClaudeUsage

type ClaudeUsage struct {
	InputTokens              int                       `json:"input_tokens"`
	CacheCreationInputTokens int                       `json:"cache_creation_input_tokens"`
	CacheReadInputTokens     int                       `json:"cache_read_input_tokens"`
	OutputTokens             int                       `json:"output_tokens"`
	CacheCreation            *ClaudeCacheCreationUsage `json:"cache_creation,omitempty"`
	// claude cache 1h
	ClaudeCacheCreation5mTokens int                  `json:"claude_cache_creation_5_m_tokens"`
	ClaudeCacheCreation1hTokens int                  `json:"claude_cache_creation_1_h_tokens"`
	ServerToolUse               *ClaudeServerToolUse `json:"server_tool_use,omitempty"`
	BillingUsage                *BillingUsage        `json:"billing_usage,omitempty"`
}

func MergeClaudeUsageNonZero added in v0.2.0

func MergeClaudeUsageNonZero(current *ClaudeUsage, incoming *ClaudeUsage) *ClaudeUsage

func (*ClaudeUsage) GetCacheCreation1hTokens

func (u *ClaudeUsage) GetCacheCreation1hTokens() int

func (*ClaudeUsage) GetCacheCreation5mTokens

func (u *ClaudeUsage) GetCacheCreation5mTokens() int

func (*ClaudeUsage) GetCacheCreationTotalTokens

func (u *ClaudeUsage) GetCacheCreationTotalTokens() int

type ClaudeWebSearchTool

type ClaudeWebSearchTool struct {
	Type              string                       `json:"type"`
	Name              string                       `json:"name"`
	MaxUses           int                          `json:"max_uses,omitempty"`
	AllowedDomains    []string                     `json:"allowed_domains,omitempty"`
	BlockedDomains    []string                     `json:"blocked_domains,omitempty"`
	AllowedCallers    []string                     `json:"allowed_callers,omitempty"`
	ResponseInclusion string                       `json:"response_inclusion,omitempty"`
	UserLocation      *ClaudeWebSearchUserLocation `json:"user_location,omitempty"`
}

type ClaudeWebSearchUserLocation

type ClaudeWebSearchUserLocation struct {
	Type     string `json:"type"`
	Timezone string `json:"timezone,omitempty"`
	Country  string `json:"country,omitempty"`
	Region   string `json:"region,omitempty"`
	City     string `json:"city,omitempty"`
}

type CompletionsStreamResponse

type CompletionsStreamResponse struct {
	Choices []struct {
		Text         string `json:"text"`
		FinishReason string `json:"finish_reason"`
	} `json:"choices"`
}

type ContentEmbedding

type ContentEmbedding struct {
	Values []float64 `json:"values"`
}

type DifferenceItem

type DifferenceItem struct {
	Current    interface{}            `json:"current"`
	Upstreams  map[string]interface{} `json:"upstreams"`
	Confidence map[string]bool        `json:"confidence"`
}

type EmbeddingOptions

type EmbeddingOptions struct {
	Seed             int      `json:"seed,omitempty"`
	Temperature      *float64 `json:"temperature,omitempty"`
	TopK             int      `json:"top_k,omitempty"`
	TopP             *float64 `json:"top_p,omitempty"`
	FrequencyPenalty *float64 `json:"frequency_penalty,omitempty"`
	PresencePenalty  *float64 `json:"presence_penalty,omitempty"`
	NumPredict       int      `json:"num_predict,omitempty"`
	NumCtx           int      `json:"num_ctx,omitempty"`
}

type EmbeddingRequest

type EmbeddingRequest struct {
	Model            string   `json:"model"`
	Input            any      `json:"input"`
	EncodingFormat   string   `json:"encoding_format,omitempty"`
	Dimensions       *int     `json:"dimensions,omitempty"`
	User             string   `json:"user,omitempty"`
	Seed             *float64 `json:"seed,omitempty"`
	Temperature      *float64 `json:"temperature,omitempty"`
	TopP             *float64 `json:"top_p,omitempty"`
	FrequencyPenalty *float64 `json:"frequency_penalty,omitempty"`
	PresencePenalty  *float64 `json:"presence_penalty,omitempty"`
}

func (*EmbeddingRequest) GetTokenCountMeta

func (r *EmbeddingRequest) GetTokenCountMeta() *types.TokenCountMeta

func (*EmbeddingRequest) IsStream

func (r *EmbeddingRequest) IsStream(c *http.Request) bool

func (*EmbeddingRequest) ParseInput

func (r *EmbeddingRequest) ParseInput() []string

func (*EmbeddingRequest) SetModelName

func (r *EmbeddingRequest) SetModelName(modelName string)

type EmbeddingResponse

type EmbeddingResponse struct {
	Object string                  `json:"object"`
	Data   []EmbeddingResponseItem `json:"data"`
	Model  string                  `json:"model"`
	Usage  `json:"usage"`
}

type EmbeddingResponseItem

type EmbeddingResponseItem struct {
	Object    string    `json:"object"`
	Index     int       `json:"index"`
	Embedding []float64 `json:"embedding"`
}

type FlexibleEmbeddingResponse

type FlexibleEmbeddingResponse struct {
	Object string                          `json:"object"`
	Data   []FlexibleEmbeddingResponseItem `json:"data"`
	Model  string                          `json:"model"`
	Usage  `json:"usage"`
}

type FlexibleEmbeddingResponseItem

type FlexibleEmbeddingResponseItem struct {
	Object    string `json:"object"`
	Index     int    `json:"index"`
	Embedding any    `json:"embedding"`
}

type FormatJsonSchema

type FormatJsonSchema struct {
	Description string          `json:"description,omitempty"`
	Name        string          `json:"name"`
	Schema      any             `json:"schema,omitempty"`
	Strict      json.RawMessage `json:"strict,omitempty"`
}

type FunctionCall

type FunctionCall struct {
	// ID is optional in the Gemini protocol and identifies the matching function response.
	ID           string             `json:"id,omitempty"`
	FunctionName string             `json:"name"`
	Arguments    any                `json:"args"`
	PartialArgs  []GeminiPartialArg `json:"partialArgs,omitempty"`
	WillContinue *bool              `json:"willContinue,omitempty"`
}

type FunctionCallingConfig

type FunctionCallingConfig struct {
	Mode                        FunctionCallingConfigMode `json:"mode,omitempty"`
	AllowedFunctionNames        []string                  `json:"allowedFunctionNames,omitempty"`
	StreamFunctionCallArguments *bool                     `json:"streamFunctionCallArguments,omitempty"`
}

type FunctionCallingConfigMode

type FunctionCallingConfigMode string

type FunctionRequest

type FunctionRequest struct {
	Description string `json:"description,omitempty"`
	Name        string `json:"name"`
	Parameters  any    `json:"parameters,omitempty"`
	Arguments   string `json:"arguments,omitempty"`
	Strict      *bool  `json:"strict,omitempty"`
}

type FunctionResponse

type FunctionResponse struct {
	Description string `json:"description,omitempty"`
	Name        string `json:"name,omitempty"`
	// call function with arguments in JSON format
	Parameters any    `json:"parameters,omitempty"` // request
	Arguments  string `json:"arguments"`            // response
}

type GeminiBatchEmbeddingRequest

type GeminiBatchEmbeddingRequest struct {
	Requests []*GeminiEmbeddingRequest `json:"requests"`
}

func (*GeminiBatchEmbeddingRequest) GetTokenCountMeta

func (r *GeminiBatchEmbeddingRequest) GetTokenCountMeta() *types.TokenCountMeta

func (*GeminiBatchEmbeddingRequest) IsStream

func (r *GeminiBatchEmbeddingRequest) IsStream(c *http.Request) bool

func (*GeminiBatchEmbeddingRequest) SetModelName

func (r *GeminiBatchEmbeddingRequest) SetModelName(modelName string)

type GeminiBatchEmbeddingResponse

type GeminiBatchEmbeddingResponse struct {
	Embeddings []*ContentEmbedding `json:"embeddings"`
}

type GeminiChatCandidate

type GeminiChatCandidate struct {
	Content           GeminiChatContent        `json:"content"`
	FinishReason      *string                  `json:"finishReason"`
	Index             int64                    `json:"index"`
	SafetyRatings     []GeminiChatSafetyRating `json:"safetyRatings"`
	GroundingMetadata *GeminiGroundingMetadata `json:"groundingMetadata,omitempty"`
}

type GeminiChatContent

type GeminiChatContent struct {
	Role  string       `json:"role,omitempty"`
	Parts []GeminiPart `json:"parts"`
}

type GeminiChatGenerationConfig

type GeminiChatGenerationConfig struct {
	Temperature                *float64              `json:"temperature,omitempty"`
	TopP                       *float64              `json:"topP,omitempty"`
	TopK                       *float64              `json:"topK,omitempty"`
	MaxOutputTokens            *uint                 `json:"maxOutputTokens,omitempty"`
	CandidateCount             *int                  `json:"candidateCount,omitempty"`
	StopSequences              []string              `json:"stopSequences,omitempty"`
	ResponseMimeType           string                `json:"responseMimeType,omitempty"`
	ResponseSchema             any                   `json:"responseSchema,omitempty"`
	ResponseJsonSchema         json.RawMessage       `json:"responseJsonSchema,omitempty"`
	PresencePenalty            *float32              `json:"presencePenalty,omitempty"`
	FrequencyPenalty           *float32              `json:"frequencyPenalty,omitempty"`
	ResponseLogprobs           *bool                 `json:"responseLogprobs,omitempty"`
	Logprobs                   *int32                `json:"logprobs,omitempty"`
	EnableEnhancedCivicAnswers *bool                 `json:"enableEnhancedCivicAnswers,omitempty"`
	MediaResolution            MediaResolution       `json:"mediaResolution,omitempty"`
	Seed                       *int64                `json:"seed,omitempty"`
	ResponseModalities         []string              `json:"responseModalities,omitempty"`
	ThinkingConfig             *GeminiThinkingConfig `json:"thinkingConfig,omitempty"`
	SpeechConfig               json.RawMessage       `json:"speechConfig,omitempty"` // RawMessage to allow flexible speech config
	ImageConfig                json.RawMessage       `json:"imageConfig,omitempty"`  // RawMessage to allow flexible image config
}

func (*GeminiChatGenerationConfig) UnmarshalJSON

func (c *GeminiChatGenerationConfig) UnmarshalJSON(data []byte) error

UnmarshalJSON allows GeminiChatGenerationConfig to accept both snake_case and camelCase fields.

type GeminiChatPromptFeedback

type GeminiChatPromptFeedback struct {
	SafetyRatings []GeminiChatSafetyRating `json:"safetyRatings"`
	BlockReason   *string                  `json:"blockReason,omitempty"`
}

type GeminiChatRequest

type GeminiChatRequest struct {
	Requests           []GeminiChatRequest        `json:"requests,omitempty"` // For batch requests
	Contents           []GeminiChatContent        `json:"contents"`
	SafetySettings     []GeminiChatSafetySettings `json:"safetySettings,omitempty"`
	GenerationConfig   GeminiChatGenerationConfig `json:"generationConfig,omitempty"`
	Tools              json.RawMessage            `json:"tools,omitempty"`
	ToolConfig         *ToolConfig                `json:"toolConfig,omitempty"`
	SystemInstructions *GeminiChatContent         `json:"systemInstruction,omitempty"`
	CachedContent      string                     `json:"cachedContent,omitempty"`
}

func (*GeminiChatRequest) GetTokenCountMeta

func (r *GeminiChatRequest) GetTokenCountMeta() *types.TokenCountMeta

func (*GeminiChatRequest) GetTools

func (r *GeminiChatRequest) GetTools() []GeminiChatTool

func (*GeminiChatRequest) IsStream

func (r *GeminiChatRequest) IsStream(c *http.Request) bool

func (*GeminiChatRequest) SetModelName

func (r *GeminiChatRequest) SetModelName(modelName string)

func (*GeminiChatRequest) SetTools

func (r *GeminiChatRequest) SetTools(tools []GeminiChatTool)

func (*GeminiChatRequest) UnmarshalJSON

func (r *GeminiChatRequest) UnmarshalJSON(data []byte) error

UnmarshalJSON allows GeminiChatRequest to accept both snake_case and camelCase fields.

type GeminiChatResponse

type GeminiChatResponse struct {
	Candidates       []GeminiChatCandidate     `json:"candidates"`
	PromptFeedback   *GeminiChatPromptFeedback `json:"promptFeedback,omitempty"`
	UsageMetadata    GeminiUsageMetadata       `json:"usageMetadata"`
	HasUsageMetadata bool                      `json:"-"`
}

func (*GeminiChatResponse) GetUsageMetadata

func (r *GeminiChatResponse) GetUsageMetadata() *GeminiUsageMetadata

func (*GeminiChatResponse) UnmarshalJSON

func (r *GeminiChatResponse) UnmarshalJSON(data []byte) error

UnmarshalJSON records whether Gemini returned usageMetadata while preserving the historical wire shape that always marshals the usageMetadata field.

IMPORTANT: aux shadows GeminiChatResponse. Any field added to GeminiChatResponse must also be added to aux (and copied below), otherwise it is silently dropped during unmarshal.

type GeminiChatSafetyRating

type GeminiChatSafetyRating struct {
	Category    string `json:"category"`
	Probability string `json:"probability"`
}

type GeminiChatSafetySettings

type GeminiChatSafetySettings struct {
	Category  string `json:"category"`
	Threshold string `json:"threshold"`
}

type GeminiChatTool

type GeminiChatTool struct {
	GoogleSearch          any             `json:"googleSearch,omitempty"`
	GoogleSearchRetrieval any             `json:"googleSearchRetrieval,omitempty"`
	GoogleMaps            json.RawMessage `json:"googleMaps,omitempty"`
	EnterpriseWebSearch   json.RawMessage `json:"enterpriseWebSearch,omitempty"`
	CodeExecution         any             `json:"codeExecution,omitempty"`
	FunctionDeclarations  any             `json:"functionDeclarations,omitempty"`
	URLContext            any             `json:"urlContext,omitempty"`
	FileSearch            json.RawMessage `json:"fileSearch,omitempty"`
	ComputerUse           json.RawMessage `json:"computerUse,omitempty"`
	Retrieval             json.RawMessage `json:"retrieval,omitempty"`
}

type GeminiEmbeddingRequest

type GeminiEmbeddingRequest struct {
	Model                string            `json:"model,omitempty"`
	Content              GeminiChatContent `json:"content"`
	TaskType             string            `json:"taskType,omitempty"`
	Title                string            `json:"title,omitempty"`
	OutputDimensionality int               `json:"outputDimensionality,omitempty"`
}

Embedding related structs

func (*GeminiEmbeddingRequest) GetTokenCountMeta

func (r *GeminiEmbeddingRequest) GetTokenCountMeta() *types.TokenCountMeta

func (*GeminiEmbeddingRequest) IsStream

func (r *GeminiEmbeddingRequest) IsStream(c *http.Request) bool

func (*GeminiEmbeddingRequest) SetModelName

func (r *GeminiEmbeddingRequest) SetModelName(modelName string)

type GeminiEmbeddingResponse

type GeminiEmbeddingResponse struct {
	Embedding ContentEmbedding `json:"embedding"`
}

type GeminiFileData

type GeminiFileData struct {
	MimeType string `json:"mimeType,omitempty"`
	FileUri  string `json:"fileUri,omitempty"`
}

type GeminiFunctionResponse

type GeminiFunctionResponse struct {
	Name         string                 `json:"name"`
	Response     map[string]interface{} `json:"response"`
	WillContinue json.RawMessage        `json:"willContinue,omitempty"`
	Scheduling   json.RawMessage        `json:"scheduling,omitempty"`
	Parts        json.RawMessage        `json:"parts,omitempty"`
	ID           json.RawMessage        `json:"id,omitempty"`
}

type GeminiGroundingMetadata

type GeminiGroundingMetadata struct {
	WebSearchQueries             []string        `json:"webSearchQueries,omitempty"`
	RetrievalQueries             []string        `json:"retrievalQueries,omitempty"`
	GroundingChunks              json.RawMessage `json:"groundingChunks,omitempty"`
	GroundingSupports            json.RawMessage `json:"groundingSupports,omitempty"`
	SearchEntryPoint             json.RawMessage `json:"searchEntryPoint,omitempty"`
	RetrievalMetadata            json.RawMessage `json:"retrievalMetadata,omitempty"`
	SourceFlaggingUris           json.RawMessage `json:"sourceFlaggingUris,omitempty"`
	GoogleMapsWidgetContextToken string          `json:"googleMapsWidgetContextToken,omitempty"`
}

type GeminiImageInstance

type GeminiImageInstance struct {
	Prompt string `json:"prompt"`
}

type GeminiImageParameters

type GeminiImageParameters struct {
	SampleCount      int    `json:"sampleCount,omitempty"`
	AspectRatio      string `json:"aspectRatio,omitempty"`
	PersonGeneration string `json:"personGeneration,omitempty"`
	ImageSize        string `json:"imageSize,omitempty"`
}

type GeminiImagePrediction

type GeminiImagePrediction struct {
	MimeType           string `json:"mimeType"`
	BytesBase64Encoded string `json:"bytesBase64Encoded"`
	RaiFilteredReason  string `json:"raiFilteredReason,omitempty"`
	SafetyAttributes   any    `json:"safetyAttributes,omitempty"`
}

type GeminiImageRequest

type GeminiImageRequest struct {
	Instances  []GeminiImageInstance `json:"instances"`
	Parameters GeminiImageParameters `json:"parameters"`
}

Imagen related structs

type GeminiImageResponse

type GeminiImageResponse struct {
	Predictions []GeminiImagePrediction `json:"predictions"`
}

type GeminiInlineData

type GeminiInlineData struct {
	MimeType string `json:"mimeType"`
	Data     string `json:"data"`
}

func (*GeminiInlineData) ToFileSource

func (d *GeminiInlineData) ToFileSource() types.FileSource

func (*GeminiInlineData) UnmarshalJSON

func (g *GeminiInlineData) UnmarshalJSON(data []byte) error

UnmarshalJSON custom unmarshaler for GeminiInlineData to support snake_case and camelCase for MimeType

type GeminiModel

type GeminiModel struct {
	Name                       interface{}   `json:"name"`
	BaseModelId                interface{}   `json:"baseModelId"`
	Version                    interface{}   `json:"version"`
	DisplayName                interface{}   `json:"displayName"`
	Description                interface{}   `json:"description"`
	InputTokenLimit            interface{}   `json:"inputTokenLimit"`
	OutputTokenLimit           interface{}   `json:"outputTokenLimit"`
	SupportedGenerationMethods []interface{} `json:"supportedGenerationMethods"`
	Thinking                   interface{}   `json:"thinking"`
	Temperature                interface{}   `json:"temperature"`
	MaxTemperature             interface{}   `json:"maxTemperature"`
	TopP                       interface{}   `json:"topP"`
	TopK                       interface{}   `json:"topK"`
}

type GeminiPart

type GeminiPart struct {
	Text             string                  `json:"text,omitempty"`
	Thought          bool                    `json:"thought,omitempty"`
	InlineData       *GeminiInlineData       `json:"inlineData,omitempty"`
	FunctionCall     *FunctionCall           `json:"functionCall,omitempty"`
	ThoughtSignature json.RawMessage         `json:"thoughtSignature,omitempty"`
	FunctionResponse *GeminiFunctionResponse `json:"functionResponse,omitempty"`
	// Optional. Media resolution for the input media.
	MediaResolution     json.RawMessage                `json:"mediaResolution,omitempty"`
	VideoMetadata       json.RawMessage                `json:"videoMetadata,omitempty"`
	FileData            *GeminiFileData                `json:"fileData,omitempty"`
	ExecutableCode      *GeminiPartExecutableCode      `json:"executableCode,omitempty"`
	CodeExecutionResult *GeminiPartCodeExecutionResult `json:"codeExecutionResult,omitempty"`
}

func (*GeminiPart) UnmarshalJSON

func (p *GeminiPart) UnmarshalJSON(data []byte) error

UnmarshalJSON custom unmarshaler for GeminiPart to support snake_case and camelCase for InlineData

type GeminiPartCodeExecutionResult

type GeminiPartCodeExecutionResult struct {
	Outcome string `json:"outcome,omitempty"`
	Output  string `json:"output,omitempty"`
}

type GeminiPartExecutableCode

type GeminiPartExecutableCode struct {
	Language string `json:"language,omitempty"`
	Code     string `json:"code,omitempty"`
}

type GeminiPartialArg added in v0.2.0

type GeminiPartialArg struct {
	JSONPath     string          `json:"jsonPath"`
	NumberValue  *float64        `json:"numberValue,omitempty"`
	StringValue  *string         `json:"stringValue,omitempty"`
	BoolValue    *bool           `json:"boolValue,omitempty"`
	NullValue    json.RawMessage `json:"nullValue,omitempty"`
	WillContinue *bool           `json:"willContinue,omitempty"`
}

type GeminiPromptTokensDetails

type GeminiPromptTokensDetails struct {
	Modality   string `json:"modality"`
	TokenCount int    `json:"tokenCount"`
}

type GeminiThinkingConfig

type GeminiThinkingConfig struct {
	IncludeThoughts *bool `json:"includeThoughts,omitempty"`
	ThinkingBudget  *int  `json:"thinkingBudget,omitempty"`
	// TODO Conflict with thinkingbudget.
	ThinkingLevel string `json:"thinkingLevel,omitempty"`
}

func (*GeminiThinkingConfig) SetThinkingBudget

func (c *GeminiThinkingConfig) SetThinkingBudget(budget int)

func (*GeminiThinkingConfig) UnmarshalJSON

func (c *GeminiThinkingConfig) UnmarshalJSON(data []byte) error

UnmarshalJSON allows GeminiThinkingConfig to accept both snake_case and camelCase fields.

type GeminiUsageMetadata

type GeminiUsageMetadata struct {
	PromptTokenCount           int                         `json:"promptTokenCount"`
	ToolUsePromptTokenCount    int                         `json:"toolUsePromptTokenCount"`
	CandidatesTokenCount       int                         `json:"candidatesTokenCount"`
	TotalTokenCount            int                         `json:"totalTokenCount"`
	ThoughtsTokenCount         int                         `json:"thoughtsTokenCount"`
	CachedContentTokenCount    int                         `json:"cachedContentTokenCount"`
	PromptTokensDetails        []GeminiPromptTokensDetails `json:"promptTokensDetails"`
	ToolUsePromptTokensDetails []GeminiPromptTokensDetails `json:"toolUsePromptTokensDetails"`
	CandidatesTokensDetails    []GeminiPromptTokensDetails `json:"candidatesTokensDetails"`
	BillingUsage               *BillingUsage               `json:"billing_usage,omitempty"`
}

func MergeGeminiUsageMetadataNonZero added in v0.2.0

func MergeGeminiUsageMetadataNonZero(current *GeminiUsageMetadata, incoming *GeminiUsageMetadata) *GeminiUsageMetadata

MergeGeminiUsageMetadataNonZero overlays Gemini's cumulative usage snapshots: a later non-zero field overwrites the current value without dropping fields omitted by a later chunk.

type GeneralErrorResponse

type GeneralErrorResponse struct {
	Error    json.RawMessage `json:"error"`
	Message  string          `json:"message"`
	Msg      string          `json:"msg"`
	Err      string          `json:"err"`
	ErrorMsg string          `json:"error_msg"`
	Metadata json.RawMessage `json:"metadata,omitempty"`
	Detail   string          `json:"detail,omitempty"`
	Header   struct {
		Message string `json:"message"`
	} `json:"header"`
	Response struct {
		Error struct {
			Message string `json:"message"`
		} `json:"error"`
	} `json:"response"`
}

func (GeneralErrorResponse) ToMessage

func (e GeneralErrorResponse) ToMessage() string

func (GeneralErrorResponse) TryToOpenAIError

func (e GeneralErrorResponse) TryToOpenAIError() *types.OpenAIError

type GeneralOpenAIRequest

type GeneralOpenAIRequest struct {
	Model               string            `json:"model,omitempty"`
	Messages            []Message         `json:"messages,omitempty"`
	Prompt              any               `json:"prompt,omitempty"`
	Prefix              any               `json:"prefix,omitempty"`
	Suffix              any               `json:"suffix,omitempty"`
	Stream              *bool             `json:"stream,omitempty"`
	StreamOptions       *StreamOptions    `json:"stream_options,omitempty"`
	MaxTokens           *uint             `json:"max_tokens,omitempty"`
	MaxCompletionTokens *uint             `json:"max_completion_tokens,omitempty"`
	ReasoningEffort     string            `json:"reasoning_effort,omitempty"`
	Verbosity           json.RawMessage   `json:"verbosity,omitempty"` // gpt-5
	Temperature         *float64          `json:"temperature,omitempty"`
	TopP                *float64          `json:"top_p,omitempty"`
	TopK                *int              `json:"top_k,omitempty"`
	Stop                any               `json:"stop,omitempty"`
	N                   *int              `json:"n,omitempty"`
	Input               any               `json:"input,omitempty"`
	Instruction         string            `json:"instruction,omitempty"`
	Size                string            `json:"size,omitempty"`
	Functions           json.RawMessage   `json:"functions,omitempty"`
	FrequencyPenalty    *float64          `json:"frequency_penalty,omitempty"`
	PresencePenalty     *float64          `json:"presence_penalty,omitempty"`
	ResponseFormat      *ResponseFormat   `json:"response_format,omitempty"`
	EncodingFormat      json.RawMessage   `json:"encoding_format,omitempty"`
	Seed                *float64          `json:"seed,omitempty"`
	ParallelTooCalls    *bool             `json:"parallel_tool_calls,omitempty"`
	Tools               []ToolCallRequest `json:"tools,omitempty"`
	ToolChoice          any               `json:"tool_choice,omitempty"`
	FunctionCall        json.RawMessage   `json:"function_call,omitempty"`
	User                json.RawMessage   `json:"user,omitempty"`
	// ServiceTier specifies upstream service level and may affect billing.
	// This field is filtered by default and can be enabled via channel setting allow_service_tier.
	ServiceTier json.RawMessage `json:"service_tier,omitempty"`
	LogProbs    *bool           `json:"logprobs,omitempty"`
	TopLogProbs *int            `json:"top_logprobs,omitempty"`
	Dimensions  *int            `json:"dimensions,omitempty"`
	Modalities  json.RawMessage `json:"modalities,omitempty"`
	Audio       json.RawMessage `json:"audio,omitempty"`
	// 安全标识符,用于帮助 OpenAI 检测可能违反使用政策的应用程序用户
	// 注意:此字段会向 OpenAI 发送用户标识信息,默认过滤,可通过 allow_safety_identifier 开启
	SafetyIdentifier json.RawMessage `json:"safety_identifier,omitempty"`
	// Whether or not to store the output of this chat completion request for use in our model distillation or evals products.
	// 是否存储此次请求数据供 OpenAI 用于评估和优化产品
	// 注意:默认允许透传,可通过 disable_store 禁用;禁用后可能导致 Codex 无法正常使用
	Store json.RawMessage `json:"store,omitempty"`
	// Used by OpenAI to cache responses for similar requests to optimize your cache hit rates. Replaces the user field
	PromptCacheKey       string          `json:"prompt_cache_key,omitempty"`
	PromptCacheRetention json.RawMessage `json:"prompt_cache_retention,omitempty"`
	LogitBias            json.RawMessage `json:"logit_bias,omitempty"`
	Metadata             json.RawMessage `json:"metadata,omitempty"`
	Prediction           json.RawMessage `json:"prediction,omitempty"`
	// gemini
	ExtraBody json.RawMessage `json:"extra_body,omitempty"`
	//xai
	SearchParameters json.RawMessage `json:"search_parameters,omitempty"`
	// OpenAI Chat web search.
	WebSearchOptions *WebSearchOptions `json:"web_search_options,omitempty"`
	// OpenRouter Params
	Usage     json.RawMessage `json:"usage,omitempty"`
	Reasoning json.RawMessage `json:"reasoning,omitempty"`
	// Ali Qwen Params
	VlHighResolutionImages json.RawMessage `json:"vl_high_resolution_images,omitempty"`
	EnableThinking         json.RawMessage `json:"enable_thinking,omitempty"`
	ThinkingBudget         json.RawMessage `json:"thinking_budget,omitempty"`
	ChatTemplateKwargs     json.RawMessage `json:"chat_template_kwargs,omitempty"`
	EnableSearch           json.RawMessage `json:"enable_search,omitempty"`
	// ollama Params
	Think json.RawMessage `json:"think,omitempty"`
	// baidu v2
	WebSearch json.RawMessage `json:"web_search,omitempty"`
	// doubao,zhipu_v4
	THINKING json.RawMessage `json:"thinking,omitempty"`
	// pplx Params
	SearchDomainFilter     json.RawMessage `json:"search_domain_filter,omitempty"`
	SearchRecencyFilter    json.RawMessage `json:"search_recency_filter,omitempty"`
	ReturnImages           *bool           `json:"return_images,omitempty"`
	ReturnRelatedQuestions *bool           `json:"return_related_questions,omitempty"`
	SearchMode             json.RawMessage `json:"search_mode,omitempty"`
	// Minimax
	ReasoningSplit json.RawMessage `json:"reasoning_split,omitempty"`
	// vLLM
	ThinkingTokenBudget json.RawMessage `json:"thinking_token_budget,omitempty"`

	// Internal conversion state; never serialized to an upstream protocol.
	ReasoningConversion *ReasoningConversionState `json:"-"`
}

GeneralOpenAIRequest represents a general request structure for OpenAI-compatible APIs. 参数增加规范:无引用的参数必须使用json.RawMessage类型,并添加omitempty标签

func (*GeneralOpenAIRequest) GetMaxTokens

func (r *GeneralOpenAIRequest) GetMaxTokens() uint

func (*GeneralOpenAIRequest) GetSystemRoleName

func (r *GeneralOpenAIRequest) GetSystemRoleName() string

func (*GeneralOpenAIRequest) GetTokenCountMeta

func (r *GeneralOpenAIRequest) GetTokenCountMeta() *types.TokenCountMeta

func (*GeneralOpenAIRequest) IsStream

func (r *GeneralOpenAIRequest) IsStream(c *http.Request) bool

func (GeneralOpenAIRequest) MarshalJSON added in v0.2.0

func (r GeneralOpenAIRequest) MarshalJSON() ([]byte, error)

func (*GeneralOpenAIRequest) ParseInput

func (r *GeneralOpenAIRequest) ParseInput() []string

func (*GeneralOpenAIRequest) SetModelName

func (r *GeneralOpenAIRequest) SetModelName(modelName string)

func (*GeneralOpenAIRequest) ToMap

func (r *GeneralOpenAIRequest) ToMap() map[string]any

type ImageData

type ImageData struct {
	Url           string `json:"url"`
	B64Json       string `json:"b64_json"`
	RevisedPrompt string `json:"revised_prompt"`
}

type ImageRequest

type ImageRequest struct {
	Model             string          `json:"model"`
	Prompt            string          `json:"prompt" binding:"required"`
	N                 *uint           `json:"n,omitempty"`
	Size              string          `json:"size,omitempty"`
	Quality           string          `json:"quality,omitempty"`
	ResponseFormat    string          `json:"response_format,omitempty"`
	Style             json.RawMessage `json:"style,omitempty"`
	User              json.RawMessage `json:"user,omitempty"`
	ExtraFields       json.RawMessage `json:"extra_fields,omitempty"`
	Background        json.RawMessage `json:"background,omitempty"`
	Moderation        json.RawMessage `json:"moderation,omitempty"`
	OutputFormat      json.RawMessage `json:"output_format,omitempty"`
	OutputCompression json.RawMessage `json:"output_compression,omitempty"`
	PartialImages     json.RawMessage `json:"partial_images,omitempty"`
	Stream            *bool           `json:"stream,omitempty"`
	Images            json.RawMessage `json:"images,omitempty"`
	Mask              json.RawMessage `json:"mask,omitempty"`
	InputFidelity     json.RawMessage `json:"input_fidelity,omitempty"`
	Watermark         *bool           `json:"watermark,omitempty"`
	// zhipu 4v
	WatermarkEnabled json.RawMessage `json:"watermark_enabled,omitempty"`
	UserId           json.RawMessage `json:"user_id,omitempty"`
	Image            json.RawMessage `json:"image,omitempty"`
	// 用匿名参数接收额外参数
	Extra map[string]json.RawMessage `json:"-"`
}

func (*ImageRequest) GetTokenCountMeta

func (i *ImageRequest) GetTokenCountMeta() *types.TokenCountMeta

func (*ImageRequest) IsStream

func (i *ImageRequest) IsStream(c *http.Request) bool

func (ImageRequest) MarshalJSON

func (r ImageRequest) MarshalJSON() ([]byte, error)

序列化时需要重新把字段平铺

func (*ImageRequest) SetModelName

func (i *ImageRequest) SetModelName(modelName string)

func (*ImageRequest) UnmarshalJSON

func (i *ImageRequest) UnmarshalJSON(data []byte) error

type ImageResponse

type ImageResponse struct {
	Data     []ImageData     `json:"data"`
	Created  int64           `json:"created"`
	Metadata json.RawMessage `json:"metadata,omitempty"`
}

type IncompleteDetails

type IncompleteDetails struct {
	Reason string `json:"reason"`
}

type Input

type Input struct {
	Type    string          `json:"type,omitempty"`
	Role    string          `json:"role,omitempty"`
	Content json.RawMessage `json:"content,omitempty"`
}

type InputAudioTranscription

type InputAudioTranscription struct {
	Model string `json:"model"`
}

type InputSchema

type InputSchema struct {
	Type       string `json:"type"`
	Properties any    `json:"properties,omitempty"`
	Required   any    `json:"required,omitempty"`
}

type InputTokenDetails

type InputTokenDetails struct {
	CachedTokens         int `json:"cached_tokens"`
	CachedCreationTokens int `json:"cached_creation_tokens,omitempty"`
	// CacheWriteTokens is OpenAI's native cache-write count, reported as
	// prompt_tokens_details.cache_write_tokens (Chat Completions) or
	// input_tokens_details.cache_write_tokens (Responses). It is billed at the
	// cache-creation price.
	CacheWriteTokens int `json:"cache_write_tokens,omitempty"`
	TextTokens       int `json:"text_tokens"`
	AudioTokens      int `json:"audio_tokens"`
	ImageTokens      int `json:"image_tokens"`
}

func (InputTokenDetails) CacheCreationTokensTotal

func (d InputTokenDetails) CacheCreationTokensTotal() int

CacheCreationTokensTotal returns the cache-write token count regardless of which field the upstream reported it in: Claude-derived conversions populate CachedCreationTokens while OpenAI reports cache_write_tokens natively. Both are billed at the cache-creation price; when both are present the larger value wins so the same tokens are never double-counted. Negative upstream values are clamped to zero so they can never lower a charge.

type IntValue

type IntValue int

func (IntValue) MarshalJSON

func (i IntValue) MarshalJSON() ([]byte, error)

func (*IntValue) UnmarshalJSON

func (i *IntValue) UnmarshalJSON(b []byte) error

type LatLng

type LatLng struct {
	Latitude  *float64 `json:"latitude,omitempty"`
	Longitude *float64 `json:"longitude,omitempty"`
}

type MediaContent

type MediaContent struct {
	Type       string `json:"type"`
	Text       string `json:"text,omitempty"`
	ImageUrl   any    `json:"image_url,omitempty"`
	InputAudio any    `json:"input_audio,omitempty"`
	File       any    `json:"file,omitempty"`
	VideoUrl   any    `json:"video_url,omitempty"`
	// OpenRouter Params
	CacheControl json.RawMessage `json:"cache_control,omitempty"`
}

func (*MediaContent) GetFile

func (m *MediaContent) GetFile() *MessageFile

func (*MediaContent) GetImageMedia

func (m *MediaContent) GetImageMedia() *MessageImageUrl

func (*MediaContent) GetInputAudio

func (m *MediaContent) GetInputAudio() *MessageInputAudio

func (*MediaContent) GetVideoUrl

func (m *MediaContent) GetVideoUrl() *MessageVideoUrl

func (*MediaContent) ToFileSource

func (m *MediaContent) ToFileSource() types.FileSource

type MediaInput

type MediaInput struct {
	Type     string `json:"type"`
	Text     string `json:"text,omitempty"`
	FileUrl  string `json:"file_url,omitempty"`
	ImageUrl string `json:"image_url,omitempty"`
	Detail   string `json:"detail,omitempty"` // 仅 input_image 有效
}

type MediaResolution

type MediaResolution string

type Message

type Message struct {
	Role             string          `json:"role"`
	Content          any             `json:"content"`
	Name             *string         `json:"name,omitempty"`
	Prefix           *bool           `json:"prefix,omitempty"`
	ReasoningContent *string         `json:"reasoning_content,omitempty"`
	Reasoning        *string         `json:"reasoning,omitempty"`
	ToolCalls        json.RawMessage `json:"tool_calls,omitempty"`
	ToolCallId       string          `json:"tool_call_id,omitempty"`
	// Annotations is an official Chat response field. Keeping it on the shared
	// message type also preserves annotations when clients replay assistant output.
	Annotations json.RawMessage `json:"annotations,omitempty"`
	// contains filtered or unexported fields
}

func (*Message) GetPrefix

func (m *Message) GetPrefix() bool

func (*Message) GetReasoningContent

func (m *Message) GetReasoningContent() string

func (*Message) IsStringContent

func (m *Message) IsStringContent() bool

func (*Message) ParseContent

func (m *Message) ParseContent() []MediaContent

func (*Message) ParseToolCalls

func (m *Message) ParseToolCalls() []ToolCallRequest

func (*Message) SetMediaContent

func (m *Message) SetMediaContent(content []MediaContent)

func (*Message) SetNullContent

func (m *Message) SetNullContent()

func (*Message) SetPrefix

func (m *Message) SetPrefix(prefix bool)

func (*Message) SetStringContent

func (m *Message) SetStringContent(content string)

func (*Message) SetToolCalls

func (m *Message) SetToolCalls(toolCalls any)

func (*Message) StringContent

func (m *Message) StringContent() string

type MessageFile

type MessageFile struct {
	FileName string `json:"filename,omitempty"`
	FileData string `json:"file_data,omitempty"`
	FileId   string `json:"file_id,omitempty"`
}

type MessageImageUrl

type MessageImageUrl struct {
	Url      string `json:"url"`
	Detail   string `json:"detail,omitempty"`
	MimeType string
}

func (*MessageImageUrl) IsRemoteImage

func (m *MessageImageUrl) IsRemoteImage() bool

type MessageInputAudio

type MessageInputAudio struct {
	Data   string `json:"data"` //base64
	Format string `json:"format"`
}

type MessageVideoUrl

type MessageVideoUrl struct {
	Url string `json:"url"`
}

type Notify

type Notify struct {
	Type    string        `json:"type"`
	Title   string        `json:"title"`
	Content string        `json:"content"`
	Values  []interface{} `json:"values"`
}

func NewNotify

func NewNotify(t string, title string, content string, values []interface{}) Notify

type OpenAIEmbeddingResponse

type OpenAIEmbeddingResponse struct {
	Object string                        `json:"object"`
	Data   []OpenAIEmbeddingResponseItem `json:"data"`
	Model  string                        `json:"model"`
	Usage  `json:"usage"`
}

type OpenAIEmbeddingResponseItem

type OpenAIEmbeddingResponseItem struct {
	Object    string    `json:"object"`
	Index     int       `json:"index"`
	Embedding []float64 `json:"embedding"`
}

type OpenAIErrorWithStatusCode

type OpenAIErrorWithStatusCode struct {
	Error      types.OpenAIError `json:"error"`
	StatusCode int               `json:"status_code"`
	LocalError bool
}

type OpenAIModels

type OpenAIModels struct {
	Id                     string               `json:"id"`
	Object                 string               `json:"object"`
	Created                int                  `json:"created"`
	OwnedBy                string               `json:"owned_by"`
	SupportedEndpointTypes []types.EndpointType `json:"supported_endpoint_types"`
}

这里不好动就不动了,本来想独立出来的(

type OpenAIResponsesCompactionRequest

type OpenAIResponsesCompactionRequest struct {
	Model              string          `json:"model"`
	Input              json.RawMessage `json:"input,omitempty"`
	Instructions       json.RawMessage `json:"instructions,omitempty"`
	PreviousResponseID string          `json:"previous_response_id,omitempty"`
	// Codex compact request parity:
	// https://github.com/openai/codex/commit/53d59722268dde82fb93c1f37964ce196c2a86d7
	// https://github.com/openai/codex/commit/5d6f23a27bf9c90709af527a7108c1c2eadf5123
	Tools                json.RawMessage `json:"tools,omitempty"`
	ParallelToolCalls    json.RawMessage `json:"parallel_tool_calls,omitempty"`
	Reasoning            *Reasoning      `json:"reasoning,omitempty"`
	ServiceTier          string          `json:"service_tier,omitempty"`
	PromptCacheKey       json.RawMessage `json:"prompt_cache_key,omitempty"`
	PromptCacheOptions   json.RawMessage `json:"prompt_cache_options,omitempty"`
	PromptCacheRetention json.RawMessage `json:"prompt_cache_retention,omitempty"`
	Text                 json.RawMessage `json:"text,omitempty"`
}

func (*OpenAIResponsesCompactionRequest) GetTokenCountMeta

func (r *OpenAIResponsesCompactionRequest) GetTokenCountMeta() *types.TokenCountMeta

func (*OpenAIResponsesCompactionRequest) IsStream

func (*OpenAIResponsesCompactionRequest) SetModelName

func (r *OpenAIResponsesCompactionRequest) SetModelName(modelName string)

type OpenAIResponsesCompactionResponse

type OpenAIResponsesCompactionResponse struct {
	ID        string          `json:"id"`
	Object    string          `json:"object"`
	CreatedAt int             `json:"created_at"`
	Output    json.RawMessage `json:"output"`
	Usage     *Usage          `json:"usage"`
	Error     any             `json:"error,omitempty"`
}

func (*OpenAIResponsesCompactionResponse) GetOpenAIError

type OpenAIResponsesRequest

type OpenAIResponsesRequest struct {
	Model   string          `json:"model"`
	Input   json.RawMessage `json:"input,omitempty"`
	Include json.RawMessage `json:"include,omitempty"`
	// 在后台运行推理,暂时还不支持依赖的接口
	// Background         json.RawMessage `json:"background,omitempty"`
	Conversation      json.RawMessage `json:"conversation,omitempty"`
	ContextManagement json.RawMessage `json:"context_management,omitempty"`
	Instructions      json.RawMessage `json:"instructions,omitempty"`
	MaxOutputTokens   *uint           `json:"max_output_tokens,omitempty"`
	TopLogProbs       *int            `json:"top_logprobs,omitempty"`
	Metadata          json.RawMessage `json:"metadata,omitempty"`
	Moderation        json.RawMessage `json:"moderation,omitempty"`
	ParallelToolCalls json.RawMessage `json:"parallel_tool_calls,omitempty"`
	// FrequencyPenalty/PresencePenalty are not part of the official OpenAI
	// Responses API; they are forwarded verbatim for OpenAI-compatible upstreams
	// (e.g. vLLM) that accept them.
	FrequencyPenalty   json.RawMessage `json:"frequency_penalty,omitempty"`
	PresencePenalty    json.RawMessage `json:"presence_penalty,omitempty"`
	PreviousResponseID string          `json:"previous_response_id,omitempty"`
	Reasoning          *Reasoning      `json:"reasoning,omitempty"`
	// ServiceTier specifies upstream service level and may affect billing.
	// This field is filtered by default and can be enabled via channel setting allow_service_tier.
	ServiceTier string `json:"service_tier,omitempty"`
	// Store controls whether upstream may store request/response data.
	// This field is allowed by default and can be disabled via channel setting disable_store.
	Store                json.RawMessage `json:"store,omitempty"`
	PromptCacheKey       json.RawMessage `json:"prompt_cache_key,omitempty"`
	PromptCacheOptions   json.RawMessage `json:"prompt_cache_options,omitempty"`
	PromptCacheRetention json.RawMessage `json:"prompt_cache_retention,omitempty"`
	// SafetyIdentifier carries client identity for policy abuse detection.
	// This field is filtered by default and can be enabled via channel setting allow_safety_identifier.
	SafetyIdentifier json.RawMessage `json:"safety_identifier,omitempty"`
	Stream           *bool           `json:"stream,omitempty"`
	StreamOptions    *StreamOptions  `json:"stream_options,omitempty"`
	Temperature      *float64        `json:"temperature,omitempty"`
	Text             json.RawMessage `json:"text,omitempty"`
	ToolChoice       json.RawMessage `json:"tool_choice,omitempty"`
	Tools            json.RawMessage `json:"tools,omitempty"` // 需要处理的参数很少,MCP 参数太多不确定,所以用 map
	TopP             *float64        `json:"top_p,omitempty"`
	Truncation       json.RawMessage `json:"truncation,omitempty"`
	User             json.RawMessage `json:"user,omitempty"`
	MaxToolCalls     *uint           `json:"max_tool_calls,omitempty"`
	Prompt           json.RawMessage `json:"prompt,omitempty"`
	// Codex Responses metadata/client_metadata:
	// https://github.com/openai/codex/commit/14df0e8833aad0d6d78287954b61ffac67af936c
	ClientMetadata json.RawMessage `json:"client_metadata,omitempty"`
	// qwen
	EnableThinking json.RawMessage `json:"enable_thinking,omitempty"`
	ThinkingBudget json.RawMessage `json:"thinking_budget,omitempty"`
	// perplexity
	Preset json.RawMessage `json:"preset,omitempty"`

	// Internal conversion state; never serialized to an upstream protocol.
	ReasoningConversion *ReasoningConversionState `json:"-"`
}

https://platform.openai.com/docs/api-reference/responses/create

func (*OpenAIResponsesRequest) GetTokenCountMeta

func (r *OpenAIResponsesRequest) GetTokenCountMeta() *types.TokenCountMeta

func (*OpenAIResponsesRequest) GetToolsMap

func (r *OpenAIResponsesRequest) GetToolsMap() []map[string]any

func (*OpenAIResponsesRequest) IsStream

func (r *OpenAIResponsesRequest) IsStream(c *http.Request) bool

func (OpenAIResponsesRequest) MarshalJSON added in v0.2.0

func (r OpenAIResponsesRequest) MarshalJSON() ([]byte, error)

func (*OpenAIResponsesRequest) ParseInput

func (r *OpenAIResponsesRequest) ParseInput() []MediaInput

ParseInput parses the Responses API `input` field into a normalized slice of MediaInput. Reference implementation mirrors Message.ParseContent:

  • input can be a string, treated as an input_text item
  • input can be an array of objects with a `type` field supported types: input_text, input_image, input_file

func (*OpenAIResponsesRequest) SetModelName

func (r *OpenAIResponsesRequest) SetModelName(modelName string)

type OpenAIResponsesResponse

type OpenAIResponsesResponse struct {
	ID                 string             `json:"id"`
	Object             string             `json:"object"`
	CreatedAt          int                `json:"created_at"`
	Status             json.RawMessage    `json:"status"`
	Error              any                `json:"error,omitempty"`
	IncompleteDetails  *IncompleteDetails `json:"incomplete_details,omitempty"`
	Instructions       json.RawMessage    `json:"instructions"`
	MaxOutputTokens    int                `json:"max_output_tokens"`
	Model              string             `json:"model"`
	Output             []ResponsesOutput  `json:"output"`
	ParallelToolCalls  bool               `json:"parallel_tool_calls"`
	PreviousResponseID json.RawMessage    `json:"previous_response_id"`
	Reasoning          *Reasoning         `json:"reasoning"`
	Store              bool               `json:"store"`
	Temperature        float64            `json:"temperature"`
	ToolChoice         json.RawMessage    `json:"tool_choice"`
	Tools              []map[string]any   `json:"tools"`
	TopP               float64            `json:"top_p"`
	Truncation         json.RawMessage    `json:"truncation"`
	Usage              *Usage             `json:"usage"`
	User               json.RawMessage    `json:"user"`
	Metadata           json.RawMessage    `json:"metadata"`
}

func (*OpenAIResponsesResponse) GetOpenAIError

func (o *OpenAIResponsesResponse) GetOpenAIError() *types.OpenAIError

GetOpenAIError 从动态错误类型中提取OpenAIError结构

type OpenAITextResponse

type OpenAITextResponse struct {
	Id      string                     `json:"id"`
	Model   string                     `json:"model"`
	Object  string                     `json:"object"`
	Created any                        `json:"created"`
	Choices []OpenAITextResponseChoice `json:"choices"`
	Error   any                        `json:"error,omitempty"`
	Usage   `json:"usage"`
}

func (*OpenAITextResponse) GetOpenAIError

func (o *OpenAITextResponse) GetOpenAIError() *types.OpenAIError

GetOpenAIError 从动态错误类型中提取OpenAIError结构

type OpenAITextResponseChoice

type OpenAITextResponseChoice struct {
	Index        int `json:"index"`
	Message      `json:"message"`
	FinishReason string `json:"finish_reason"`
}

type OpenAIVideo

type OpenAIVideo struct {
	ID                 string            `json:"id"`
	TaskID             string            `json:"task_id,omitempty"` //兼容旧接口 待废弃
	Object             string            `json:"object"`
	Model              string            `json:"model"`
	Status             string            `json:"status"` // Should use VideoStatus constants: VideoStatusQueued, VideoStatusInProgress, VideoStatusCompleted, VideoStatusFailed
	Progress           int               `json:"progress"`
	CreatedAt          int64             `json:"created_at"`
	CompletedAt        int64             `json:"completed_at,omitempty"`
	ExpiresAt          int64             `json:"expires_at,omitempty"`
	Seconds            string            `json:"seconds,omitempty"`
	Size               string            `json:"size,omitempty"`
	RemixedFromVideoID string            `json:"remixed_from_video_id,omitempty"`
	Error              *OpenAIVideoError `json:"error,omitempty"`
	Metadata           map[string]any    `json:"metadata,omitempty"`
}

func NewOpenAIVideo

func NewOpenAIVideo() *OpenAIVideo

func (*OpenAIVideo) SetMetadata

func (m *OpenAIVideo) SetMetadata(k string, v any)

func (*OpenAIVideo) SetProgressStr

func (m *OpenAIVideo) SetProgressStr(progress string)

type OpenAIVideoError

type OpenAIVideoError struct {
	Message string `json:"message"`
	Code    string `json:"code"`
}

type OpenAIVideoResponse

type OpenAIVideoResponse struct {
	Id        string `json:"id" example:"file-abc123"`
	Object    string `json:"object" example:"file"`
	Bytes     int64  `json:"bytes" example:"120000"`
	CreatedAt int64  `json:"created_at" example:"1677610602"`
	ExpiresAt int64  `json:"expires_at" example:"1677614202"`
	Filename  string `json:"filename" example:"mydata.jsonl"`
	Purpose   string `json:"purpose" example:"fine-tune"`
}

type OutputConfigForEffort

type OutputConfigForEffort struct {
	Effort string `json:"effort,omitempty"`
}

OutputConfigForEffort just for extract effort

type OutputTokenDetails

type OutputTokenDetails struct {
	TextTokens      int `json:"text_tokens"`
	AudioTokens     int `json:"audio_tokens"`
	ImageTokens     int `json:"image_tokens"`
	ReasoningTokens int `json:"reasoning_tokens"`
}

type PlayGroundRequest

type PlayGroundRequest struct {
	Model string `json:"model,omitempty"`
	Group string `json:"group,omitempty"`
}

type RealTimeTool

type RealTimeTool struct {
	Type        string `json:"type"`
	Name        string `json:"name"`
	Description string `json:"description"`
	Parameters  any    `json:"parameters"`
}

type RealtimeContent

type RealtimeContent struct {
	Type       string `json:"type"`
	Text       string `json:"text,omitempty"`
	Audio      string `json:"audio,omitempty"` // Base64-encoded audio bytes.
	Transcript string `json:"transcript,omitempty"`
}

type RealtimeEvent

type RealtimeEvent struct {
	EventId string `json:"event_id"`
	Type    string `json:"type"`
	//PreviousItemId string `json:"previous_item_id"`
	Session  *RealtimeSession   `json:"session,omitempty"`
	Item     *RealtimeItem      `json:"item,omitempty"`
	Error    *types.OpenAIError `json:"error,omitempty"`
	Response *RealtimeResponse  `json:"response,omitempty"`
	Delta    string             `json:"delta,omitempty"`
	Audio    string             `json:"audio,omitempty"`
}

type RealtimeItem

type RealtimeItem struct {
	Id        string            `json:"id"`
	Type      string            `json:"type"`
	Status    string            `json:"status"`
	Role      string            `json:"role"`
	Content   []RealtimeContent `json:"content"`
	Name      *string           `json:"name,omitempty"`
	ToolCalls any               `json:"tool_calls,omitempty"`
	CallId    string            `json:"call_id,omitempty"`
}

type RealtimeResponse

type RealtimeResponse struct {
	Usage *RealtimeUsage `json:"usage"`
}

type RealtimeSession

type RealtimeSession struct {
	Modalities              []string                `json:"modalities"`
	Instructions            string                  `json:"instructions"`
	Voice                   string                  `json:"voice"`
	InputAudioFormat        string                  `json:"input_audio_format"`
	OutputAudioFormat       string                  `json:"output_audio_format"`
	InputAudioTranscription InputAudioTranscription `json:"input_audio_transcription"`
	TurnDetection           interface{}             `json:"turn_detection"`
	Tools                   []RealTimeTool          `json:"tools"`
	ToolChoice              string                  `json:"tool_choice"`
	Temperature             float64                 `json:"temperature"`
}

type RealtimeUsage

type RealtimeUsage struct {
	TotalTokens        int                `json:"total_tokens"`
	InputTokens        int                `json:"input_tokens"`
	OutputTokens       int                `json:"output_tokens"`
	InputTokenDetails  InputTokenDetails  `json:"input_token_details"`
	OutputTokenDetails OutputTokenDetails `json:"output_token_details"`
}

type Reasoning

type Reasoning struct {
	Effort  string          `json:"effort,omitempty"`
	Summary string          `json:"summary,omitempty"`
	Mode    json.RawMessage `json:"mode,omitempty"`
	Context json.RawMessage `json:"context,omitempty"`
}

type ReasoningConversionState added in v0.2.0

type ReasoningConversionState struct {
	Mode            string
	Effort          string
	BudgetTokens    *int
	IncludeThoughts *bool
}

ReasoningConversionState carries provider-native reasoning controls between in-process conversion steps. It is not part of any provider wire protocol; request fields that reference it must use json:"-".

Converters that rebuild an OpenAI request must copy this state so exact budgets and explicit include-thoughts choices survive multi-step routes.

type Request

type Request interface {
	GetTokenCountMeta() *types.TokenCountMeta
	IsStream(c *http.Request) bool
	SetModelName(modelName string)
}

type RerankDocument

type RerankDocument struct {
	Text any `json:"text"`
}

type RerankRequest

type RerankRequest struct {
	Documents       []any  `json:"documents"`
	Query           string `json:"query"`
	Model           string `json:"model"`
	TopN            *int   `json:"top_n,omitempty"`
	ReturnDocuments *bool  `json:"return_documents,omitempty"`
	MaxChunkPerDoc  *int   `json:"max_chunk_per_doc,omitempty"`
	OverLapTokens   *int   `json:"overlap_tokens,omitempty"`
}

func (*RerankRequest) GetReturnDocuments

func (r *RerankRequest) GetReturnDocuments() bool

func (*RerankRequest) GetTokenCountMeta

func (r *RerankRequest) GetTokenCountMeta() *types.TokenCountMeta

func (*RerankRequest) IsStream

func (r *RerankRequest) IsStream(c *http.Request) bool

func (*RerankRequest) SetModelName

func (r *RerankRequest) SetModelName(modelName string)

type RerankResponse

type RerankResponse struct {
	Results []RerankResponseResult `json:"results"`
	Usage   Usage                  `json:"usage"`
}

type RerankResponseResult

type RerankResponseResult struct {
	Document       any     `json:"document,omitempty"`
	Index          int     `json:"index"`
	RelevanceScore float64 `json:"relevance_score"`
}

type ResponseFormat

type ResponseFormat struct {
	Type       string          `json:"type,omitempty"`
	JsonSchema json.RawMessage `json:"json_schema,omitempty"`
}

type ResponsesOutput

type ResponsesOutput struct {
	Type                string                          `json:"type"`
	ID                  string                          `json:"id"`
	Status              string                          `json:"status"`
	Role                string                          `json:"role"`
	Content             []ResponsesOutputContent        `json:"content"`
	Summary             []ResponsesReasoningSummaryPart `json:"summary,omitempty"`
	Quality             string                          `json:"quality"`
	Size                string                          `json:"size"`
	Result              string                          `json:"result,omitempty"`
	CallId              string                          `json:"call_id,omitempty"`
	Name                string                          `json:"name,omitempty"`
	Arguments           json.RawMessage                 `json:"arguments,omitempty"`
	Action              json.RawMessage                 `json:"action,omitempty"`
	Queries             json.RawMessage                 `json:"queries,omitempty"`
	Results             json.RawMessage                 `json:"results,omitempty"`
	Sources             json.RawMessage                 `json:"sources,omitempty"`
	Code                json.RawMessage                 `json:"code,omitempty"`
	Outputs             json.RawMessage                 `json:"outputs,omitempty"`
	ContainerID         string                          `json:"container_id,omitempty"`
	PendingSafetyChecks json.RawMessage                 `json:"pending_safety_checks,omitempty"`
	Caller              json.RawMessage                 `json:"caller,omitempty"`
	ServerLabel         string                          `json:"server_label,omitempty"`
	Output              json.RawMessage                 `json:"output,omitempty"`
	ItemError           json.RawMessage                 `json:"error,omitempty"`
	ApprovalRequestID   string                          `json:"approval_request_id,omitempty"`
	MCPTools            json.RawMessage                 `json:"tools,omitempty"`
}

func (*ResponsesOutput) ArgumentsString

func (r *ResponsesOutput) ArgumentsString() string

ArgumentsString returns function call arguments in the string form expected by Chat Completions.

func (ResponsesOutput) MarshalJSON added in v0.2.0

func (r ResponsesOutput) MarshalJSON() ([]byte, error)

MarshalJSON keeps hosted-tool variants within their protocol-specific schemas. ResponsesOutput also represents messages, images, and function calls, whose fields must not leak into web_search_call or mcp_call items.

type ResponsesOutputContent

type ResponsesOutputContent struct {
	Type        string        `json:"type"`
	Text        string        `json:"text"`
	Annotations []interface{} `json:"annotations"`
}

type ResponsesReasoningSummaryPart

type ResponsesReasoningSummaryPart struct {
	Type string `json:"type"`
	Text string `json:"text"`
}

type ResponsesStreamResponse

type ResponsesStreamResponse struct {
	Type            string                   `json:"type"`
	Response        *OpenAIResponsesResponse `json:"response,omitempty"`
	Code            string                   `json:"code,omitempty"`
	Message         string                   `json:"message,omitempty"`
	Param           string                   `json:"param,omitempty"`
	Delta           string                   `json:"delta,omitempty"`
	Arguments       *string                  `json:"arguments,omitempty"`
	Name            string                   `json:"name,omitempty"`
	Text            *string                  `json:"text,omitempty"`
	Item            *ResponsesOutput         `json:"item,omitempty"`
	SequenceNumber  *int                     `json:"sequence_number,omitempty"`
	Annotation      json.RawMessage          `json:"annotation,omitempty"`
	AnnotationIndex *int                     `json:"annotation_index,omitempty"`
	Obfuscation     string                   `json:"obfuscation,omitempty"`
	// - response.function_call_arguments.delta
	// - response.function_call_arguments.done
	OutputIndex  *int                           `json:"output_index,omitempty"`
	ContentIndex *int                           `json:"content_index,omitempty"`
	SummaryIndex *int                           `json:"summary_index,omitempty"`
	ItemID       string                         `json:"item_id,omitempty"`
	Part         *ResponsesReasoningSummaryPart `json:"part,omitempty"`
}

ResponsesStreamResponse 用于处理 /v1/responses 流式响应

type RetrievalConfig

type RetrievalConfig struct {
	LatLng       *LatLng `json:"latLng,omitempty"`
	LanguageCode string  `json:"languageCode,omitempty"`
}

type Segment

type Segment struct {
	Id               int     `json:"id"`
	Seek             int     `json:"seek"`
	Start            float64 `json:"start"`
	End              float64 `json:"end"`
	Text             string  `json:"text"`
	Tokens           []int   `json:"tokens"`
	Temperature      float64 `json:"temperature"`
	AvgLogprob       float64 `json:"avg_logprob"`
	CompressionRatio float64 `json:"compression_ratio"`
	NoSpeechProb     float64 `json:"no_speech_prob"`
}

type SensitiveResponse

type SensitiveResponse struct {
	SensitiveWords []string `json:"sensitive_words"`
	Content        string   `json:"content"`
}

type SimpleResponse

type SimpleResponse struct {
	Usage `json:"usage"`
	Error any `json:"error"`
}

func (*SimpleResponse) GetOpenAIError

func (s *SimpleResponse) GetOpenAIError() *types.OpenAIError

GetOpenAIError 从动态错误类型中提取OpenAIError结构

type StreamOptions

type StreamOptions struct {
	IncludeUsage bool `json:"include_usage,omitempty"`
	// IncludeObfuscation is only for /v1/responses stream payload.
	// This field is filtered by default and can be enabled via channel setting allow_include_obfuscation.
	IncludeObfuscation bool `json:"include_obfuscation,omitempty"`
}

type StringValue

type StringValue string

func (StringValue) MarshalJSON

func (s StringValue) MarshalJSON() ([]byte, error)

func (*StringValue) UnmarshalJSON

func (s *StringValue) UnmarshalJSON(data []byte) error

type SyncableChannel

type SyncableChannel struct {
	ID      int    `json:"id"`
	Name    string `json:"name"`
	BaseURL string `json:"base_url"`
	Status  int    `json:"status"`
	Type    int    `json:"type"`
}

type TestResult

type TestResult struct {
	Name   string `json:"name"`
	Status string `json:"status"`
	Error  string `json:"error,omitempty"`
}

TestResult 上游测试连通性结果

type TextResponse

type TextResponse struct {
	Id      string                     `json:"id"`
	Object  string                     `json:"object"`
	Created int64                      `json:"created"`
	Model   string                     `json:"model"`
	Choices []OpenAITextResponseChoice `json:"choices"`
	Usage   `json:"usage"`
}

type Thinking

type Thinking struct {
	Type         string `json:"type,omitempty"`
	BudgetTokens *int   `json:"budget_tokens,omitempty"`
	// Display controls whether thinking content is returned in the response.
	// Used with adaptive thinking on Claude Opus 4.7+: "summarized" restores
	// the visible summary that was default on Opus 4.6; "omitted" (default on
	// 4.7) suppresses it. Pass-through field from upstream Anthropic API.
	Display string `json:"display,omitempty"`
}

func (*Thinking) GetBudgetTokens

func (c *Thinking) GetBudgetTokens() int

type Tool

type Tool struct {
	Name        string                 `json:"name"`
	Description string                 `json:"description,omitempty"`
	InputSchema map[string]interface{} `json:"input_schema"`
	Strict      *bool                  `json:"strict,omitempty"`
}

type ToolCallRequest

type ToolCallRequest struct {
	ID       string          `json:"id,omitempty"`
	Type     string          `json:"type"`
	Function FunctionRequest `json:"function,omitempty"`
	Custom   json.RawMessage `json:"custom,omitempty"`
}

type ToolCallResponse

type ToolCallResponse struct {
	// Index is not nil only in chat completion chunk object
	Index    *int             `json:"index,omitempty"`
	ID       string           `json:"id,omitempty"`
	Type     any              `json:"type"`
	Function FunctionResponse `json:"function"`
}

func (*ToolCallResponse) SetIndex

func (c *ToolCallResponse) SetIndex(i int)

type ToolConfig

type ToolConfig struct {
	FunctionCallingConfig            *FunctionCallingConfig `json:"functionCallingConfig,omitempty"`
	RetrievalConfig                  *RetrievalConfig       `json:"retrievalConfig,omitempty"`
	IncludeServerSideToolInvocations *bool                  `json:"includeServerSideToolInvocations,omitempty"`
}

type UpstreamDTO

type UpstreamDTO struct {
	ID       int    `json:"id,omitempty"`
	Name     string `json:"name" binding:"required"`
	BaseURL  string `json:"base_url" binding:"required"`
	Endpoint string `json:"endpoint"`
}

type UpstreamRequest

type UpstreamRequest struct {
	ChannelIDs []int64       `json:"channel_ids"`
	Upstreams  []UpstreamDTO `json:"upstreams"`
	Timeout    int           `json:"timeout"`
}

type Usage

type Usage struct {
	PromptTokens         int           `json:"prompt_tokens"`
	CompletionTokens     int           `json:"completion_tokens"`
	TotalTokens          int           `json:"total_tokens"`
	PromptCacheHitTokens int           `json:"prompt_cache_hit_tokens,omitempty"`
	UsageSemantic        string        `json:"usage_semantic,omitempty"`
	UsageSource          string        `json:"usage_source,omitempty"`
	BillingUsage         *BillingUsage `json:"billing_usage,omitempty"`

	PromptTokensDetails    InputTokenDetails  `json:"prompt_tokens_details"`
	CompletionTokenDetails OutputTokenDetails `json:"completion_tokens_details"`
	InputTokens            int                `json:"input_tokens"`
	OutputTokens           int                `json:"output_tokens"`
	InputTokensDetails     *InputTokenDetails `json:"input_tokens_details"`

	// claude cache 1h
	ClaudeCacheCreation5mTokens int `json:"claude_cache_creation_5_m_tokens"`
	ClaudeCacheCreation1hTokens int `json:"claude_cache_creation_1_h_tokens"`

	// OpenRouter Params
	Cost any `json:"cost,omitempty"`
}

func MergeUsageNonZero added in v0.2.0

func MergeUsageNonZero(current *Usage, incoming *Usage) *Usage

MergeUsageNonZero overlays usage snapshots: a later non-zero field overwrites the current value, while a later zero value never erases an earlier positive count. Compatible BillingUsage snapshots follow the same rule within their provider-native payload.

type UserSetting

type UserSetting struct {
	NotifyType                       string  `json:"notify_type,omitempty"`                          // QuotaWarningType 额度预警类型
	QuotaWarningThreshold            float64 `json:"quota_warning_threshold,omitempty"`              // QuotaWarningThreshold 额度预警阈值
	WebhookUrl                       string  `json:"webhook_url,omitempty"`                          // WebhookUrl webhook地址
	WebhookSecret                    string  `json:"webhook_secret,omitempty"`                       // WebhookSecret webhook密钥
	NotificationEmail                string  `json:"notification_email,omitempty"`                   // NotificationEmail 通知邮箱地址
	BarkUrl                          string  `json:"bark_url,omitempty"`                             // BarkUrl Bark推送URL
	GotifyUrl                        string  `json:"gotify_url,omitempty"`                           // GotifyUrl Gotify服务器地址
	GotifyToken                      string  `json:"gotify_token,omitempty"`                         // GotifyToken Gotify应用令牌
	GotifyPriority                   int     `json:"gotify_priority"`                                // GotifyPriority Gotify消息优先级
	UpstreamModelUpdateNotifyEnabled bool    `json:"upstream_model_update_notify_enabled,omitempty"` // 是否接收上游模型更新定时检测通知(仅管理员)
	AcceptUnsetRatioModel            bool    `json:"accept_unset_model_ratio_model,omitempty"`       // AcceptUnsetRatioModel 是否接受未设置价格的模型
	RecordIpLog                      bool    `json:"record_ip_log,omitempty"`                        // 是否记录请求和错误日志IP
	SidebarModules                   string  `json:"sidebar_modules,omitempty"`                      // SidebarModules 左侧边栏模块配置
	BillingPreference                string  `json:"billing_preference,omitempty"`                   // BillingPreference 扣费策略(订阅/钱包)
	Language                         string  `json:"language,omitempty"`                             // Language 用户语言偏好 (zh, en)
}

type VertexKeyType

type VertexKeyType string
const (
	VertexKeyTypeJSON   VertexKeyType = "json"
	VertexKeyTypeAPIKey VertexKeyType = "api_key"
)

type WebSearchOptions

type WebSearchOptions struct {
	SearchContextSize string          `json:"search_context_size,omitempty"`
	UserLocation      json.RawMessage `json:"user_location,omitempty"`
}

type WhisperVerboseJSONResponse

type WhisperVerboseJSONResponse struct {
	Task     string    `json:"task,omitempty"`
	Language string    `json:"language,omitempty"`
	Duration float64   `json:"duration,omitempty"`
	Text     string    `json:"text,omitempty"`
	Segments []Segment `json:"segments,omitempty"`
}

Jump to

Keyboard shortcuts

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