Documentation
¶
Overview ¶
Package proxy contains configuration, middleware, routing, and model interaction logic for the language model proxy server.
Index ¶
- Constants
- Variables
- func BuildPublicCapabilityRouter(capabilityCatalog PublicCapabilityCatalog, logLevel string) *gin.Engine
- func BuildRequestPayload(modelIdentifier string, rawRequestProfile string, combinedPrompt string, ...) any
- func BuildRouter(configuration Configuration, structuredLogger *zap.SugaredLogger) (*gin.Engine, error)
- func RenderManagementConfigUI(configuration ManagementConfiguration) string
- func Serve(configuration Configuration, structuredLogger *zap.SugaredLogger) error
- func ServePublicCapabilities(capabilityCatalog PublicCapabilityCatalog, port int, logLevel string) error
- type CatalogControl
- type CatalogLimit
- type CatalogMediaLimit
- type CatalogMinimumCharge
- type CatalogPriceConditions
- type CatalogPriceDescriptor
- type CatalogPriceRate
- type CatalogPriceSelection
- type CatalogProvider
- type CatalogService
- type Configuration
- type Endpoints
- func (endpointConfiguration *Endpoints) GetModelsURL() string
- func (endpointConfiguration *Endpoints) GetResponsesURL() string
- func (endpointConfiguration *Endpoints) GetTranscriptionsURL() string
- func (endpointConfiguration *Endpoints) ResetModelsURL()
- func (endpointConfiguration *Endpoints) ResetResponsesURL()
- func (endpointConfiguration *Endpoints) ResetTranscriptionsURL()
- func (endpointConfiguration *Endpoints) SetModelsURL(newURL string)
- func (endpointConfiguration *Endpoints) SetResponsesURL(newURL string)
- func (endpointConfiguration *Endpoints) SetTranscriptionsURL(newURL string)
- type ExactModel
- type HTTPDoer
- type ManagementConfiguration
- type ModelCatalog
- type ModelFamily
- type ModelOperationKind
- type ModelPayloadSchema
- type ModelPublisher
- type OpenAIClient
- type ProviderOffering
- type PublicCapabilityCatalog
- type PublicCapabilityCounts
- type PublicExactModelCapability
- type PublicModelFamily
- type PublicModelPublisher
- type PublicProviderCapability
- type PublicProviderOffering
- type Reasoning
- type ReasoningEffortCapability
- type TenantConfiguration
- type TenantDefaults
- type Tool
- type UpstreamRateLimitConfiguration
Constants ¶
const ( // CatalogControlEnum identifies a control with an exact value vocabulary. CatalogControlEnum = "enum" // CatalogControlInteger identifies a bounded integer control. CatalogControlInteger = "integer" // CatalogControlBoolean identifies a Boolean control. CatalogControlBoolean = "boolean" // CatalogCurrencyUSD identifies published United States dollar prices. CatalogCurrencyUSD = "USD" )
const ( // DefaultPort is the TCP port used by the HTTP server when no explicit port is provided. DefaultPort = 8080 // DefaultWorkers is the maximum number of concurrent upstream HTTP operations. DefaultWorkers = 4 // DefaultQueueSize is the number of upstream HTTP operations that may wait for a worker. DefaultQueueSize = 100 // DefaultModel is the model identifier used when the client does not supply one. DefaultModel = ModelNameGPT41 // DefaultProvider is the provider identifier used when the client does not supply one. DefaultProvider = ProviderNameOpenAI // DefaultDictationProvider is the provider used when /dictate does not supply one. DefaultDictationProvider = ProviderNameOpenAI // DefaultRequestTimeoutSeconds is the request work budget used when the client omits one. DefaultRequestTimeoutSeconds = 360 // DefaultMaxRequestTimeoutSeconds is the one-hour operator capacity ceiling for a request. DefaultMaxRequestTimeoutSeconds = 60 * 60 // DefaultMaxPromptBytes limits JSON LLM request bodies accepted by POST /. DefaultMaxPromptBytes = 4 * 1024 * 1024 // DefaultMaxAssetBytes bounds one tenant asset upload at the largest supported provider file size. DefaultMaxAssetBytes int64 = 2_000_000_000 // DefaultAssetRetentionSeconds keeps uploaded tenant assets for 48 hours. DefaultAssetRetentionSeconds = 48 * 60 * 60 // DefaultAssetStorePath is the persistent filesystem location for tenant assets. DefaultAssetStorePath = "/data/assets" DefaultDictationModel = "gpt-4o-mini-transcribe" DefaultMaxInputAudioBytes = 25 * 1024 * 1024 DefaultManagementJWTIssuer = "tauth" // DefaultManagementUsageQueueSize is the number of managed usage events retained for asynchronous persistence. DefaultManagementUsageQueueSize = 1024 )
const ( // LogLevelDebug indicates that the application should log debug information. LogLevelDebug = "debug" // LogLevelInfo indicates that the application should log informational messages. LogLevelInfo = "info" )
const ( ManagementConfigUIFileName = "config-ui.yaml" ManagementConfigUIPath = "/" + ManagementConfigUIFileName )
const ( CatalogMediaLimitStatusBounded = "bounded" CatalogMediaLimitStatusUnbounded = "unbounded" CatalogMediaLimitStatusUnknown = "unknown" CatalogMediaTransportAny = "any" CatalogMediaTransportFile = "file" CatalogMediaTransportInline = "inline" CatalogMediaLimitUnitBytes = "bytes" CatalogMediaLimitUnitFiles = "files" CatalogMediaLimitScopeAttachment = "attachment" CatalogMediaLimitScopeRequest = "request" CatalogMediaLimitScopeRequestEncodedBytes = "request_encoded_bytes" CatalogMediaLimitTypeAll = "all" CatalogMediaLimitIDInlineRequestBytes = "inline_request_bytes" CatalogMediaLimitIDImageCount = "image_count" CatalogMediaLimitIDAudioCount = "audio_count" CatalogMediaLimitIDImageFileBytes = "image_file_bytes" CatalogMediaLimitIDAudioFileBytes = "audio_file_bytes" )
const ( // ModelNameGPT4oMini identifies the GPT-4o-mini model. ModelNameGPT4oMini = "gpt-4o-mini" // ModelNameGPT4o identifies the GPT-4o model. ModelNameGPT4o = "gpt-4o" // ModelNameGPT41 identifies the GPT-4.1 model. ModelNameGPT41 = "gpt-4.1" // ModelNameGPT5Mini identifies the GPT-5-mini model. ModelNameGPT5Mini = "gpt-5-mini" // ModelNameGPT5 identifies the GPT-5 model which does not accept the temperature field. ModelNameGPT5 = "gpt-5" // ModelNameGPT55 identifies the GPT-5.5 model which does not accept the temperature field. ModelNameGPT55 = "gpt-5.5" // ModelNameGPT55Pro identifies the GPT-5.5 pro model which does not accept the temperature field. ModelNameGPT55Pro = "gpt-5.5-pro" // ModelNameGPT56 identifies the GPT-5.6 model which does not accept the temperature field. ModelNameGPT56 = "gpt-5.6" )
const ( // ModelOperationText identifies text generation through the proxy messages contract. ModelOperationText = "text" // ModelOperationDictation identifies audio transcription through the proxy dictation contract. ModelOperationDictation = "dictation" // ModelOperationVideoGeneration identifies provider-backed video generation. ModelOperationVideoGeneration = "video_generation" // CatalogCredentialAPIKey identifies one opaque provider API key. CatalogCredentialAPIKey = "api_key" // CatalogArtifactText identifies text input or output. CatalogArtifactText = "text" // CatalogArtifactImage identifies image input or output. CatalogArtifactImage = "image" // CatalogArtifactAudio identifies audio input or output. CatalogArtifactAudio = "audio" // CatalogArtifactVideo identifies video input or output. CatalogArtifactVideo = "video" // CatalogWireContractMultipartTranscription identifies normalized multipart dictation. CatalogWireContractMultipartTranscription = "multipart_transcription" )
const ( // ModelWeightAccessProprietary identifies families whose model weights are not published for independent deployment. ModelWeightAccessProprietary = "proprietary" // ModelWeightAccessOpenWeights identifies families with published weights for independent deployment. ModelWeightAccessOpenWeights = "open_weights" )
const ( // ProviderNameOpenAI identifies the OpenAI provider. ProviderNameOpenAI = "openai" // ProviderNameDeepSeek identifies the DeepSeek provider. ProviderNameDeepSeek = "deepseek" // ProviderNameDashScope identifies Alibaba Cloud Model Studio DashScope-compatible routing. ProviderNameDashScope = "dashscope" // ProviderNameMoonshot identifies Moonshot/Kimi routing. ProviderNameMoonshot = "moonshot" // ProviderNameMiniMax identifies MiniMax routing. ProviderNameMiniMax = "minimax" // ProviderNameSiliconFlow identifies SiliconFlow routing. ProviderNameSiliconFlow = "siliconflow" // ProviderNameZhipu identifies Zhipu/GLM routing. ProviderNameZhipu = "zhipu" // ProviderNameGemini identifies Google Gemini routing. ProviderNameGemini = "gemini" // ProviderNameAnthropic identifies Anthropic Claude routing. ProviderNameAnthropic = "anthropic" // ProviderNameMeta identifies Meta Model API routing. ProviderNameMeta = "meta" // ProviderNameXAI identifies the xAI credential and routing boundary. ProviderNameXAI = "xai" )
const ( // ModelNameDeepSeekV4Flash identifies the low-cost DeepSeek V4 flash model. ModelNameDeepSeekV4Flash = "deepseek-v4-flash" // ModelNameDeepSeekV4Pro identifies the higher-capability DeepSeek V4 pro model. ModelNameDeepSeekV4Pro = "deepseek-v4-pro" // ModelNameDeepSeekChat identifies the legacy DeepSeek chat model name. ModelNameDeepSeekChat = "deepseek-chat" // ModelNameDeepSeekReasoner identifies the legacy DeepSeek reasoner model name. ModelNameDeepSeekReasoner = "deepseek-reasoner" // ModelNameDashScopeQwenPlus identifies DashScope Qwen Plus. ModelNameDashScopeQwenPlus = "qwen-plus" // ModelNameMoonshotKimiK26 identifies Moonshot Kimi K2.6. ModelNameMoonshotKimiK26 = "kimi-k2.6" // ModelNameMoonshotKimiK3 identifies Moonshot Kimi K3. ModelNameMoonshotKimiK3 = "kimi-k3" // ModelNameMoonshotKimiK27Code identifies Moonshot Kimi K2.7 Code. ModelNameMoonshotKimiK27Code = "kimi-k2.7-code" // ModelNameMoonshotKimiK27CodeHighSpeed identifies Moonshot Kimi K2.7 Code Highspeed. ModelNameMoonshotKimiK27CodeHighSpeed = "kimi-k2.7-code-highspeed" // ModelNameMiniMaxM27 identifies MiniMax M2.7. ModelNameMiniMaxM27 = "minimax-m2.7" // ModelNameSiliconFlowDeepSeek identifies SiliconFlow-hosted DeepSeek R1. ModelNameSiliconFlowDeepSeek = ModelNameDeepSeekReasoner // ModelNameZhipuGLM identifies the GLM 5.1 model. ModelNameZhipuGLM = "glm-5.1" // ModelNameGemini35Flash identifies Gemini 3.5 Flash. ModelNameGemini35Flash = "gemini-3.5-flash" // ModelNameGemini31FlashLite identifies Gemini 3.1 Flash-Lite. ModelNameGemini31FlashLite = "gemini-3.1-flash-lite" // ModelNameGemini25Flash identifies Gemini 2.5 Flash. ModelNameGemini25Flash = "gemini-2.5-flash" // ModelNameGemini25FlashLite identifies Gemini 2.5 Flash-Lite. ModelNameGemini25FlashLite = "gemini-2.5-flash-lite" // ModelNameGemini25Pro identifies Gemini 2.5 Pro. ModelNameGemini25Pro = "gemini-2.5-pro" // ModelNameClaudeOpus48 identifies Claude Opus 4.8. ModelNameClaudeOpus48 = "claude-opus-4-8" // ModelNameClaudeSonnet46 identifies Claude Sonnet 4.6. ModelNameClaudeSonnet46 = "claude-sonnet-4-6" // ModelNameClaudeHaiku45 identifies Claude Haiku 4.5. ModelNameClaudeHaiku45 = "claude-haiku-4-5-20251001" // ModelNameClaudeHaiku45Alias identifies the Claude Haiku 4.5 convenience alias. ModelNameClaudeHaiku45Alias = "claude-haiku-4-5" // ModelNameClaudeSonnet45 identifies Claude Sonnet 4.5. ModelNameClaudeSonnet45 = "claude-sonnet-4-5-20250929" // ModelNameClaudeSonnet45Alias identifies the Claude Sonnet 4.5 convenience alias. ModelNameClaudeSonnet45Alias = "claude-sonnet-4-5" // ModelNameClaudeOpus41 identifies Claude Opus 4.1. ModelNameClaudeOpus41 = "claude-opus-4-1-20250805" // ModelNameClaudeOpus41Alias identifies the Claude Opus 4.1 convenience alias. ModelNameClaudeOpus41Alias = "claude-opus-4-1" // ModelNameMuseSpark11 identifies Meta Muse Spark 1.1. ModelNameMuseSpark11 = "muse-spark-1.1" // ModelNameGrok43 identifies the current Grok 4.3 model. ModelNameGrok43 = "grok-4.3" // ModelNameGrok43Latest identifies the Grok 4.3 latest alias. ModelNameGrok43Latest = "grok-4.3-latest" // ModelNameGrokLatest identifies the current Grok latest alias. ModelNameGrokLatest = "grok-latest" // ModelNameGrokBuild01 identifies the Grok Build coding model. ModelNameGrokBuild01 = "grok-build-0.1" // ModelNameGrokCodeFast identifies the Grok code fast alias. ModelNameGrokCodeFast = "grok-code-fast" // ModelNameGrokCodeFast1 identifies the Grok code fast 1 alias. ModelNameGrokCodeFast1 = "grok-code-fast-1" // ModelNameGrokCodeFast10825 identifies the dated Grok code fast 1 model. ModelNameGrokCodeFast10825 = "grok-code-fast-1-0825" )
const ( PublicModelCapabilityText = "text" PublicModelCapabilityDictation = "dictation" PublicModelCapabilityWebSearch = "web_search" PublicModelCapabilityImageInput = "image_input" PublicModelCapabilityAudioInput = "audio_input" PublicModelCapabilityReasoning = "reasoning" PublicModelCapabilityVideo = "video_generation" )
Public model capability identifiers are the stable filter vocabulary for the generated public catalog.
const PublicCapabilitiesPath = "/api/public/capabilities"
PublicCapabilitiesPath is the canonical unauthenticated capability catalog resource consumed by public frontend builds and external API clients.
Variables ¶
var ( // SchemaGPT4oMini defines allowed payload fields for the GPT-4o-mini model. SchemaGPT4oMini = ModelPayloadSchema{AllowedRequestFields: []string{keyModel, keyInput, keyMaxOutputTokens, keyBackground, keyStore, keyTemperature}} // SchemaGPT4o defines allowed payload fields for the GPT-4o model. SchemaGPT4o = ModelPayloadSchema{AllowedRequestFields: []string{keyModel, keyInput, keyMaxOutputTokens, keyBackground, keyStore, keyTemperature, keyTools, keyToolChoice}} // SchemaGPT41 defines allowed payload fields for the GPT-4.1 model. SchemaGPT41 = ModelPayloadSchema{AllowedRequestFields: []string{keyModel, keyInput, keyMaxOutputTokens, keyBackground, keyStore, keyTemperature, keyTools, keyToolChoice}} // SchemaGPT5 defines allowed payload fields for the GPT-5 model. SchemaGPT5 = ModelPayloadSchema{AllowedRequestFields: []string{keyModel, keyInput, keyMaxOutputTokens, keyBackground, keyStore, keyTools, keyToolChoice, keyReasoning}} // SchemaGPT55 defines allowed payload fields for GPT-5.5 family models. SchemaGPT55 = SchemaGPT5 )
var ( // ErrUnknownProvider is returned when a request names a provider that is not registered. ErrUnknownProvider = errors.New(errorUnknownProvider) // ErrProviderNotConfigured is returned when a registered provider lacks a required server-side credential. ErrProviderNotConfigured = errors.New(errorProviderNotConfigured) // ErrUnsupportedCapability is returned when a request asks a provider for an unsupported capability. ErrUnsupportedCapability = errors.New(errorUnsupportedCapability) // ErrUnsupportedEndpoint is returned when a provider does not support the requested endpoint. ErrUnsupportedEndpoint = errors.New(errorUnsupportedEndpoint) // ErrConflictingModelParameters is returned when query and JSON body model values disagree. ErrConflictingModelParameters = errors.New(errorConflictingModelParameters) // ErrProviderRateLimited is returned when an upstream provider reports rate limiting. ErrProviderRateLimited = errors.New(errorProviderRateLimited) // ErrProviderAPI is returned when an upstream provider returns an unsuccessful response. ErrProviderAPI = errors.New(errorProviderAPI) // ErrProviderMediaLimit is returned when media exceeds the selected provider offering limit. ErrProviderMediaLimit = errors.New("provider media limit exceeded") // ErrInvalidChatMessages is returned when a JSON request body contains invalid chat messages. ErrInvalidChatMessages = errors.New(errorInvalidChatMessages) // ErrInvalidModelCatalog is returned when configured provider model catalogs are incomplete or inconsistent. ErrInvalidModelCatalog = errors.New("invalid_model_catalog") )
var ( ErrMissingTenants = errors.New("tenants must include at least one tenant") ErrInvalidTenant = errors.New("invalid tenant") ErrInvalidManagementConfiguration = errors.New("invalid management configuration") )
var ErrInvalidUpstreamRateLimitConfiguration = errors.New("invalid_upstream_rate_limit_configuration")
ErrInvalidUpstreamRateLimitConfiguration identifies an invalid shared upstream rate-limit rule.
var ErrUnknownModel = errors.New(errorUnknownModel)
ErrUnknownModel is returned when a model identifier is not recognized.
Functions ¶
func BuildPublicCapabilityRouter ¶ added in v0.3.0
func BuildPublicCapabilityRouter(capabilityCatalog PublicCapabilityCatalog, logLevel string) *gin.Engine
BuildPublicCapabilityRouter constructs the minimal public REST surface used when frontend tooling needs capability data without private runtime config.
func BuildRequestPayload ¶
func BuildRequestPayload(modelIdentifier string, rawRequestProfile string, combinedPrompt string, webSearchEnabled bool, maxTokens *int, reasoningEffort string) any
BuildRequestPayload selects the correct OpenAI Responses payload shape for the configured request profile.
func BuildRouter ¶
func BuildRouter(configuration Configuration, structuredLogger *zap.SugaredLogger) (*gin.Engine, error)
BuildRouter constructs the HTTP router used by the proxy. configuration supplies queue sizes, worker counts, timeout values, API credentials and other settings. structuredLogger records structured log messages during routing.
func RenderManagementConfigUI ¶ added in v0.2.19
func RenderManagementConfigUI(configuration ManagementConfiguration) string
RenderManagementConfigUI renders the browser-facing llm-proxy, MPR UI, and TAuth YAML config.
func Serve ¶
func Serve(configuration Configuration, structuredLogger *zap.SugaredLogger) error
Serve builds the router from the supplied configuration and structuredLogger and starts the HTTP server on the configured port.
func ServePublicCapabilities ¶ added in v0.3.0
func ServePublicCapabilities(capabilityCatalog PublicCapabilityCatalog, port int, logLevel string) error
ServePublicCapabilities starts the minimal public REST surface on port.
Types ¶
type CatalogControl ¶ added in v1.0.0
type CatalogControl struct {
ID string `json:"id" mapstructure:"id"`
Kind string `json:"kind" mapstructure:"kind"`
Values []string `json:"values" mapstructure:"values"`
Minimum *int `json:"minimum" mapstructure:"minimum"`
Maximum *int `json:"maximum" mapstructure:"maximum"`
AccountDependent bool `json:"account_dependent" mapstructure:"account_dependent"`
}
CatalogControl declares one route-specific request control.
type CatalogLimit ¶ added in v1.0.0
type CatalogLimit struct {
ID string `json:"id" mapstructure:"id"`
Value *int `json:"value" mapstructure:"value"`
Unit string `json:"unit" mapstructure:"unit"`
AccountDependent bool `json:"account_dependent" mapstructure:"account_dependent"`
}
CatalogLimit declares one fixed or account-dependent route limit.
type CatalogMediaLimit ¶ added in v1.0.0
type CatalogMediaLimit struct {
ID string `json:"id" mapstructure:"id"`
MediaType string `json:"media_type" mapstructure:"media_type"`
Transport string `json:"transport" mapstructure:"transport"`
Status string `json:"status" mapstructure:"status"`
Value *int64 `json:"value" mapstructure:"value"`
Unit string `json:"unit" mapstructure:"unit"`
Scope string `json:"scope" mapstructure:"scope"`
Source string `json:"source" mapstructure:"source"`
LastVerified string `json:"last_verified" mapstructure:"last_verified"`
}
CatalogMediaLimit declares one provider-offering media admission rule.
type CatalogMinimumCharge ¶ added in v1.0.0
type CatalogMinimumCharge struct {
Currency string `json:"currency" mapstructure:"currency"`
Amount float64 `json:"amount" mapstructure:"amount"`
Unit string `json:"unit" mapstructure:"unit"`
}
CatalogMinimumCharge declares one published request minimum.
type CatalogPriceConditions ¶ added in v1.0.0
type CatalogPriceConditions struct {
Resolution string `json:"resolution" mapstructure:"resolution"`
GeneratedAudio string `json:"generated_audio" mapstructure:"generated_audio"`
InputMedia string `json:"input_media" mapstructure:"input_media"`
OutputMedia string `json:"output_media" mapstructure:"output_media"`
Duration string `json:"duration" mapstructure:"duration"`
Quantity string `json:"quantity" mapstructure:"quantity"`
Quality string `json:"quality" mapstructure:"quality"`
Mode string `json:"mode" mapstructure:"mode"`
APIVersion string `json:"api_version" mapstructure:"api_version"`
AvatarType string `json:"avatar_type" mapstructure:"avatar_type"`
BillingMode string `json:"billing_mode" mapstructure:"billing_mode"`
BillingOutcome string `json:"billing_outcome" mapstructure:"billing_outcome"`
}
CatalogPriceConditions identifies one exact published billing condition set.
type CatalogPriceDescriptor ¶ added in v1.0.0
type CatalogPriceDescriptor struct {
Provider string `json:"provider" mapstructure:"provider"`
Model string `json:"model" mapstructure:"model"`
Operation string `json:"operation" mapstructure:"operation"`
Available bool `json:"available" mapstructure:"available"`
Rates []CatalogPriceRate `json:"rates" mapstructure:"rates"`
MinimumCharge *CatalogMinimumCharge `json:"minimum_charge" mapstructure:"minimum_charge"`
Source string `json:"source" mapstructure:"source"`
LastVerified string `json:"last_verified" mapstructure:"last_verified"`
}
CatalogPriceDescriptor owns pricing for one provider, model, and operation.
type CatalogPriceRate ¶ added in v1.0.0
type CatalogPriceRate struct {
Component string `json:"component" mapstructure:"component"`
Currency string `json:"currency" mapstructure:"currency"`
Rate float64 `json:"rate" mapstructure:"rate"`
Unit string `json:"unit" mapstructure:"unit"`
Conditions CatalogPriceConditions `json:"conditions" mapstructure:"conditions"`
}
CatalogPriceRate is one exact published billing component.
type CatalogPriceSelection ¶ added in v1.0.0
type CatalogPriceSelection struct {
Available bool
Rate *CatalogPriceRate
MinimumCharge *CatalogMinimumCharge
Source string
LastVerified string
}
CatalogPriceSelection is an exact price result. Unavailable selections carry a stable reason and never guess a rate.
type CatalogProvider ¶ added in v1.0.0
type CatalogProvider struct {
ID string `mapstructure:"id"`
Label string `mapstructure:"label"`
CredentialKinds []string `mapstructure:"credential_kinds"`
}
CatalogProvider declares one provider that can own provider offerings.
type CatalogService ¶ added in v1.0.0
type CatalogService struct {
// contains filtered or unexported fields
}
CatalogService is the validated model-operation capability and price snapshot used by routing, public discovery, management, and later planning.
func NewCatalogService ¶ added in v1.0.0
func NewCatalogService(catalog ModelCatalog) (CatalogService, error)
NewCatalogService validates one complete catalog snapshot.
func (CatalogService) ResolveOffering ¶ added in v1.0.0
func (service CatalogService) ResolveOffering(provider string, model string) (ProviderOffering, error)
ResolveOffering resolves one canonical provider and model pair.
func (CatalogService) Revision ¶ added in v1.0.0
func (service CatalogService) Revision() string
Revision returns the exact catalog snapshot identifier.
func (CatalogService) SelectPrice ¶ added in v1.0.0
func (service CatalogService) SelectPrice(provider string, model string, operation string, component string, conditions CatalogPriceConditions) CatalogPriceSelection
SelectPrice returns the exact component and condition match. Missing or incomplete selections return a typed unavailable result.
type Configuration ¶
type Configuration struct {
Tenants []TenantConfiguration
Management ManagementConfiguration
OpenAIKey string
DeepSeekKey string
DashScopeKey string
MoonshotKey string
MiniMaxKey string
SiliconFlowKey string
ZhipuKey string
GeminiKey string
AnthropicKey string
MetaKey string
XAIKey string
OpenAIBaseURL string
OpenAITranscriptionsURL string
DeepSeekBaseURL string
DashScopeBaseURL string
MoonshotBaseURL string
MiniMaxBaseURL string
SiliconFlowBaseURL string
SiliconFlowTranscriptionsURL string
ZhipuBaseURL string
ZhipuTranscriptionsURL string
GeminiBaseURL string
AnthropicBaseURL string
MetaBaseURL string
XAIBaseURL string
XAITranscriptionsURL string
Port int
LogLevel string
WorkerCount int
QueueSize int
RequestTimeoutSeconds int
MaxRequestTimeoutSeconds int
MaxPromptBytes int64
MaxAssetBytes int64
AssetRetentionSeconds int
AssetStorePath string
MaxInputAudioBytes int64
UpstreamRateLimits []UpstreamRateLimitConfiguration
Endpoints *Endpoints
ModelCatalog ModelCatalog
// contains filtered or unexported fields
}
Configuration holds runtime settings.
func NewConfiguration ¶
func NewConfiguration(configuration Configuration) (Configuration, error)
NewConfiguration returns a normalized runtime configuration after validating startup invariants.
func (*Configuration) ApplyTunables ¶
func (configuration *Configuration) ApplyTunables()
ApplyTunables ensures tunable configuration values have sensible defaults.
type Endpoints ¶
type Endpoints struct {
// contains filtered or unexported fields
}
Endpoints provides concurrency-safe access to OpenAI endpoint URLs.
func NewEndpoints ¶
func NewEndpoints() *Endpoints
NewEndpoints creates an Endpoints instance initialized with default URLs.
func NewEndpointsForURLs ¶ added in v0.2.17
NewEndpointsForURLs creates an Endpoints instance from configured OpenAI URLs.
func (*Endpoints) GetModelsURL ¶
GetModelsURL returns the URL used for the OpenAI models endpoint.
func (*Endpoints) GetResponsesURL ¶
GetResponsesURL returns the URL used for the OpenAI responses endpoint.
func (*Endpoints) GetTranscriptionsURL ¶
GetTranscriptionsURL returns the URL used for the OpenAI audio transcriptions endpoint.
func (*Endpoints) ResetModelsURL ¶
func (endpointConfiguration *Endpoints) ResetModelsURL()
ResetModelsURL resets the models endpoint to the default.
func (*Endpoints) ResetResponsesURL ¶
func (endpointConfiguration *Endpoints) ResetResponsesURL()
ResetResponsesURL resets the responses endpoint to the default.
func (*Endpoints) ResetTranscriptionsURL ¶
func (endpointConfiguration *Endpoints) ResetTranscriptionsURL()
ResetTranscriptionsURL resets the transcriptions endpoint to the default.
func (*Endpoints) SetModelsURL ¶
SetModelsURL sets the URL for the OpenAI models endpoint.
func (*Endpoints) SetResponsesURL ¶
SetResponsesURL sets the URL for the OpenAI responses endpoint.
func (*Endpoints) SetTranscriptionsURL ¶
SetTranscriptionsURL sets the URL for the OpenAI audio transcriptions endpoint.
type ExactModel ¶ added in v1.0.0
type ExactModel struct {
ID string `mapstructure:"id"`
Publisher string `mapstructure:"publisher"`
Family string `mapstructure:"family"`
Version string `mapstructure:"version"`
Operations []string `mapstructure:"operations"`
MediaInputs []string `mapstructure:"media_inputs"`
}
ExactModel declares provider-independent identity and model capabilities.
type HTTPDoer ¶
HTTPDoer executes HTTP requests, allowing the proxy to abstract the underlying HTTP client.
var ( // HTTPClient is the default HTTPDoer implementation that delegates to http.DefaultClient. HTTPClient HTTPDoer = http.DefaultClient )
type ManagementConfiguration ¶ added in v0.2.19
type ManagementConfiguration struct {
Enabled bool
PublicOrigin string
UIDescription string
UIOrigins []string
AdminEmails []string
TAuthURL string
TAuthTenantID string
GoogleClientID string
LoginPath string
LogoutPath string
NoncePath string
SessionPath string
JWTSigningKey string
JWTIssuer string
SessionCookieName string
DatabasePath string
UsageQueueSize int
ProviderKeyEncryptionKey string
ManagementAPIOrigin string
ProxyOrigin string
DatabaseDialector gorm.Dialector
}
ManagementConfiguration holds authenticated browser UI and self-service tenant settings.
func (*ManagementConfiguration) ApplyTunables ¶ added in v0.2.19
func (configuration *ManagementConfiguration) ApplyTunables()
ApplyTunables normalizes optional management settings.
type ModelCatalog ¶ added in v1.0.0
type ModelCatalog struct {
Revision string `mapstructure:"revision"`
Operations []ModelOperationKind `mapstructure:"operations"`
Providers []CatalogProvider `mapstructure:"providers"`
Publishers []ModelPublisher `mapstructure:"publishers"`
Families []ModelFamily `mapstructure:"families"`
Models []ExactModel `mapstructure:"models"`
Offerings []ProviderOffering `mapstructure:"offerings"`
Prices []CatalogPriceDescriptor `mapstructure:"prices"`
}
ModelCatalog is the canonical normalized model and provider-offering registry.
type ModelFamily ¶ added in v1.0.0
type ModelFamily struct {
ID string `mapstructure:"id"`
Publisher string `mapstructure:"publisher"`
Label string `mapstructure:"label"`
WeightAccess string `mapstructure:"weight_access"`
}
ModelFamily groups exact models from one publisher.
type ModelOperationKind ¶ added in v1.0.0
type ModelOperationKind struct {
ID string `json:"id" mapstructure:"id"`
InputArtifacts []string `json:"input_artifacts" mapstructure:"input_artifacts"`
OutputArtifacts []string `json:"output_artifacts" mapstructure:"output_artifacts"`
}
ModelOperationKind declares one operation and its possible artifact types.
type ModelPayloadSchema ¶
type ModelPayloadSchema struct {
// AllowedRequestFields enumerates JSON fields permitted in the request payload.
AllowedRequestFields []string
}
ModelPayloadSchema lists request fields allowed by a model.
func ResolveModelPayloadSchema ¶
func ResolveModelPayloadSchema(requestProfile string) ModelPayloadSchema
ResolveModelPayloadSchema returns the schema for a request profile or an empty schema when unknown.
type ModelPublisher ¶ added in v1.0.0
ModelPublisher declares the organization or community that publishes models.
type OpenAIClient ¶
type OpenAIClient struct {
// contains filtered or unexported fields
}
OpenAIClient provides access to the OpenAI responses API with configurable endpoints and tunable parameters.
func NewOpenAIClient ¶
func NewOpenAIClient(httpClient HTTPDoer, endpoints *Endpoints) *OpenAIClient
NewOpenAIClient constructs an OpenAIClient initialized with the supplied components.
type ProviderOffering ¶ added in v1.0.0
type ProviderOffering struct {
Provider string `mapstructure:"provider"`
Model string `mapstructure:"model"`
ProviderModel string `mapstructure:"provider_model"`
Operations []string `mapstructure:"operations"`
DefaultOperations []string `mapstructure:"default_operations"`
WireContract string `mapstructure:"wire_contract"`
ExecutionLifecycle string `mapstructure:"execution_lifecycle"`
RequestProfile string `mapstructure:"request_profile"`
WebSearch bool `mapstructure:"web_search"`
OutputTokenLimit int `mapstructure:"output_token_limit"`
ReasoningEffort *ReasoningEffortCapability `mapstructure:"reasoning_effort"`
MediaInputs []string `mapstructure:"media_inputs"`
MediaLimits []CatalogMediaLimit `mapstructure:"media_limits"`
Controls []CatalogControl `mapstructure:"controls"`
Limits []CatalogLimit `mapstructure:"limits"`
}
ProviderOffering declares one provider route for one exact model.
type PublicCapabilityCatalog ¶ added in v0.2.59
type PublicCapabilityCatalog struct {
Revision string `json:"revision"`
Operations []ModelOperationKind `json:"operations"`
Providers []PublicProviderCapability `json:"providers"`
Publishers []PublicModelPublisher `json:"publishers"`
Families []PublicModelFamily `json:"families"`
Models []PublicExactModelCapability `json:"models"`
Offerings []PublicProviderOffering `json:"offerings"`
Prices []CatalogPriceDescriptor `json:"prices"`
Counts PublicCapabilityCounts `json:"counts"`
MaxPromptBytes int64 `json:"max_prompt_bytes"`
MaxInputAudioBytes int64 `json:"max_input_audio_bytes"`
MaxRequestTimeoutSeconds int `json:"max_request_timeout_seconds"`
}
PublicCapabilityCatalog is the normalized tenant-safe model discovery contract.
func NewPublicCapabilityCatalog ¶ added in v0.2.59
func NewPublicCapabilityCatalog(configuration Configuration) (PublicCapabilityCatalog, error)
NewPublicCapabilityCatalog validates and projects the runtime catalog into a deterministic public representation.
type PublicCapabilityCounts ¶ added in v1.0.0
type PublicCapabilityCounts struct {
Providers int `json:"providers"`
ModelPublishers int `json:"model_publishers"`
ModelFamilies int `json:"model_families"`
ExactModels int `json:"exact_models"`
ProviderOfferings int `json:"provider_offerings"`
}
PublicCapabilityCounts reports each normalized catalog dimension separately.
type PublicExactModelCapability ¶ added in v1.0.0
type PublicExactModelCapability struct {
Identifier string `json:"identifier"`
Publisher string `json:"publisher"`
Family string `json:"family"`
Version string `json:"version"`
Operations []string `json:"operations"`
MediaInputs []string `json:"media_inputs"`
Capabilities []string `json:"capabilities"`
ProviderOfferings []string `json:"provider_offerings"`
}
PublicExactModelCapability describes one provider-independent exact model.
type PublicModelFamily ¶ added in v1.0.0
type PublicModelFamily struct {
Identifier string `json:"identifier"`
Publisher string `json:"publisher"`
Label string `json:"label"`
WeightAccess string `json:"weight_access"`
}
PublicModelFamily identifies one family within a model publisher.
type PublicModelPublisher ¶ added in v1.0.0
type PublicModelPublisher struct {
Identifier string `json:"identifier"`
Label string `json:"label"`
ModelCount int `json:"model_count"`
}
PublicModelPublisher identifies one model publisher and its exact-model count.
type PublicProviderCapability ¶ added in v0.2.59
type PublicProviderCapability struct {
Identifier string `json:"identifier"`
Label string `json:"label"`
CredentialKinds []string `json:"credential_kinds"`
}
PublicProviderCapability identifies one selectable provider.
type PublicProviderOffering ¶ added in v1.0.0
type PublicProviderOffering struct {
Identifier string `json:"identifier"`
Provider string `json:"provider"`
Model string `json:"model"`
Capabilities []string `json:"capabilities"`
WireContract string `json:"wire_contract"`
ExecutionLifecycle string `json:"execution_lifecycle"`
OutputTokenLimit int `json:"output_token_limit"`
ReasoningEfforts []string `json:"reasoning_efforts"`
Controls []CatalogControl `json:"controls"`
Limits []CatalogLimit `json:"limits"`
MediaLimits []CatalogMediaLimit `json:"media_limits"`
}
PublicProviderOffering describes one selectable provider and exact-model route.
type Reasoning ¶
type Reasoning struct {
Effort string `json:"effort"`
}
Reasoning specifies configuration options for reasoning-capable models. Effort indicates the tenant-selected reasoning intensity supported by the configured upstream adapter.
type ReasoningEffortCapability ¶ added in v0.2.35
type ReasoningEffortCapability struct {
Adapter string `mapstructure:"adapter"`
Efforts []string `mapstructure:"efforts"`
}
ReasoningEffortCapability declares the configured upstream mapping for one exact provider offering.
type TenantConfiguration ¶ added in v0.2.15
type TenantConfiguration struct {
ID string
Secret string
Defaults TenantDefaults
}
TenantConfiguration is the config-file shape for one authenticated tenant.
func DefaultTenantConfiguration ¶ added in v0.2.15
func DefaultTenantConfiguration(identifier string, secret string) TenantConfiguration
DefaultTenantConfiguration returns one tenant using the built-in request defaults.
func SingleTenantConfigurations ¶ added in v0.2.15
func SingleTenantConfigurations(identifier string, secret string) []TenantConfiguration
SingleTenantConfigurations returns a tenant slice for tests and small deployments.
func SingleTenantConfigurationsWithDefaults ¶ added in v0.2.15
func SingleTenantConfigurationsWithDefaults(identifier string, secret string, defaults TenantDefaults) []TenantConfiguration
SingleTenantConfigurationsWithDefaults returns one tenant with caller-specified request defaults.
type TenantDefaults ¶ added in v0.2.15
type TenantDefaults struct {
Provider string
Model string
DictationProvider string
DictationModel string
SystemPrompt string
ReasoningEffort string
}
TenantDefaults holds default request values selected by an authenticated tenant.
func DefaultTenantDefaults ¶ added in v0.2.15
func DefaultTenantDefaults() TenantDefaults
DefaultTenantDefaults returns the built-in request defaults for a single tenant.
type Tool ¶
type Tool struct {
Type string `json:"type"`
}
Tool represents a tool available to the model.
type UpstreamRateLimitConfiguration ¶ added in v0.2.28
UpstreamRateLimitConfiguration describes one exact-origin rolling-window limit.
Source Files
¶
- anthropic.go
- assets.go
- catalog_service.go
- chat_messages.go
- config.go
- constants.go
- doc.go
- endpoints.go
- formats.go
- gemini.go
- limited_http.go
- management_api.go
- management_frontend_config.go
- management_routing_defaults.go
- management_session.go
- management_store.go
- management_usage.go
- management_usage_writer.go
- media_limits.go
- message_media.go
- middleware.go
- model_capabilities.go
- model_catalog.go
- model_validator.go
- openai.go
- openai_compatible_chat.go
- openai_dictation.go
- provider_error_response.go
- provider_errors.go
- provider_key_rejection.go
- provider_key_verifier.go
- provider_registry.go
- provider_router.go
- provider_types.go
- public_capabilities.go
- request_telemetry.go
- request_timeout.go
- router.go
- tenants.go
- token_usage.go
- upstream_rate_limit.go