providers

package
v0.4.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Dec 5, 2026 License: Apache-2.0 Imports: 21 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Overview

Package providers owns provider metadata and explicitly requested HTTP work.

Index

Constants

View Source
const (
	DefaultCopilotAgent        = "GitHubCopilotChat/0.68.0"
	DefaultCopilotEditor       = "vscode/1.140.0"
	DefaultCopilotEditorPlugin = "copilot-chat/0.68.0"
)

Copilot's service identifies its editor client by these values.

View Source
const CatalogURL = "https://models.dev/api.json"
View Source
const DefaultCatalogVersion = "0.170.0"

DefaultCatalogVersion tracks the reviewed stable Codex release used to query the ChatGPT account's model catalog.

View Source
const DefaultClaudeAgent = "claude-cli/2.1.280 (external, cli)"
View Source
const LegacyCatalogVersion = "0.160.1"

Variables

This section is empty.

Functions

func APIKeyHeaderDefaults

func APIKeyHeaderDefaults(api protocol.ConversationModelApi) map[string]string

APIKeyHeaderDefaults keeps native model discovery and conversation requests on the same client and protocol defaults before applying provider overrides.

func AccountResourceEndpoint

func AccountResourceEndpoint(authentication protocol.Authentication, value string) bool

func AnthropicBaseURL

func AnthropicBaseURL(endpoint url.URL) url.URL

AnthropicBaseURL returns the mount before the versioned Messages and Models routes.

func BundledCatalogProvider

func BundledCatalogProvider(endpoint string) (string, error)

BundledCatalogProvider resolves an unambiguous catalog endpoint from the pinned snapshot independently of which model metadata snapshot is active.

func CanonicalModelShortID

func CanonicalModelShortID(raw string) string

CanonicalModelShortID returns the last '/'-delimited segment of a model identifier (e.g. "openai/gpt-5.4" -> "gpt-5.4").

func CatalogOutputs added in v0.2.4

func CatalogOutputs(outputs []string) (known []string)

CatalogOutputs keeps known native modalities without giving them a media route.

func ChannelCatalogNamespace added in v0.2.4

func ChannelCatalogNamespace(endpoint string, authentication protocol.Authentication) (string, error)

ChannelCatalogNamespace identifies a known offering namespace for a channel.

func ClassifyModelKind

func ClassifyModelKind(rawID string, outputs []string) string

ClassifyModelKind resolves whether a model is a language/chat model ("chat") or a specialized non-language model ("image", "video", "audio", "embedding"). Explicit channel outputs take precedence, then models.dev metadata, then ID heuristics, defaulting to "chat".

func CompleteChannelModel

CompleteChannelModel enriches a model with a reference from its channel lookup.

func CompleteModel

CompleteModel resolves metadata from a matched offering without replacing configured limits, explicit effort choices, user-chosen tags or compaction.

func CompleteModelInputs added in v0.2.4

func CompleteModelInputs(model protocol.ConversationModel, catalogInputs []string) protocol.ConversationModel

CompleteModelInputs updates just the input tags. Native vision overrides the catalog's image entry, but says nothing about the other modalities.

func Endpoint

func Endpoint(value string) (*url.URL, error)

func InferModelFamily

func InferModelFamily(shortID string) string

InferModelFamily infers a canonical brand slug from a short model ID when the model is unlisted or supplied through an aggregator/proxy channel.

func InferModelKind

func InferModelKind(rawID string) string

InferModelKind classifies well-known non-chat model IDs when explicit output modalities are unavailable (e.g. custom proxy channels).

func OAuthFields

func OAuthFields(provider protocol.ConversationProvider) (map[string]string, error)

func OpenAIBaseURL

func OpenAIBaseURL(endpoint url.URL) url.URL

OpenAIBaseURL resolves the shared base for API-key inference and discovery. A bare origin uses /v1. A full operation URL can explicitly select another mount, including an API served at the root.

func ParsePresets

func ParsePresets(raw []byte) (protocol.ConversationPresetsCatalog, error)

func PathSegment

func PathSegment(value string) bool

PathSegment reports a value safe to place as one URL path segment, such as an Azure API version, deployment or a provider's job ID.

func RecoveryAccountIdentity

func RecoveryAccountIdentity(grant AccountGrant) string

RecoveryAccountIdentity names only service-issued principal and workspace identifiers. Missing identifiers cannot be replaced by an email, a label or a token: those do not prove that a fresh login owns the original task.

func RecoveryAuthenticationTarget

func RecoveryAuthenticationTarget(provider protocol.ConversationProvider, target *AccountTarget, grant AccountGrant) string

RecoveryAuthenticationTarget excludes installation-specific package digests while retaining the auth origin, flow and service/client target. The digest is an identity comparison, never an authorization or renewal credential.

func RefreshDiscoveredCapabilities

RefreshDiscoveredCapabilities updates the native request capabilities of a saved model while preserving its configuration.

func ReservedHeader

func ReservedHeader(name string) bool

ReservedHeader reports whether name is set only by the transport.

func RuntimeAccount

func RuntimeAccount(provider protocol.ConversationProvider, grant AccountGrant) (protocol.RuntimeCredential, error)

RuntimeAccount exports only fields used to execute an already selected model. Plugin extras enter the projection only through declared header injections.

func RuntimeAccountSecret

func RuntimeAccountSecret(value protocol.RuntimeCredential) (*protocol.Secret, error)

func RuntimeField

func RuntimeField(name string) bool

func ValidateBinding

func ValidateBinding(provider protocol.ConversationProvider) error

func ValidateCloud

func ValidateCloud(provider protocol.ConversationProvider) error

ValidateCloud checks an Amazon Bedrock or Vertex AI provider: API-key authentication (the Bedrock API key or the service-account JSON), the region, or the project and location, its options name, and an endpoint that is a service host without a path.

func ValidateConfiguration

func ValidateConfiguration(provider protocol.ConversationProvider) error

func ValidateFeatures

func ValidateFeatures(api protocol.ConversationModelApi, model protocol.ConversationModel, selected map[string]string) error

func ValidateHeaders

func ValidateHeaders(provider protocol.ConversationProvider) error

ValidateHeaders checks the custom request headers before saving or discovery.

func ValidatePreset

func ValidatePreset(preset protocol.ConversationPresetsPreset, builtin bool) error

func ValidateSelection

func ValidateSelection(provider protocol.ConversationProvider, config protocol.SessionConfig) error

Types

type AccountGrant

type AccountGrant struct {
	Kind              protocol.Authentication     `json:"kind"`
	Access            string                      `json:"access,omitempty"`
	IssuedAtMs        *uint64                     `json:"issued_at_ms,omitempty"`
	Refresh           string                      `json:"refresh,omitempty"`
	ExpiresAtMs       uint64                      `json:"expires_at_ms,omitempty"`
	EarliestRefreshAt *uint64                     `json:"earliest_refresh_at,omitempty"`
	AccountID         *string                     `json:"account_id,omitempty"`
	ClientID          string                      `json:"client_id,omitempty"`
	Subject           string                      `json:"subject,omitempty"`
	Email             *string                     `json:"email,omitempty"`
	IDToken           string                      `json:"id_token,omitempty"`
	Scopes            []string                    `json:"scopes,omitempty"`
	OrgID             *string                     `json:"org_id,omitempty"`
	OrgName           *string                     `json:"org_name,omitempty"`
	InstallationID    *string                     `json:"installation_id,omitempty"`
	Github            string                      `json:"github,omitempty"`
	Endpoint          string                      `json:"endpoint,omitempty"`
	Record            *AccountRecord              `json:"record,omitempty"`
	RenewalPending    bool                        `json:"renewal_pending"`
	RenewalUncertain  bool                        `json:"renewal_uncertain,omitempty"`
	RenewalRejected   bool                        `json:"renewal_rejected,omitempty"`
	Runtime           *protocol.RuntimeCredential `json:"runtime,omitempty"`
}

func AccountHeaders

func AccountHeaders(provider protocol.ConversationProvider, secret *protocol.Secret) (AccountGrant, http.Header, error)

func AccountResourceHeaders

func AccountResourceHeaders(provider protocol.ConversationProvider, secret *protocol.Secret, target string) (AccountGrant, http.Header, error)

func DecodeAccount

func DecodeAccount(secret *protocol.Secret, authentication protocol.Authentication) (AccountGrant, error)

func (AccountGrant) Expiry

func (grant AccountGrant) Expiry() *uint64

func (AccountGrant) Label

func (grant AccountGrant) Label() *string

func (AccountGrant) RenewalAt

func (grant AccountGrant) RenewalAt() *uint64

RenewalAt returns the next refresh time without inventing an unknown TTL. Legacy grants retain their former one-minute-before-expiry behavior.

func (AccountGrant) SameAccount

func (grant AccountGrant) SameAccount(other AccountGrant) bool

func (AccountGrant) Secrets

func (grant AccountGrant) Secrets() []protocol.Secret

type AccountRecord

type AccountRecord struct {
	Target AccountTarget        `json:"target"`
	Issued authorization.Issued `json:"issued"`
}

type AccountTarget

type AccountTarget struct {
	Provider    protocol.ProviderID                 `json:"provider"`
	Package     protocol.PluginReference            `json:"package"`
	Origin      protocol.ConversationConsentOrigin  `json:"origin"`
	Flow        string                              `json:"flow"`
	Endpoint    string                              `json:"endpoint"`
	Declaration protocol.PluginModelAuthDeclaration `json:"declaration"`
	Fields      map[string]string                   `json:"fields"`
}

func (AccountTarget) Matches

func (target AccountTarget) Matches(current AccountTarget) bool

type CanonicalModelInfo

type CanonicalModelInfo struct {
	ID          string // short ID after last '/', e.g. "claude-sonnet-4-6"
	Name        string // models.dev canonical name, or ID if unlisted
	Family      string // canonical brand slug ("openai", "anthropic", "gemini", "deepseek", ...)
	Kind        string // "chat", "image", "video", "audio", "embedding" (empty if unknown)
	ReleaseDate string // ISO date "YYYY-MM-DD" from models.dev release_date / last_updated
}

CanonicalModelInfo holds the normalized short ID, models.dev canonical display name, canonical model family/brand slug, and output kind ("chat", "image", "video", "audio", "embedding") for a model identifier.

func LookupCanonicalModel

func LookupCanonicalModel(rawID string) CanonicalModelInfo

LookupCanonicalModel resolves a provider-local or prefixed model ID against the bundled models.dev catalog and family heuristics.

type CatalogDownload

type CatalogDownload struct {
	Entries   []CatalogEntry
	Bytes     uint64
	Providers uint32
	Fault     *protocol.Fault
	// contains filtered or unexported fields
}

func BundledCatalog

func BundledCatalog() (*CatalogDownload, error)

BundledCatalog provides the build's validated offline metadata snapshot. Its returned entries and bodies are shared and must not be modified.

func ParseCatalog

func ParseCatalog(raw []byte) (*CatalogDownload, error)

type CatalogEntry

type CatalogEntry struct {
	Provider string
	ID       string
	Body     json.RawMessage
}

type Directory

type Directory struct {
	// contains filtered or unexported fields
}

func (*Directory) Read

type Prepared

type Prepared struct {
	Provider *protocol.ConversationProvider
	Output   *protocol.Output
	Catalog  *CatalogDownload
}

func Run

func Run(ctx context.Context, work Work) (*Prepared, error)

type Work

type Work struct {
	Command   protocol.Command
	Provider  *protocol.ConversationProvider
	Secret    *protocol.Secret
	Directory *Directory
	Client    *http.Client
}

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL