Documentation
¶
Index ¶
- Constants
- Variables
- func ClientUserAgentFromContext(ctx context.Context) string
- func CodexClientHeadersFromContext(ctx context.Context) http.Header
- func ConversationFromContext(ctx context.Context) string
- func DisabledThinkingField() map[string]any
- func IsTLSVerifyError(err error) bool
- func NormalizeReasoningLevel(raw string) string
- func RequestsDisabledThinking(req translate.ChatRequest) bool
- func Resolve(provider, region string) (ProviderDescriptor, RegionDescriptor, error)
- func ResolveReasoningLevel(level string, caps ModelCapabilities) string
- func UniqueReasoningOptions(values []string) []string
- func ValidateCredentialFormat(provider, format string) error
- func WithClientUserAgent(ctx context.Context, ua string) context.Context
- func WithCodexClientHeaders(ctx context.Context, src http.Header) context.Context
- func WithConversation(ctx context.Context, key string) context.Context
- type AccountCheckiner
- type AccountHealth
- type AccountProber
- type ActionError
- type Adapter
- type AdminRequest
- type AdminResponse
- type AuthType
- type ChatOutcome
- type CheckinPolicy
- type CheckinResult
- type ClassifiedError
- type CredentialBatchExpander
- type CredentialCodec
- type CredentialImport
- type CredentialImporter
- type Error
- type ErrorClassifier
- type ImportExporter
- type LoginCompleter
- type LoginSession
- type LoginSessionProvider
- type ModelCapabilities
- type ModelCatalogProvider
- type ModelInfo
- type NativeResponsesStreamer
- type ProviderCapabilities
- type ProviderChat
- type ProviderDescriptor
- type QuotaInfo
- type QuotaPackage
- type QuotaWindow
- type RegionDescriptor
- type Registry
- type RequestOptions
- type ResolvedChat
- type RuntimeKind
Constants ¶
const CodeClientVersionTooLow = "client_version_too_low"
CodeClientVersionTooLow marks an upstream "upgrade required" hard gate (Qoder HTTP 430). Every account shares it, so it is never retried.
const CodeTLSVerifyFailed = "tls_verify_failed"
CodeTLSVerifyFailed marks a certificate/hostname verification failure. The executor never retries or fails over on it: every account shares the same trust chain, so another attempt only repeats the failed handshake.
const CodeUpstreamImageConversionTimeout = "upstream_image_conversion_timeout"
CodeUpstreamImageConversionTimeout marks a provider image-conversion TTL (Qoder hub v1.8.0). Same-account bounded retry only; no account rotation.
const CodeUpstreamQueued = "upstream_queued"
CodeUpstreamQueued marks a model-level upstream queue rejection (Qoder 10605). The account is healthy: no cooldown, no failover, Retry-After only.
const DisabledThinkingType = "disabled"
DisabledThinkingType is the marker OpenAI-compatible clients use to ask for a response without a chain of thought (for example Qwen's `{"type":"disabled"}` and the value EverOS llm-router sends on extraction calls). Keep it as a separate channel from reasoning_effort levels: AGENTS.md says reasoning levels are catalog-driven and must be clamped to what a model advertises, so "none" cannot be forced through the level path.
const StreamFormatResponses = "responses"
StreamFormatNames the SSE dialect a ProviderChat.ChatStream body speaks. Empty means OpenAI chat-completions deltas (the shared internal contract); "responses" means the upstream already emits OpenAI Responses events and the /v1/responses endpoint can relay them without translation.
Variables ¶
var CodeArts = ProviderDescriptor{ ID: "codearts", Label: "CodeArts", Runtime: RuntimeInProcess, AuthTypes: []AuthType{AuthOAuth}, CredentialFormats: []string{"codearts-oauth-v1"}, Capabilities: ProviderCapabilities{ Chat: true, Stream: true, Tools: true, Images: true, Reasoning: true, ModelCatalog: true, Usage: true, Login: true, BrowserLogin: true, PATLogin: false, ImportExport: true, }, Regions: []RegionDescriptor{ { ID: "cn-north-4", Label: "CN", ChatBase: "https://snap-access.cn-north-4.myhuaweicloud.com", BillingBase: "https://snap-access.cn-north-4.myhuaweicloud.com", AuthBase: "https://codearts.huaweicloud.com", DefaultDomain: "huaweicloud.com", Checkin: &CheckinPolicy{Timezone: "Asia/Shanghai"}, }, }, DefaultRegion: "cn-north-4", }
CodeArts descriptor. Protocol constants stay in internal/providers/codearts. CN-only in-process adapter for Huawei Cloud CodeArts Agent (码道): OAuth PKCE against the CodeArts portal mints a short-lived STS trio, and chat goes directly to the snap-access OpenAI-compatible gateway. The AK/SK in the credential are the STS material, not the account-level IAM keys.
var Codex = ProviderDescriptor{ ID: "codex", Label: "Codex", Runtime: RuntimeInProcess, AuthTypes: []AuthType{AuthOAuth}, CredentialFormats: []string{"codex-oauth-v1"}, Capabilities: ProviderCapabilities{ Chat: true, Stream: true, Tools: true, Images: true, Reasoning: true, ModelCatalog: true, Usage: true, Login: true, BrowserLogin: true, PATLogin: false, ImportExport: true, }, Regions: []RegionDescriptor{ { ID: "global", Label: "Global", ChatBase: "https://chatgpt.com/backend-api/codex", AuthBase: "https://auth.openai.com", BillingBase: "https://chatgpt.com", DefaultDomain: "chatgpt.com", }, }, DefaultRegion: "global", }
Codex descriptor. OpenAI Codex (ChatGPT subscription) via the ChatGPT backend Responses endpoint; OAuth with a fixed loopback redirect.
var CodexPassthroughHeaderNames = []string{
"X-Codex-Turn-Metadata",
"X-Codex-Turn-State",
"X-Codex-Window-Id",
}
CodexPassthroughHeaderNames are inbound headers CLIProxyAPI EnsureHeader forwards onto ChatGPT Codex OAuth requests for turn continuity. Kept narrow: Routing-Hint / Responses-Lite are set by the adapter itself; Session-Id is managed locally; SIWC does not receive these.
var Command = ProviderDescriptor{ ID: "command", Label: "Command Code", Runtime: RuntimeInProcess, AuthTypes: []AuthType{AuthPAT}, CredentialFormats: []string{"command-key-v1"}, Capabilities: ProviderCapabilities{ Chat: true, Stream: true, Tools: true, Images: true, Reasoning: false, ModelCatalog: true, Usage: true, Login: false, BrowserLogin: false, PATLogin: true, ImportExport: true, }, Regions: []RegionDescriptor{ { ID: "global", Label: "Global", ChatBase: "https://api.commandcode.ai", BillingBase: "https://api.commandcode.ai", AuthBase: "https://api.commandcode.ai", DefaultDomain: "commandcode.ai", }, }, DefaultRegion: "global", }
Command descriptor. Protocol constants stay in internal/providers/command. Global-only in-process adapter. Auth is a single pasted user_… Bearer key shared by the CLI and the API: no OAuth, no browser loopback. Generation goes through /alpha/generate, the CLI's own endpoint, so the $1 Go plan (which has no /provider/v1/* API access) is served too.
var Devin = ProviderDescriptor{ ID: "devin", Label: "Devin", Runtime: RuntimeInProcess, AuthTypes: []AuthType{AuthOAuth}, CredentialFormats: []string{"devin-session-v1"}, Capabilities: ProviderCapabilities{ Chat: true, Stream: true, Tools: true, Images: true, Reasoning: true, ModelCatalog: true, Usage: true, Login: true, BrowserLogin: true, PATLogin: false, ImportExport: true, }, Regions: []RegionDescriptor{ { ID: "global", Label: "Global", ChatBase: "https://server.codeium.com", BillingBase: "https://api.devin.ai", AuthBase: "https://app.devin.ai", DefaultDomain: "devin.ai", }, }, DefaultRegion: "global", }
Devin descriptor. Protocol constants stay in internal/providers/devin. Global-only Connect-RPC adapter; no Devin CLI child process.
var DoubaoWork = ProviderDescriptor{ ID: "doubaowork", Label: "Doubao Work", Runtime: RuntimeInProcess, AuthTypes: []AuthType{AuthPAT}, CredentialFormats: []string{"doubaowork-cookie-v1"}, Capabilities: ProviderCapabilities{ Chat: true, Stream: true, Tools: true, Images: false, Reasoning: true, ModelCatalog: true, Usage: true, Login: false, BrowserLogin: false, PATLogin: true, ImportExport: true, }, Regions: []RegionDescriptor{ { ID: "cn", Label: "CN", ChatBase: "https://www.doubao.com", BillingBase: "https://www.doubao.com", AuthBase: "https://www.doubao.com", DefaultDomain: "doubao.com", Checkin: &CheckinPolicy{Timezone: "Asia/Shanghai"}, }, }, DefaultRegion: "cn", }
DoubaoWork descriptor. Protocol constants stay in internal/providers/doubaowork; the registry only carries control-plane metadata. CN-only in-process adapter for the Doubao Work (豆包工作) desktop subscription. Auth is a pasted web session Cookie: the server runs headless, so there is no browser or client login round, only an operator-pasted credential validated on import.
var ErrFirstByteTimeout = errors.New("first byte timeout")
ErrFirstByteTimeout is returned by streaming chat adapters when the upstream did not send the response head (headers + first byte) within the TTFB deadline. The executor classifies it as upstream_unavailable with failover so the next eligible account is tried, instead of hanging on a stuck upstream. It must not be wrapped with context.DeadlineExceeded, or the executor would re-classify it as a client cancellation and skip failover.
var ErrUnsupported = errors.New("provider capability unsupported")
ErrUnsupported is returned by capability interfaces a provider does not implement. Callers must treat nil adapters as missing registrations, not as implicit support.
var Kimi = ProviderDescriptor{ ID: "kimi", Label: "Kimi Code", Runtime: RuntimeInProcess, AuthTypes: []AuthType{AuthOAuth}, CredentialFormats: []string{"kimi-oauth-v1"}, Capabilities: ProviderCapabilities{ Chat: true, Stream: true, Tools: true, Images: true, Reasoning: true, ModelCatalog: true, Usage: true, Login: true, BrowserLogin: true, PATLogin: false, ImportExport: true, }, Regions: []RegionDescriptor{ { ID: "cn", Label: "CN", ChatBase: "https://api.kimi.com/coding/v1", BillingBase: "https://www.kimi.com", AuthBase: "https://auth.kimi.com", DefaultDomain: "kimi.com", }, }, DefaultRegion: "cn", }
Kimi descriptor. Protocol constants stay in internal/providers/kimi. CN-only in-process adapter for the Kimi Code subscription: OAuth device grant against auth.kimi.com, distinct from the Moonshot Open Platform API-key product that lives on api.moonshot.cn.
var Kiro = ProviderDescriptor{ ID: "kiro", Label: "Kiro", Runtime: RuntimeInProcess, AuthTypes: []AuthType{AuthOAuth, AuthPAT}, CredentialFormats: []string{"kiro-oauth-v1"}, Capabilities: ProviderCapabilities{ Chat: true, Stream: true, Tools: true, Images: true, Reasoning: true, ModelCatalog: true, Usage: false, Login: true, BrowserLogin: true, PATLogin: true, ImportExport: true, }, Regions: []RegionDescriptor{ { ID: "us-east-1", Label: "US East", ChatBase: "https://runtime.us-east-1.kiro.dev", BillingBase: "https://q.us-east-1.amazonaws.com", AuthBase: "https://oidc.us-east-1.amazonaws.com", DefaultDomain: "kiro.dev", }, { ID: "eu-central-1", Label: "EU Central", ChatBase: "https://runtime.eu-central-1.kiro.dev", BillingBase: "https://q.eu-central-1.amazonaws.com", AuthBase: "https://oidc.eu-central-1.amazonaws.com", DefaultDomain: "kiro.dev", }, }, DefaultRegion: "us-east-1", }
Kiro descriptor. Protocol constants stay in internal/providers/kiro. In-process adapter for a personal Kiro login. Chat goes to CreateResponse on runtime.{region}.kiro.dev. The two regions are the data planes the IDE uses.
var Meta = ProviderDescriptor{ ID: "meta", Label: "Muse (Meta)", Runtime: RuntimeInProcess, AuthTypes: []AuthType{AuthOAuth, AuthPAT}, CredentialFormats: []string{"meta-oauth-v1", "meta-key-v1"}, Capabilities: ProviderCapabilities{ Chat: true, Stream: true, Tools: true, Images: true, Reasoning: true, ModelCatalog: true, Usage: false, Login: true, BrowserLogin: true, PATLogin: true, ImportExport: true, }, Regions: []RegionDescriptor{ { ID: "global", Label: "Global", ChatBase: "https://api.meta.ai/v1", BillingBase: "https://www.meta.ai", AuthBase: "https://auth.meta.com", DefaultDomain: "meta.ai", }, }, DefaultRegion: "global", }
Meta descriptor. Protocol constants stay in internal/providers/meta. Global-only Muse (Meta) adapter: RFC 8628 device grant against auth.meta.com, minting an LLM API key at api.meta.ai/muse-code/key. Alias "muse" resolves to this family at NormalizeProviderFamily / Get; it is not a second provider.
var MiniMaxCode = ProviderDescriptor{ ID: "minimaxcode", Label: "MiniMax Code", Runtime: RuntimeInProcess, AuthTypes: []AuthType{AuthOAuth}, CredentialFormats: []string{"minimaxcode-oauth-v1"}, Capabilities: ProviderCapabilities{ Chat: true, Stream: true, Tools: true, Images: true, Reasoning: false, ModelCatalog: true, Usage: true, Login: true, BrowserLogin: true, PATLogin: false, ImportExport: true, }, Regions: []RegionDescriptor{ { ID: "cn", Label: "CN", ChatBase: "https://agent.minimax.cn", BillingBase: "https://agent.minimax.cn", AuthBase: "https://account.minimax.cn", DefaultDomain: "minimax.cn", }, { ID: "global", Label: "Global", ChatBase: "https://agent.minimax.io", BillingBase: "https://agent.minimax.io", AuthBase: "https://account.minimax.io", DefaultDomain: "minimax.io", }, }, DefaultRegion: "cn", }
MiniMaxCode is the MiniMax Code subscription product, reached through its OAuth device flow and Anthropic-compatible agent gateway. It is distinct from the MiniMax Open Platform API-key gateway.
var Qoder = ProviderDescriptor{ ID: "qoder", Label: "Qoder", Runtime: RuntimeChildProcess, AuthTypes: []AuthType{AuthNone, AuthOAuth, AuthPAT, AuthNative}, CredentialFormats: []string{"qoder-pat-v1", "qoder-native-v1"}, Capabilities: ProviderCapabilities{ Chat: true, Stream: true, Tools: true, Images: true, Reasoning: true, ModelCatalog: true, Usage: true, Login: true, BrowserLogin: true, PATLogin: true, ImportExport: true, }, Regions: []RegionDescriptor{ { ID: "global", Label: "Global", ChatBase: "https://api1.qoder.sh", BillingBase: "https://openapi.qoder.sh", AuthBase: "https://qoder.sh", DefaultDomain: "qoder.global", Checkin: &CheckinPolicy{Timezone: "Asia/Shanghai"}, }, { ID: "cn", Label: "CN", ChatBase: "https://gateway.qoder.com.cn", BillingBase: "https://openapi.qoder.com.cn", AuthBase: "https://qoder.com.cn", DefaultDomain: "qoder.com.cn", Checkin: &CheckinPolicy{Timezone: "Asia/Shanghai"}, }, }, DefaultRegion: "global", }
Qoder descriptor. Region selects the pinned CLI and config directory: global uses @qoder-ai/qodercli + .qoder, cn uses @qodercn-ai/qoderclicn + .qoder-cn.
var QwenWork = ProviderDescriptor{ ID: "qwenwork", Label: "QwenWork", Runtime: RuntimeInProcess, AuthTypes: []AuthType{AuthOAuth}, CredentialFormats: []string{"qwenwork-oauth-v1"}, Capabilities: ProviderCapabilities{ Chat: true, Stream: true, Tools: true, Images: true, Reasoning: true, ModelCatalog: true, Usage: true, Login: true, BrowserLogin: true, PATLogin: false, ImportExport: true, }, Regions: []RegionDescriptor{ { ID: "global", Label: "International", ChatBase: "https://gateway.qwenwork.ai", BillingBase: "https://gateway.qwenwork.ai", AuthBase: "https://gateway.qwenwork.ai", DefaultDomain: "qwenwork.ai", Checkin: &CheckinPolicy{Timezone: "Asia/Shanghai"}, }, { ID: "cn", Label: "CN", ChatBase: "https://gateway.qwenwork.cn", BillingBase: "https://gateway.qwenwork.cn", AuthBase: "https://gateway.qwenwork.cn", DefaultDomain: "qwenwork.cn", Checkin: &CheckinPolicy{Timezone: "Asia/Shanghai"}, }, }, DefaultRegion: "global", }
QwenWork descriptor. Protocol constants stay in internal/providers/qwenwork; the registry only carries control-plane metadata. QwenWork is the rebranded QoderWork desktop product: global is qwenwork.ai, cn is 千问办公 qwenwork.cn. Daily free credits are granted by the server at 00:00 Asia/Shanghai (CN wallet copy: "每日 0 点刷新"; global pricing lists the same "daily login bonus"), so both regions use that day boundary.
var Trae = ProviderDescriptor{ ID: "trae", Label: "Trae", Runtime: RuntimeInProcess, AuthTypes: []AuthType{AuthOAuth}, CredentialFormats: []string{"trae-oauth-v1"}, Capabilities: ProviderCapabilities{ Chat: true, Stream: true, Tools: true, Images: false, Reasoning: true, ModelCatalog: true, Usage: true, Login: true, BrowserLogin: true, PATLogin: false, ImportExport: true, }, Regions: []RegionDescriptor{ { ID: "cn", Label: "CN Solo", ChatBase: "https://trae-api-cn.mchost.guru", BillingBase: "https://api.trae.cn", AuthBase: "https://api.trae.com.cn", DefaultDomain: "trae.cn", Checkin: &CheckinPolicy{Timezone: "Asia/Shanghai"}, }, }, DefaultRegion: "cn", }
Trae descriptor. Protocol constants stay in internal/providers/trae; the registry only carries control-plane metadata. CN Solo is the only region implemented; do not spawn official traecli.
var WorkBuddy = ProviderDescriptor{ ID: "workbuddy", Label: "WorkBuddy", Runtime: RuntimeInProcess, AuthTypes: []AuthType{AuthNone, AuthOAuth}, CredentialFormats: []string{"workbuddy-oauth-v1", "workbuddy-accounts"}, Capabilities: ProviderCapabilities{ Chat: true, Stream: true, Tools: true, Images: false, Reasoning: true, ModelCatalog: true, Usage: true, Login: true, BrowserLogin: true, PATLogin: false, ImportExport: true, }, Regions: []RegionDescriptor{ { ID: "cn", Label: "CN", ChatBase: "https://copilot.tencent.com", BillingBase: "https://www.codebuddy.cn", AuthBase: "https://copilot.tencent.com", DefaultDomain: "codebuddy.cn", Checkin: &CheckinPolicy{Timezone: "Local"}, }, { ID: "global", Label: "Global", ChatBase: "https://www.workbuddy.ai", BillingBase: "https://www.workbuddy.ai", AuthBase: "https://www.workbuddy.ai", DefaultDomain: "workbuddy.ai", Checkin: &CheckinPolicy{Timezone: "Local"}, }, }, DefaultRegion: "cn", }
WorkBuddy descriptor. Protocol constants stay in internal/providers/workbuddy; the registry only carries control-plane metadata.
var Zhipu = ProviderDescriptor{ ID: "zhipu", Label: "Zhipu GLM", Runtime: RuntimeInProcess, AuthTypes: []AuthType{AuthPAT}, CredentialFormats: []string{"zhipu-key-v1"}, Capabilities: ProviderCapabilities{ Chat: true, Stream: true, Tools: true, Images: false, Reasoning: true, ModelCatalog: true, Usage: true, Login: false, BrowserLogin: false, PATLogin: true, ImportExport: true, }, Regions: []RegionDescriptor{ { ID: "cn", Label: "CN", ChatBase: "https://open.bigmodel.cn", BillingBase: "https://open.bigmodel.cn", AuthBase: "https://open.bigmodel.cn", DefaultDomain: "bigmodel.cn", }, }, DefaultRegion: "cn", }
Zhipu descriptor. Protocol constants stay in internal/providers/zhipu. CN-only in-process adapter. Auth is a pasted API key; pay-as-you-go and Coding Plan differ by base URL, not by a second provider family.
Functions ¶
func ClientUserAgentFromContext ¶ added in v0.7.4
ClientUserAgentFromContext returns the inbound User-Agent set by WithClientUserAgent, or empty when unset.
func CodexClientHeadersFromContext ¶ added in v0.7.8
CodexClientHeadersFromContext returns the inbound Codex passthrough headers set by WithCodexClientHeaders, or nil when unset.
func ConversationFromContext ¶ added in v0.7.32
ConversationFromContext returns the session key set by WithConversation, or empty when the request has no stable conversation.
func DisabledThinkingField ¶ added in v0.7.34
DisabledThinkingField returns the canonical body value for a disabled thinking request, ready to be set on an outbound JSON body.
func IsTLSVerifyError ¶ added in v0.7.1
IsTLSVerifyError reports whether err is a certificate or hostname verification failure (as opposed to a transient TLS reset or timeout).
func NormalizeReasoningLevel ¶ added in v0.2.21
func RequestsDisabledThinking ¶ added in v0.7.34
func RequestsDisabledThinking(req translate.ChatRequest) bool
RequestsDisabledThinking reports whether the caller explicitly asked to switch reasoning off with a nested thinking object. It deliberately does not treat reasoning_effort:"none" / enable_thinking:false as this signal: those are already handled by each adapter's level path and, for models that do not advertise "none", are clamped back to the catalog default.
func Resolve ¶
func Resolve(provider, region string) (ProviderDescriptor, RegionDescriptor, error)
Resolve validates a provider/region pair. Empty values fall back to the historical qoder/global default so pre-provider rows keep behaving the same.
func ResolveReasoningLevel ¶ added in v0.2.21
func ResolveReasoningLevel(level string, caps ModelCapabilities) string
func UniqueReasoningOptions ¶ added in v0.2.21
func ValidateCredentialFormat ¶
ValidateCredentialFormat rejects formats that the provider cannot store.
func WithClientUserAgent ¶ added in v0.7.4
WithClientUserAgent records the inbound User-Agent so providers can branch on the calling client (for example Codex SIWC vs outer OAuth).
func WithCodexClientHeaders ¶ added in v0.7.8
WithCodexClientHeaders records selected inbound Codex headers so the Codex adapter can pass them through on non-SIWC upstream requests.
Types ¶
type AccountCheckiner ¶ added in v0.6.1
type AccountCheckiner interface {
Checkin(ctx context.Context, accountID string) (CheckinResult, error)
}
type AccountHealth ¶ added in v0.2.10
AccountHealth is the provider-neutral readiness snapshot for in-process accounts that have no child-process /health endpoint.
type AccountProber ¶ added in v0.2.10
type AccountProber interface {
Probe(ctx context.Context, accountID string) (AccountHealth, error)
Quota(ctx context.Context, accountID string) (*QuotaInfo, error)
}
AccountProber refreshes provider-native readiness and optional display quota.
type ActionError ¶ added in v0.6.0
func (*ActionError) Error ¶ added in v0.6.0
func (e *ActionError) Error() string
func (*ActionError) Unwrap ¶ added in v0.6.0
func (e *ActionError) Unwrap() error
type Adapter ¶
type Adapter struct {
ID string
Credential CredentialCodec
Login LoginSessionProvider
Chat ProviderChat
Models ModelCatalogProvider
Classifier ErrorClassifier
ImportExport ImportExporter
Prober AccountProber
Checkin AccountCheckiner
// StreamFormat declares the SSE dialect ChatStream returns (see
// StreamFormat* constants). Empty means chat-completions deltas.
StreamFormat string
// NativeResponses is the optional native Responses capability. When set,
// /v1/responses requests routed to this adapter skip the chat form.
NativeResponses NativeResponsesStreamer
}
Adapter bundles the optional capability interfaces. Every field may be nil; use Supports() before calling so unsupported paths fail explicitly.
type AdminRequest ¶ added in v0.6.0
AdminRequest/Response carry worker protocol data, never a public HTTP writer.
type AdminResponse ¶ added in v0.6.0
type ChatOutcome ¶
type ChatOutcome struct {
Model string
Content string
Reasoning string
ToolCalls json.RawMessage
FinishReason string
PromptTokens int
CompletionTokens int
CacheReadTokens *int
CacheWriteTokens *int
UsageSource string
Credits *float64
// ReasoningLevel is the clamped reasoning level actually sent upstream,
// empty when the provider did not include one in the payload.
ReasoningLevel string
}
ChatOutcome is the provider-neutral non-stream result.
type CheckinPolicy ¶ added in v0.6.1
type CheckinPolicy struct {
Timezone string `json:"timezone"`
}
func CheckinFor ¶ added in v0.6.1
func CheckinFor(providerID, regionID string) (*CheckinPolicy, bool)
type CheckinResult ¶ added in v0.6.1
type CheckinResult struct {
Status string `json:"status"`
Message string `json:"message"`
RewardCredits float64 `json:"reward_credits,omitempty"`
}
func (CheckinResult) Valid ¶ added in v0.6.1
func (result CheckinResult) Valid() bool
type ClassifiedError ¶
type CredentialBatchExpander ¶ added in v0.7.10
CredentialBatchExpander unwraps a multi-account credential package into one raw credential JSON per account. Importers that only accept a single payload do not implement this interface. Control prepares and persists each chunk independently so invalid entries can fail without blocking the rest of the package.
type CredentialCodec ¶
CredentialCodec validates and stores provider credentials.
type CredentialImport ¶ added in v0.6.0
type CredentialImport struct {
Payload []byte
Ready bool
// Region overrides the operator's region when the credential itself names a
// data plane. Empty keeps the region from the import request.
Region string
// Name is a display label read from the credential (email, nickname). Empty
// keeps the name from the import request.
Name string
}
CredentialImport prepares a canonical payload without persistence. Ready controls whether an imported account may be enabled immediately.
type CredentialImporter ¶ added in v0.6.0
type CredentialImporter interface {
Format() string
PrepareImport([]byte) (CredentialImport, error)
}
type Error ¶ added in v0.2.16
type Error struct {
Kind string
Status int
Message string
Code string
Type string
RetryAfter time.Duration
}
Error is the in-process adapter error the executor classifies for cooldown and failover. Kind must be an accounts taxonomy value.
type ErrorClassifier ¶
type ErrorClassifier interface {
Classify(status int, body string) ClassifiedError
}
ErrorClassifier maps provider errors to the internal taxonomy.
type ImportExporter ¶
type ImportExporter interface {
ValidateImport(payload []byte) error
Export(ctx context.Context, accountID string) (map[string]any, error)
}
ImportExporter validates and exports provider-specific credential JSON.
type LoginCompleter ¶ added in v0.2.17
type LoginCompleter interface {
CompleteLogin(ctx context.Context, accountID, callbackURL string) error
}
LoginCompleter accepts a provider callback URL copied from the browser when the automatic loopback redirect cannot reach this process.
type LoginSession ¶
LoginSession describes one browser-login round for an account.
type LoginSessionProvider ¶
type LoginSessionProvider interface {
StartLogin(ctx context.Context, accountID string) (LoginSession, error)
PollLogin(ctx context.Context, accountID string) (done bool, message string, err error)
}
LoginSessionProvider starts and polls provider-native browser login.
type ModelCapabilities ¶
type ModelCapabilities struct {
ContextWindow int `json:"context_window,omitempty"`
ContextWindowMax int `json:"context_window_max,omitempty"`
MaxOutput int `json:"max_output_tokens,omitempty"`
PromptMaxTokens int `json:"prompt_max_tokens,omitempty"`
// MaxMode tiers: when a model declares a second (Max/Max-mode) tier, these
// carry the Max-tier prompt/output ceilings so the console can show the
// value that matches the max-mode toggle instead of the default tier.
PromptMaxTokensMax int `json:"prompt_max_tokens_max,omitempty"`
MaxOutputMax int `json:"max_output_tokens_max,omitempty"`
MaxMode bool `json:"max_mode,omitempty"`
Tools bool `json:"tools"`
Images bool `json:"images"`
Reasoning bool `json:"reasoning"`
ReasoningOptions []string `json:"reasoning_options,omitempty"`
ReasoningDefault string `json:"reasoning_default,omitempty"`
ReasoningType string `json:"reasoning_type,omitempty"`
CanDisableThinking bool `json:"can_disable_thinking,omitempty"`
}
type ModelCatalogProvider ¶
type ModelCatalogProvider interface {
Models(ctx context.Context, accountID string) ([]ModelInfo, error)
}
ModelCatalogProvider lists models an account can currently serve.
type ModelInfo ¶
type ModelInfo struct {
NativeModel string `json:"native_model"`
PublicModel string `json:"public_model"`
DisplayName string `json:"display_name,omitempty"`
Credits string `json:"credits,omitempty"`
Free bool `json:"free,omitempty"`
Capabilities ModelCapabilities `json:"capabilities"`
// Scene is the provider-native scene/function a chat for this model must be
// sent under. Empty means the provider has no scene split. Providers use it
// to keep a model routed to the scene that actually serves it; it is
// provider-internal and never a public API field.
Scene string `json:"-"`
}
type NativeResponsesStreamer ¶ added in v0.6.7
type NativeResponsesStreamer interface {
ResponsesStream(ctx context.Context, accountID string, req *translate.NativeResponsesRequest, options RequestOptions) (*http.Response, ResolvedChat, error)
}
NativeResponsesStreamer is the optional native OpenAI Responses capability. An adapter implements it only when its upstream speaks Responses and it can build the upstream request from the client's original Responses body, so item identity, reasoning replay, and unknown members survive. The returned body is always an upstream Responses SSE stream; a non-stream client call collects it. Adapters without it serve /v1/responses through ChatStream / ChatNonStream and the shared chat form.
type ProviderCapabilities ¶
type ProviderCapabilities struct {
Chat bool `json:"chat"`
Stream bool `json:"stream"`
Tools bool `json:"tools"`
Images bool `json:"images"`
Reasoning bool `json:"reasoning"`
ModelCatalog bool `json:"model_catalog"`
Usage bool `json:"usage"`
Login bool `json:"login"`
BrowserLogin bool `json:"browser_login"`
PATLogin bool `json:"pat_login"`
ImportExport bool `json:"import_export"`
}
type ProviderChat ¶
type ProviderChat interface {
ChatNonStream(ctx context.Context, accountID string, req translate.ChatRequest) (ChatOutcome, error)
ChatStream(ctx context.Context, accountID string, req translate.ChatRequest) (*http.Response, ResolvedChat, error)
}
ProviderChat executes chat for one account. Stream implementations return the raw upstream response for the API layer to relay.
type ProviderDescriptor ¶
type ProviderDescriptor struct {
ID string `json:"id"`
Label string `json:"label"`
Runtime RuntimeKind `json:"runtime"`
AuthTypes []AuthType `json:"auth_types"`
CredentialFormats []string `json:"credential_formats"`
Capabilities ProviderCapabilities `json:"capabilities"`
Regions []RegionDescriptor `json:"regions"`
DefaultRegion string `json:"default_region"`
}
func Get ¶
func Get(id string) (ProviderDescriptor, bool)
func List ¶
func List() []ProviderDescriptor
func (ProviderDescriptor) Region ¶
func (d ProviderDescriptor) Region(id string) (RegionDescriptor, bool)
func (ProviderDescriptor) SupportsAuthType ¶
func (d ProviderDescriptor) SupportsAuthType(auth AuthType) bool
func (ProviderDescriptor) SupportsCheckin ¶ added in v0.6.1
func (descriptor ProviderDescriptor) SupportsCheckin() bool
func (ProviderDescriptor) SupportsCredentialFormat ¶
func (d ProviderDescriptor) SupportsCredentialFormat(format string) bool
type QuotaInfo ¶ added in v0.2.10
type QuotaInfo struct {
Used float64
Total float64
Remaining float64
Percentage float64
Unit string
Exceeded bool
FetchedAt string
Windows []QuotaWindow
// ProviderID identifies which adapter produced this info. Callers use it
// to gate provider-specific fields (e.g. package expiry) instead of
// trusting that every adapter populates them.
ProviderID string
// Plan is the upstream subscription tier, such as Codex plan_type "plus".
// Empty means the provider did not report one.
Plan string
// ExpiresAt is the soonest package expiry (Unix seconds); 0 means the
// provider did not report one. ExpiringRemain is the remaining amount that
// expires at that time. Packages carries the per-pack expiry detail.
ExpiresAt int64
ExpiringRemain float64
Packages []QuotaPackage
// AddOn / ResourcePackage carry the Qoder credit-bucket breakdown so the
// persisted snapshot keeps the same detail the browser/worker path shows.
// They are only populated by providers that report these buckets (Qoder).
HasAddOn bool
AddOnUsed float64
AddOnTotal float64
AddOnRemaining float64
AddOnUnit string
AddOnAvailable *bool
HasResourcePackage bool
ResourcePackageUsed float64
ResourcePackageTotal float64
ResourcePackageRemaining float64
ResourcePackageUnit string
ResourcePackageAvailable *bool
}
QuotaInfo is account usage for the console and exhausted-account routing. Callers must treat probe readiness and quota independently; quota errors never flip Ready.
type QuotaPackage ¶ added in v0.6.6
type QuotaPackage struct {
Remain float64
Used float64
Size float64
Unit string
// Scope follows accounts.QuotaPackageScopeAccountFEFO; empty is unknown.
Scope string
EndsAt int64
EndTime string
}
QuotaPackage is one upstream credit/resource pack with its own expiry. EndsAt is a Unix second; EndTime is the provider-native wall-clock string.
type QuotaWindow ¶ added in v0.6.3
type QuotaWindow struct {
ID string
Label string
Used float64
Total float64
Remaining float64
Percentage float64
Unit string
ResetAt string
Exceeded bool
}
QuotaWindow is one provider-native usage period. Console cards may render each window; routing still uses the tighter top-level QuotaInfo values.
type RegionDescriptor ¶
type Registry ¶
type Registry struct {
// contains filtered or unexported fields
}
Registry holds runtime adapters keyed by provider family. Descriptors stay static; adapters own upstream protocol behavior.
func NewRegistry ¶
func NewRegistry() *Registry
type RequestOptions ¶ added in v0.6.7
type RequestOptions struct {
// Model is the upstream model id resolved for this account (its catalog
// spelling), not the public id the client sent.
Model string
// DropSystemPrompt removes caller system/developer prompts before send
// (account policy for upstreams with content screening).
DropSystemPrompt bool
}
RequestOptions are the per-attempt execution decisions the executor makes for one picked account. They travel explicitly, never through ctx, and are recomputed for every failover attempt.
type ResolvedChat ¶ added in v0.6.1
type ResolvedChat struct {
// ReasoningLevel is the clamped reasoning level actually sent upstream,
// empty when the provider did not include one in the payload.
ReasoningLevel string
}
ResolvedChat carries provider-side metadata for a stream request that the API layer may want to log alongside the relayed upstream response.
type RuntimeKind ¶
type RuntimeKind string
const ( RuntimeChildProcess RuntimeKind = "child_process" RuntimeInProcess RuntimeKind = "in_process" )
Source Files
¶
Directories
¶
| Path | Synopsis |
|---|---|
|
Package codearts implements the Huawei Cloud CodeArts Agent (码道) in-process provider.
|
Package codearts implements the Huawei Cloud CodeArts Agent (码道) in-process provider. |
|
Package codex implements the OpenAI Codex (ChatGPT subscription) in-process provider.
|
Package codex implements the OpenAI Codex (ChatGPT subscription) in-process provider. |
|
Package command implements the Command Code (commandcode.ai) in-process provider.
|
Package command implements the Command Code (commandcode.ai) in-process provider. |
|
Package devin implements the Devin / Codeium Connect-RPC in-process provider.
|
Package devin implements the Devin / Codeium Connect-RPC in-process provider. |
|
Package doubaowork is the in-process provider adapter for Doubao Work (豆包工作).
|
Package doubaowork is the in-process provider adapter for Doubao Work (豆包工作). |
|
Package kimi implements the China-region Kimi Code (Moonshot AI) in-process provider.
|
Package kimi implements the China-region Kimi Code (Moonshot AI) in-process provider. |
|
Package kiro is the in-process adapter for a personal Kiro login.
|
Package kiro is the in-process adapter for a personal Kiro login. |
|
Package meta is the in-process Adapter for Meta Muse (provider=meta, alias muse).
|
Package meta is the in-process Adapter for Meta Muse (provider=meta, alias muse). |
|
Package minimaxcode implements an in-process adapter for the MiniMax Code subscription product (agent.minimax.cn / agent.minimax.io).
|
Package minimaxcode implements an in-process adapter for the MiniMax Code subscription product (agent.minimax.cn / agent.minimax.io). |
|
qauth
Package qauth implements Qoder gateway authentication, encryption, and HTTP client.
|
Package qauth implements Qoder gateway authentication, encryption, and HTTP client. |
|
Package qwenwork implements the QwenWork (千问办公) in-process provider.
|
Package qwenwork implements the QwenWork (千问办公) in-process provider. |
|
Package trae implements the Trae CN Solo in-process provider.
|
Package trae implements the Trae CN Solo in-process provider. |
|
Package workbuddy implements the WorkBuddy / CodeBuddy in-process provider.
|
Package workbuddy implements the WorkBuddy / CodeBuddy in-process provider. |
|
Package zhipu implements the Zhipu GLM (open.bigmodel.cn) in-process provider.
|
Package zhipu implements the Zhipu GLM (open.bigmodel.cn) in-process provider. |