catalog

package
v0.0.1 Latest Latest
Warning

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

Go to latest
Published: Sep 4, 2026 License: MIT Imports: 13 Imported by: 0

Documentation

Overview

Package catalog defines graycode-router's model catalog: the versioned set of known providers and their model entries, the bootstrap (built-in) catalog, and helpers to compile and query catalog data (e.g. resolving model entries for a given provider).

Index

Constants

View Source
const (
	ClaudeOpusV4_6   = "claude-opus-4-6"
	ClaudeSonnetV4_6 = "claude-sonnet-4-6"
	ClaudeHaikuV4_5  = "claude-haiku-4-5-20251001"
	GPT_4o           = "gpt-4o"
	GPT_4oMini       = "gpt-4o-mini"
	Grokk_2          = "grok-2"
	Glm51            = "glm-5.1"
)

ModelID constants for well-known models used across tests.

View Source
const (
	CatalogSchemaVersion = "model-catalog/v1"
	// SeedCatalogURL is the published model-catalog/v1 document.
	SeedCatalogURL = "https://langdag.com/model-catalog/v1/catalog.json"
	EnvCatalogURL  = "GRAYCODE_ROUTER_MODEL_CATALOG_URL"
	// LiveStaleDuration is how long a cache remains fresh after live provider APIs were merged.
	LiveStaleDuration = 24 * time.Hour
)

Variables

View Source
var DefaultDeploymentEnvFallbacks = func() map[string][]EnvFallback {
	result := make(map[string][]EnvFallback, len(registry.DeploymentEnvFallbacks())+len(extraDeploymentEnvFallbacks))
	for id, fbs := range registry.DeploymentEnvFallbacks() {
		var converted []EnvFallback
		for _, fb := range fbs {
			converted = append(converted, EnvFallback{Field: fb.Field, Env: fb.Env})
		}
		result[id] = converted
	}
	for id, fbs := range extraDeploymentEnvFallbacks {
		if _, ok := result[id]; !ok {
			result[id] = fbs
		}
	}
	return result
}()

DefaultDeploymentEnvFallbacks seeds env_fallbacks per deployment until the published catalog includes them.

View Source
var DeprecatedModels = map[string]DeprecationEntry{
	"claude-3-opus": {
		ModelName:       "Claude 3 Opus",
		RetirementDates: map[string]string{"anthropic": "January 5, 2026"},
	},
	"claude-3-7-sonnet": {
		ModelName:       "Claude 3.7 Sonnet",
		RetirementDates: map[string]string{"anthropic": "February 19, 2026"},
	},
	"claude-3-5-haiku": {
		ModelName:       "Claude 3.5 Haiku",
		RetirementDates: map[string]string{"anthropic": "February 19, 2026"},
	},
}

DeprecatedModels lists deprecated models and their per-provider retirement dates.

View Source
var ErrCatalogCacheRequired = errors.New("model catalog cache required")

ErrCatalogCacheRequired is returned when no valid ~/.graycode-router/model_catalog.json exists. Run catalog discovery (hawk models refresh / graycode-router catalog discover) to populate the cache.

View Source
var ModelTierAliases = []ModelTier{TierSonnet, TierHaiku, TierOpus}

ModelTierAliases lists all valid tier names.

Functions

func APIKeyEnvsForProvider

func APIKeyEnvsForProvider(compiled *CompiledCatalog, providerID string) []string

APIKeyEnvsForProvider lists API key env var names for a provider from deployment env_fallbacks.

func AllModelProviders

func AllModelProviders(compiled *CompiledCatalog) []string

AllModelProviders lists canonical model owner providers in the catalog.

func AnthropicNameToCanonical

func AnthropicNameToCanonical(name string) string

AnthropicNameToCanonical normalizes an Anthropic model ID to its canonical short name.

func BootstrapSource

func BootstrapSource() string

BootstrapSource returns the provenance label for the embedded catalog seed.

func CacheInfo

func CacheInfo(cachePath string) (exists bool, modTime time.Time, size int64, err error)

CacheInfo reports on-disk cache metadata when present.

func CanonicalModelForProviderNative

func CanonicalModelForProviderNative(compiled *CompiledCatalog, providerID, modelID string) (string, bool)

CanonicalModelForProviderNative maps a picker native id to the canonical model for that provider's deployment, without using global catalog aliases (e.g. mimo-v2.5-pro → xiaomi, not opencodego).

func CanonicalProviderID

func CanonicalProviderID(providerID string) string

CanonicalProviderID normalizes legacy provider aliases (e.g. gemini -> google, cline-pass -> clinepass).

func CheapestModelForProvider

func CheapestModelForProvider(compiled *CompiledCatalog, provider, fallback string) string

CheapestModelForProvider returns the lowest known input-priced model for a provider.

func CredentialStatusForProvider

func CredentialStatusForProvider(compiled *CompiledCatalog, providerID string) string

CredentialStatusForProvider reports whether a provider needs an API key (local vs required). For set/empty status use hawk config.EnvKeyStatus or credentials.HasSecret — catalog does not read env.

func DefaultCachePath

func DefaultCachePath() string

DefaultCachePath returns the shared model catalog cache location.

func DeploymentIDForLiveCatalogKey

func DeploymentIDForLiveCatalogKey(catalogKey string) string

DeploymentIDForLiveCatalogKey maps a live fetch catalog key to a deployment ID.

func DiscoveryEnvKeyNames

func DiscoveryEnvKeyNames(ctx context.Context) []string

DiscoveryEnvKeyNames returns env var names used for credential discovery from the catalog.

func DiscoveryEnvKeysFromCatalog

func DiscoveryEnvKeysFromCatalog(compiled *CompiledCatalog) []string

DiscoveryEnvKeysFromCatalog returns env var names needed for catalog discovery (API keys, base URLs) from deployment env_fallbacks in the compiled catalog.

func DisplayModelLabel

func DisplayModelLabel(id, displayName string) string

DisplayModelLabel returns a UI-friendly model name. OpenRouter latest aliases use a leading ~ in the API id (e.g. ~anthropic/claude-haiku-latest); strip it for display only.

func DisplayModelOwner

func DisplayModelOwner(owner, id string, liveMetadata ...json.RawMessage) string

DisplayModelOwner returns a UI-friendly owner slug without OpenRouter ~ prefixes.

func EnsureCredentialRegistryInCatalog

func EnsureCredentialRegistryInCatalog(c *Catalog)

EnsureCredentialRegistryInCatalog merges registry providers/deployments into catalog v1.

func EnsureDeploymentEnvFallbacks

func EnsureDeploymentEnvFallbacks(c *Catalog)

EnsureDeploymentEnvFallbacks fills missing env_fallbacks from the embedded seed. Published catalogs with env_fallbacks set are left unchanged.

func EnvVarsForDeployment

func EnvVarsForDeployment(deploymentID string) []string

EnvVarsForDeployment returns env var names for a deployment ID from the seed catalog.

func FetchLiveProviderCatalog

func FetchLiveProviderCatalog(env map[string]string) (Catalog, []LiveProviderEnrichment)

FetchLiveProviderCatalog discovers models from all registered live provider APIs that have API keys available in env. Returns a catalog with enriched model listings and a list of per-provider fetch statuses.

func FirstModelForProvider

func FirstModelForProvider(compiled *CompiledCatalog, providerID string) string

FirstModelForProvider returns the first canonical model ID for a provider from compiled catalog.

func GatewayForModel

func GatewayForModel(compiled *CompiledCatalog, modelID string) string

GatewayForModel returns the setup gateway that serves a model (e.g. openrouter for openrouter/auto).

func GetModelDeprecationWarning

func GetModelDeprecationWarning(modelID, provider string) string

GetModelDeprecationWarning returns a deprecation warning or empty string.

func GetModelMarketingName

func GetModelMarketingName(modelID string) string

GetModelMarketingName returns the marketing display name for a model ID.

func IsBootstrapCatalog

func IsBootstrapCatalog(c *Catalog) bool

IsBootstrapCatalog reports whether c is the empty wiring-only catalog.

func IsSetupGateway

func IsSetupGateway(providerID string) bool

IsSetupGateway reports whether id is a registered API-key gateway (not an aggregator owner slug).

func LiveDiscoverableDeploymentIDs

func LiveDiscoverableDeploymentIDs() []string

LiveDiscoverableDeploymentIDs returns provider IDs that have live model-list APIs.

func ModelForRoleV1

func ModelForRoleV1(compiled *CompiledCatalog, roles ModelRoleAssignments, role ModelRole) string

ModelForRoleV1 resolves a role assignment with coder then catalog fallback.

func ModelOwner

func ModelOwner(entry ModelCatalogEntry) string

ModelOwner returns the upstream vendor for a catalog row (owned_by or id prefix).

func MostExpensiveModelForProvider

func MostExpensiveModelForProvider(compiled *CompiledCatalog, provider, fallback string) string

MostExpensiveModelForProvider returns the highest known input-priced model for a provider.

func PreferredModelsForTier

func PreferredModelsForTier(compiled *CompiledCatalog, primaryProvider string, tier ModelTier, limit int) []string

PreferredModelsForTier returns unique preferred models for a tier, starting with primaryProvider and then following the registry chat preference order.

func PreferredProviderModel

func PreferredProviderModel(compiled *CompiledCatalog, provider string, tier ModelTier, fallback string) string

PreferredProviderModel returns the preferred model for provider and tier.

func PrimaryAPIKeyEnvForDeployment

func PrimaryAPIKeyEnvForDeployment(compiled *CompiledCatalog, deploymentID string) string

PrimaryAPIKeyEnvForDeployment returns the primary API key env var for a deployment ID.

func PrimaryAPIKeyEnvForProvider

func PrimaryAPIKeyEnvForProvider(compiled *CompiledCatalog, providerID string) string

PrimaryAPIKeyEnvForProvider returns the preferred API key env var for a provider.

func PrimaryModel

func PrimaryModel(compiled *CompiledCatalog) string

PrimaryModel returns a stable best-effort model from chat-preferred providers.

func ProviderDefaultModel

func ProviderDefaultModel(compiled *CompiledCatalog, provider, fallback string) string

ProviderDefaultModel returns the provider's first catalog model.

func ProviderDisplayName

func ProviderDisplayName(providerID string) string

ProviderDisplayName returns UI label from registry.

func ProviderForModel

func ProviderForModel(compiled *CompiledCatalog, modelName string) string

ProviderForModel returns the canonical owner provider for modelName.

func ProviderIDsFromCompiled

func ProviderIDsFromCompiled(compiled *CompiledCatalog) []string

ProviderIDsFromCompiled lists provider IDs from catalog providers and deployments.

func PruneUnreferencedDeployments

func PruneUnreferencedDeployments(c *Catalog)

PruneUnreferencedDeployments makes the embedded catalog and provider registry authoritative for first-class providers, then removes unrelated orphan deployments. Referenced deployments for custom providers remain valid.

func ResolveModel

func ResolveModel(compiled *CompiledCatalog, model string) string

ResolveModel maps a model alias or native ID to its canonical catalog ID. It trims whitespace, handles nil catalogs, and falls back to the input itself when it looks like a provider-native ID (contains "/"). This centralizes the alias-resolution pattern used across engine, runtime, and router packages, replacing per-caller trim + nil-check + fallback logic.

func ResolvedRemoteCatalogURL

func ResolvedRemoteCatalogURL(explicit string) string

func SanitizePricing

func SanitizePricing(c *Catalog)

SanitizePricing drops invalid rate dimensions (e.g. negative prices).

func SpecByEnvVar

func SpecByEnvVar(env string) (registry.ProviderSpec, bool)

SpecByEnvVar returns the registry ProviderSpec for the given credential env var.

func SpecByProviderID

func SpecByProviderID(id string) (registry.ProviderSpec, bool)

SpecByProviderID returns the registry ProviderSpec for the given provider ID or catalog alias.

func SplitOfferingID

func SplitOfferingID(id string) (deploymentID, nativeModelID string, ok bool)

func ValidateCatalog

func ValidateCatalog(c *Catalog) error

func WriteCatalogCache

func WriteCatalogCache(cachePath string, c *Catalog) error

Types

type CapabilitySet

type CapabilitySet struct {
	ServerTools            map[string]CapabilityState `json:"server_tools,omitempty"`
	FunctionCalling        CapabilityState            `json:"function_calling,omitempty"`
	ExplicitThinkingBudget CapabilityState            `json:"explicit_thinking_budget,omitempty"`
	AdaptiveThinking       CapabilityState            `json:"adaptive_thinking,omitempty"`
	Effort                 CapabilityState            `json:"effort,omitempty"`
	StructuredOutput       CapabilityState            `json:"structured_output,omitempty"`
	CodeExecution          CapabilityState            `json:"code_execution,omitempty"`
	Citations              CapabilityState            `json:"citations,omitempty"`
	PDFInput               CapabilityState            `json:"pdf_input,omitempty"`
	ImageInput             CapabilityState            `json:"image_input,omitempty"`
	MaxInputTokens         int                        `json:"max_input_tokens,omitempty"`
	MaxOutputTokens        int                        `json:"max_output_tokens,omitempty"`
	ThinkingTypes          []string                   `json:"thinking_types,omitempty"`
	EffortLevels           []string                   `json:"effort_levels,omitempty"`
}

func CapabilitySetFromEntry

func CapabilitySetFromEntry(e live.Entry) CapabilitySet

CapabilitySetFromEntry builds a CapabilitySet from a live entry's features.

type CapabilityState

type CapabilityState string
const (
	CapabilitySupported   CapabilityState = "supported"
	CapabilityUnsupported CapabilityState = "unsupported"
	CapabilityUnknown     CapabilityState = "unknown"
)

type Catalog

type Catalog struct {
	SchemaVersion     string                  `json:"schema_version"`
	GeneratedAt       time.Time               `json:"generated_at"`
	StaleAfter        time.Time               `json:"stale_after"`
	Providers         map[string]Provider     `json:"providers"`
	Protocols         map[string]Protocol     `json:"api_protocols"`
	Deployments       map[string]Deployment   `json:"deployments"`
	Models            map[string]Model        `json:"models"`
	Offerings         []ModelOffering         `json:"offerings"`
	OfferingTemplates []ModelOfferingTemplate `json:"offering_templates,omitempty"`
	Aliases           map[string]string       `json:"aliases,omitempty"`
	Provenance        *Provenance             `json:"provenance,omitempty"`
}

Catalog separates model ownership from the API protocol and deployment used to call the model. It is intentionally data-only; adapters remain code.

func BootstrapCatalog

func BootstrapCatalog() Catalog

BootstrapCatalog returns deployment/provider wiring only — no chat models. Chat models come from the published catalog cache and live provider discovery.

func FetchRemoteCatalog

func FetchRemoteCatalog(ctx context.Context, opts LoadCatalogOptions) (*Catalog, error)

func ParseCatalog

func ParseCatalog(data []byte) (*Catalog, error)

func SeedCatalog

func SeedCatalog() Catalog

SeedCatalog returns a catalog built from the embedded test fixtures.

type CatalogDiagnostic

type CatalogDiagnostic struct {
	Code    string `json:"code"`
	Message string `json:"message"`
}

type CompiledCatalog

type CompiledCatalog struct {
	Catalog                   *Catalog
	ProvidersByID             map[string]Provider
	ProtocolsByID             map[string]Protocol
	DeploymentsByID           map[string]Deployment
	ModelsByID                map[string]Model
	OfferingsByID             map[string]ModelOffering
	OfferingsByCanonicalModel map[string][]ModelOffering
	OfferingsByDeployment     map[string][]ModelOffering
	TemplatesByCanonicalModel map[string][]ModelOfferingTemplate
	Diagnostics               []CatalogDiagnostic
}

func CompileCatalog

func CompileCatalog(c *Catalog) (*CompiledCatalog, error)

func CompileTestCatalog

func CompileTestCatalog() (*CompiledCatalog, error)

CompileTestCatalog builds a compiled catalog from the embedded test fixtures.

func LoadCatalog

func LoadCatalog(ctx context.Context, opts LoadCatalogOptions) (*CompiledCatalog, error)

func LoadCatalogForDiscovery

func LoadCatalogForDiscovery(ctx context.Context) (*CompiledCatalog, error)

LoadCatalogForDiscovery returns the cached catalog or bootstrap wiring (no network).

func LoadValidCatalogCache

func LoadValidCatalogCache(cachePath string) (*CompiledCatalog, bool)

func (*CompiledCatalog) CanonicalModelForAliasOrID

func (c *CompiledCatalog) CanonicalModelForAliasOrID(value string) (string, bool)

func (*CompiledCatalog) CapabilitiesForModel

func (c *CompiledCatalog) CapabilitiesForModel(modelID, deploymentID string) CapabilitySet

CapabilitiesForModel returns the capability set for a model on a deployment.

func (*CompiledCatalog) FirstModelForProvider

func (c *CompiledCatalog) FirstModelForProvider(providerID string) (string, bool)

func (*CompiledCatalog) ModelIDsForProvider

func (c *CompiledCatalog) ModelIDsForProvider(providerID string) []string

ModelIDsForProvider returns all model IDs for a given provider, sorted.

func (*CompiledCatalog) OfferingForDeployment

func (c *CompiledCatalog) OfferingForDeployment(canonicalModelID, deploymentID string) (ModelOffering, bool)

func (*CompiledCatalog) ProviderNames

func (c *CompiledCatalog) ProviderNames() []string

type Credential

type Credential struct {
	Field    string `json:"field"`
	Secret   bool   `json:"secret,omitempty"`
	Required bool   `json:"required,omitempty"`
}

type Credentials

type Credentials struct {
	APIKeys map[string]string
}

Credentials carries API keys and related env (base URLs) for provider-backed catalog discovery. Keys use standard env var names (e.g. OPENROUTER_API_KEY). Populate via config.DiscoveryCredentials. or pass an explicit map from hawk — do not hardcode provider lists in hawk.

func (Credentials) Env

func (c Credentials) Env() map[string]string

Env returns a copy of the key map suitable for catalog discovery.

func (*Credentials) Merge

func (c *Credentials) Merge(other Credentials)

MergeCredentials merges additional keys into c (later keys win).

type Deployment

type Deployment struct {
	ID                     string              `json:"id"`
	Name                   string              `json:"name"`
	ProviderID             string              `json:"provider_id"`
	APIProtocolID          string              `json:"api_protocol_id"`
	AdapterConstructor     string              `json:"adapter_constructor"`
	CredentialRequirements []Credential        `json:"credential_requirements,omitempty"`
	EnvFallbacks           []EnvFallback       `json:"env_fallbacks,omitempty"`
	NativeModelIDSource    NativeModelIDSource `json:"native_model_id_source"`
	ModelMappingsRequired  bool                `json:"model_mappings_required,omitempty"`
	Local                  bool                `json:"local,omitempty"`
	Provenance             *Provenance         `json:"provenance,omitempty"`
}

type DeprecationEntry

type DeprecationEntry struct {
	ModelName       string
	RetirementDates map[string]string // provider → date string, empty = not deprecated
}

DeprecationEntry holds deprecation metadata for a model.

type EnvFallback

type EnvFallback struct {
	Field string   `json:"field"`
	Env   []string `json:"env"`
}

type LiveProviderEnrichment

type LiveProviderEnrichment struct {
	Provider   string `json:"provider"`
	ModelCount int    `json:"model_count"`
	Error      string `json:"error,omitempty"`
	DurationMs int64  `json:"duration_ms,omitempty"`
}

LiveProviderEnrichment records a live provider API fetch during catalog discovery.

type LoadCatalogOptions

type LoadCatalogOptions struct {
	CachePath     string
	RemoteURL     string
	RefreshRemote bool
	RequireCache  bool
	HTTPClient    *http.Client
	Timeout       time.Duration
}

type Model

type Model struct {
	ID            string      `json:"id"`
	ProviderID    string      `json:"provider_id"`
	Name          string      `json:"name"`
	Family        string      `json:"family,omitempty"`
	ContextWindow int         `json:"context_window,omitempty"`
	MaxOutput     int         `json:"max_output,omitempty"`
	Aliases       []string    `json:"aliases,omitempty"`
	Provenance    *Provenance `json:"provenance,omitempty"`
}

type ModelCatalog

type ModelCatalog struct {
	UpdatedAt string                         `json:"updated_at"`
	Source    string                         `json:"source"`
	Providers map[string][]ModelCatalogEntry `json:"providers"`
}

ModelCatalog holds the full model catalog with per-provider entries.

func SeedModelCatalog

func SeedModelCatalog() ModelCatalog

SeedModelCatalog returns the embedded test model catalog.

type ModelCatalogEntry

type ModelCatalogEntry struct {
	ID               string          `json:"id"`
	InputPricePer1M  float64         `json:"input_price_per_1m"`
	OutputPricePer1M float64         `json:"output_price_per_1m"`
	ContextWindow    int             `json:"context_window"`
	MaxOutput        int             `json:"max_output"`
	ServerTools      []string        `json:"server_tools,omitempty"`
	DisplayName      string          `json:"display_name,omitempty"`
	Description      string          `json:"description,omitempty"`
	Owner            string          `json:"owner,omitempty"` // upstream vendor (API owned_by)
	LiveMetadata     json.RawMessage `json:"live_metadata,omitempty"`
}

ModelCatalogEntry represents a single model in the catalog.

func FetchLiveModelEntriesForProvider

func FetchLiveModelEntriesForProvider(env map[string]string, providerID string) ([]ModelCatalogEntry, error)

FetchLiveModelEntriesForProvider lists models from one provider's live API with full JSON metadata.

func FetchOllamaModels

func FetchOllamaModels(env map[string]string) ([]ModelCatalogEntry, error)

FetchOllamaModels lists models installed on a running Ollama instance.

func LiveEntriesToCatalog

func LiveEntriesToCatalog(in []live.Entry) []ModelCatalogEntry

LiveEntriesToCatalog converts live fetch rows to catalog entries.

func ModelEntriesForProvider

func ModelEntriesForProvider(compiled *CompiledCatalog, provider string) []ModelCatalogEntry

ModelEntriesForProvider lists models from a compiled v1 catalog for one provider. New models appear here automatically when the graycode-router catalog is updated — hosts must not hardcode IDs.

type ModelConfig

type ModelConfig map[string]ModelName

ModelConfig maps each APIProvider to a model name.

type ModelCostTier

type ModelCostTier int

ModelCostTier is a relative cost band for model selection.

const (
	// CostTierCheap is appropriate for short, low-risk, or summarization work.
	CostTierCheap ModelCostTier = iota
	// CostTierMid is the default balanced cost band.
	CostTierMid
	// CostTierExpensive is appropriate for complex planning or generation work.
	CostTierExpensive
)

func ModelCostTierOf

func ModelCostTierOf(compiled *CompiledCatalog, modelName string) ModelCostTier

ModelCostTierOf resolves a model's cost tier from catalog family and pricing data.

type ModelKey

type ModelKey string

ModelKey identifies a specific model version config.

type ModelName

type ModelName = string

ModelName is a model identifier string.

func GetPreferredProviderModel

func GetPreferredProviderModel(provider string, _ ModelTier, catalog *ModelCatalog) ModelName

GetPreferredProviderModel returns the preferred model for a provider/tier from the catalog. Returns "" if catalog is nil or has no models for this provider. The tier parameter is currently unused; all models are returned equally.

func GetProviderDefaultModel

func GetProviderDefaultModel(provider string, catalog *ModelCatalog) ModelName

GetProviderDefaultModel returns the first model from the catalog for a provider. Returns "" if no catalog data is available.

type ModelOffering

type ModelOffering struct {
	ID               string          `json:"id"`
	CanonicalModelID string          `json:"canonical_model_id"`
	DeploymentID     string          `json:"deployment_id"`
	NativeModelID    string          `json:"native_model_id"`
	Capabilities     CapabilitySet   `json:"capabilities,omitempty"`
	Pricing          Pricing         `json:"pricing"`
	LiveMetadata     json.RawMessage `json:"live_metadata,omitempty"`
	Provenance       *Provenance     `json:"provenance,omitempty"`
}

type ModelOfferingTemplate

type ModelOfferingTemplate struct {
	ID                  string              `json:"id"`
	CanonicalModelID    string              `json:"canonical_model_id"`
	DeploymentID        string              `json:"deployment_id"`
	NativeModelIDSource NativeModelIDSource `json:"native_model_id_source"`
	MappingRequired     bool                `json:"mapping_required"`
	Capabilities        CapabilitySet       `json:"capabilities,omitempty"`
	Pricing             Pricing             `json:"pricing"`
	Provenance          *Provenance         `json:"provenance,omitempty"`
}

func DefaultOfferingTemplates

func DefaultOfferingTemplates(generatedAt time.Time) []ModelOfferingTemplate

DefaultOfferingTemplates returns offering templates for Azure deployments (model mappings required).

type ModelRole

type ModelRole string

ModelRole identifies the purpose of a model in a multi-model workflow.

const (
	ModelRolePlanner  ModelRole = "planner"
	ModelRoleCoder    ModelRole = "coder"
	ModelRoleReviewer ModelRole = "reviewer"
	ModelRoleCommit   ModelRole = "commit"
)

type ModelRoleAssignments

type ModelRoleAssignments struct {
	Planner  string `json:"planner,omitempty"`
	Coder    string `json:"coder,omitempty"`
	Reviewer string `json:"reviewer,omitempty"`
	Commit   string `json:"commit,omitempty"`
}

ModelRoleAssignments maps workflow roles to concrete model IDs.

func DefaultModelRolesV1

func DefaultModelRolesV1(compiled *CompiledCatalog, primaryModel string) ModelRoleAssignments

DefaultModelRolesV1 uses the primary model for interactive roles and the cheapest same-provider model for commit/summarization work when catalog data is available.

type ModelTier

type ModelTier string

ModelTier represents opus/sonnet/haiku tiers.

const (
	TierOpus   ModelTier = "opus"
	TierSonnet ModelTier = "sonnet"
	TierHaiku  ModelTier = "haiku"
)

type NativeModelIDSource

type NativeModelIDSource string
const (
	NativeModelIDCatalogKnown   NativeModelIDSource = "catalog_known"
	NativeModelIDDiscovered     NativeModelIDSource = "discovered"
	NativeModelIDUserConfigured NativeModelIDSource = "user_configured"
	NativeModelIDCatalogOrUser  NativeModelIDSource = "catalog_or_user_configured"
)

type Pricing

type Pricing struct {
	Status            PricingStatus      `json:"status"`
	Currency          string             `json:"currency,omitempty"`
	EffectiveAt       time.Time          `json:"effective_at,omitempty"`
	RatesPer1M        map[string]float64 `json:"rates_per_1m,omitempty"`
	MissingDimensions []string           `json:"missing_dimensions,omitempty"`
	Notes             []string           `json:"notes,omitempty"`
	Source            string             `json:"source,omitempty"`
}

func PricingFromEntry

func PricingFromEntry(e live.Entry) Pricing

PricingFromEntry builds a Pricing from a live entry's per-token rates.

type PricingStatus

type PricingStatus string
const (
	PricingKnown   PricingStatus = "known"
	PricingPartial PricingStatus = "partial"
	PricingUnknown PricingStatus = "unknown"
	PricingFree    PricingStatus = "free"
)

type Protocol

type Protocol struct {
	ID          string      `json:"id"`
	Name        string      `json:"name"`
	Description string      `json:"description,omitempty"`
	Provenance  *Provenance `json:"provenance,omitempty"`
}

type Provenance

type Provenance struct {
	Source     string    `json:"source"`
	SourceURL  string    `json:"source_url,omitempty"`
	ObservedAt time.Time `json:"observed_at,omitempty"`
}

type Provider

type Provider struct {
	ID          string      `json:"id"`
	Name        string      `json:"name"`
	Description string      `json:"description,omitempty"`
	HomepageURL string      `json:"homepage_url,omitempty"`
	Aliases     []string    `json:"aliases,omitempty"`
	Provenance  *Provenance `json:"provenance,omitempty"`
}

type RefreshResult

type RefreshResult struct {
	Compiled   *CompiledCatalog
	CachePath  string
	Source     string // remote, cache, embedded, remote+providers
	RemoteURL  string
	Refreshed  bool
	StaleAfter time.Time
	// RemoteRefreshed is true when the published remote catalog was fetched successfully.
	RemoteRefreshed bool
	// LiveProviders lists provider APIs queried with API keys (empty if none attempted).
	LiveProviders []LiveProviderEnrichment
}

RefreshResult summarizes a strict remote catalog refresh (graycode-router published catalog).

func RefreshCatalog

func RefreshCatalog(ctx context.Context, opts LoadCatalogOptions) (*RefreshResult, error)

RefreshCatalog fetches the published catalog, validates it, and writes the cache. Unlike LoadCatalog with RefreshRemote, this fails when the remote fetch fails so callers never treat a stale cache as a successful refresh.

func (*RefreshResult) DiscoverReport

func (r *RefreshResult) DiscoverReport() string

DiscoverReport returns a multi-line report for `hawk models refresh` / `graycode-router catalog discover`.

func (*RefreshResult) Summary

func (r *RefreshResult) Summary() string

Summary returns a one-line human summary for CLI output.

Directories

Path Synopsis
Package concentrate holds shared constants and pricing-cache helpers for the Concentrate AI Responses API gateway (https://concentrate.ai).
Package concentrate holds shared constants and pricing-cache helpers for the Concentrate AI Responses API gateway (https://concentrate.ai).
Package opencodego holds shared constants and helpers for the OpenCode Go gateway (https://opencode.ai/docs/go/).
Package opencodego holds shared constants and helpers for the OpenCode Go gateway (https://opencode.ai/docs/go/).
Package opengateway holds shared constants for the OpenGateway inference gateway (https://gitlawb.com/opengateway), an OpenAI-compatible endpoint that routes requests across providers (MiMo, Gemini, MiniMax, Qwen, Kimi, GLM, etc.) and returns the live model catalog with inline pricing from GET /v1/models.
Package opengateway holds shared constants for the OpenGateway inference gateway (https://gitlawb.com/opengateway), an OpenAI-compatible endpoint that routes requests across providers (MiMo, Gemini, MiniMax, Qwen, Kimi, GLM, etc.) and returns the live model catalog with inline pricing from GET /v1/models.
Package xiaomi resolves Xiaomi MiMo API base URLs for pay-as-you-go and Token Plan.
Package xiaomi resolves Xiaomi MiMo API base URLs for pay-as-you-go and Token Plan.
Package zai resolves Z.AI (Zhipu GLM) API base URLs for General (pay-as-you-go) and Coding Plan subscriptions across International vs China regions.
Package zai resolves Z.AI (Zhipu GLM) API base URLs for General (pay-as-you-go) and Coding Plan subscriptions across International vs China regions.

Jump to

Keyboard shortcuts

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