Documentation
¶
Index ¶
- Constants
- Variables
- func GetJSONFieldNames(t reflect.Type) map[string]struct{}
- func GetOpenAIError(errorField any) *types.OpenAIError
- func HasClaudeUsageTokens(usage *ClaudeUsage) bool
- func HasGeminiUsageEvidence(metadata *GeminiUsageMetadata) bool
- func HasGeminiUsageMetadataTokens(metadata *GeminiUsageMetadata) bool
- func HasOpenAIUsageTokens(usage *Usage) bool
- func IsAdvancedCustomConverterAllowed(converter string) bool
- func IsOpenAIGPT5Model(modelName string) bool
- func IsOpenAIReasoningOModel(modelName string) bool
- func IsQwenThinkingBudgetModel(modelName string) bool
- func ProcessTools(tools []any) ([]*Tool, []*ClaudeWebSearchTool)
- func ResponsesArgumentsString(arguments json.RawMessage) string
- type AdvancedCustomConfig
- func (c *AdvancedCustomConfig) BalanceRoute() (AdvancedCustomRoute, bool)
- func (c *AdvancedCustomConfig) MatchPath(requestPath string) (AdvancedCustomRoute, bool)
- func (c *AdvancedCustomConfig) MatchPathForModel(requestPath string, model string) (AdvancedCustomRoute, bool)
- func (c *AdvancedCustomConfig) ModelListRoute() (AdvancedCustomRoute, bool)
- func (c *AdvancedCustomConfig) SupportedEndpointTypesForModel(model string) []types.EndpointType
- func (c *AdvancedCustomConfig) SupportsPath(requestPath string) bool
- func (c *AdvancedCustomConfig) SupportsPathForModel(requestPath string, model string) bool
- func (c *AdvancedCustomConfig) Validate() error
- type AdvancedCustomRoute
- type AdvancedCustomRouteAuth
- type AlphaSearchRequest
- type AnthropicModel
- type AudioRequest
- type AudioResponse
- type AwsKeyType
- type BaseRequest
- type BillingUsage
- func CloneBillingUsage(usage *BillingUsage) *BillingUsage
- func NewClaudeMessagesBillingUsage(usage *ClaudeUsage) *BillingUsage
- func NewEstimatedGeminiChatBillingUsage(usage *Usage) *BillingUsage
- func NewGeminiChatBillingUsage(metadata *GeminiUsageMetadata) *BillingUsage
- func NewOpenAIChatBillingUsage(usage *Usage) *BillingUsage
- func NewOpenAIResponsesBillingUsage(usage *Usage) *BillingUsage
- type BoolValue
- type CachedTokenDetails
- type ChannelOtherSettings
- type ChannelSettings
- type ChatCompletionsStreamResponse
- func (c *ChatCompletionsStreamResponse) ClearToolCalls()
- func (c *ChatCompletionsStreamResponse) Copy() *ChatCompletionsStreamResponse
- func (c *ChatCompletionsStreamResponse) GetFirstToolCall() *ToolCallResponse
- func (c *ChatCompletionsStreamResponse) GetSystemFingerprint() string
- func (c *ChatCompletionsStreamResponse) IsFinished() bool
- func (c *ChatCompletionsStreamResponse) IsToolCall() bool
- func (c *ChatCompletionsStreamResponse) SetSystemFingerprint(s string)
- type ChatCompletionsStreamResponseChoice
- type ChatCompletionsStreamResponseChoiceDelta
- func (c *ChatCompletionsStreamResponseChoiceDelta) GetContentString() string
- func (c *ChatCompletionsStreamResponseChoiceDelta) GetReasoningContent() string
- func (c *ChatCompletionsStreamResponseChoiceDelta) SetContentString(s string)
- func (c *ChatCompletionsStreamResponseChoiceDelta) SetReasoningContent(s string)
- type ChatCompletionsStreamResponseSimple
- type ChatTextEvidence
- type ClaudeCacheCreationUsage
- type ClaudeErrorWithStatusCode
- type ClaudeMediaMessage
- func (c *ClaudeMediaMessage) GetJsonRowString() string
- func (c *ClaudeMediaMessage) GetStringContent() string
- func (c *ClaudeMediaMessage) GetText() string
- func (c *ClaudeMediaMessage) IsStringContent() bool
- func (c *ClaudeMediaMessage) ParseMediaContent() []ClaudeMediaMessage
- func (c *ClaudeMediaMessage) SetContent(content any)
- func (c *ClaudeMediaMessage) SetText(s string)
- func (m *ClaudeMediaMessage) ToFileSource() types.FileSource
- type ClaudeMessage
- type ClaudeMessageSource
- type ClaudeMetadata
- type ClaudeRequest
- func (c *ClaudeRequest) AddTool(tool any)
- func (c *ClaudeRequest) EffectiveMaxTokens() uint
- func (c *ClaudeRequest) GetEfforts() string
- func (c *ClaudeRequest) GetStringSystem() string
- func (c *ClaudeRequest) GetTokenCountMeta() *types.TokenCountMeta
- func (c *ClaudeRequest) GetTools() []any
- func (c *ClaudeRequest) IsStream(ctx *http.Request) bool
- func (c *ClaudeRequest) IsStringSystem() bool
- func (c *ClaudeRequest) ParseSystem() []ClaudeMediaMessage
- func (c *ClaudeRequest) SearchToolNameByToolCallId(toolCallId string) string
- func (c *ClaudeRequest) SetModelName(modelName string)
- func (c *ClaudeRequest) SetStringSystem(system string)
- type ClaudeResponse
- type ClaudeServerToolUse
- type ClaudeToolChoice
- type ClaudeUsage
- type ClaudeWebSearchTool
- type ClaudeWebSearchUserLocation
- type CompletionsStreamResponse
- type ContentEmbedding
- type DifferenceItem
- type EmbeddingOptions
- type EmbeddingRequest
- type EmbeddingResponse
- type EmbeddingResponseItem
- type FlexibleEmbeddingResponse
- type FlexibleEmbeddingResponseItem
- type FormatJsonSchema
- type FunctionCall
- type FunctionCallingConfig
- type FunctionCallingConfigMode
- type FunctionRequest
- type FunctionResponse
- type GeminiBatchEmbeddingRequest
- type GeminiBatchEmbeddingResponse
- type GeminiChatCandidate
- type GeminiChatContent
- type GeminiChatGenerationConfig
- type GeminiChatPromptFeedback
- type GeminiChatRequest
- func (r *GeminiChatRequest) GetTokenCountMeta() *types.TokenCountMeta
- func (r *GeminiChatRequest) GetTools() []GeminiChatTool
- func (r *GeminiChatRequest) IsStream(c *http.Request) bool
- func (r *GeminiChatRequest) SetModelName(modelName string)
- func (r *GeminiChatRequest) SetTools(tools []GeminiChatTool)
- func (r *GeminiChatRequest) UnmarshalJSON(data []byte) error
- type GeminiChatResponse
- type GeminiChatSafetyRating
- type GeminiChatSafetySettings
- type GeminiChatTool
- type GeminiEmbeddingRequest
- type GeminiEmbeddingResponse
- type GeminiFileData
- type GeminiFunctionResponse
- type GeminiGroundingMetadata
- type GeminiImageInstance
- type GeminiImageParameters
- type GeminiImagePrediction
- type GeminiImageRequest
- type GeminiImageResponse
- type GeminiInlineData
- type GeminiModel
- type GeminiPart
- type GeminiPartCodeExecutionResult
- type GeminiPartExecutableCode
- type GeminiPromptTokensDetails
- type GeminiThinkingConfig
- type GeminiUsageMetadata
- type GeneralErrorResponse
- type GeneralOpenAIRequest
- func (r *GeneralOpenAIRequest) GetMaxTokens() uint
- func (r *GeneralOpenAIRequest) GetSystemRoleName() string
- func (r *GeneralOpenAIRequest) GetTokenCountMeta() *types.TokenCountMeta
- func (r *GeneralOpenAIRequest) IsStream(c *http.Request) bool
- func (r GeneralOpenAIRequest) MarshalJSON() ([]byte, error)
- func (r *GeneralOpenAIRequest) ParseInput() []string
- func (r *GeneralOpenAIRequest) SetModelName(modelName string)
- func (r *GeneralOpenAIRequest) ToMap() map[string]any
- type ImageData
- type ImageRequest
- type ImageResponse
- type IncompleteDetails
- type Input
- type InputAudioTranscription
- type InputSchema
- type InputTokenDetails
- type IntValue
- type LatLng
- type MediaContent
- type MediaInput
- type MediaResolution
- type Message
- func (m *Message) GetPrefix() bool
- func (m *Message) GetReasoningContent() string
- func (m *Message) IsStringContent() bool
- func (m *Message) ParseContent() []MediaContent
- func (m *Message) ParseToolCalls() []ToolCallRequest
- func (m *Message) SetMediaContent(content []MediaContent)
- func (m *Message) SetNullContent()
- func (m *Message) SetPrefix(prefix bool)
- func (m *Message) SetStringContent(content string)
- func (m *Message) SetToolCalls(toolCalls any)
- func (m *Message) StringContent() string
- type MessageFile
- type MessageImageUrl
- type MessageInputAudio
- type MessageVideoUrl
- type ModelRoute
- type Notify
- type OpenAIEmbeddingResponse
- type OpenAIEmbeddingResponseItem
- type OpenAIErrorWithStatusCode
- type OpenAIModels
- type OpenAIResponsesCompactionRequest
- type OpenAIResponsesCompactionResponse
- type OpenAIResponsesRequest
- func (r *OpenAIResponsesRequest) GetTokenCountMeta() *types.TokenCountMeta
- func (r *OpenAIResponsesRequest) GetToolsMap() []map[string]any
- func (r *OpenAIResponsesRequest) IsStream(c *http.Request) bool
- func (r OpenAIResponsesRequest) MarshalJSON() ([]byte, error)
- func (r *OpenAIResponsesRequest) ParseInput() []MediaInput
- func (r *OpenAIResponsesRequest) SetModelName(modelName string)
- type OpenAIResponsesResponse
- type OpenAITextResponse
- type OpenAITextResponseChoice
- type OpenAIVideo
- type OpenAIVideoError
- type OpenAIVideoResponse
- type OutputConfigForEffort
- type OutputTokenDetails
- type PlayGroundRequest
- type RealTimeTool
- type RealtimeContent
- type RealtimeEvent
- type RealtimeItem
- type RealtimeResponse
- type RealtimeSession
- type RealtimeUsage
- type Reasoning
- type Request
- type RerankDocument
- type RerankRequest
- type RerankResponse
- type RerankResponseResult
- type ResponseFormat
- type ResponsesOutput
- type ResponsesOutputContent
- type ResponsesReasoningSummaryPart
- type ResponsesStreamResponse
- type ResponsesTextEvidence
- type RetrievalConfig
- type Segment
- type SensitiveResponse
- type SimpleResponse
- type StreamOptions
- type StringValue
- type SyncableChannel
- type TestResult
- type TextResponse
- type Thinking
- type TokenHubSettings
- type Tool
- type ToolCallRequest
- type ToolCallResponse
- type ToolConfig
- type UpstreamDTO
- type UpstreamRequest
- type Usage
- type UserSetting
- type VertexKeyType
- type WebSearchOptions
- type WhisperVerboseJSONResponse
Constants ¶
const ( BillingUsageSourceClaudeMessages = "claude_messages" BillingUsageSourceGeminiChat = "gemini_chat" BillingUsageSourceOAIChat = "oai_chat" BillingUsageSourceOAIResponses = "oai_responses" BillingUsageSemanticAnthropic = "anthropic" BillingUsageSemanticGemini = "gemini" BillingUsageSemanticOpenAI = "openai" )
const ( HTTPProtocolAuto = "auto" HTTPProtocolHTTP1 = "http1" MaxHTTP2ConnectionShards = 8 )
const ( AdvancedCustomAuthTypeNone = "none" AdvancedCustomAuthTypeHeader = "header" AdvancedCustomAuthTypeQuery = "query" )
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" )
const ( NotifyTypeQuotaExceed = "quota_exceed" NotifyTypeChannelUpdate = "channel_update" NotifyTypeChannelTest = "channel_test" )
const ( ContentTypeText = "text" ContentTypeImageURL = "image_url" ContentTypeInputAudio = "input_audio" ContentTypeFile = "file" ContentTypeVideoUrl = "video_url" // 阿里百炼视频识别 )
const ( BuildInToolWebSearchPreview = "web_search_preview" BuildInToolWebSearch = "web_search" BuildInToolFileSearch = "file_search" BuildInToolGoogleSearch = "google_search" BuildInToolImageGeneration = "image_generation" )
const ( BuildInCallWebSearchCall = "web_search_call" BuildInCallFileSearchCall = "file_search_call" BuildInCallFunctionCall = "function_call" BuildInCallToolUse = "tool_use" )
const ( ResponsesOutputTypeItemAdded = "response.output_item.added" ResponsesOutputTypeItemDone = "response.output_item.done" )
const ( VideoStatusUnknown = "unknown" VideoStatusQueued = "queued" VideoStatusInProgress = "in_progress" VideoStatusCompleted = "completed" VideoStatusFailed = "failed" )
const ( RealtimeEventTypeError = "error" RealtimeEventTypeSessionUpdate = "session.update" RealtimeEventTypeConversationCreate = "conversation.item.create" RealtimeEventTypeResponseCreate = "response.create" RealtimeEventInputAudioBufferAppend = "input_audio_buffer.append" )
const ( RealtimeEventTypeResponseDone = "response.done" RealtimeEventTypeResponseCreated = "response.created" 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" )
const ContentValueParam = "{{value}}"
const CustomType = "custom"
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.
const (
ResponsesOutputTypeImageGenerationCall = "image_generation_call"
)
Variables ¶
var ( NotifyTypeEmail = "email" // Email 邮件 NotifyTypeWebhook = "webhook" // Webhook NotifyTypeBark = "bark" // Bark 推送 NotifyTypeGotify = "gotify" // Gotify 推送 )
Functions ¶
func GetJSONFieldNames ¶
func GetOpenAIError ¶
func GetOpenAIError(errorField any) *types.OpenAIError
GetOpenAIError 从动态错误类型中提取OpenAIError结构
func HasClaudeUsageTokens ¶
func HasClaudeUsageTokens(usage *ClaudeUsage) bool
HasClaudeUsageTokens mirrors HasOpenAIUsageTokens/HasGeminiUsageMetadataTokens: an unproven programmatic all-zero DTO must not override compatibility usage. NewClaudeMessagesBillingUsage separately retains raw explicit-zero evidence and raw missing/null evidence, which have different settlement meanings.
func HasGeminiUsageEvidence ¶
func HasGeminiUsageEvidence(metadata *GeminiUsageMetadata) bool
Raw empty/all-zero metadata remains evidence to classify, not an absent object.
func HasGeminiUsageMetadataTokens ¶
func HasGeminiUsageMetadataTokens(metadata *GeminiUsageMetadata) bool
func HasOpenAIUsageTokens ¶
func IsOpenAIGPT5Model ¶
func IsOpenAIReasoningOModel ¶
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 ¶
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 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) SetModelName ¶
func (r *AlphaSearchRequest) SetModelName(modelName string)
type AnthropicModel ¶
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) 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) SetModelName ¶
func (b *BaseRequest) SetModelName(modelName string)
type BillingUsage ¶
type BillingUsage struct {
ChatTextEvidence *ChatTextEvidence `json:"chat_text_evidence,omitempty"`
ResponsesTextEvidence *ResponsesTextEvidence `json:"responses_text_evidence,omitempty"`
Source string `json:"source,omitempty"`
Semantic string `json:"semantic,omitempty"`
Estimated bool `json:"estimated,omitempty"`
Incomplete bool `json:"incomplete,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 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
type BoolValue ¶
type BoolValue bool
func (BoolValue) MarshalJSON ¶
func (*BoolValue) UnmarshalJSON ¶
type CachedTokenDetails ¶
type CachedTokenDetails struct {
TextTokens *int `json:"text_tokens,omitempty"`
AudioTokens *int `json:"audio_tokens,omitempty"`
ImageTokens *int `json:"image_tokens,omitempty"`
}
func NewCachedTokenDetails ¶
func NewCachedTokenDetails(text, audio, image int) *CachedTokenDetails
type ChannelOtherSettings ¶
type ChannelOtherSettings struct {
ModelRoutes []ModelRoute `json:"model_routes,omitempty"`
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"`
// TokenHub configures an explicit TokenHub-compatible upstream. It is
// intentionally provider-neutral; credentials remain in Channel.Key and
// are never part of this settings object.
TokenHub *TokenHubSettings `json:"tokenhub,omitempty"`
}
func (*ChannelOtherSettings) IsOpenRouterEnterprise ¶
func (s *ChannelOtherSettings) IsOpenRouterEnterprise() bool
type ChannelSettings ¶
type ChannelSettings struct {
// InputTokenLimits bounds local text estimates by exact client model name.
InputTokenLimits map[string]int64 `json:"input_token_limits,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 ¶
func (s *ChannelSettings) ValidateHTTPTransport() error
ValidateHTTPTransport validates save-time HTTP transport channel settings.
func (*ChannelSettings) ValidateInputTokenLimits ¶
func (s *ChannelSettings) ValidateInputTokenLimits() error
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 (c *ChatCompletionsStreamResponse) Copy() *ChatCompletionsStreamResponse
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"`
}
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 ChatTextEvidence ¶
type ChatTextEvidence struct {
Model string `json:"model"`
ServiceTier string `json:"service_tier"`
PromptTokens int `json:"prompt_tokens"`
CompletionTokens int `json:"completion_tokens"`
TotalTokens int `json:"total_tokens"`
CacheRead *int `json:"cache_read"`
CacheWrite *int `json:"cache_write"`
Reasoning *int `json:"reasoning"`
Stream bool `json:"stream"`
}
ChatTextEvidence is created only by the native adapter from unambiguous raw JSON. Counts are actual prompt/completion fields, not compatibility estimates.
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"`
Signature string `json:"signature,omitempty"`
Delta string `json:"delta,omitempty"`
CacheControl json.RawMessage `json:"cache_control,omitempty"`
// tool_calls
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 ¶
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 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) EffectiveMaxTokens ¶
func (c *ClaudeRequest) EffectiveMaxTokens() uint
EffectiveMaxTokens returns the largest completion limit supplied through either Claude spelling. Both fields are accepted for compatibility, but billing must account for the effective (largest) limit rather than silently ignoring max_tokens_to_sample.
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) 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结构
type ClaudeServerToolUse ¶
type ClaudeServerToolUse struct {
WebSearchRequests int `json:"web_search_requests"`
}
type ClaudeToolChoice ¶
type ClaudeUsage ¶
type ClaudeUsage struct {
// Private raw-field evidence. JSON cannot manufacture these proof flags.
RawUsageObserved bool `json:"-"`
InputTokensReported bool `json:"-"`
OutputTokensReported bool `json:"-"`
InvalidTokenEvidence bool `json:"-"`
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 (*ClaudeUsage) GetCacheCreation1hTokens ¶
func (u *ClaudeUsage) GetCacheCreation1hTokens() int
func (*ClaudeUsage) GetCacheCreation5mTokens ¶
func (u *ClaudeUsage) GetCacheCreation5mTokens() int
func (*ClaudeUsage) GetCacheCreationTotalTokens ¶
func (u *ClaudeUsage) GetCacheCreationTotalTokens() int
func (*ClaudeUsage) UnmarshalJSON ¶
func (u *ClaudeUsage) UnmarshalJSON(data []byte) error
Preserve missing/null versus explicitly reported zero at the wire boundary. Programmatically constructed compatibility DTOs retain their old behavior.
type ClaudeWebSearchTool ¶
type ClaudeWebSearchTool struct {
Type string `json:"type"`
Name string `json:"name"`
MaxUses int `json:"max_uses,omitempty"`
UserLocation *ClaudeWebSearchUserLocation `json:"user_location,omitempty"`
}
type ContentEmbedding ¶
type ContentEmbedding struct {
Values []float64 `json:"values"`
}
type DifferenceItem ¶
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) 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 FlexibleEmbeddingResponse ¶
type FlexibleEmbeddingResponse struct {
Object string `json:"object"`
Data []FlexibleEmbeddingResponseItem `json:"data"`
Model string `json:"model"`
Usage `json:"usage"`
}
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 FunctionCallingConfig ¶
type FunctionCallingConfig struct {
Mode FunctionCallingConfigMode `json:"mode,omitempty"`
AllowedFunctionNames []string `json:"allowedFunctionNames,omitempty"`
}
type FunctionCallingConfigMode ¶
type FunctionCallingConfigMode string
type FunctionRequest ¶
type FunctionResponse ¶
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) 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 GeminiChatTool ¶
type GeminiChatTool struct {
GoogleSearch any `json:"googleSearch,omitempty"`
GoogleSearchRetrieval any `json:"googleSearchRetrieval,omitempty"`
CodeExecution any `json:"codeExecution,omitempty"`
FunctionDeclarations any `json:"functionDeclarations,omitempty"`
URLContext any `json:"urlContext,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 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"`
}
type GeminiImageInstance ¶
type GeminiImageInstance struct {
Prompt string `json:"prompt"`
}
type GeminiImageParameters ¶
type GeminiImagePrediction ¶
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 ¶
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 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 {
// Private wire evidence; upstream JSON cannot manufacture proof flags.
RawUsageObserved bool `json:"-"`
PromptTokensReported bool `json:"-"`
CandidatesTokensReported bool `json:"-"`
TotalTokensReported bool `json:"-"`
InvalidTokenEvidence bool `json:"-"`
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 (*GeminiUsageMetadata) UnmarshalJSON ¶
func (u *GeminiUsageMetadata) UnmarshalJSON(data []byte) error
Preserve explicit zero separately from absent/null counts at the wire boundary. Existing programmatically constructed DTOs retain their compatibility behavior.
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"`
// claude
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"`
}
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 ¶
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 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) 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 InputTokenDetails ¶
type InputTokenDetails struct {
CachedTokens int `json:"cached_tokens"`
CachedTokensDetails *CachedTokenDetails `json:"cached_tokens_details,omitempty"`
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 CloneInputTokenDetails ¶
func CloneInputTokenDetails(details InputTokenDetails) InputTokenDetails
CloneInputTokenDetails keeps optional cache modality details independent across raw billing snapshots and mutable settlement projections.
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 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 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"`
// contains filtered or unexported fields
}
func (*Message) GetReasoningContent ¶
func (*Message) IsStringContent ¶
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) SetStringContent ¶
func (*Message) SetToolCalls ¶
func (*Message) StringContent ¶
type MessageFile ¶
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 MessageVideoUrl ¶
type MessageVideoUrl struct {
Url string `json:"url"`
}
type ModelRoute ¶
type ModelRoute struct {
PublicModel string `json:"public_model"`
UpstreamModel string `json:"upstream_model"`
Endpoint string `json:"endpoint"`
Match string `json:"match"`
Priority int64 `json:"priority"`
}
ModelRoute is an explicit mapping for already-enabled public model names. Prefix matching never enables a model or derives a target by guessing a suffix.
type Notify ¶
type OpenAIEmbeddingResponse ¶
type OpenAIEmbeddingResponse struct {
Object string `json:"object"`
Data []OpenAIEmbeddingResponseItem `json:"data"`
Model string `json:"model"`
Usage `json:"usage"`
}
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 (r *OpenAIResponsesCompactionRequest) IsStream(c *http.Request) bool
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 ¶
func (o *OpenAIResponsesCompactionResponse) GetOpenAIError() *types.OpenAIError
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"`
}
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 ¶
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 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 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 PlayGroundRequest ¶
type RealTimeTool ¶
type RealtimeContent ¶
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 RealtimeResponse ¶
type RealtimeResponse struct {
ID string `json:"id,omitempty"`
Status string `json:"status,omitempty"`
Usage *RealtimeUsage `json:"usage"`
}
type RealtimeSession ¶
type RealtimeSession struct {
// Derived only from raw session settings; never accepted as wire metadata.
AutomaticResponseDisabled bool `json:"-"`
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"`
}
func (*RealtimeSession) UnmarshalJSON ¶
func (s *RealtimeSession) UnmarshalJSON(data []byte) error
Both beta and GA represent automatic response creation in turn detection. Missing settings are unknown, never proof that automatic generation is off.
type RealtimeUsage ¶
type RealtimeUsage struct {
// Local evidence only; upstream JSON cannot supply or clear these markers.
RawUsageObserved bool `json:"-"`
UsageIncomplete bool `json:"-"`
CachedTokensReported bool `json:"-"`
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"`
}
func (*RealtimeUsage) UnmarshalJSON ¶
func (u *RealtimeUsage) UnmarshalJSON(data []byte) error
Optional wire fields cannot establish a zero count when absent or null. Existing programmatically constructed compatibility values are unchanged.
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 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) SetModelName ¶
func (r *RerankRequest) SetModelName(modelName string)
type RerankResponse ¶
type RerankResponse struct {
Results []RerankResponseResult `json:"results"`
Usage Usage `json:"usage"`
}
type RerankResponseResult ¶
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"`
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"`
}
func (*ResponsesOutput) ArgumentsString ¶
func (r *ResponsesOutput) ArgumentsString() string
ArgumentsString returns function call arguments in the string form expected by Chat Completions.
type ResponsesOutputContent ¶
type ResponsesStreamResponse ¶
type ResponsesStreamResponse struct {
Type string `json:"type"`
Response *OpenAIResponsesResponse `json:"response,omitempty"`
Delta string `json:"delta,omitempty"`
Item *ResponsesOutput `json:"item,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 ResponsesTextEvidence ¶
type ResponsesTextEvidence struct {
Model string `json:"model"`
ServiceTier string `json:"service_tier"`
CacheRead *int `json:"cache_read"`
CacheWrite *int `json:"cache_write"`
}
ResponsesTextEvidence retains raw field presence for strict fee accounting. Value-only compatibility DTO counters cannot prove an omitted cache count is zero.
type RetrievalConfig ¶
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 SimpleResponse ¶
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 TestResult ¶
type TestResult struct {
Name string `json:"name"`
Status string `json:"status"`
Error string `json:"error,omitempty"`
}
TestResult 上游测试连通性结果
type TextResponse ¶
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 ¶
type TokenHubSettings ¶
type TokenHubSettings struct {
Enabled bool `json:"enabled,omitempty"`
BaseURL string `json:"base_url,omitempty"`
Region string `json:"region,omitempty"`
Protocol string `json:"protocol,omitempty"`
ModelListPath string `json:"model_list_path,omitempty"`
HealthPath string `json:"health_path,omitempty"`
AllowModelDiscovery bool `json:"allow_model_discovery,omitempty"`
ModelAliases map[string]string `json:"model_aliases,omitempty"`
}
TokenHubSettings describes the non-secret connection contract for a TokenHub-compatible gateway. Enabled must be set explicitly; an absent value preserves legacy channel behaviour.
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 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"`
OutputTokensDetails *OutputTokenDetails `json:"output_tokens_details,omitempty"`
// 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"`
}
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"`
}
Source Files
¶
- alpha_search_request.go
- audio.go
- billing_usage.go
- channel_settings.go
- claude.go
- claude_usage_evidence.go
- embedding.go
- error.go
- gemini.go
- gemini_usage_evidence.go
- model_route.go
- notify.go
- openai_compaction.go
- openai_image.go
- openai_request.go
- openai_response.go
- openai_responses_compaction_request.go
- openai_video.go
- playground.go
- pricing.go
- ratio_sync.go
- realtime.go
- realtime_session_evidence.go
- realtime_usage_evidence.go
- request_common.go
- rerank.go
- sensitive.go
- user_settings.go
- values.go