modelrouting

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Jul 14, 2026 License: MIT Imports: 4 Imported by: 0

Documentation

Overview

Package modelrouting selects provider routes and model settings.

Index

Constants

View Source
const (
	ProviderAnthropic = "anthropic"
	ProviderOpenAI    = "openai"
	ProviderXAI       = "xai"
	ProviderDashScope = "dashscope"

	DefaultAnthropicBaseURL = "https://api.anthropic.com"
	DefaultOpenAIBaseURL    = "https://api.openai.com/v1"
	DefaultXAIBaseURL       = "https://api.x.ai/v1"
	DefaultDashScopeBaseURL = "https://dashscope.aliyuncs.com/compatible-mode/v1"
)

Variables

This section is empty.

Functions

func IsLocalBaseURL

func IsLocalBaseURL(baseURL string) bool

IsLocalBaseURL reports whether baseURL points at loopback or private-network host.

func IsOpenAICompatibleModel

func IsOpenAICompatibleModel(model string) bool

func IsReasoningModel

func IsReasoningModel(model string) bool

func LooksLikeLocalOpenAICompatibleModel

func LooksLikeLocalOpenAICompatibleModel(model string) bool

func ModelRejectsIsErrorField

func ModelRejectsIsErrorField(model string) bool

func ProviderForModel

func ProviderForModel(model string) string

func RedactURL

func RedactURL(raw string) string

RedactURL returns raw with URL userinfo replaced when it can be parsed.

func RequiresReasoningContentHistory

func RequiresReasoningContentHistory(model string) bool

func ResolveAlias

func ResolveAlias(model string) string

func UsesMaxCompletionTokens

func UsesMaxCompletionTokens(model string) bool

func WireModelForBaseURL

func WireModelForBaseURL(model string, baseURL string) string

Types

type BaseURLDiagnostic

type BaseURLDiagnostic struct {
	Provider  string `json:"provider,omitempty"`
	Env       string `json:"base_url_env,omitempty"`
	Source    string `json:"base_url_source,omitempty"`
	URL       string `json:"base_url,omitempty"`
	Valid     bool   `json:"base_url_valid"`
	Scheme    string `json:"base_url_scheme,omitempty"`
	Host      string `json:"base_url_host,omitempty"`
	Local     bool   `json:"local_base_url,omitempty"`
	ErrorKind string `json:"base_url_error_kind,omitempty"`
	Error     string `json:"base_url_error,omitempty"`
}

BaseURLDiagnostic is a redaction-safe provider endpoint validation result.

func DiagnoseBaseURL

func DiagnoseBaseURL(provider string, envName string, source string, raw string) BaseURLDiagnostic

DiagnoseBaseURL validates a provider base URL without exposing credentials.

type ModelAlias

type ModelAlias struct {
	Name  string
	Model string
}

func BuiltInAliases

func BuiltInAliases() []ModelAlias

type TokenLimit

type TokenLimit struct {
	MaxOutputTokens     int
	ContextWindowTokens int
}

func TokenLimitForModel

func TokenLimitForModel(model string) (TokenLimit, bool)

Jump to

Keyboard shortcuts

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