Documentation
¶
Overview ¶
Package objects contains some objects need used by schema and biz. To avoid circular dependencies, we put them here. NOTE: there are some history issue, the json tag is not consistent. To reduce the maintenance cost, we keep the json tag as it is. For the new objects, we will use the same json tag, just use the camel case.
Index ¶
- Constants
- Variables
- func ConvertGUIDPtrToInt(guid *GUID) (int, error)
- func ConvertGUIDPtrToIntPtr(guid *GUID) (*int, error)
- func ConvertGUIDPtrsToIntPtrs(guid []*GUID) ([]*int, error)
- func ConvertGUIDPtrsToInts(guid []*GUID) ([]int, error)
- func ConvertGUIDToInt(guid GUID) (int, error)
- func ConvertGUIDToIntPtr(guid GUID) (*int, error)
- func Evaluate(condition Condition, data any) bool
- func IntGuids(guids []*GUID) []int
- func IsSupportedInboundAPIFormat(protocol string) bool
- func MarshalDecimal(d decimal.Decimal) graphql.Marshaler
- func MatchChannelTags(allowedTags []string, matchMode ChannelTagsMatchMode, channelTags []string) bool
- func ProtocolPoolKeyForAPIFormat(apiFormat string) (string, bool)
- func SerializeOverrideOperations(ops []OverrideOperation) (string, error)
- func ToExpr(condition Condition) (string, error)
- func UnmarshalDecimal(v any) (decimal.Decimal, error)
- type APIKeyProfile
- type APIKeyProfiles
- type APIKeyQuota
- type APIKeyQuotaCalendarDuration
- type APIKeyQuotaCalendarDurationUnit
- type APIKeyQuotaPastDuration
- type APIKeyQuotaPastDurationUnit
- type APIKeyQuotaPeriod
- type APIKeyQuotaPeriodType
- type AdapterDiagnostic
- type AdapterRuntimeStatus
- type AdapterSnapshot
- type AdapterTargetCapabilities
- type AzureCredential
- type CapabilityPolicy
- type ChannelCredentials
- type ChannelEndpoint
- type ChannelModelAssociation
- type ChannelModelCapability
- type ChannelModelKey
- type ChannelPolicies
- type ChannelProtocolCapabilities
- type ChannelProviderQuotaSettings
- type ChannelRateLimit
- type ChannelRegexAssociation
- type ChannelSettings
- type ChannelTagsMatchMode
- type ChannelTagsModelAssociation
- type ChannelTagsRegexAssociation
- type Condition
- type ConditionType
- type CostItem
- type DailyTimeRange
- type DataStorageSettings
- type DateRange
- type DisabledAPIKey
- type Error
- type ErrorResponse
- type ExcludeAssociation
- type GCPCredential
- type GCPCredentialsJSON
- type GCS
- type GUID
- type HeaderEntry
- type JSONRawMessage
- type ModelAssociation
- type ModelAssociationWhen
- type ModelCard
- type ModelCardCost
- type ModelCardLimit
- type ModelCardModalities
- type ModelCardReasoning
- type ModelIDAssociation
- type ModelMapping
- type ModelPrice
- type ModelPriceItem
- type ModelSettings
- type OAuthCredentials
- type OIDCIdentityInfo
- type OpenCodeGoQuotaSettings
- type OverrideMatch
- type OverrideOperation
- type OverrideWhen
- type PriceItemCode
- type PriceOverride
- type PriceSchedule
- type PriceTier
- type Pricing
- type PricingMode
- type ProjectProfile
- type ProjectProfiles
- type PromptAction
- type PromptActionType
- type PromptActivationCondition
- type PromptActivationConditionComposite
- type PromptActivationConditionType
- type PromptProtectionAction
- type PromptProtectionScope
- type PromptProtectionSettings
- type PromptSettings
- type PromptWriteCacheVariant
- type PromptWriteCacheVariantCode
- type ProxyConfig
- type ProxyType
- type QianwenQuotaSettings
- type RegexAssociation
- type RetryableErrorPattern
- type RoleInfo
- type RuntimeAdapter
- type RuntimeAdapterBinding
- type RuntimeModel
- type S3
- type TierCost
- type TieredPricing
- type TransformOptions
- type UserInfo
- type UserProjectInfo
- type WebDAV
Constants ¶
const ( ChannelEndpointTransportHTTP = "http" ChannelEndpointTransportWebSocket = "websocket" )
const ( OverrideOpSet = "set" OverrideOpSetIfAbsent = "set_if_absent" OverrideOpDelete = "delete" OverrideOpRename = "rename" OverrideOpCopy = "copy" OverrideOpArrayAppend = "array_append" OverrideOpArrayPrepend = "array_prepend" OverrideOpArrayInsert = "array_insert" OverrideOpArrayRemove = "array_remove" )
Override operation types.
const ( ModelAssociationConditionFieldPromptTokens = "prompt_tokens" ModelAssociationConditionFieldStream = "stream" ModelAssociationConditionFieldRequestFormat = "request_format" ModelAssociationConditionFieldDailyTime = "daily_time" ModelAssociationConditionFieldHasImage = "has_image" ModelAssociationConditionFieldHasVideo = "has_video" ModelAssociationConditionFieldHasDocument = "has_document" ModelAssociationConditionFieldHasAudio = "has_audio" ModelAssociationConditionFieldRequestHeader = "request_header" ModelAssociationConditionFieldRequestHeaderPrefix = "request_header." )
Variables ¶
var SupportedInboundAPIFormats = map[string]struct{}{
"openai": {},
"openai_responses": {},
"anthropic": {},
}
SupportedInboundAPIFormats 是协议池允许的入站协议。协议池 key 同时决定出站协议。
Functions ¶
func ConvertGUIDPtrToInt ¶
func ConvertGUIDPtrToIntPtr ¶
func ConvertGUIDPtrsToInts ¶
func ConvertGUIDToInt ¶
ConvertGUIDToInt converts a GUID to an int id. TODO: validate the type from the context.
func ConvertGUIDToIntPtr ¶
func IsSupportedInboundAPIFormat ¶
IsSupportedInboundAPIFormat 判断协议池 key 是否在当前支持的协议族白名单内。
func MatchChannelTags ¶
func MatchChannelTags(allowedTags []string, matchMode ChannelTagsMatchMode, channelTags []string) bool
func ProtocolPoolKeyForAPIFormat ¶
ProtocolPoolKeyForAPIFormat 返回完整入站 API 格式对应的协议池 key。
func SerializeOverrideOperations ¶
func SerializeOverrideOperations(ops []OverrideOperation) (string, error)
SerializeOverrideOperations converts override operations to a JSON string for storage.
Types ¶
type APIKeyProfile ¶
type APIKeyProfile struct {
Name string `json:"name"`
ModelMappings []ModelMapping `json:"modelMappings"`
Quota *APIKeyQuota `json:"quota,omitempty"`
LoadBalanceStrategy *string `json:"loadBalanceStrategy,omitempty"`
ChannelIDs []int `json:"channelIDs,omitempty"`
ChannelTags []string `json:"channelTags,omitempty"`
ChannelTagsMatchMode ChannelTagsMatchMode `json:"channelTagsMatchMode,omitempty"`
ModelIDs []string `json:"modelIDs,omitempty"`
}
func (*APIKeyProfile) Clone ¶
func (p *APIKeyProfile) Clone() *APIKeyProfile
func (*APIKeyProfile) MatchChannelTags ¶
func (p *APIKeyProfile) MatchChannelTags(tags []string) bool
type APIKeyProfiles ¶
type APIKeyProfiles struct {
ActiveProfile string `json:"activeProfile"`
Profiles []APIKeyProfile `json:"profiles"`
}
type APIKeyQuota ¶
type APIKeyQuota struct {
Requests *int64 `json:"requests,omitempty"`
TotalTokens *int64 `json:"totalTokens,omitempty"`
Cost *decimal.Decimal `json:"cost,omitempty"`
Period APIKeyQuotaPeriod `json:"period"`
}
type APIKeyQuotaCalendarDuration ¶
type APIKeyQuotaCalendarDuration struct {
Unit APIKeyQuotaCalendarDurationUnit `json:"unit"`
}
type APIKeyQuotaCalendarDurationUnit ¶
type APIKeyQuotaCalendarDurationUnit string
const ( APIKeyQuotaCalendarDurationUnitDay APIKeyQuotaCalendarDurationUnit = "day" APIKeyQuotaCalendarDurationUnitMonth APIKeyQuotaCalendarDurationUnit = "month" )
type APIKeyQuotaPastDuration ¶
type APIKeyQuotaPastDuration struct {
Value int64 `json:"value"`
Unit APIKeyQuotaPastDurationUnit `json:"unit"`
}
type APIKeyQuotaPastDurationUnit ¶
type APIKeyQuotaPastDurationUnit string
const ( APIKeyQuotaPastDurationUnitMinute APIKeyQuotaPastDurationUnit = "minute" APIKeyQuotaPastDurationUnitHour APIKeyQuotaPastDurationUnit = "hour" APIKeyQuotaPastDurationUnitDay APIKeyQuotaPastDurationUnit = "day" )
type APIKeyQuotaPeriod ¶
type APIKeyQuotaPeriod struct {
Type APIKeyQuotaPeriodType `json:"type"`
PastDuration *APIKeyQuotaPastDuration `json:"pastDuration,omitempty"`
CalendarDuration *APIKeyQuotaCalendarDuration `json:"calendarDuration,omitempty"`
}
type APIKeyQuotaPeriodType ¶
type APIKeyQuotaPeriodType string
const ( APIKeyQuotaPeriodTypeAllTime APIKeyQuotaPeriodType = "all_time" APIKeyQuotaPeriodTypePastDuration APIKeyQuotaPeriodType = "past_duration" APIKeyQuotaPeriodTypeCalendarDuration APIKeyQuotaPeriodType = "calendar_duration" )
type AdapterDiagnostic ¶
type AdapterDiagnostic struct {
AdapterName string
SourceModelID string
TargetID int
ChannelID int
TargetModelID string
Reason string
}
AdapterDiagnostic 描述快照构建时被排除的目标或配置问题。
type AdapterRuntimeStatus ¶
type AdapterRuntimeStatus struct {
SnapshotVersion uint64
RefreshedAt time.Time
LastSuccessfulRefreshAt time.Time
LastRefreshError string
}
AdapterRuntimeStatus 描述最近一次刷新结果,失败时不会影响当前快照。
type AdapterSnapshot ¶
type AdapterSnapshot struct {
Version uint64
RefreshedAt time.Time
LastSuccessfulRefreshAt time.Time
Adapters map[string]*RuntimeAdapter
Diagnostics []AdapterDiagnostic
}
AdapterSnapshot 是一次完整的适配器运行时快照。 Adapters、map 和切片在发布后只读,刷新通过一次原子替换整体生效。
type AdapterTargetCapabilities ¶
type AdapterTargetCapabilities struct {
SupportsTools bool `json:"supports_tools"`
SupportsStream bool `json:"supports_stream"`
SupportsReasoning bool `json:"supports_reasoning"`
ContextLength int `json:"context_length,omitempty"`
MaxOutputTokens int `json:"max_output_tokens,omitempty"`
// StreamPolicy 目标级流式响应策略:"unlimited"(跟随下游)、"require"(强制流式)、"forbid"(禁止流式)。
// 空字符串表示旧数据,按 supports_stream bool 兼容处理。
StreamPolicy string `json:"stream_policy,omitempty"`
InputModalities []string `json:"input_modalities"`
OutputModalities []string `json:"output_modalities"`
}
AdapterTargetCapabilities 描述适配器目标显式声明的能力。 零值表示目标未声明该能力,因此不会被能力过滤视为支持。
type AzureCredential ¶
type AzureCredential struct {
// APIVersion is a optional version for the channel.
APIVersion string `json:"apiVersion"`
}
type CapabilityPolicy ¶
type CapabilityPolicy string
const ( CapabilityPolicyUnlimited CapabilityPolicy = "unlimited" CapabilityPolicyRequire CapabilityPolicy = "require" CapabilityPolicyForbid CapabilityPolicy = "forbid" )
type ChannelCredentials ¶
type ChannelCredentials struct {
// APIKey is the API key for the channel, for the single key channel, e.g. Codex, Claude code, Antigravity.
// It is kept for backward compatibility with existing data, recommend to use OAuth instead.
APIKey string `json:"apiKey,omitempty"`
// OAuth is the OAuth credentials for the channel, for the OAuth channel, e.g. Codex, Claude code, Antigravity.
OAuth *OAuthCredentials `json:"oauth,omitempty"`
// APIKeys is a list of API keys for the channel.
// When multiple keys are provided, they will be used in a round-robin fashion.
APIKeys []string `json:"apiKeys,omitempty"`
// Azure configuration for the channel.
Azure *AzureCredential `json:"azure,omitempty"`
// GCP is the GCP credentials for the channel.
GCP *GCPCredential `json:"gcp,omitempty"`
}
func (*ChannelCredentials) GetAllAPIKeys ¶
func (c *ChannelCredentials) GetAllAPIKeys() []string
GetAllAPIKeys returns all API keys for the channel, combining APIKey and APIKeys fields. This ensures backward compatibility with old data that only has APIKey set.
func (*ChannelCredentials) GetEnabledAPIKeys ¶
func (c *ChannelCredentials) GetEnabledAPIKeys(disabledKeys []DisabledAPIKey) []string
GetEnabledAPIKeys returns API keys that are not disabled.
func (*ChannelCredentials) IsOAuth ¶
func (c *ChannelCredentials) IsOAuth() bool
IsOAuth returns true if OAuth credentials are configured and valid. It checks both the new OAuth field and legacy APIKey field for backward compatibility.
type ChannelEndpoint ¶
type ChannelEndpoint struct {
APIFormat string `json:"api_format"`
Path string `json:"path,omitempty"`
BaseURL string `json:"base_url,omitempty"`
Transport string `json:"transport,omitempty"`
}
ChannelEndpoint represents an outbound API endpoint configuration within a Channel. Each endpoint specifies the upstream API format and an optional custom path override. Within a single channel, api_format must be unique.
type ChannelModelAssociation ¶
type ChannelModelCapability ¶
type ChannelModelCapability struct {
ModelID string `json:"modelId"`
Protocols []string `json:"protocols"`
}
ChannelModelCapability 描述渠道上单个物理模型支持的协议族。
type ChannelModelKey ¶
ChannelModelKey 用于对象层校验,避免引入业务 matcher 包。
type ChannelPolicies ¶
type ChannelPolicies struct {
Stream CapabilityPolicy `json:"stream,omitempty"`
}
type ChannelProtocolCapabilities ¶
type ChannelProtocolCapabilities struct {
DeclaredProtocols []string `json:"declaredProtocols"`
Models []ChannelModelCapability `json:"models"`
}
ChannelProtocolCapabilities 描述渠道声明的协议族与逐模型协议例外。
type ChannelProviderQuotaSettings ¶
type ChannelProviderQuotaSettings struct {
OpencodeGo *OpenCodeGoQuotaSettings `json:"opencodeGo,omitempty"`
Qianwen *QianwenQuotaSettings `json:"qianwen,omitempty"`
}
type ChannelRateLimit ¶
type ChannelRateLimit struct {
RPM *int64 `json:"rpm,omitempty"` // Requests Per Minute, nil = unlimited
TPM *int64 `json:"tpm,omitempty"` // Tokens Per Minute, nil = unlimited
MaxConcurrent *int64 `json:"maxConcurrent,omitempty"` // Maximum concurrent requests, nil = unlimited
// QueueSize controls the limiter mode when MaxConcurrent is set:
// nil / 0 = soft mode (count only, no blocking, no rejection — preserves PR #1322 scoring behaviour)
// > 0 = hard mode (FIFO wait queue with bounded capacity; excess requests rejected)
// Has no effect when MaxConcurrent is unset or <= 0.
QueueSize *int64 `json:"queueSize,omitempty"`
// QueueTimeoutMs is the per-channel queue wait timeout in milliseconds.
// nil / 0 = no per-channel timeout (only the request context bounds the wait)
// > 0 = waiters that exceed this duration receive ErrChannelQueueTimeout
// Only meaningful in hard mode (QueueSize > 0).
QueueTimeoutMs *int64 `json:"queueTimeoutMs,omitempty"`
}
type ChannelRegexAssociation ¶
type ChannelSettings ¶
type ChannelSettings struct {
// ExtraModelPrefix sets the channel accept the model with the extra prefix.
// e.g. a channel
// supported_modles is ["deepseek-chat", "deepseek-reasoner"]
// extraModelPrefix is "deepseek"
// then the model "deepseek-chat", "deepseek-reasoner", "deepseek/deepseek-chat", "deepseek/deepseek-reasoner" will be accepted.
// And if other channel support "deepseek/deepseek-chat", "deepseek/deepseek-reasoner" modles, the two channels can accept the request both.
ExtraModelPrefix string `json:"extraModelPrefix"`
// AutoTrimedModelPrefixes configures prefixes to automatically trim the model name when added to supported models.
// e.g. a channel
// supported_modles is ["deepseek-ai/deepseek-chat", "openai/gpt-4"]
// autoTrimedModelPrefixes is ["openai", "deepseek"]
// then the model "openai/gpt-4", "deepseek/deepseek-chat", "deepseek-chat", "gpt-4" will be accepted.
AutoTrimedModelPrefixes []string `json:"autoTrimedModelPrefixes"`
// ModelMappings add model alias for the model in the channels.
// e.g. {"from": "deepseek-chat", "to": "deepseek/deepseek-chat"} will add a alias "deepseek-chat" for "deepseek/deepseek-chat".
ModelMappings []ModelMapping `json:"modelMappings"`
// HideOriginalModels hides the original models from the model list when model mappings are configured.
// When enabled, only the mapped model names (from field) will be exposed, not the actual model names (to field).
HideOriginalModels bool `json:"hideOriginalModels"`
// HideMappedModels hides the mapped models from the model list when model mappings are configured.
// When enabled, only the original model names (from field) will be exposed, not the mapped model names (to field).
HideMappedModels bool `json:"hideMappedModels"`
// LowercaseModelID converts model name matching keys to lowercase.
// When enabled, only RequestModel (used for matching) is lowercased; ActualModel
// (sent to provider) preserves original casing. This enables cross-channel load
// balancing where providers use different casing for the same model.
LowercaseModelID bool `json:"lowercaseModelId"`
// OverrideParameters sets the channel override the request body.
// A json string.
// e.g. {"max_tokens": 100}, {"temperature": 0.7}
// Deprecated Use bodyOverrideOperations instead.
OverrideParameters string `json:"overrideParameters"`
// BodyOverrideOperations sets the channel override operations for the request body.
// When present (including an empty array), it takes precedence over OverrideParameters.
BodyOverrideOperations []OverrideOperation `json:"bodyOverrideOperations,omitempty"`
// OverrideHeaders sets the channel override the request headers.
// e.g. [{"key": "User-Agent", "value": "llm-proxy"}]
// Supported ops: set (default), delete, rename, copy.
// Deprecated Use headerOverrideOperations instead.
OverrideHeaders []HeaderEntry `json:"overrideHeaders"`
// HeaderOverrideOperations sets the channel override operations for request headers.
// When present (including an empty array), it takes precedence over OverrideHeaders.
HeaderOverrideOperations []OverrideOperation `json:"headerOverrideOperations,omitempty"`
// Proxy configuration for the channel. If not set, defaults to environment proxy type.
Proxy *httpclient.ProxyConfig `json:"proxy,omitempty"`
// TransformOptions configures the transform options for the channel.
TransformOptions TransformOptions `json:"transformOptions"`
// PassThroughUserAgent controls whether to pass through the original User-Agent header to upstream AI providers.
// When set to nil, it inherits from the global system setting.
// When set to true/false, it overrides the global setting.
PassThroughUserAgent *bool `json:"passThroughUserAgent,omitempty"`
// PassThroughBody controls whether to forward the original request body directly
// to the upstream provider and the raw provider response/stream directly to the client
// without re-serialization through the transform pipelines.
// Only effective when the inbound and outbound API formats are identical.
// When set to nil, it inherits from the global system setting.
// When set to true/false, it overrides the global setting.
PassThroughBody *bool `json:"passThroughBody,omitempty"`
// RateLimit configures the upstream rate limit for the channel.
// When configured, the load balancer will skip channels that have exceeded their rate limits.
RateLimit *ChannelRateLimit `json:"rateLimit,omitempty"`
// RetryableStatusCodes configures additional HTTP status codes that should
// trigger retry for this channel. Default retryable codes (429 and 5xx) are
// always handled by the retry policy even when this list is empty.
RetryableStatusCodes []int `json:"retryableStatusCodes,omitempty"`
// RetryableErrorPatterns configures additional error text patterns that should
// trigger retry for this channel. When Regex is false, Pattern is matched as a
// case-sensitive substring of the error text.
RetryableErrorPatterns []RetryableErrorPattern `json:"retryableErrorPatterns,omitempty"`
// ProviderQuota stores provider-specific credentials used only for quota
// polling. Keep upstream request credentials in ChannelCredentials.
ProviderQuota *ChannelProviderQuotaSettings `json:"providerQuota,omitempty"`
}
type ChannelTagsMatchMode ¶
type ChannelTagsMatchMode string
ChannelTagsMatchMode controls how profile channel tags are matched. If this enum is changed, update MatchChannelTags in this file.
const ( ChannelTagsMatchModeAny ChannelTagsMatchMode = "any" ChannelTagsMatchModeAll ChannelTagsMatchMode = "all" ChannelTagsMatchModeNone ChannelTagsMatchMode = "none" )
func (ChannelTagsMatchMode) IsValid ¶
func (m ChannelTagsMatchMode) IsValid() bool
func (ChannelTagsMatchMode) OrDefault ¶
func (m ChannelTagsMatchMode) OrDefault() ChannelTagsMatchMode
type Condition ¶
type Condition struct {
Type ConditionType `json:"type"`
Logic string `json:"logic,omitempty"`
Conditions []Condition `json:"conditions,omitempty"`
Field string `json:"field,omitempty"`
Operator string `json:"operator,omitempty"`
Value any `json:"value,omitempty"`
}
func (*Condition) UnmarshalJSON ¶
type ConditionType ¶
type ConditionType string
const ( ConditionTypeCondition ConditionType = "condition" ConditionTypeGroup ConditionType = "group" )
type CostItem ¶
type CostItem struct {
ItemCode PriceItemCode `json:"itemCode"`
PromptWriteCacheVariantCode PromptWriteCacheVariantCode `json:"promptWriteCacheVariantCode,omitempty"`
Quantity int64 `json:"quantity"`
TierBreakdown []TierCost `json:"tierBreakdown,omitempty"`
Subtotal decimal.Decimal `json:"subtotal"`
}
type DailyTimeRange ¶
type DailyTimeRange struct {
// Start is the start time in "HH:mm" format.
Start string `json:"start"`
// End is the end time in "HH:mm" format.
End string `json:"end"`
}
DailyTimeRange defines a daily time range. Start and End are in "HH:mm" format (e.g. "03:00", "18:30").
func (*DailyTimeRange) Equals ¶
func (d *DailyTimeRange) Equals(other *DailyTimeRange) bool
func (*DailyTimeRange) Validate ¶
func (d *DailyTimeRange) Validate() error
type DataStorageSettings ¶
type DataStorageSettings struct {
// DSN is the database data storage.
DSN *string `json:"dsn"`
// Directory is the directory of the fs data storage.
Directory *string `json:"directory"`
// S3 is the s3 data storage.
S3 *S3 `json:"s3"`
// GCS is the gcs data storage.
GCS *GCS `json:"gcs"`
// WebDAV is the webdav data storage.
WebDAV *WebDAV `json:"webdav"`
}
type DateRange ¶
type DateRange struct {
// Start is the start date in "YYYY-MM-DD" format (inclusive).
Start string `json:"start"`
// End is the end date in "YYYY-MM-DD" format (inclusive).
End string `json:"end"`
}
DateRange defines a date range.
type DisabledAPIKey ¶
type DisabledAPIKey struct {
Key string `json:"key"`
DisabledAt time.Time `json:"disabledAt"`
ErrorCode int `json:"errorCode"`
Reason string `json:"reason,omitempty"`
}
DisabledAPIKey 记录被禁用的 API key 信息(敏感,按 credentials 同级保护) 注意:禁用判断以 Key 明文为主键。
type ErrorResponse ¶
type ErrorResponse struct {
Error Error `json:"error"`
}
type ExcludeAssociation ¶
type GCPCredential ¶
type GCPCredentialsJSON ¶
type GCPCredentialsJSON struct {
Type string `json:"type" validate:"required"`
ProjectID string `json:"projectID" validate:"required"`
PrivateKeyID string `json:"privateKeyID" validate:"required"`
PrivateKey string `json:"privateKey" validate:"required"`
ClientEmail string `json:"clientEmail" validate:"required"`
ClientID string `json:"clientID" validate:"required"`
AuthURI string `json:"authURI" validate:"required"`
TokenURI string `json:"tokenURI" validate:"required"`
AuthProviderX509CertURL string `json:"authProviderX509CertURL" validate:"required"`
ClientX509CertURL string `json:"clientX509CertURL" validate:"required"`
UniverseDomain string `json:"universeDomain" validate:"required"`
}
type HeaderEntry ¶
type JSONRawMessage ¶
type JSONRawMessage []byte
func (JSONRawMessage) MarshalGQL ¶
func (m JSONRawMessage) MarshalGQL(w io.Writer)
MarshalGQL returns m as the JSON encoding of m.
func (JSONRawMessage) MarshalJSON ¶
func (m JSONRawMessage) MarshalJSON() ([]byte, error)
MarshalJSON returns m as the JSON encoding of m.
func (*JSONRawMessage) UnmarshalGQL ¶
func (m *JSONRawMessage) UnmarshalGQL(v any) error
UnmarshalGQL sets *m to a copy of data.
func (*JSONRawMessage) UnmarshalJSON ¶
func (m *JSONRawMessage) UnmarshalJSON(data []byte) error
UnmarshalJSON sets *m to a copy of data.
type ModelAssociation ¶
type ModelAssociation struct {
// channel_model: the specified model id in the specified channel
// channel_regex: the specified pattern in the specified channel
// regex: the pattern for all channels
// model: the specified model id
// channel_tags_model: the specified model id in channels with specified tags (OR logic)
// channel_tags_regex: the specified pattern in channels with specified tags (OR logic)
Type string `json:"type"`
Priority int `json:"priority"` // Lower value = higher priority, default 0
Disabled bool `json:"disabled"`
Auto bool `json:"auto,omitempty"`
DisabledReason string `json:"disabledReason,omitempty"`
When *ModelAssociationWhen `json:"when,omitempty"`
ChannelModel *ChannelModelAssociation `json:"channelModel"`
ChannelRegex *ChannelRegexAssociation `json:"channelRegex"`
Regex *RegexAssociation `json:"regex"`
ModelID *ModelIDAssociation `json:"modelId"`
ChannelTagsModel *ChannelTagsModelAssociation `json:"channelTagsModel"`
ChannelTagsRegex *ChannelTagsRegexAssociation `json:"channelTagsRegex"`
}
type ModelAssociationWhen ¶
type ModelCard ¶
type ModelCard struct {
Reasoning ModelCardReasoning `json:"reasoning"`
ToolCall bool `json:"toolCall"`
Temperature bool `json:"temperature"`
Modalities ModelCardModalities `json:"modalities"`
Vision bool `json:"vision"`
Cost ModelCardCost `json:"cost"`
Limit ModelCardLimit `json:"limit"`
Knowledge string `json:"knowledge"`
ReleaseDate string `json:"releaseDate"`
LastUpdated string `json:"lastUpdated"`
}
type ModelCardCost ¶
type ModelCardLimit ¶
type ModelCardModalities ¶
type ModelCardReasoning ¶
type ModelIDAssociation ¶
type ModelIDAssociation struct {
ModelID string `json:"modelId"`
Exclude []*ExcludeAssociation `json:"exclude"`
}
type ModelMapping ¶
type ModelPrice ¶
type ModelPrice struct {
// Items is the list of price items for the price.
Items []ModelPriceItem `json:"items"`
// Schedule is the optional time-based price override configuration.
Schedule *PriceSchedule `json:"schedule,omitempty"`
}
ModelPrice is the price for the thing.
func (*ModelPrice) Equals ¶
func (p *ModelPrice) Equals(other ModelPrice) bool
func (*ModelPrice) Validate ¶
func (p *ModelPrice) Validate() error
type ModelPriceItem ¶
type ModelPriceItem struct {
// ItemCode is the code of the item.
ItemCode PriceItemCode `json:"itemCode"`
// Pricing is the pricing for the item.
Pricing Pricing `json:"pricing"`
// PromptWriteCacheVariants is the list of variants for the item prompt write cached tokens.
// If the variants present, it will find the variant price first, if not hit, it will use the item pricing.
PromptWriteCacheVariants []PromptWriteCacheVariant `json:"promptWriteCacheVariants,omitempty"`
}
func (*ModelPriceItem) Equals ¶
func (i *ModelPriceItem) Equals(other *ModelPriceItem) bool
func (*ModelPriceItem) FindPromptWriteCacheVariantPricing ¶
func (i *ModelPriceItem) FindPromptWriteCacheVariantPricing(variantCode PromptWriteCacheVariantCode) Pricing
FindPromptWriteCacheVariantPricing finds the variant pricing for the item prompt write cached tokens. If the variant pricing is not found, it will return the item pricing.
func (*ModelPriceItem) Validate ¶
func (i *ModelPriceItem) Validate() error
type ModelSettings ¶
type ModelSettings struct {
DisableDeveloperSettingsInheritance bool `json:"disableDeveloperSettingsInheritance"`
ProtocolPools map[string][]*ModelAssociation `json:"protocolPools,omitempty"`
}
func (*ModelSettings) ValidateProtocolPools ¶
func (s *ModelSettings) ValidateProtocolPools() error
ValidateProtocolPools 校验协议池结构,避免旧 settings 被静默转换或写入非法协议。
type OAuthCredentials ¶
type OAuthCredentials = oauth.OAuthCredentials
type OIDCIdentityInfo ¶
type OpenCodeGoQuotaSettings ¶
type OverrideMatch ¶
type OverrideMatch struct {
// Path is resolved relative to each array item.
Path string `json:"path"`
// Eq is the value that removes the item when it matches.
Eq string `json:"eq"`
}
OverrideMatch defines a simple equality matcher for array_remove operations.
type OverrideOperation ¶
type OverrideOperation struct {
Op string `json:"op"`
Path string `json:"path,omitempty"`
From string `json:"from,omitempty"`
To string `json:"to,omitempty"`
Value string `json:"value,omitempty"`
Condition string `json:"condition,omitempty"`
// Match identifies array items removed by array_remove.
Match *OverrideMatch `json:"match,omitempty"`
// Index is the target position for array_insert. Only used by array_insert.
// Negative values count from the end (-1 = before last). Out-of-range values are clamped to [0, len].
Index *int `json:"index,omitempty"`
// Splat controls whether a JSON-array value is spread into the target array
// (true: each element inserted individually) or inserted as a single nested element (false).
// Only meaningful for array_append, array_prepend, and array_insert. Defaults to true.
Splat *bool `json:"splat,omitempty"`
}
OverrideOperation defines a structured override operation for request body/header manipulation.
func HeaderEntriesToOverrideOperations ¶
func HeaderEntriesToOverrideOperations(headers []HeaderEntry) []OverrideOperation
func ParseOverrideOperations ¶
func ParseOverrideOperations(raw string) ([]OverrideOperation, error)
ParseOverrideOperations parses the override parameters string. Supports both legacy map format (JSON object) and new operation array format (JSON array). Legacy format is automatically converted to OverrideOperation slice.
type OverrideWhen ¶
type OverrideWhen struct {
// DailyTime is the daily time range with structured start/end times.
DailyTime *DailyTimeRange `json:"dailyTime,omitempty"`
// Weekdays is the list of weekdays (1=Monday, 7=Sunday) when the override is active.
Weekdays []int `json:"weekdays,omitempty"`
// DateRange is the date range when the override is active.
DateRange *DateRange `json:"dateRange,omitempty"`
}
OverrideWhen defines the conditions for a price override to take effect.
func (*OverrideWhen) Equals ¶
func (w *OverrideWhen) Equals(other *OverrideWhen) bool
func (*OverrideWhen) Validate ¶
func (w *OverrideWhen) Validate() error
type PriceItemCode ¶
type PriceItemCode string
const ( // PriceItemCodeUsage is the price item code for the token usage. PriceItemCodeUsage PriceItemCode = "prompt_tokens" // PriceItemCodeCompletion is the price item code for the token completion. PriceItemCodeCompletion PriceItemCode = "completion_tokens" // PriceItemCodePromptCachedToken is the price item code for the cached token usage. PriceItemCodePromptCachedToken PriceItemCode = "prompt_cached_tokens" // PriceItemCodeWriteCachedTokens is the price item code for the cached token write. //nolint:gosec // not token. PriceItemCodeWriteCachedTokens PriceItemCode = "prompt_write_cached_tokens" )
type PriceOverride ¶
type PriceOverride struct {
// Name is the human-readable name for this override, e.g. "Night Discount".
Name string `json:"name"`
// Priority determines the order of evaluation. Lower values have higher priority.
Priority int `json:"priority"`
// When defines the conditions for this override to take effect.
When OverrideWhen `json:"when"`
// Items is the price configuration to use when this override is active.
Items []ModelPriceItem `json:"items"`
}
PriceOverride defines a single time-based price override rule.
func (*PriceOverride) Equals ¶
func (o *PriceOverride) Equals(other *PriceOverride) bool
func (*PriceOverride) Validate ¶
func (o *PriceOverride) Validate() error
type PriceSchedule ¶
type PriceSchedule struct {
// Timezone is the IANA timezone name, e.g. "Asia/Shanghai".
Timezone string `json:"timezone"`
// Overrides is the list of time-based price override rules.
Overrides []PriceOverride `json:"overrides"`
}
PriceSchedule defines time-based price override configuration.
func (*PriceSchedule) Equals ¶
func (s *PriceSchedule) Equals(other *PriceSchedule) bool
func (*PriceSchedule) Validate ¶
func (s *PriceSchedule) Validate() error
type PriceTier ¶
type PriceTier struct {
// UpTo is the upper bound of the token usage for the price tier.
// If the upper bound is nil, it means no upper bound, it must be the last price tier.
UpTo *int64 `json:"upTo,omitempty"`
// PricePerUnit is the price per token for the price tier.
PricePerUnit decimal.Decimal `json:"pricePerUnit"`
}
PriceTier is the price tier for the tiered pricing.
type Pricing ¶
type Pricing struct {
Mode PricingMode `json:"mode"`
// FlatFee is the fixed fee for the pricing.
FlatFee *decimal.Decimal `json:"flatFee,omitempty"`
// UsagePerUnit is the price per token for the pricing.
UsagePerUnit *decimal.Decimal `json:"usagePerUnit,omitempty"`
// UsageTiered is the tiered pricing for the pricing.
// Used by both UsageTiered and UsageVolume modes — they share the same data structure
// but differ in calculation logic.
UsageTiered *TieredPricing `json:"usageTiered,omitempty"`
}
type PricingMode ¶
type PricingMode string
const ( // PricingModeFlatFee means the request is charged a fixed fee. PricingModeFlatFee PricingMode = "flat_fee" // PricingModeUsagePerUnit means the request is charged a fee bases on the token usage. // e.g. $0.01 per token, if the usage is 1,500 then the fee is $0.01 x 1,500 = $15.00. PricingModeUsagePerUnit PricingMode = "usage_per_unit" // PricingModeTiered means the request is charged a fee based on the token usage tiers. // Each tier segment is billed separately at its own rate. // e.g. tiers are [{upTo: 1000, pricePerUnit: $0.01}, {upTo: nil, pricePerUnit: $0.02}], // if usage is 1,500 then the fee is (1000/1e6)*$0.01 + (500/1e6)*$0.02. PricingModeTiered PricingMode = "usage_tiered" // PricingModeVolume means the request is charged a fee based on the token usage volume tiers. // The tier matched by the total token count determines the unit price for ALL tokens. // e.g. tiers are [{upTo: 1000, pricePerUnit: $0.01}, {upTo: nil, pricePerUnit: $0.02}], // if usage is 1,500 then all tokens are billed at $0.02 => (1500/1e6)*$0.02. PricingModeVolume PricingMode = "usage_volume" )
type ProjectProfile ¶
type ProjectProfile struct {
Name string `json:"name"`
ChannelIDs []int `json:"channelIDs,omitempty"`
ChannelTags []string `json:"channelTags,omitempty"`
ChannelTagsMatchMode ChannelTagsMatchMode `json:"channelTagsMatchMode,omitempty"`
}
func (*ProjectProfile) MatchChannelTags ¶
func (p *ProjectProfile) MatchChannelTags(tags []string) bool
type ProjectProfiles ¶
type ProjectProfiles struct {
ActiveProfile string `json:"activeProfile"`
Profiles []ProjectProfile `json:"profiles"`
}
type PromptAction ¶
type PromptAction struct {
// Type is the type of prompt action.
// It is continue to add more action types in the future.
Type PromptActionType `json:"type"`
}
PromptAction is the action to perform when the prompt is activated.
type PromptActionType ¶
type PromptActionType string
const ( // PromptActionTypePrepend is the action to prepend the prompt before the request messages. PromptActionTypePrepend PromptActionType = "prepend" // PromptActionTypeAppend is the action to append the prompt after the request messages. PromptActionTypeAppend PromptActionType = "append" )
type PromptActivationCondition ¶
type PromptActivationCondition struct {
// Type is the type of prompt activation condition.
// It is continue to add more condition types in the future.
Type PromptActivationConditionType `json:"type"`
// ModelID is the ID of the model to activate the prompt.
ModelID *string `json:"model_id,omitempty"`
// ModelPattern is the pattern of the model to activate the prompt.
// The pattern is a regular expression.
ModelPattern *string `json:"model_pattern,omitempty"`
// APIKeyID is the ID of the API key to activate the prompt.
APIKeyID *int `json:"api_key_id,omitempty"`
}
PromptActivationCondition is the condition to activate the prompt.
type PromptActivationConditionComposite ¶
type PromptActivationConditionComposite struct {
// Conditions is the conditions to activate the prompt.
// At least one condition must be met to activate the prompt.
Conditions []PromptActivationCondition `json:"conditions,omitempty"`
}
PromptActivationConditionComposite is the composite condition to activate the prompt.
type PromptActivationConditionType ¶
type PromptActivationConditionType string
const ( // PromptActivationConditionTypeModelID is the condition to activate the prompt for the specified model ID. PromptActivationConditionTypeModelID PromptActivationConditionType = "model_id" // PromptActivationConditionTypeModelPattern is the condition to activate the prompt for the models that match the pattern. PromptActivationConditionTypeModelPattern PromptActivationConditionType = "model_pattern" // PromptActivationConditionTypeAPIKey is the condition to activate the prompt for the specified API key. PromptActivationConditionTypeAPIKey PromptActivationConditionType = "api_key" )
type PromptProtectionAction ¶
type PromptProtectionAction string
const ( PromptProtectionActionMask PromptProtectionAction = "mask" PromptProtectionActionReject PromptProtectionAction = "reject" )
type PromptProtectionScope ¶
type PromptProtectionScope string
const ( PromptProtectionScopeSystem PromptProtectionScope = "system" PromptProtectionScopeDeveloper PromptProtectionScope = "developer" PromptProtectionScopeUser PromptProtectionScope = "user" PromptProtectionScopeAssistant PromptProtectionScope = "assistant" PromptProtectionScopeTool PromptProtectionScope = "tool" )
type PromptProtectionSettings ¶
type PromptProtectionSettings struct {
Action PromptProtectionAction `json:"action"`
Replacement string `json:"replacement,omitempty"`
Scopes []PromptProtectionScope `json:"scopes,omitempty"`
}
type PromptSettings ¶
type PromptSettings struct {
// Action is the action to perform when the prompt is activated.
Action PromptAction `json:"action"`
// Conditions of the prompts must to be met to activate the prompt.
// All conditions must be met to activate the prompt.
Conditions []PromptActivationConditionComposite `json:"conditions,omitempty"`
}
type PromptWriteCacheVariant ¶
type PromptWriteCacheVariant struct {
// VariantCode is the code of the variant.
VariantCode PromptWriteCacheVariantCode `json:"variantCode"`
// Pricing is the pricing for the variant.
Pricing Pricing `json:"pricing"`
}
PromptWriteCacheVariant is the variant for cached token write.
func (*PromptWriteCacheVariant) Equals ¶
func (p *PromptWriteCacheVariant) Equals(other *PromptWriteCacheVariant) bool
func (*PromptWriteCacheVariant) Validate ¶
func (p *PromptWriteCacheVariant) Validate() error
type PromptWriteCacheVariantCode ¶
type PromptWriteCacheVariantCode string
const ( // PromptWriteCacheVariantCode5Min is the variant code for cached token write in 5 minutes. PromptWriteCacheVariantCode5Min PromptWriteCacheVariantCode = "five_min" // PromptWriteCacheVariantCode1Hour is the variant code for cached token write in 1 hour. PromptWriteCacheVariantCode1Hour PromptWriteCacheVariantCode = "one_hour" )
type ProxyConfig ¶
type ProxyConfig = httpclient.ProxyConfig
type ProxyType ¶
type ProxyType = httpclient.ProxyType
type QianwenQuotaSettings ¶
type QianwenQuotaSettings struct {
AuthCookie string `json:"authCookie,omitempty"`
}
QianwenQuotaSettings 存储用于轮询千问(bailian)Token Plan 用量的控制台会话 Cookie。 千问没有可用 API Key 调用的配额查询接口,因此配额轮询复用平台控制台会话。 Cookie 会过期,过期后配额状态会显示为不可用,需要重新粘贴。
type RegexAssociation ¶
type RegexAssociation struct {
Pattern string `json:"pattern"`
Exclude []*ExcludeAssociation `json:"exclude"`
}
type RetryableErrorPattern ¶
type RuntimeAdapter ¶
type RuntimeAdapter struct {
ID int
Name string
DisplayName string
InboundAPIFormat string
Bindings map[string]*RuntimeAdapterBinding
BindingOrder []string
}
RuntimeAdapter 是消费请求使用的不可变适配器运行时配置。
type RuntimeAdapterBinding ¶
type RuntimeAdapterBinding struct {
ID int
SourceModelID string
Model *RuntimeModel
Enabled bool
}
RuntimeAdapterBinding 将消费端逻辑模型绑定到不可变模型快照。
type RuntimeModel ¶
type RuntimeModel struct {
ID int
ModelID string
Name string
Settings *ModelSettings
}
RuntimeModel 是适配器运行时使用的逻辑模型及其协议池快照。
type S3 ¶
type S3 struct {
BucketName string `json:"bucketName"`
Endpoint string `json:"endpoint"`
Region string `json:"region"`
AccessKey string `json:"accessKey"`
SecretKey string `json:"secretKey"`
// PathStyle enables Path Style access for S3 compatible storage services (e.g., MinIO, Ceph RGW).
// When enabled, uses https://s3.amazonaws.com/<bucket-name>/object format instead of Virtual Hosted Style.
PathStyle bool `json:"pathStyle"`
}
type TieredPricing ¶
type TieredPricing struct {
Tiers []PriceTier `json:"tiers"`
}
func (*TieredPricing) Equals ¶
func (p *TieredPricing) Equals(other *TieredPricing) bool
func (*TieredPricing) Validate ¶
func (p *TieredPricing) Validate() error
type TransformOptions ¶
type TransformOptions struct {
// ForceArrayInstructions forces the channel to accept array format for instructions.
ForceArrayInstructions bool `json:"forceArrayInstructions"`
// ForceArrayInputs forces the channel to accept array format for inputs.
ForceArrayInputs bool `json:"forceArrayInputs"`
// ReplaceDeveloperRoleWithSystem replaces developer role with system in messages for Bailian compatibility.
ReplaceDeveloperRoleWithSystem bool `json:"replaceDeveloperRoleWithSystem"`
// ReasoningEffortMapping maps inbound reasoning_effort values to outbound ones for
// non-standard OpenAI-compatible providers. The first entry whose From matches the
// effort value wins; values not in the list pass through unchanged.
// e.g. [{"from":"xhigh","to":"max"}] converts Anthropic's internal "xhigh" (mapped
// from "max") back to "max" for providers that only recognize "max".
// Consumed by the OpenAI-shared outbound transformer. Other transformers ignore it
// for now. Strong-typed to mirror ModelMapping; see llm.ReasoningEffortMapping.
ReasoningEffortMapping []llm.ReasoningEffortMapping `json:"reasoningEffortMapping,omitempty"`
}
type UserInfo ¶
type UserInfo struct {
ID GUID `json:"id"`
Email string `json:"email"`
FirstName string `json:"firstName"`
LastName string `json:"lastName"`
IsOwner bool `json:"isOwner"`
PreferLanguage string `json:"preferLanguage"`
Avatar *string `json:"avatar,omitempty"`
Scopes []string `json:"scopes"`
Roles []RoleInfo `json:"roles"`
Projects []UserProjectInfo `json:"projects"`
OIDCIdentities []OIDCIdentityInfo `json:"oidcIdentities"`
HasPassword bool `json:"hasPassword"`
}