Documentation
¶
Overview ¶
Package config holds eyrie's provider configuration model and accessors for the active provider/model selection (ActiveProvider, ActiveModel, SetActiveProvider, SetProviderModel) used to route requests.
Index ¶
- Constants
- Variables
- func ActiveModel(cfg *ProviderConfig) string
- func ActiveProvider(cfg *ProviderConfig) string
- func AddProfile(profile ProviderProfile) error
- func AgentRoutingPath() string
- func AgentRoutingSummary() string
- func ApplyOpenAICompatibleProvider(prefix, apiKey, model, baseURL string, overwrite bool)
- func ApplyProviderConfigToEnv(config *ProviderConfig, overwrite bool, cat *catalog.ModelCatalog) string
- func ApplyProviderEnv(provider string, config *ProviderConfig, activeModel string, overwrite bool, ...) map[string]string
- func ApplyProviderEnvToProcess(provider string, config *ProviderConfig, activeModel string, overwrite bool, ...)
- func AsNonEmptyString(v string) string
- func ClearActiveSelection(cfg *ProviderConfig)
- func ClearProviderRuntimeEnv()
- func CommitCredential(ctx context.Context, inference CredentialInference, secret string) error
- func CommitLocalCredential(ctx context.Context, inference CredentialInference, value string) error
- func DefaultCategories() map[ModelCategory]CategoryConfig
- func DefaultProviderFromConfig(config *ProviderConfig) string
- func DeleteProfile(name string) error
- func DeploymentConfigured(deploymentID string, dep catalog.DeploymentV1, dc DeploymentConfig) bool
- func DiscoveryCredentials(ctx context.Context) catalog.Credentials
- func DiscoveryEnvMap(ctx context.Context) map[string]string
- func FormatOllamaConnectError(err error) error
- func GetProviderAPIKey(config *ProviderConfig, provider string) string
- func GetProviderActiveModel(config *ProviderConfig, provider string) string
- func GetProviderConfigDir() string
- func GetProviderConfigPath() string
- func GetProviderModel(config *ProviderConfig, provider string) string
- func HasAnyConfiguredDeployment(ctx context.Context) bool
- func IsLocalProviderURL(baseURL string) bool
- func IsOpenAICompatibleRuntimeEnabled() bool
- func IsProviderConfigured(config *ProviderConfig, provider string) bool
- func IsXiaomiMimoProvider(providerID string) bool
- func IsZAIProvider(providerID string) bool
- func ListProfiles() string
- func LooksLikePlaceholderSecret(secret string) bool
- func MigrateLegacyXiaomiProvider(cfg *ProviderConfig)
- func NormalizeOllamaOpenAIBaseURL(baseURL string) string
- func ParseRoute(route string) (provider, model string)
- func PrepareCredentialForSave(inference CredentialInference, secret string) (string, error)
- func ProbeCredential(ctx context.Context, envKey, secret string) error
- func ProbeLocalCredential(ctx context.Context, envKey, value string) error
- func ProfilesPath() string
- func ProviderIDForEnv(envKey string) string
- func ResetCategoryRegistry()
- func ResolveXiaomiAnthropicBase(providerID string, cfg *ProviderConfig) (string, error)
- func ResolveXiaomiOpenAIBase(providerID string, cfg *ProviderConfig) (string, error)
- func ResolveZAIAnthropicBase(cfg *ProviderConfig) string
- func ResolveZAIOpenAIBase(providerID string, cfg *ProviderConfig) (string, error)
- func SaveAgentRouting(cfg *AgentRoutingConfig) error
- func SaveProfiles(profiles []ProviderProfile) error
- func SaveProviderConfig(config *ProviderConfig, path string) error
- func SetActiveProvider(cfg *ProviderConfig, provider string)
- func SetEnvValue(key, value string, overwrite bool)
- func SetProviderModel(cfg *ProviderConfig, provider, model string)
- func ValidateAPIKey(apiKey, providerName string) string
- func ValidateBaseURL(baseURL string) string
- func ValidateCredentialBeforeSave(inference CredentialInference, secret string) error
- func ValidateCredentialSecret(envKey, secret string) error
- func ValidateKeyFormat(secret string) error
- func VertexGeminiBaseURL(projectID, region string) string
- func XiaomiTokenPlanRegionFromConfig(cfg *ProviderConfig) xiaomi.Region
- type APIKeyDef
- type APIProvider
- type AgentRoutingConfig
- type CategoryConfig
- type CategoryRegistry
- func (r *CategoryRegistry) AllCategories() map[ModelCategory]CategoryConfig
- func (r *CategoryRegistry) Resolve(cat ModelCategory) CategoryConfig
- func (r *CategoryRegistry) ResolveWithDefaults(cat ModelCategory, defaultModel string) CategoryConfig
- func (r *CategoryRegistry) SetCategory(cat ModelCategory, cfg CategoryConfig)
- type CredentialInference
- func InferCredentialsFromAPIKey(ctx context.Context, secret string) []CredentialInference
- func InferenceForProvider(providerID string) (CredentialInference, error)
- func InferenceFromOption(opt CredentialProviderOption) CredentialInference
- func LocalCredentialInference(providerID string) (CredentialInference, error)
- type CredentialProviderOption
- type CredentialResolveResult
- type DeploymentChoice
- type DeploymentConfig
- type ModelCategory
- type OpenAICompatibleApiKeySource
- type OpenAICompatibleRuntimeMode
- type ProviderConfig
- func EnsureDeploymentConfigV2(cfg *ProviderConfig) *ProviderConfig
- func LoadProviderConfig(path string) *ProviderConfig
- func LoadProviderConfigWithError(path string) (*ProviderConfig, error)
- func SyncProviderConfigFromCatalog(compiled *catalog.CompiledCatalogV1, env map[string]string) *ProviderConfig
- type ProviderProfile
- type ProviderTransport
- type ReasoningEffort
- type ResolvedOpenAICompatibleRuntime
- type ResolvedProviderRequest
- type RoutingPolicy
- type RoutingStage
- type RuntimeProviderProfile
Constants ¶
const ( OllamaDefaultBaseURL = "http://localhost:11434/v1" OpenCodeGoDefaultBaseURL = opencodego.DefaultBaseURL )
const ( DefaultOpenAIBaseURL = "https://api.openai.com/v1" DefaultOpenRouterOpenAIBaseURL = "https://openrouter.ai/api/v1" DefaultCanopyWaveOpenAIBaseURL = "https://inference.canopywave.io/v1" DefaultZAIOpenAIBaseURL = "https://api.z.ai/api/paas/v4" DefaultZAICodingOpenAIBaseURL = "https://api.z.ai/api/coding/paas/v4" DefaultGeminiOpenAIBaseURL = "https://generativelanguage.googleapis.com/v1beta/openai" DefaultAnthropicOpenAIBaseURL = "https://api.anthropic.com/v1" DefaultGrokOpenAIBaseURL = "https://api.x.ai/v1" DefaultOpenCodeGoBaseURL = opencodego.DefaultBaseURL DefaultKimiOpenAIBaseURL = "https://api.moonshot.ai/v1" DefaultXiaomiOpenAIBaseURL = "https://api.xiaomimimo.com/v1" DefaultMiniMaxOpenAIBaseURL = "https://api.minimax.io/v1" DefaultMiniMaxAnthropicBaseURL = "https://api.minimax.io/anthropic" )
Default base URLs for each provider.
const ( EnvXiaomiPaygAPIKey = "XIAOMI_MIMO_PAYG_API_KEY" EnvXiaomiTokenPlanAPIKey = "XIAOMI_MIMO_TOKEN_PLAN_API_KEY" EnvXiaomiPaygBaseURL = "XIAOMI_MIMO_PAYG_BASE_URL" EnvXiaomiTokenPlanBaseURL = "XIAOMI_MIMO_TOKEN_PLAN_BASE_URL" EnvXiaomiTokenPlanRegion = "XIAOMI_MIMO_TOKEN_PLAN_REGION" )
Variables ¶
var ( AnthropicRuntimeProfile = RuntimeProviderProfile{ Mode: "anthropic", DefaultBaseURL: DefaultAnthropicOpenAIBaseURL, DefaultModel: "claude-3-5-sonnet-latest", DetectionEnv: []string{"ANTHROPIC_API_KEY"}, ModelEnv: []string{"ANTHROPIC_MODEL", "OPENAI_MODEL"}, BaseURLEnv: []string{"ANTHROPIC_BASE_URL", "OPENAI_BASE_URL", "OPENAI_API_BASE"}, APIKeys: []APIKeyDef{{Env: "ANTHROPIC_API_KEY", Source: "anthropic"}, {Env: "OPENAI_API_KEY", Source: "openai"}}, } OpenAIRuntimeProfile = RuntimeProviderProfile{ Mode: "openai", DefaultBaseURL: DefaultOpenAIBaseURL, DefaultModel: "gpt-4o", DetectionEnv: []string{"OPENAI_API_KEY"}, ModelEnv: []string{"OPENAI_MODEL"}, BaseURLEnv: []string{"OPENAI_BASE_URL", "OPENAI_API_BASE"}, APIKeys: []APIKeyDef{{Env: "OPENAI_API_KEY", Source: "openai"}}, } GrokRuntimeProfile = RuntimeProviderProfile{ Mode: "grok", DefaultBaseURL: DefaultGrokOpenAIBaseURL, DefaultModel: "grok-2", DetectionEnv: []string{"XAI_API_KEY"}, ModelEnv: []string{"XAI_MODEL", "OPENAI_MODEL"}, BaseURLEnv: []string{"XAI_BASE_URL", "OPENAI_BASE_URL", "OPENAI_API_BASE"}, APIKeys: []APIKeyDef{{Env: "XAI_API_KEY", Source: "grok"}}, } GeminiRuntimeProfile = RuntimeProviderProfile{ Mode: "gemini", DefaultBaseURL: DefaultGeminiOpenAIBaseURL, DefaultModel: "gemini-2.0-flash", DetectionEnv: []string{"GEMINI_API_KEY"}, ModelEnv: []string{"GEMINI_MODEL", "OPENAI_MODEL"}, BaseURLEnv: []string{"GEMINI_BASE_URL", "OPENAI_BASE_URL", "OPENAI_API_BASE"}, APIKeys: []APIKeyDef{{Env: "GEMINI_API_KEY", Source: "gemini"}, {Env: "OPENAI_API_KEY", Source: "openai"}}, } VertexRuntimeProfile = RuntimeProviderProfile{ Mode: "gemini-vertex", DefaultBaseURL: "", DefaultModel: "gemini-2.0-flash", DetectionEnv: []string{"VERTEX_ACCESS_TOKEN", "GOOGLE_OAUTH_ACCESS_TOKEN"}, ModelEnv: []string{"VERTEX_MODEL", "GEMINI_MODEL", "OPENAI_MODEL"}, BaseURLEnv: []string{"VERTEX_PROJECT_ID", "VERTEX_REGION"}, APIKeys: []APIKeyDef{{Env: "VERTEX_ACCESS_TOKEN", Source: "vertex"}, {Env: "GOOGLE_OAUTH_ACCESS_TOKEN", Source: "google"}}, } AzureRuntimeProfile = RuntimeProviderProfile{ Mode: "azure", DefaultBaseURL: "", DefaultModel: "", DetectionEnv: []string{"AZURE_OPENAI_API_KEY"}, ModelEnv: []string{"AZURE_OPENAI_DEPLOYMENT", "AZURE_OPENAI_MODEL", "OPENAI_MODEL"}, BaseURLEnv: []string{"AZURE_OPENAI_ENDPOINT"}, APIKeys: []APIKeyDef{{Env: "AZURE_OPENAI_API_KEY", Source: "azure"}}, } BedrockRuntimeProfile = RuntimeProviderProfile{ Mode: "bedrock", DefaultBaseURL: "", DefaultModel: "", DetectionEnv: []string{"AWS_ACCESS_KEY_ID", "AWS_SECRET_ACCESS_KEY"}, ModelEnv: []string{"BEDROCK_MODEL", "ANTHROPIC_MODEL", "OPENAI_MODEL"}, BaseURLEnv: []string{"AWS_REGION", "AWS_DEFAULT_REGION"}, APIKeys: []APIKeyDef{{Env: "AWS_SECRET_ACCESS_KEY", Source: "bedrock"}, {Env: "AWS_ACCESS_KEY_ID", Source: "bedrock"}}, } OpenRouterRuntimeProfile = RuntimeProviderProfile{ Mode: "openrouter", DefaultBaseURL: DefaultOpenRouterOpenAIBaseURL, DetectionEnv: []string{"OPENROUTER_API_KEY"}, ModelEnv: []string{"OPENROUTER_MODEL", "OPENAI_MODEL"}, BaseURLEnv: []string{"OPENROUTER_BASE_URL", "OPENAI_BASE_URL", "OPENAI_API_BASE"}, APIKeys: []APIKeyDef{{Env: "OPENROUTER_API_KEY", Source: "openrouter"}, {Env: "OPENAI_API_KEY", Source: "openai"}}, } ZAIPaygRuntimeProfile = RuntimeProviderProfile{ Mode: "openai", DefaultBaseURL: DefaultZAIOpenAIBaseURL, DetectionEnv: []string{"ZAI_API_KEY"}, ModelEnv: []string{"ZAI_MODEL", "OPENAI_MODEL"}, BaseURLEnv: []string{"ZAI_BASE_URL", "ZAI_API_BASE", "OPENAI_BASE_URL", "OPENAI_API_BASE"}, APIKeys: []APIKeyDef{{Env: "ZAI_API_KEY", Source: "zai_payg"}}, } ZAICodingRuntimeProfile = RuntimeProviderProfile{ Mode: "openai", DefaultBaseURL: DefaultZAICodingOpenAIBaseURL, DetectionEnv: []string{"ZAI_CODING_API_KEY"}, ModelEnv: []string{"ZAI_CODING_MODEL", "ZAI_MODEL", "OPENAI_MODEL"}, BaseURLEnv: []string{"ZAI_CODING_BASE_URL", "ZAI_BASE_URL", "OPENAI_BASE_URL", "OPENAI_API_BASE"}, APIKeys: []APIKeyDef{{Env: "ZAI_CODING_API_KEY", Source: "zai_coding"}}, } CanopyWaveRuntimeProfile = RuntimeProviderProfile{ Mode: "openai", DefaultBaseURL: DefaultCanopyWaveOpenAIBaseURL, DetectionEnv: []string{"CANOPYWAVE_API_KEY"}, ModelEnv: []string{"CANOPYWAVE_MODEL", "OPENAI_MODEL"}, BaseURLEnv: []string{"CANOPYWAVE_BASE_URL", "OPENAI_BASE_URL", "OPENAI_API_BASE"}, APIKeys: []APIKeyDef{{Env: "CANOPYWAVE_API_KEY", Source: "canopywave"}, {Env: "OPENAI_API_KEY", Source: "openai"}}, } DeepSeekRuntimeProfile = RuntimeProviderProfile{ Mode: "openai", DefaultBaseURL: "https://api.deepseek.com/v1", DetectionEnv: []string{"DEEPSEEK_API_KEY"}, ModelEnv: []string{"DEEPSEEK_MODEL", "OPENAI_MODEL"}, BaseURLEnv: []string{"DEEPSEEK_BASE_URL", "OPENAI_BASE_URL", "OPENAI_API_BASE"}, APIKeys: []APIKeyDef{{Env: "DEEPSEEK_API_KEY", Source: "deepseek"}}, } OpenCodeGoRuntimeProfile = RuntimeProviderProfile{ Mode: "opencodego", DefaultBaseURL: DefaultOpenCodeGoBaseURL, DetectionEnv: []string{"OPENCODEGO_API_KEY"}, ModelEnv: []string{"OPENCODEGO_MODEL"}, BaseURLEnv: []string{"OPENCODEGO_BASE_URL"}, APIKeys: []APIKeyDef{{Env: "OPENCODEGO_API_KEY", Source: "opencodego"}}, } KimiRuntimeProfile = RuntimeProviderProfile{ Mode: "openai", DefaultBaseURL: DefaultKimiOpenAIBaseURL, DetectionEnv: []string{"MOONSHOT_API_KEY"}, ModelEnv: []string{"MOONSHOT_MODEL", "OPENAI_MODEL"}, BaseURLEnv: []string{"MOONSHOT_BASE_URL", "OPENAI_BASE_URL", "OPENAI_API_BASE"}, APIKeys: []APIKeyDef{{Env: "MOONSHOT_API_KEY", Source: "kimi"}}, } XiaomiPaygRuntimeProfile = RuntimeProviderProfile{ Mode: "openai", DefaultBaseURL: DefaultXiaomiOpenAIBaseURL, DetectionEnv: []string{EnvXiaomiPaygAPIKey}, ModelEnv: []string{"XIAOMI_MIMO_PAYG_MODEL", "XIAOMI_MODEL", "OPENAI_MODEL"}, BaseURLEnv: []string{EnvXiaomiPaygBaseURL, "XIAOMI_BASE_URL", "OPENAI_BASE_URL", "OPENAI_API_BASE"}, APIKeys: []APIKeyDef{{Env: EnvXiaomiPaygAPIKey, Source: "xiaomi_mimo_payg"}}, } XiaomiTokenPlanRuntimeProfile = RuntimeProviderProfile{ Mode: "openai", DefaultBaseURL: "", DetectionEnv: []string{EnvXiaomiTokenPlanAPIKey}, ModelEnv: []string{"XIAOMI_MIMO_TOKEN_PLAN_MODEL", "XIAOMI_MODEL", "OPENAI_MODEL"}, BaseURLEnv: []string{EnvXiaomiTokenPlanBaseURL, "OPENAI_BASE_URL", "OPENAI_API_BASE"}, APIKeys: []APIKeyDef{{Env: EnvXiaomiTokenPlanAPIKey, Source: "xiaomi_mimo_token_plan"}}, } MiniMaxTokenPlanRuntimeProfile = RuntimeProviderProfile{ Mode: "openai", DefaultBaseURL: DefaultMiniMaxOpenAIBaseURL, DetectionEnv: []string{"MINIMAX_TOKEN_PLAN_API_KEY"}, ModelEnv: []string{"MINIMAX_TOKEN_PLAN_MODEL", "MINIMAX_MODEL", "OPENAI_MODEL"}, BaseURLEnv: []string{"MINIMAX_TOKEN_PLAN_BASE_URL", "MINIMAX_BASE_URL", "OPENAI_BASE_URL", "OPENAI_API_BASE"}, APIKeys: []APIKeyDef{{Env: "MINIMAX_TOKEN_PLAN_API_KEY", Source: "minimax_token_plan"}}, } MiniMaxPaygRuntimeProfile = RuntimeProviderProfile{ Mode: "openai", DefaultBaseURL: DefaultMiniMaxOpenAIBaseURL, DetectionEnv: []string{"MINIMAX_PAYG_API_KEY"}, ModelEnv: []string{"MINIMAX_PAYG_MODEL", "MINIMAX_MODEL", "OPENAI_MODEL"}, BaseURLEnv: []string{"MINIMAX_PAYG_BASE_URL", "MINIMAX_BASE_URL", "OPENAI_BASE_URL", "OPENAI_API_BASE"}, APIKeys: []APIKeyDef{{Env: "MINIMAX_PAYG_API_KEY", Source: "minimax_payg"}}, } OllamaRuntimeProfile = RuntimeProviderProfile{ Mode: "openai", DefaultBaseURL: OllamaDefaultBaseURL, DetectionEnv: []string{"OLLAMA_BASE_URL"}, ModelEnv: []string{"OLLAMA_MODEL", "OPENAI_MODEL"}, BaseURLEnv: []string{"OLLAMA_BASE_URL"}, APIKeys: []APIKeyDef{{Env: "OLLAMA_API_KEY", Source: "ollama"}}, } )
Provider runtime profiles.
var APIProviderDetectionOrder = []APIProvider{ ProviderAnthropic, ProviderOpenRouter, ProviderGrok, ProviderGemini, ProviderVertex, ProviderBedrock, ProviderZAICoding, ProviderZAIPayg, ProviderCanopyWave, ProviderDeepSeek, ProviderAzure, ProviderOpenAI, ProviderOpenCodeGo, ProviderKimi, ProviderXiaomiMimoPayg, ProviderXiaomiMimoTokenPlan, ProviderMiniMaxTokenPlan, ProviderMiniMaxPayg, ProviderOllama, }
APIProviderDetectionOrder is the priority order for provider detection.
var OpenAICompatibleRuntimeProfileOrder = []string{
"openrouter", "grok", "gemini", "anthropic", "zai_coding", "zai_payg", "canopywave", "deepseek", "openai", "opencodego", "kimi", "xiaomi_mimo_payg", "xiaomi_mimo_token_plan", "minimax_token_plan", "minimax_payg",
}
OpenAICompatibleRuntimeProfileOrder is the detection order for runtime profiles.
var OpenAICompatibleRuntimeProfiles = map[string]RuntimeProviderProfile{ "anthropic": AnthropicRuntimeProfile, "grok": GrokRuntimeProfile, "gemini": GeminiRuntimeProfile, "zai_payg": ZAIPaygRuntimeProfile, "zai_coding": ZAICodingRuntimeProfile, "canopywave": CanopyWaveRuntimeProfile, "deepseek": DeepSeekRuntimeProfile, "openai": OpenAIRuntimeProfile, "openrouter": OpenRouterRuntimeProfile, "opencodego": OpenCodeGoRuntimeProfile, "kimi": KimiRuntimeProfile, "xiaomi_mimo_payg": XiaomiPaygRuntimeProfile, "xiaomi_mimo_token_plan": XiaomiTokenPlanRuntimeProfile, "minimax_token_plan": MiniMaxTokenPlanRuntimeProfile, "minimax_payg": MiniMaxPaygRuntimeProfile, }
OpenAICompatibleRuntimeProfiles maps profile key to its runtime profile.
var ProviderDetectionOrder = APIProviderDetectionOrder
ProviderDetectionOrder is the priority order for provider detection.
var ProviderModelEnvKeys = map[APIProvider][]string{ ProviderAnthropic: AnthropicRuntimeProfile.ModelEnv, ProviderOpenAI: OpenAIRuntimeProfile.ModelEnv, ProviderAzure: AzureRuntimeProfile.ModelEnv, ProviderCanopyWave: CanopyWaveRuntimeProfile.ModelEnv, ProviderDeepSeek: DeepSeekRuntimeProfile.ModelEnv, ProviderZAIPayg: ZAIPaygRuntimeProfile.ModelEnv, ProviderZAICoding: ZAICodingRuntimeProfile.ModelEnv, ProviderOpenRouter: OpenRouterRuntimeProfile.ModelEnv, ProviderGrok: GrokRuntimeProfile.ModelEnv, ProviderGemini: GeminiRuntimeProfile.ModelEnv, ProviderBedrock: BedrockRuntimeProfile.ModelEnv, ProviderVertex: VertexRuntimeProfile.ModelEnv, ProviderOllama: {"OLLAMA_MODEL", "OPENAI_MODEL"}, ProviderOpenCodeGo: OpenCodeGoRuntimeProfile.ModelEnv, ProviderKimi: KimiRuntimeProfile.ModelEnv, ProviderXiaomiMimoPayg: XiaomiPaygRuntimeProfile.ModelEnv, ProviderXiaomiMimoTokenPlan: XiaomiTokenPlanRuntimeProfile.ModelEnv, ProviderMiniMaxTokenPlan: {"MINIMAX_TOKEN_PLAN_MODEL", "MINIMAX_MODEL", "OPENAI_MODEL"}, ProviderMiniMaxPayg: {"MINIMAX_PAYG_MODEL", "MINIMAX_MODEL", "OPENAI_MODEL"}, }
ProviderModelEnvKeys maps each provider to its model env var keys.
var RuntimeProviderProfiles = map[string]RuntimeProviderProfile{ "anthropic": AnthropicRuntimeProfile, "openai": OpenAIRuntimeProfile, "grok": GrokRuntimeProfile, "gemini": GeminiRuntimeProfile, "vertex": VertexRuntimeProfile, "azure": AzureRuntimeProfile, "bedrock": BedrockRuntimeProfile, "openrouter": OpenRouterRuntimeProfile, "zai_payg": ZAIPaygRuntimeProfile, "zai_coding": ZAICodingRuntimeProfile, "canopywave": CanopyWaveRuntimeProfile, "deepseek": DeepSeekRuntimeProfile, "opencodego": OpenCodeGoRuntimeProfile, "kimi": KimiRuntimeProfile, "xiaomi_mimo_payg": XiaomiPaygRuntimeProfile, "xiaomi_mimo_token_plan": XiaomiTokenPlanRuntimeProfile, "minimax_token_plan": MiniMaxTokenPlanRuntimeProfile, "minimax_payg": MiniMaxPaygRuntimeProfile, "ollama": OllamaRuntimeProfile, }
RuntimeProviderProfiles maps provider/profile keys to runtime detection profiles.
Functions ¶
func ActiveModel ¶ added in v0.1.1
func ActiveModel(cfg *ProviderConfig) string
ActiveModel returns the user's selected model from provider.json (canonical when possible).
func ActiveProvider ¶ added in v0.1.1
func ActiveProvider(cfg *ProviderConfig) string
ActiveProvider returns the configured active provider id.
func AddProfile ¶ added in v0.1.1
func AddProfile(profile ProviderProfile) error
AddProfile adds or updates a profile.
func AgentRoutingPath ¶ added in v0.1.1
func AgentRoutingPath() string
AgentRoutingPath returns the path to the agent routing config.
func AgentRoutingSummary ¶ added in v0.1.1
func AgentRoutingSummary() string
AgentRoutingSummary returns a human-readable summary of routing config.
func ApplyOpenAICompatibleProvider ¶
ApplyOpenAICompatibleProvider sets env vars for an OpenAI-compatible provider.
func ApplyProviderConfigToEnv ¶
func ApplyProviderConfigToEnv(config *ProviderConfig, overwrite bool, cat *catalog.ModelCatalog) string
ApplyProviderConfigToEnv applies the full provider config to env vars. Returns the detected provider or empty string.
func ApplyProviderEnv ¶
func ApplyProviderEnv(provider string, config *ProviderConfig, activeModel string, overwrite bool, cat *catalog.ModelCatalog) map[string]string
ApplyProviderEnv computes the env vars for a specific provider and returns them as a map without modifying the process environment.
func ApplyProviderEnvToProcess ¶
func ApplyProviderEnvToProcess(provider string, config *ProviderConfig, activeModel string, overwrite bool, cat *catalog.ModelCatalog)
ApplyProviderEnvToProcess applies the env vars for a specific provider directly to the process environment via os.Setenv.
func AsNonEmptyString ¶
AsNonEmptyString returns trimmed string or empty.
func ClearActiveSelection ¶ added in v0.1.1
func ClearActiveSelection(cfg *ProviderConfig)
ClearActiveSelection clears active provider/model fields.
func ClearProviderRuntimeEnv ¶
func ClearProviderRuntimeEnv()
ClearProviderRuntimeEnv clears all provider-related env vars.
func CommitCredential ¶ added in v0.1.1
func CommitCredential(ctx context.Context, inference CredentialInference, secret string) error
CommitCredential validates and probes a credential before persistence.
func CommitLocalCredential ¶ added in v0.1.1
func CommitLocalCredential(ctx context.Context, inference CredentialInference, value string) error
CommitLocalCredential validates and probes a no-key provider.
func DefaultCategories ¶ added in v0.1.1
func DefaultCategories() map[ModelCategory]CategoryConfig
DefaultCategories returns the built-in category-to-model mappings.
func DefaultProviderFromConfig ¶
func DefaultProviderFromConfig(config *ProviderConfig) string
DefaultProviderFromConfig determines the default provider from config.
func DeleteProfile ¶ added in v0.1.1
DeleteProfile removes a profile by name.
func DeploymentConfigured ¶ added in v0.1.1
func DeploymentConfigured(deploymentID string, dep catalog.DeploymentV1, dc DeploymentConfig) bool
DeploymentConfigured reports whether env supplies enough credentials for this deployment.
func DiscoveryCredentials ¶ added in v0.1.1
func DiscoveryCredentials(ctx context.Context) catalog.Credentials
DiscoveryCredentials loads API keys from the OS secret store (not process env or .env files), merged with non-secret routing from ~/.hawk/provider.json (e.g. MiMo Token Plan region/base URL).
func DiscoveryEnvMap ¶ added in v0.1.1
DiscoveryEnvMap returns merged credential env (keychain + provider.json routing) for status UI.
func FormatOllamaConnectError ¶ added in v0.1.1
FormatOllamaConnectError turns probe/network failures into actionable setup hints.
func GetProviderAPIKey ¶
func GetProviderAPIKey(config *ProviderConfig, provider string) string
GetProviderAPIKey returns the configured API key for a provider.
func GetProviderActiveModel ¶
func GetProviderActiveModel(config *ProviderConfig, provider string) string
GetProviderActiveModel gets the active model for a provider from config.
func GetProviderConfigDir ¶
func GetProviderConfigDir() string
GetProviderConfigDir returns the config directory path.
func GetProviderConfigPath ¶
func GetProviderConfigPath() string
GetProviderConfigPath returns the full path to provider.json.
func GetProviderModel ¶
func GetProviderModel(config *ProviderConfig, provider string) string
GetProviderModel returns the configured model for a provider.
func HasAnyConfiguredDeployment ¶ added in v0.1.1
HasAnyConfiguredDeployment reports whether catalog env + keychain satisfy any deployment.
func IsLocalProviderURL ¶
IsLocalProviderURL checks if a base URL points to localhost.
func IsOpenAICompatibleRuntimeEnabled ¶
func IsOpenAICompatibleRuntimeEnabled() bool
IsOpenAICompatibleRuntimeEnabled checks if any provider API key is set.
func IsProviderConfigured ¶
func IsProviderConfigured(config *ProviderConfig, provider string) bool
IsProviderConfigured checks if a provider has valid configuration.
func IsXiaomiMimoProvider ¶ added in v0.1.1
IsXiaomiMimoProvider reports whether id is a MiMo setup gateway (payg or token plan).
func IsZAIProvider ¶ added in v0.1.1
IsZAIProvider reports whether id is a Z.AI setup gateway (payg or coding).
func ListProfiles ¶ added in v0.1.1
func ListProfiles() string
ListProfiles returns a human-readable list of profiles.
func LooksLikePlaceholderSecret ¶ added in v0.1.1
LooksLikePlaceholderSecret detects obvious placeholder API keys.
func MigrateLegacyXiaomiProvider ¶ added in v0.1.1
func MigrateLegacyXiaomiProvider(cfg *ProviderConfig)
MigrateLegacyXiaomiProvider rewrites deprecated xiaomi_mimo ids and env to payg.
func NormalizeOllamaOpenAIBaseURL ¶
NormalizeOllamaOpenAIBaseURL ensures the URL ends with /v1.
func ParseRoute ¶ added in v0.1.1
ParseRoute splits a route string into provider and model. Format: "provider/model" or just "model".
func PrepareCredentialForSave ¶ added in v0.1.1
func PrepareCredentialForSave(inference CredentialInference, secret string) (string, error)
PrepareCredentialForSave validates and returns the normalized value to persist.
func ProbeCredential ¶ added in v0.1.1
ProbeCredential verifies a key against the provider API when a probe is configured.
func ProbeLocalCredential ¶ added in v0.1.1
ProbeLocalCredential verifies a local provider endpoint when configured.
func ProfilesPath ¶ added in v0.1.1
func ProfilesPath() string
ProfilesPath returns the path to the profiles file.
func ProviderIDForEnv ¶ added in v0.1.1
ProviderIDForEnv maps an env var to registry provider id.
func ResetCategoryRegistry ¶ added in v0.1.1
func ResetCategoryRegistry()
ResetCategoryRegistry clears the global registry (for testing).
func ResolveXiaomiAnthropicBase ¶ added in v0.1.1
func ResolveXiaomiAnthropicBase(providerID string, cfg *ProviderConfig) (string, error)
ResolveXiaomiAnthropicBase resolves the Anthropic-compat base for a MiMo gateway id.
func ResolveXiaomiOpenAIBase ¶ added in v0.1.1
func ResolveXiaomiOpenAIBase(providerID string, cfg *ProviderConfig) (string, error)
ResolveXiaomiOpenAIBase resolves the OpenAI-compat base for a MiMo gateway id.
func ResolveZAIAnthropicBase ¶ added in v0.1.1
func ResolveZAIAnthropicBase(cfg *ProviderConfig) string
ResolveZAIAnthropicBase resolves the Anthropic-compat base for Z.AI. Prefers coding region if set, falls back to general region.
func ResolveZAIOpenAIBase ¶ added in v0.1.1
func ResolveZAIOpenAIBase(providerID string, cfg *ProviderConfig) (string, error)
ResolveZAIOpenAIBase resolves the OpenAI-compat base for a Z.AI gateway id.
func SaveAgentRouting ¶ added in v0.1.1
func SaveAgentRouting(cfg *AgentRoutingConfig) error
SaveAgentRouting persists the agent routing config.
func SaveProfiles ¶ added in v0.1.1
func SaveProfiles(profiles []ProviderProfile) error
SaveProfiles persists provider profiles.
func SaveProviderConfig ¶
func SaveProviderConfig(config *ProviderConfig, path string) error
SaveProviderConfig saves provider config to disk.
func SetActiveProvider ¶ added in v0.1.1
func SetActiveProvider(cfg *ProviderConfig, provider string)
SetActiveProvider updates active_provider in provider config.
func SetEnvValue ¶
SetEnvValue sets an env var if value is non-empty and overwrite is allowed.
func SetProviderModel ¶ added in v0.1.1
func SetProviderModel(cfg *ProviderConfig, provider, model string)
SetProviderModel sets active_model and the provider-scoped model field.
func ValidateAPIKey ¶
ValidateAPIKey validates an API key.
func ValidateBaseURL ¶
ValidateBaseURL validates a base URL. Returns an error message if the URL is syntactically invalid (unparseable or missing a scheme), or empty if valid.
func ValidateCredentialBeforeSave ¶ added in v0.1.1
func ValidateCredentialBeforeSave(inference CredentialInference, secret string) error
ValidateCredentialBeforeSave checks format without a live API probe.
func ValidateCredentialSecret ¶ added in v0.1.1
ValidateCredentialSecret validates env-specific secret shape.
func ValidateKeyFormat ¶ added in v0.1.1
ValidateKeyFormat checks a pasted secret before any provider is chosen.
func VertexGeminiBaseURL ¶ added in v0.1.1
VertexGeminiBaseURL returns the Google Vertex AI publisher endpoint for Gemini.
func XiaomiTokenPlanRegionFromConfig ¶ added in v0.1.1
func XiaomiTokenPlanRegionFromConfig(cfg *ProviderConfig) xiaomi.Region
XiaomiTokenPlanRegionFromConfig reads persisted Token Plan cluster from provider.json.
Types ¶
type APIProvider ¶
type APIProvider = string
APIProvider is the type for supported LLM providers.
const ( ProviderAnthropic APIProvider = "anthropic" ProviderOpenAI APIProvider = "openai" ProviderAzure APIProvider = "azure" ProviderCanopyWave APIProvider = "canopywave" ProviderDeepSeek APIProvider = "deepseek" ProviderZAICoding APIProvider = "zai_coding" ProviderZAIPayg APIProvider = "zai_payg" ProviderOpenRouter APIProvider = "openrouter" ProviderGrok APIProvider = "grok" ProviderGemini APIProvider = "gemini" ProviderBedrock APIProvider = "bedrock" ProviderVertex APIProvider = "vertex" ProviderOllama APIProvider = "ollama" ProviderOpenCodeGo APIProvider = "opencodego" ProviderKimi APIProvider = "kimi" ProviderXiaomiMimoPayg APIProvider = "xiaomi_mimo_payg" ProviderXiaomiMimoTokenPlan APIProvider = "xiaomi_mimo_token_plan" ProviderMiniMaxTokenPlan APIProvider = "minimax_token_plan" ProviderMiniMaxPayg APIProvider = "minimax_payg" )
type AgentRoutingConfig ¶ added in v0.1.1
type AgentRoutingConfig struct {
// Routes maps agent type to model identifier (provider/model).
// Special keys: "default" for fallback, "general-purpose" for main chat.
Routes map[string]string `json:"routes"`
}
AgentRoutingConfig holds per-agent model routing rules.
func DefaultAgentRouting ¶ added in v0.1.1
func DefaultAgentRouting() *AgentRoutingConfig
DefaultAgentRouting returns the default routing config.
func LoadAgentRouting ¶ added in v0.1.1
func LoadAgentRouting() (*AgentRoutingConfig, error)
LoadAgentRouting reads the agent routing config.
func (*AgentRoutingConfig) ResolveModel ¶ added in v0.1.1
func (c *AgentRoutingConfig) ResolveModel(agentType, fallback string) string
ResolveModel returns the model for the given agent type. Falls back to "default" route, then to the provided fallback.
func (*AgentRoutingConfig) SetRoute ¶ added in v0.1.1
func (c *AgentRoutingConfig) SetRoute(agentType, model string)
SetRoute sets the model for an agent type.
type CategoryConfig ¶ added in v0.1.1
type CategoryConfig struct {
Model string `json:"model"`
Provider string `json:"provider,omitempty"`
Temperature float64 `json:"temperature,omitempty"`
MaxTokens int `json:"max_tokens,omitempty"`
Description string `json:"description,omitempty"`
}
CategoryConfig maps a category to a specific model configuration.
func ResolveCategory ¶ added in v0.1.1
func ResolveCategory(cat ModelCategory) CategoryConfig
ResolveCategory is a convenience function that resolves a category using the global registry.
type CategoryRegistry ¶ added in v0.1.1
type CategoryRegistry struct {
// contains filtered or unexported fields
}
CategoryRegistry holds the mapping from categories to model configs.
func GetCategoryRegistry ¶ added in v0.1.1
func GetCategoryRegistry() *CategoryRegistry
GetCategoryRegistry returns the global category registry. It loads overrides from Hawk user config if present.
func (*CategoryRegistry) AllCategories ¶ added in v0.1.1
func (r *CategoryRegistry) AllCategories() map[ModelCategory]CategoryConfig
AllCategories returns all registered categories.
func (*CategoryRegistry) Resolve ¶ added in v0.1.1
func (r *CategoryRegistry) Resolve(cat ModelCategory) CategoryConfig
Resolve returns the CategoryConfig for the given category. Falls back to CategoryUnspecifiedHigh if the category is unknown.
func (*CategoryRegistry) ResolveWithDefaults ¶ added in v0.1.1
func (r *CategoryRegistry) ResolveWithDefaults(cat ModelCategory, defaultModel string) CategoryConfig
ResolveWithDefaults returns the config for a category, falling back to the provided defaults if the category-specific field is empty.
func (*CategoryRegistry) SetCategory ¶ added in v0.1.1
func (r *CategoryRegistry) SetCategory(cat ModelCategory, cfg CategoryConfig)
SetCategory overrides a category configuration at runtime.
type CredentialInference ¶ added in v0.1.1
type CredentialInference = credential.CredentialInference
func InferCredentialsFromAPIKey ¶ added in v0.1.1
func InferCredentialsFromAPIKey(ctx context.Context, secret string) []CredentialInference
InferCredentialsFromAPIKey is deprecated; use InferenceForProvider after gateway selection.
func InferenceForProvider ¶ added in v0.1.1
func InferenceForProvider(providerID string) (CredentialInference, error)
InferenceForProvider returns save metadata for a gateway selected in setup UI.
func InferenceFromOption ¶ added in v0.1.1
func InferenceFromOption(opt CredentialProviderOption) CredentialInference
InferenceFromOption converts a provider picker row to persistence metadata.
func LocalCredentialInference ¶ added in v0.1.1
func LocalCredentialInference(providerID string) (CredentialInference, error)
LocalCredentialInference returns setup metadata for no-key providers.
type CredentialProviderOption ¶ added in v0.1.1
type CredentialProviderOption = credential.CredentialProviderOption
func ListCredentialProviders ¶ added in v0.1.1
func ListCredentialProviders() []CredentialProviderOption
ListCredentialProviders returns all registry providers for setup UIs.
type CredentialResolveResult ¶ added in v0.1.1
type CredentialResolveResult = credential.CredentialResolveResult
func ResolveCredential ¶ added in v0.1.1
func ResolveCredential(ctx context.Context, secret string) CredentialResolveResult
ResolveCredential validates format and lists registered providers (gateway must be chosen first).
type DeploymentChoice ¶ added in v0.1.1
type DeploymentConfig ¶ added in v0.1.1
type DeploymentConfig struct {
APIKey string `json:"api_key,omitempty"`
BaseURL string `json:"base_url,omitempty"`
Endpoint string `json:"endpoint,omitempty"`
APIVersion string `json:"api_version,omitempty"`
ProjectID string `json:"project_id,omitempty"`
Region string `json:"region,omitempty"`
Token string `json:"token,omitempty"`
AccessKeyID string `json:"access_key_id,omitempty"`
SecretAccessKey string `json:"secret_access_key,omitempty"`
SessionToken string `json:"session_token,omitempty"`
ModelMappings map[string]string `json:"model_mappings,omitempty"`
// OIDC keyless auth (opt-in). When RoleARN (Bedrock) or WIFAudience (Vertex)
// is set — or EYRIE_OIDC=1 — and the process runs in GitHub Actions, the
// deployment obtains short-lived credentials via OIDC instead of stored
// secrets. Empty by default; the non-OIDC path is unchanged.
RoleARN string `json:"role_arn,omitempty"`
WIFAudience string `json:"wif_audience,omitempty"`
ServiceAccountEmail string `json:"service_account_email,omitempty"`
}
func DeploymentConfigFromEnv ¶ added in v0.1.1
func DeploymentConfigFromEnv(dep catalog.DeploymentV1, env map[string]string) DeploymentConfig
DeploymentConfigFromEnv builds deployment credentials from catalog env_fallbacks and env values.
func SanitizeDeploymentConfigForDisk ¶ added in v0.1.1
func SanitizeDeploymentConfigForDisk(dc DeploymentConfig) DeploymentConfig
SanitizeDeploymentConfigForDisk removes secret fields before writing provider.json. Runtime clients resolve API keys from the process environment or credential store.
type ModelCategory ¶ added in v0.1.1
type ModelCategory string
ModelCategory identifies a semantic task category for model routing. Instead of selecting specific models, agents delegate by category (e.g., "deep" for reasoning-heavy tasks, "quick" for fast responses).
const ( CategoryDeep ModelCategory = "deep" CategoryQuick ModelCategory = "quick" CategoryUltraBrain ModelCategory = "ultrabrain" CategoryVisualEngineering ModelCategory = "visual-engineering" CategoryArtistry ModelCategory = "artistry" CategoryWriting ModelCategory = "writing" CategoryUnspecifiedLow ModelCategory = "unspecified-low" CategoryUnspecifiedHigh ModelCategory = "unspecified-high" )
type OpenAICompatibleApiKeySource ¶
type OpenAICompatibleApiKeySource = string
OpenAICompatibleApiKeySource identifies where the API key came from.
type OpenAICompatibleRuntimeMode ¶
type OpenAICompatibleRuntimeMode = string
OpenAICompatibleRuntimeMode identifies the runtime mode.
type ProviderConfig ¶
type ProviderConfig struct {
ConfigVersion int `json:"config_version,omitempty"`
Version string `json:"_version,omitempty"`
ActiveProvider string `json:"active_provider,omitempty"`
AnthropicAPIKey string `json:"anthropic_api_key,omitempty"`
GrokAPIKey string `json:"grok_api_key,omitempty"`
XAIAPIKey string `json:"xai_api_key,omitempty"`
OpenAIAPIKey string `json:"openai_api_key,omitempty"`
CanopyWaveAPIKey string `json:"canopywave_api_key,omitempty"`
DeepSeekAPIKey string `json:"deepseek_api_key,omitempty"`
ZAIAPIKey string `json:"zai_api_key,omitempty"`
ZAICodingAPIKey string `json:"zai_coding_api_key,omitempty"`
OpenRouterAPIKey string `json:"openrouter_api_key,omitempty"`
GeminiAPIKey string `json:"gemini_api_key,omitempty"`
OllamaBaseURL string `json:"ollama_base_url,omitempty"`
OpenCodeGoAPIKey string `json:"opencodego_api_key,omitempty"`
MoonshotAPIKey string `json:"moonshot_api_key,omitempty"`
XiaomiMimoPaygAPIKey string `json:"xiaomi_mimo_payg_api_key,omitempty"`
XiaomiMimoTokenPlanAPIKey string `json:"xiaomi_mimo_token_plan_api_key,omitempty"`
MiniMaxTokenPlanAPIKey string `json:"minimax_token_plan_api_key,omitempty"`
MiniMaxPaygAPIKey string `json:"minimax_payg_api_key,omitempty"`
AnthropicBaseURL string `json:"anthropic_base_url,omitempty"`
CanopyWaveBaseURL string `json:"canopywave_base_url,omitempty"`
DeepSeekBaseURL string `json:"deepseek_base_url,omitempty"`
ZAIBaseURL string `json:"zai_base_url,omitempty"`
ZAICodingBaseURL string `json:"zai_coding_base_url,omitempty"`
ZAIRegion string `json:"zai_region,omitempty"`
ZAICodingRegion string `json:"zai_coding_region,omitempty"`
GrokBaseURL string `json:"grok_base_url,omitempty"`
XAIBaseURL string `json:"xai_base_url,omitempty"`
OpenAIBaseURL string `json:"openai_base_url,omitempty"`
OpenRouterBaseURL string `json:"openrouter_base_url,omitempty"`
GeminiBaseURL string `json:"gemini_base_url,omitempty"`
OpenCodeGoBaseURL string `json:"opencodego_base_url,omitempty"`
MoonshotBaseURL string `json:"moonshot_base_url,omitempty"`
XiaomiBaseURL string `json:"xiaomi_mimo_base_url,omitempty"`
XiaomiMimoPaygBaseURL string `json:"xiaomi_mimo_payg_base_url,omitempty"`
XiaomiMimoTokenPlanBaseURL string `json:"xiaomi_mimo_token_plan_base_url,omitempty"`
XiaomiMimoTokenPlanRegion string `json:"xiaomi_mimo_token_plan_region,omitempty"`
MiniMaxTokenPlanBaseURL string `json:"minimax_token_plan_base_url,omitempty"`
MiniMaxPaygBaseURL string `json:"minimax_payg_base_url,omitempty"`
MiniMaxModel string `json:"minimax_model,omitempty"`
AnthropicModel string `json:"anthropic_model,omitempty"`
OpenAIModel string `json:"openai_model,omitempty"`
CanopyWaveModel string `json:"canopywave_model,omitempty"`
DeepSeekModel string `json:"deepseek_model,omitempty"`
ZAIModel string `json:"zai_model,omitempty"`
GrokModel string `json:"grok_model,omitempty"`
XAIModel string `json:"xai_model,omitempty"`
OpenRouterModel string `json:"openrouter_model,omitempty"`
GeminiModel string `json:"gemini_model,omitempty"`
OllamaModel string `json:"ollama_model,omitempty"`
OpenCodeGoModel string `json:"opencodego_model,omitempty"`
MoonshotModel string `json:"moonshot_model,omitempty"`
XiaomiModel string `json:"xiaomi_mimo_model,omitempty"`
ActiveModel string `json:"active_model,omitempty"`
ExplorationModel string `json:"exploration_model,omitempty"`
AnthropicVersion string `json:"anthropic_version,omitempty"`
Deployments map[string]DeploymentConfig `json:"deployments,omitempty"`
Routing *RoutingPolicy `json:"routing,omitempty"`
}
ProviderConfig mirrors the Hawk provider.json file.
func EnsureDeploymentConfigV2 ¶ added in v0.1.1
func EnsureDeploymentConfigV2(cfg *ProviderConfig) *ProviderConfig
EnsureDeploymentConfigV2 upgrades legacy flat provider.json to deployment-aware v2.
func LoadProviderConfig ¶
func LoadProviderConfig(path string) *ProviderConfig
LoadProviderConfig loads provider config from disk. Returns nil if file doesn't exist. Returns error for corrupt JSON or permission issues.
func LoadProviderConfigWithError ¶
func LoadProviderConfigWithError(path string) (*ProviderConfig, error)
LoadProviderConfigWithError loads provider config from disk with detailed error reporting. Returns (nil, nil) if file doesn't exist. Returns (nil, error) for corrupt JSON or permission issues.
func SyncProviderConfigFromCatalog ¶ added in v0.1.1
func SyncProviderConfigFromCatalog(compiled *catalog.CompiledCatalogV1, env map[string]string) *ProviderConfig
SyncProviderConfigFromCatalog merges catalog + env into provider.json deployments and routing.
type ProviderProfile ¶ added in v0.1.1
type ProviderProfile struct {
Name string `json:"name"`
Provider string `json:"provider"`
Model string `json:"model"`
BaseURL string `json:"base_url,omitempty"`
APIKeyEnv string `json:"api_key_env,omitempty"` // env var to read key from
Temperature float64 `json:"temperature,omitempty"`
MaxTokens int `json:"max_tokens,omitempty"`
Description string `json:"description,omitempty"`
CreatedAt time.Time `json:"created_at"`
}
ProviderProfile is a saved provider configuration.
func FindProfile ¶ added in v0.1.1
func FindProfile(name string) (*ProviderProfile, error)
FindProfile returns a profile by name (case-insensitive).
func LoadProfiles ¶ added in v0.1.1
func LoadProfiles() ([]ProviderProfile, error)
LoadProfiles reads saved provider profiles.
func RecommendedProfile ¶ added in v0.1.1
func RecommendedProfile(goal string) ProviderProfile
RecommendedProfile returns a profile based on the user's goal.
type ProviderTransport ¶
type ProviderTransport string
ProviderTransport is the transport type for provider requests.
const TransportChatCompletions ProviderTransport = "chat_completions"
type ReasoningEffort ¶
type ReasoningEffort string
ReasoningEffort levels.
const ( ReasoningLow ReasoningEffort = "low" ReasoningMedium ReasoningEffort = "medium" ReasoningHigh ReasoningEffort = "high" )
type ResolvedOpenAICompatibleRuntime ¶
type ResolvedOpenAICompatibleRuntime struct {
Mode string `json:"mode"`
Request ResolvedProviderRequest `json:"request"`
APIKey string `json:"-"`
APIKeySource string `json:"api_key_source"`
}
ResolvedOpenAICompatibleRuntime holds the resolved runtime config.
func ResolveOpenAICompatibleRuntime ¶
func ResolveOpenAICompatibleRuntime(model, baseURL, fallbackModel string) ResolvedOpenAICompatibleRuntime
ResolveOpenAICompatibleRuntime resolves the full OpenAI-compatible runtime config.
type ResolvedProviderRequest ¶
type ResolvedProviderRequest struct {
Transport ProviderTransport `json:"transport"`
RequestedModel string `json:"requested_model"`
ResolvedModel string `json:"resolved_model"`
BaseURL string `json:"base_url"`
Reasoning *struct {
Effort ReasoningEffort `json:"effort"`
} `json:"reasoning,omitempty"`
}
ResolvedProviderRequest holds the resolved provider request details.
func ResolveProviderRequest ¶
func ResolveProviderRequest(model, baseURL, fallbackModel string) ResolvedProviderRequest
ResolveProviderRequest resolves model/baseUrl/transport from options and env.
type RoutingPolicy ¶ added in v0.1.1
type RoutingPolicy struct {
Default []RoutingStage `json:"default,omitempty"`
Providers map[string][]RoutingStage `json:"providers,omitempty"`
Models map[string][]RoutingStage `json:"models,omitempty"`
}
func BuildRoutingPolicyFromDeployments ¶ added in v0.1.1
func BuildRoutingPolicyFromDeployments(deployments map[string]DeploymentConfig) *RoutingPolicy
BuildRoutingPolicyFromDeployments builds deployment routing from configured deployments. Hawk should not author routing rules — consume this JSON from eyrie only.
type RoutingStage ¶ added in v0.1.1
type RoutingStage struct {
Deployments []DeploymentChoice `json:"deployments"`
Retries int `json:"retries,omitempty"`
}
type RuntimeProviderProfile ¶
type RuntimeProviderProfile struct {
Mode string `json:"mode"`
DefaultBaseURL string `json:"default_base_url"`
DefaultModel string `json:"default_model"`
DetectionEnv []string `json:"detection_env"`
ModelEnv []string `json:"model_env"`
BaseURLEnv []string `json:"base_url_env"`
APIKeys []APIKeyDef `json:"api_keys"`
}
RuntimeProviderProfile defines how a provider is detected and configured at runtime.
func RuntimeProfileByKey ¶ added in v0.1.3
func RuntimeProfileByKey(key string) (RuntimeProviderProfile, bool)
RuntimeProfileByKey returns the provider runtime profile registered for key.