Versions in this module Expand all Collapse all v0 v0.0.2 Oct 12, 2026 Changes in this version + const ContentTypeEventStream + const ContentTypeJSON + const CredentialMetadataAccountLabel + const CredentialMetadataOAuthClientID + const CredentialMetadataOAuthClientMode + const CredentialMetadataOAuthClientSecret + const CredentialMetadataOAuthProfile + const CredentialMetadataOAuthRedirectURI + const CredentialMetadataProjectID + const DefaultTransportFreshness + const EvidenceOperationInvoke + const EvidenceOperationListModels + const EvidenceOperationStream + const ListingChatCompletions + const ListingMessages + const ListingResponses + const ModelCapabilitiesSchemaVersion + const TokenTypeAPIKey + const TokenTypeAnthropicSetupToken + const TokenTypeGCPServiceAccount + const TransportModeNative + const TransportModeTranslated + const TransportModeTransparent + var ErrCatalogConflict = errors.New("core: catalog revision conflict") + var ErrCatalogNotFound = errors.New("core: catalog not found") + var ErrInvalidTransportRequirement = errors.New("core: a requested transport must be transparent when present") + var ErrNoCredential = errors.New("core: no credential resolves for this caller and instance") + var ErrTokenCountUnsupported = errors.New("core: the provider cannot count tokens natively") + func APIKeyRecord(apiKey string) tokenstore.Record + func KnownModelSurface(surface ModelSurface) bool + func ListingSurfaces(provider Provider, credential *Credential, evidence TransportEvidence, ...) (native, emulated, unknown []string) + func NewProviderOperationError(op string, statusCode int, retryAfter string, err error) error + func PreservesWire(provider Provider, model string, surface ModelSurface) bool + func PreservesWireFor(provider Provider, credential *Credential, model string, surface ModelSurface) bool + func ResponseTransportMode(provider Provider, credential *Credential, model string, surface ModelSurface, ...) string + func ServesNatively(provider Provider, model string, surface ModelSurface) bool + func SurfacePath(surface ModelSurface) string + type AccountEvidence struct + AccountID string + Caller Caller + CredentialKey string + CredentialRevision string + Instance string + Model string + Operation string + Outcome ProviderHealthEvidence + Surface ModelSurface + type AllowAllPolicy struct + func (AllowAllPolicy) Allows(ctx context.Context, principal *Principal, target Target) (bool, string) + type Authenticator interface + Authenticate func(r *http.Request) (*Principal, error) + type AuthenticatorFunc func(r *http.Request) (*Principal, error) + func (f AuthenticatorFunc) Authenticate(r *http.Request) (*Principal, error) + type Caller struct + ID string + Kind CallerKind + ProjectID string + func LocalCaller() Caller + func (c Caller) Validate() error + type CallerKind string + const CallerAnonymous + const CallerHuman + const CallerLocal + const CallerService + type CatalogEvidence struct + Models []ModelInfo + ObservedAt time.Time + SchemaVersion int + Status CatalogEvidenceStatus + type CatalogEvidenceStatus string + const CatalogDiscovered + const CatalogEmpty + const CatalogFailed + const CatalogNotProbed + type CatalogKey struct + CredentialKey string + Instance string + type CatalogRecord struct + Evidence CatalogEvidence + Revision string + type CatalogStore interface + Load func(ctx context.Context, key CatalogKey) (CatalogRecord, error) + Save func(ctx context.Context, key CatalogKey, evidence CatalogEvidence) (revision string, err error) + type CompletionProbeEvidence struct + FailureCode string + Latency time.Duration + ObservedAt time.Time + Status CompletionProbeStatus + Target Target + func (e CompletionProbeEvidence) InferenceVerified() bool + type CompletionProbeStatus string + const CompletionFailed + const CompletionNotProbed + const CompletionVerified + type ConditionalCatalogStore interface + Delete func(ctx context.Context, key CatalogKey) error + SaveIf func(ctx context.Context, key CatalogKey, evidence CatalogEvidence, expected string) (revision string, err error) + type Config struct + Authenticator Authenticator + CredentialResolver CredentialResolver + DefaultRoute string + PolicyGate PolicyGate + Providers map[string]ProviderConfig + Routes map[string]RouteConfig + UsageHook UsageHook + type Credential struct + APIKey string + AccountID string + ConnectionID string + CredentialRevision int64 + Headers map[string]string + Metadata map[string]string + Token string + TokenType string + func CredentialFromRecord(key string, record tokenstore.Record) *Credential + func (c Credential) Format(state fmt.State, verb rune) + func (c Credential) GoString() string + func (c Credential) LogValue() slog.Value + func (c Credential) String() string + type CredentialResolver interface + Resolve func(ctx context.Context, principal *Principal, providerID string) (*Credential, error) + type CredentialStore interface + Resolve func(ctx context.Context, caller Caller, instance string) (key string, err error) + type CredentialWirePreserver interface + PreservesWireFor func(credential *Credential, model string, surface ModelSurface) bool + type Disposition string + const DispositionFailover + const DispositionRetryable + const DispositionTerminal + type Engine struct + func NewEngine(cfg Config) *Engine + func (e *Engine) RegisterProvider(id string, provider any) + func (e *Engine) ServeHTTP(w http.ResponseWriter, r *http.Request) + type EvidenceSink interface + Record func(ctx context.Context, evidence AccountEvidence) + type EvidenceSinkFunc func(ctx context.Context, evidence AccountEvidence) + func (f EvidenceSinkFunc) Record(ctx context.Context, evidence AccountEvidence) + type FreshnessStatus string + const FreshnessExpired + const FreshnessFresh + const FreshnessUnknown + type GenerateImagesRequest struct + Count int + Model string + Prompt string + type GenerateImagesResult struct + Images []GeneratedImage + Usage map[string]any + type GeneratedImage struct + Data []byte + MimeType string + type ImageGenerator interface + GenerateImages func(context.Context, GenerateImagesRequest, *Credential) (GenerateImagesResult, error) + type Loss = translate.Loss + func StreamLosses(stream StreamIter) []Loss + type LossAction string + const LossAllow + const LossReject + type LossPolicy struct + Rules []LossRule + func (p LossPolicy) Check(losses []Loss) error + func (p LossPolicy) Decide(loss Loss) LossAction + func (p LossPolicy) Rejected(losses []Loss) []Loss + func (p LossPolicy) Validate() error + type LossPolicyError struct + Losses []Loss + func (e *LossPolicyError) Error() string + func (e *LossPolicyError) ProviderErrorClassification() ProviderErrorClassification + type LossReporter interface + Losses func() []Loss + type LossRule struct + Action LossAction + Class translate.LossClass + Path string + Severity translate.LossSeverity + type MemoryCatalogStore struct + func NewMemoryCatalogStore() *MemoryCatalogStore + func (s *MemoryCatalogStore) Delete(ctx context.Context, key CatalogKey) error + func (s *MemoryCatalogStore) Load(ctx context.Context, key CatalogKey) (CatalogRecord, error) + func (s *MemoryCatalogStore) Save(ctx context.Context, key CatalogKey, evidence CatalogEvidence) (string, error) + func (s *MemoryCatalogStore) SaveIf(ctx context.Context, key CatalogKey, evidence CatalogEvidence, expected string) (string, error) + type MemoryCredentialStore struct + func NewMemoryCredentialStore() *MemoryCredentialStore + func (s *MemoryCredentialStore) Bind(caller Caller, instance, key string) + func (s *MemoryCredentialStore) BindShared(instance, key string) + func (s *MemoryCredentialStore) Resolve(ctx context.Context, caller Caller, instance string) (string, error) + type MemoryEvidenceSink struct + func (s *MemoryEvidenceSink) Record(_ context.Context, evidence AccountEvidence) + func (s *MemoryEvidenceSink) Records() []AccountEvidence + type ModelCapabilities struct + Freshness ModelCapabilityFreshness + Inputs ModelInputCapabilities + Limits ModelCapabilityLimits + Operations ModelOperationCapabilities + Provenance ModelCapabilityProvenance + Reasoning Support + SchemaVersion int + StatefulResponses Support + Streaming Support + StructuredOutput Support + Surfaces ModelSurfaceCapabilities + Tools Support + func AdaptModelCapabilities(legacy map[string]any, surfaces []string, discoveredAt, verifiedAt time.Time) *ModelCapabilities + func InferCapabilities(model ModelInfo, discoveredAt, verifiedAt time.Time) *ModelCapabilities + func (c ModelCapabilities) OperationCompatibility(operation ModelOperation) Support + func (c ModelCapabilities) SurfaceCompatibility(surface ModelSurface) Support + type ModelCapabilityConfidence string + const ModelCapabilityConfidenceHigh + const ModelCapabilityConfidenceLow + const ModelCapabilityConfidenceMedium + type ModelCapabilityFreshness struct + DiscoveredAt *time.Time + ExpiresAt *time.Time + VerifiedAt *time.Time + func (f ModelCapabilityFreshness) IsFresh(at time.Time) bool + func (f ModelCapabilityFreshness) Status(at time.Time) FreshnessStatus + type ModelCapabilityLimits struct + ContextTokens *int64 + MaxOutputTokens *int64 + type ModelCapabilityProvenance struct + Confidence ModelCapabilityConfidence + Source ModelCapabilitySource + type ModelCapabilitySource string + const ModelCapabilitySourceInferred + const ModelCapabilitySourceModelsDev + const ModelCapabilitySourceOperatorOverride + const ModelCapabilitySourceRegistryStatic + const ModelCapabilitySourceUpstreamReported + type ModelInfo struct + APIEligible *bool + APIVisibility string + Capabilities *ModelCapabilities + Created int64 + Description string + DisplayName string + Free bool + ID string + LegacyCapabilities map[string]any + Object string + OwnedBy string + SupportedAPIs []string + Tags []string + Vendor string + type ModelInputCapabilities struct + Image Support + Text Support + type ModelOperation string + const ModelOperationAudioIn + const ModelOperationAudioOut + const ModelOperationChat + const ModelOperationEmbeddings + const ModelOperationImage + const ModelOperationTokenCount + const ModelOperationVideo + type ModelOperationCapabilities struct + AudioIn Support + AudioOut Support + Chat Support + Embeddings Support + Image Support + TokenCount Support + Video Support + type ModelSurface string + const ModelSurfaceAudioSpeech + const ModelSurfaceAudioTranscriptions + const ModelSurfaceChatCompletions + const ModelSurfaceEmbeddings + const ModelSurfaceImages + const ModelSurfaceMessages + const ModelSurfaceResponses + const ModelSurfaceVideos + func ParseSurfacePath(path string) ModelSurface + type ModelSurfaceCapabilities struct + ChatCompletions Support + Messages Support + Responses Support + type PolicyGate interface + Allows func(ctx context.Context, principal *Principal, target Target) (bool, string) + type Principal struct + ID string + Metadata map[string]any + Name string + ProjectID string + Type string + func (p *Principal) Caller() Caller + type Provider interface + Invoke func(ctx context.Context, request Request) (Response, error) + ListModels func(ctx context.Context, credential *Credential) ([]ModelInfo, error) + NativeSurfaces func(model string) []ModelSurface + Stream func(ctx context.Context, request Request) (StreamIter, error) + type ProviderAdapter struct + Complete ProviderCompletionRuntime + DiscoverModels ProviderModelDiscoverer + SelectProbeTargets ProviderProbeSelector + ValidateAuthentication ProviderAuthenticationValidator + type ProviderAuthKind string + const ProviderAuthAPIKey + const ProviderAuthAnonymous + const ProviderAuthOAuthBrowser + const ProviderAuthOAuthDevice + const ProviderAuthOfficialClient + const ProviderAuthServiceAccount + const ProviderAuthWorkloadIdentity + type ProviderAuthenticationValidator func(context.Context, ProviderConnection) error + type ProviderCompletionRuntime func(context.Context, ProviderConnection, Target, map[string]any) (map[string]any, error) + type ProviderConfig struct + APIKey string + AllowedModels []string + BaseURL string + Disabled bool + Headers map[string]string + Timeout time.Duration + Type string + type ProviderConnectRequest struct + AuthenticationValidated bool + Connection ProviderConnection + PublicationPolicy TargetPublicationPolicy + type ProviderConnectResult struct + Catalog CatalogEvidence + Connection ProviderConnection + Health ProviderHealthEvidence + Probes []CompletionProbeEvidence + Targets []Target + type ProviderConnection struct + AuthKind ProviderAuthKind + Credential *Credential + ID string + Kind ProviderConnectionKind + OwnerID string + ProviderID string + func (c ProviderConnection) Validate() error + type ProviderConnectionKind string + const ProviderConnectionAnonymous + const ProviderConnectionPersonal + const ProviderConnectionPersonalSubscription + const ProviderConnectionSystem + type ProviderConnector interface + Connect func(ctx context.Context, request ProviderConnectRequest) (ProviderConnectResult, error) + type ProviderError struct + Cause error + Class ProviderErrorClass + Classification ProviderErrorClassification + Message string + func NewConfigurationError(message string, cause error) *ProviderError + func (e *ProviderError) Error() string + func (e *ProviderError) ProviderErrorClassification() ProviderErrorClassification + func (e *ProviderError) Unwrap() error + type ProviderErrorClass string + const ProviderErrorAuth + const ProviderErrorBilling + const ProviderErrorConfiguration + const ProviderErrorContextOverflow + const ProviderErrorForbidden + const ProviderErrorInvalidRequest + const ProviderErrorMediaUnsupported + const ProviderErrorNone + const ProviderErrorRateLimited + const ProviderErrorToolsUnsupported + const ProviderErrorTransport + const ProviderErrorUnsupported + const ProviderErrorUpstream + type ProviderErrorClassification struct + CircuitFailure bool + FailoverEligible bool + RetryAfter time.Duration + Retryable bool + StatusCode int + func ClassifyError(err error) ProviderErrorClassification + func (c ProviderErrorClassification) Disposition() Disposition + type ProviderErrorClassifier interface + ProviderErrorClassification func() ProviderErrorClassification + type ProviderFailure struct + Err error + ObservedAt time.Time + RetryAfter string + StatusCode int + type ProviderHealthEvidence struct + ErrorClass ProviderErrorClass + ObservedAt time.Time + Permanent bool + RetryAfter time.Duration + Retryable bool + Status ProviderHealthStatus + func ClassifyProviderFailure(f ProviderFailure) ProviderHealthEvidence + type ProviderHealthStatus string + const ProviderHealthDegraded + const ProviderHealthHealthy + const ProviderHealthUnhealthy + const ProviderHealthUnknown + type ProviderModelDiscoverer func(context.Context, ProviderConnection) ([]ModelInfo, error) + type ProviderOperationError struct + Failure ProviderFailure + Op string + func (e *ProviderOperationError) Error() string + func (e *ProviderOperationError) ProviderErrorClassification() ProviderErrorClassification + func (e *ProviderOperationError) Unwrap() error + type ProviderOrchestrator struct + func NewProviderOrchestrator() *ProviderOrchestrator + func (o *ProviderOrchestrator) Connect(ctx context.Context, request ProviderConnectRequest) (ProviderConnectResult, error) + func (o *ProviderOrchestrator) Register(providerID string, adapter ProviderAdapter) error + type ProviderProbeSelector func(ProviderConnection, []ModelInfo) []Target + type Request struct + Body []byte + ContentType string + Credential *Credential + Header http.Header + Model string + Surface ModelSurface + func (r Request) Validate() error + type Resolution struct + Category string + Targets []Target + type Response struct + Body []byte + ContentType string + Losses []Loss + type RouteConfig struct + Description string + Fallback bool + Targets []Target + type StaticCredentialResolver struct + Credentials map[string]Credential + func (s StaticCredentialResolver) Resolve(ctx context.Context, principal *Principal, providerID string) (*Credential, error) + type StreamIter interface + Close func() error + Next func() ([]byte, error) + type Support uint8 + const SupportSupported + const SupportUnknown + const SupportUnsupported + func (s *Support) UnmarshalJSON(data []byte) error + func (s Support) IsKnown() bool + func (s Support) IsSupported() bool + func (s Support) MarshalJSON() ([]byte, error) + func (s Support) String() string + type SurfaceError struct + Model string + Surface ModelSurface + func (e *SurfaceError) Error() string + func (e *SurfaceError) ProviderErrorClassification() ProviderErrorClassification + type Target struct + Model string + Provider string + func PublishExactTargets(providerID string, catalog CatalogEvidence, probes []CompletionProbeEvidence, ...) ([]Target, error) + type TargetPublicationPolicy string + const PublishDiscoveredTargets + const PublishVerifiedTargets + type TokenCount struct + InputTokens int64 + func CountTokens(ctx context.Context, provider Provider, request TokenCountRequest) (TokenCount, error) + type TokenCountRequest struct + Header http.Header + type TokenCounter interface + CountTokens func(ctx context.Context, request TokenCountRequest) (TokenCount, error) + type TransportConfidence string + const TransportConfidenceHigh + const TransportConfidenceLow + const TransportConfidenceMedium + type TransportDisposition string + const TransportAdapted + const TransportNative + const TransportReject + type TransportEvidence struct + FreshFor time.Duration + RefreshedAt time.Time + Row ModelInfo + func (e TransportEvidence) Capabilities() ModelCapabilities + type TransportInterface struct + Native Support + Surface ModelSurface + func TransportInterfaces(provider Provider, credential *Credential, model string, surfaces []string) []TransportInterface + type TransportPlan struct + Confidence TransportConfidence + Disposition TransportDisposition + Losses []translate.Loss + Reason TransportRejectReason + Surface ModelSurface + func PlanTransport(request TransportPlanRequest) TransportPlan + type TransportPlanRequest struct + Capabilities ModelCapabilities + EvaluatedAt time.Time + ExactTarget bool + Interfaces []TransportInterface + Operation ModelOperation + Requirement TransportRequirement + Surface ModelSurface + Translation translate.Report + TranslationEvaluated bool + type TransportRejectError struct + Model string + NativeInterface bool + Reason TransportRejectReason + Surface ModelSurface + func (e *TransportRejectError) Error() string + type TransportRejectReason string + const TransportRejectExactTargetRequired + const TransportRejectInvalidRequirement + const TransportRejectNativeRequired + const TransportRejectNativeUnconfirmed + const TransportRejectNoInterface + const TransportRejectNotCataloged + const TransportRejectOperationUnsupported + const TransportRejectStreaming + const TransportRejectTranslationLoss + const TransportRejectTranslationUnevaluated + type TransportRequirement string + const TransportRequirementAny + const TransportRequirementNative + const TransportRequirementTransparent + func ParseTransportRequirement(value string) (TransportRequirement, error) + type UsageHook interface + RecordUsage func(ctx context.Context, record UsageRecord) + type UsageHookFunc func(ctx context.Context, record UsageRecord) + func (f UsageHookFunc) RecordUsage(ctx context.Context, record UsageRecord) + type UsageRecord struct + Duration time.Duration + Error string + InputTokens int + Model string + OutputTokens int + PrincipalID string + ProjectID string + Provider string + RequestID string + StatusCode int + Stream bool + type WirePreserver interface + PreservesWire func(model string, surface ModelSurface) bool