Help us shape the future of Go! Take the 2026 Go Developer Survey

catalog

package
v1.155.0 Latest Latest
Warning

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

Go to latest
Published: Nov 2, 2026 License: Apache-2.0 Imports: 7 Imported by: 0

Documentation

Overview

Package catalog provides embedded metadata for built-in model providers, without linking their SDK implementations.

Index

Constants

This section is empty.

Variables

View Source
var Providers = func() map[string]Provider {
	providers := make(map[string]Provider, len(orderedProviders))
	for _, p := range orderedProviders {
		providers[p.Name] = p
	}
	return providers
}()

Providers indexes built-in providers by name. Callers must not modify it.

Functions

func AllProviders

func AllProviders() []string

AllProviders returns all built-in provider names, sorted.

func DefaultModels

func DefaultModels() map[string]string

DefaultModels returns the configured default models, keyed by provider name.

func IsCatalogProvider

func IsCatalogProvider(name string) bool

IsCatalogProvider reports whether a provider is usable without explicit endpoint configuration.

func IsDefaultEndpoint

func IsDefaultEndpoint(name, endpoint string) bool

IsDefaultEndpoint treats an omitted endpoint and the catalog endpoint equally.

func IsKnownProvider

func IsKnownProvider(name string) bool

IsKnownProvider reports whether the name identifies a built-in provider.

func TokenKeys

func TokenKeys(name, tokenKey string) []string

TokenKeys returns credential sources in priority order. Alternatives only apply to the built-in token key, never to an explicitly overridden credential.

Types

type Provider

type Provider struct {
	// Name is the canonical provider ID used in model references and catalog lookups.
	Name string `json:"name"`
	// APIType selects the registered API implementation that serves this provider.
	APIType string `json:"api_type"`
	// BaseURL is the default endpoint; API implementations resolve dynamic endpoints themselves.
	// Environment references such as ${CLOUDFLARE_ACCOUNT_ID} expand at construction time.
	BaseURL string `json:"base_url,omitempty"`
	// TokenEnvVars lists token sources in priority order; explicit token_key overrides the list.
	TokenEnvVars []string `json:"token_env_vars,omitempty"`
	// DefaultModel is used when selecting this provider without an explicit model.
	// Providers without one are excluded from automatic selection.
	DefaultModel string `json:"default_model,omitempty"`
	// RequiresConfiguration excludes providers needing a user-supplied endpoint from catalog listings and automatic selection.
	RequiresConfiguration bool `json:"requires_configuration,omitempty"`
	// MergeConsecutiveMessages coalesces adjacent same-role Chat Completions messages
	// for servers whose chat templates reject multiple system messages.
	MergeConsecutiveMessages bool `json:"merge_consecutive_messages,omitempty"`
	// AutoResponses selects the Responses API for supported models unless api_type is explicit.
	AutoResponses bool `json:"auto_responses,omitempty"`
	// OpenAIVendor identifies genuine OpenAI model hosts, gating OpenAI-only wire fields.
	// Speaking the OpenAI-compatible protocol alone does not qualify.
	OpenAIVendor bool `json:"openai_vendor,omitempty"`
	// Headers supplies default HTTP headers; user http_headers override them case-insensitively.
	Headers map[string]string `json:"headers,omitempty"`
	// QueryParams maps string-valued provider_opts keys to URL query parameter names.
	QueryParams map[string]string `json:"query_params,omitempty"`
	// Hint describes credential setup in automatic-selection errors; defaults to the token variable names.
	Hint string `json:"hint,omitempty"`
}

Provider describes a provider's API and transport defaults. Callers must treat maps and slices returned by this package as read-only.

func CredentialProviders

func CredentialProviders() []Provider

CredentialProviders returns providers with a default model and credential detection, in catalog order. Local providers are handled by discovery.

func Find

func Find(name string) (Provider, bool)

Find returns metadata and whether the provider is registered.

func Lookup

func Lookup(name string) Provider

Lookup resolves canonical and legacy provider names. Unknown names return zero metadata.

func Ordered

func Ordered() []Provider

Ordered returns providers in JSON order, which determines selection priority.

Jump to

Keyboard shortcuts

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