Documentation
¶
Index ¶
- Constants
- Variables
- func AccountTitle(entry *providerv1.Provider, name string) string
- func Address(address string) error
- func AffinityOf(ctx context.Context) string
- func AskedTier(extra map[string]any) string
- func Astra(model string) bool
- func AtLeast(v, floor [2]int) bool
- func Attribution() map[string]string
- func AzureShare(deployment, model string) string
- func Bar(fraction float64, width int) string
- func BareModel(model string) string
- func BaseHost(base string) string
- func BaseHostMatches(base, domain string) bool
- func BasePath(base string) string
- func BoundedTier(tier string) bool
- func Carry(cfg *config.Config, values map[string]any, change Change) (map[string]any, bool)
- func ClampEffort(effort string, supported []string, overrides map[string]string) string
- func Claude(model string) bool
- func ClaudeFamily(model string) (string, [2]int, bool)
- func ClaudeSamplingForbidden(model string) bool
- func ClaudeThinking(ask Ask, model string, maxTokens int) map[string]any
- func Cleared(phrases []string) string
- func Clock(at time.Time) string
- func CodexEfforts(model string) []string
- func Contains(s string, parts ...string) bool
- func Controlled(name string, keyed bool) bool
- func DashScopeThinking(model string) map[string]any
- func EffortOptions(unset config.Option) []config.Option
- func FastDeployment(extra map[string]any) bool
- func FastFields(model, kind, base, tier string) map[string]any
- func GeminiBase(base string) string
- func GeminiSamplingDeprecated(model string) bool
- func GeminiSnake(config map[string]any) map[string]any
- func GeminiThinking(model string, a Ask) map[string]any
- func GeminiVersion(model string) (int, int)
- func Grok46(model string) bool
- func HasPrefix(s string, prefixes ...string) bool
- func Hostname(address string) string
- func KimiModel(model string) bool
- func KnownMode(mode string) bool
- func LadderOptions() []config.Option
- func LimitHeader(name string) bool
- func Lines(text, variable string) ([][2]string, error)
- func MandatoryThinking(model string) bool
- func ModelsURL(base string) string
- func NamesTier(extra map[string]any) bool
- func NativeGemini(address string) bool
- func NestedReasoning(a Ask) map[string]any
- func OfficialCodex(base string) bool
- func Overridden(model string, overrides map[string]any, order []string) (string, bool)
- func OverriddenBy(model string, overrides map[string]any, order []string) (string, string, bool)
- func ParseEffort(value any) (string, bool)
- func PercentUsed(fraction float64) string
- func Queried(address string, query url.Values) string
- func QueryOf(settings config.View) url.Values
- func Refill(header http.Header, now time.Time) (time.Duration, bool)
- func RepairPrefix(model string, catalogue []string) string
- func ResetIn(value string, now time.Time) (time.Duration, bool)
- func ResetsIn(at, now time.Time) string
- func ResponsesEfforts(model string, official bool) []string
- func RetryWait(header http.Header, now time.Time) time.Duration
- func Rung(effort string) int
- func SlowFields(model, kind, base string) map[string]any
- func StaticTier(tier string) bool
- func StripOwn(model string, names ...string) string
- func ThinkingToggle(a Ask, efforts []string, overrides map[string]string, always bool) (extra, top map[string]any)
- func Tier(word string) (string, error)
- func TierFields(model, kind, base, tier string) map[string]any
- func TierWord(tier string) string
- func Unprefixed(s Spec, model string) string
- func UserAgent(product string) string
- func Vendor(model string) string
- func Vendored(_ Spec, model string) string
- func Version() string
- func Wait(header http.Header, now time.Time) (time.Duration, bool)
- func WithAffinity(ctx context.Context, key string) context.Context
- func WithVendor(model string) string
- func WithoutTier(extra map[string]any) map[string]any
- func WrittenAddress(cfg *config.Config, address string) error
- type APIError
- type APIMode
- type AccountUsage
- type Action
- type Added
- type Additions
- type Ask
- type AuthKind
- type Billing
- type Bucket
- type Call
- type Change
- type Client
- type Counter
- type Cut
- type Edit
- type Effortful
- type ErrorKind
- type EventKind
- type Factory
- type Follower
- type Format
- type HeaderSource
- type IcebathOverlay
- type Instance
- func (i Instance) AccountFields(name string) config.View
- func (i Instance) AccountTitle(name string) string
- func (i Instance) Label() string
- func (i Instance) Launch(lookup func(name string) (string, bool)) (string, []string, error)
- func (i Instance) Offered(cfg *config.Config) bool
- func (i Instance) Takes(source string) bool
- type Keeper
- type Kept
- type Live
- type Price
- type Primary
- type Provider
- type Question
- type RateLimits
- type Reasoning
- type Registrant
- type Registry
- func (r *Registry) Add(cfg *config.Config, kind, id, title, address string) (Instance, error)
- func (r *Registry) Billing(route Route) Billing
- func (r *Registry) Connect(cfg *config.Config, id, name, title, identity string, fields map[string]any) (string, error)
- func (r *Registry) CredentialEnv() []string
- func (r *Registry) EffortKeys() (effort, overrides string, ok bool)
- func (r *Registry) EffortOf(cfg *config.Config, model string) (string, bool)
- func (r *Registry) First(cfg *config.Config, kind string) (Instance, bool)
- func (r *Registry) Follow(follower Follower)
- func (r *Registry) Instance(cfg *config.Config, name string) (Instance, bool)
- func (r *Registry) Instances(cfg *config.Config) []Instance
- func (r *Registry) KeepKey(cfg *config.Config, id, name, key string) error
- func (r *Registry) Kept(values *config.Config) []Kept
- func (r *Registry) LaunchEnv() []string
- func (r *Registry) Live() []Spec
- func (r *Registry) MoveAccount(cfg *config.Config, id, name string, place int) (int, error)
- func (r *Registry) Options(cfg *config.Config) func() []config.Option
- func (r *Registry) Overridden(cfg *config.Config, model string) (string, bool)
- func (r *Registry) Plugins() int
- func (r *Registry) Primary() (provider, model string, ok bool)
- func (r *Registry) Register(registrant Registrant)
- func (r *Registry) Rekey(ctx context.Context, cfg *config.Config, id, to string) error
- func (r *Registry) RekeyAccount(ctx context.Context, cfg *config.Config, id, name, to string) error
- func (r *Registry) Remove(ctx context.Context, cfg *config.Config, id string) (Removed, error)
- func (r *Registry) RemoveAccount(ctx context.Context, cfg *config.Config, id, name string) (Removed, error)
- func (r *Registry) Rename(ctx context.Context, cfg *config.Config, id, title string) (string, error)
- func (r *Registry) RenameAccount(ctx context.Context, cfg *config.Config, id, name, title string) (string, error)
- func (r *Registry) SetAddress(cfg *config.Config, id, address string) error
- func (r *Registry) SetOffered(cfg *config.Config, id string, on bool) error
- func (r *Registry) SetOutside(cfg *config.Config, id, source string, on bool) (bool, error)
- func (r *Registry) SetTurns(cfg *config.Config, id, name string, on bool) error
- func (r *Registry) Spec(name string) (Spec, bool)
- func (r *Registry) Specs() []Spec
- func (r *Registry) Untiered(cfg *config.Config, name, model, word string) (string, string, bool)
- func (r *Registry) UseAccount(cfg *config.Config, id, name string) error
- type Removed
- type Request
- type Response
- type Retry
- type Route
- type Session
- type Spec
- func (s Spec) AccountFields() []config.Setting
- func (s Spec) Additional(settings config.View, base string, keyed, signed bool) (Additions, error)
- func (s Spec) KeyEnvNames() []string
- func (s Spec) Keyed() bool
- func (s Spec) Label() string
- func (s Spec) Names() []string
- func (s Spec) NativeModel(model string) string
- func (s Spec) Own() bool
- func (s Spec) Retry(route Route, model string, failure *APIError, attempt int, wait time.Duration, ...) Retry
- func (s Spec) Temperature(model string, wanted *float64) *float64
- type StreamEvent
- type StreamFunc
- type Thinking
- type Usage
- type UsageWindow
- type Written
Constants ¶
const ( AzureGlobal = "" AzureZoneUS = "data_zone_us" AzureZoneEU = "data_zone_eu" )
Deployments of Foundry the prices are billed at, beside Global standard, whose are the ones listed
const ( AuthTypeAPIKey = "api_key" AuthTypeOAuthDeviceCode = "oauth_device_code" AuthTypeOAuthExternal = "oauth_external" AuthTypeOAuthMiniMax = "oauth_minimax" AuthTypeExternalProcess = "external_process" AuthTypeAWSSDK = "aws_sdk" AuthTypeVertex = "vertex" AuthTypeVirtual = "virtual" )
const Betas = "anthropic-beta"
Header whose values icebath and a person both give, the betas of the Anthropic API: an added one joins those icebath negotiates
const DefaultPolicy = "default"
Name of the caller's own schedule in the log
const GeminiMaxOutput = 65535
Published Gemini output ceiling that thinking requests are raised to
const Identity = "You are Icebath Agent, built by " + IdentityAuthor + ". Be direct: match the length of your reply to the weight of the ask. A " +
"one-line question gets a one-line answer, and finished work gets a short report of what changed, what's verified, and what's left, never " +
"a replay of the process. No filler (\"Great question,\" \"I'd be happy to\"), no restating the request back, no re-summarizing what you " +
"already said, no narrating tool calls the user can see. Plain claims over adjectives. When unsure, say so plainly. Agree because it's " +
"right, not because the user said it. Depth is earned: give it when the user asks for detail, teaches, or the stakes demand it, not by " +
"default."
Persona a request that carries no system prompt of its own is sent with where the API wants one
const IdentityAuthor = "Nicholas W. Heyer"
Author icebath's own persona names
Variables ¶
var ( DeepSeekEfforts = []string{"low", "medium", "high", "max"} DeepSeekOverrides = map[string]string{"xhigh": "max"} )
DeepSeek V4 and later efforts, with the level a missing one maps to
var ( GLM52Efforts = []string{"high", "max"} GLM52Overrides = map[string]string{"xhigh": "max"} // Spellings of GLM 5.2 in model ids GLM52Tokens = []string{"glm-5.2", "glm-5-2", "glm-5p2"} )
GLM 5.2 efforts, with the level a missing one maps to
var AzurePrices = map[string]Price{
"gpt-4.1": azure("2.00", "8.00", "0.50", ""),
"gpt-4.1-mini": azure("0.40", "1.60", "0.10", ""),
"gpt-4.1-nano": azure("0.10", "0.40", "0.025", ""),
"gpt-5": azure("1.25", "10.00", "0.125", ""),
"gpt-5-chat": azure("1.25", "10.00", "0.125", ""),
"gpt-5-codex": azure("1.25", "10.00", "0.125", ""),
"gpt-5-mini": azure("0.25", "2.00", "0.025", ""),
"gpt-5-nano": azure("0.05", "0.40", "0.005", ""),
"gpt-5-pro": azure("15.00", "120.00", "", ""),
"gpt-5.1": azure("1.25", "10.00", "0.125", ""),
"gpt-5.1-chat": azure("1.25", "10.00", "0.125", ""),
"gpt-5.1-codex": azure("1.25", "10.00", "0.125", ""),
"gpt-5.1-codex-max": azure("1.25", "10.00", "0.125", ""),
"gpt-5.1-codex-mini": azure("0.25", "2.00", "0.025", ""),
"gpt-5.2": azure("1.75", "14.00", "0.175", ""),
"gpt-5.2-chat": azure("1.75", "14.00", "0.175", ""),
"gpt-5.2-codex": azure("1.75", "14.00", "0.175", ""),
"gpt-5.2-pro": azure("21.00", "168.00", "", ""),
"gpt-5.3-chat": azure("1.75", "14.00", "0.175", ""),
"gpt-5.3-codex": azure("1.75", "14.00", "0.175", ""),
"gpt-5.4": azureLonger(azure("2.50", "15.00", "0.25", ""), azure("5.00", "22.50", "0.50", "")),
"gpt-5.4-mini": azure("0.75", "4.50", "0.075", ""),
"gpt-5.4-nano": azure("0.20", "1.25", "0.02", ""),
"gpt-5.4-pro": azureLonger(azure("30.00", "180.00", "", ""), azure("60.00", "270.00", "", "")),
"gpt-5.5": azureLonger(azure("5.00", "30.00", "0.50", ""), azure("10.00", "45.00", "1.00", "")),
"gpt-5.6-sol": azureLonger(azure("4.00", "20.00", "0.40", "5.00"), azure("8.00", "30.00", "0.80", "10.00")),
"gpt-5.6-terra": azureLonger(azure("2.00", "12.00", "0.20", "2.50"), azure("4.00", "18.00", "0.40", "5.00")),
"gpt-5.6-luna": azureLonger(azure("0.20", "1.20", "0.02", "0.25"), azure("0.40", "1.80", "0.04", "0.50")),
"gpt-6-sol": azureLonger(azure("2.00", "10.00", "0.20", "2.50"), azure("4.00", "15.00", "0.40", "5.00")),
"gpt-6-luna": azureLonger(azure("0.10", "0.50", "0.01", "0.125"), azure("0.20", "0.75", "0.02", "0.25")),
"gpt-6-astra": azureLonger(azure("10.00", "50.00", "1.00", "12.50"), azure("20.00", "75.00", "2.00", "25.00")),
"gpt-6.1-sol": azureLonger(azure("2.00", "10.00", "0.10", "2.50"), azure("4.00", "15.00", "0.20", "5.00")),
"gpt-6.1-terra": azureLonger(azure("1.00", "5.00", "0.05", "1.25"), azure("2.00", "7.50", "0.10", "2.50")),
"gpt-6.2-sol": azureLonger(azure("2.00", "10.00", "0.10", "2.50"), azure("4.00", "15.00", "0.20", "5.00")),
"gpt-6.2-astra": azureLonger(azure("8.00", "40.00", "0.40", "10.00"), azure("16.00", "60.00", "0.80", "20.00")),
}
Prices Microsoft lists for the OpenAI models of a Global standard deployment, by the model's id: the meters "<model> inp Gl", "cd inp Gl" (cached input), "Cd Wr" (a cache write of the default 30 minutes) and "opt Gl", short and long context where the model has both ("ShortCo", "LongCo"), read from the Azure Retail Prices API on Dec 1, 2026
var AzureTierPrices = map[string]map[string]Price{ "priority": { "gpt-4.1": azure("3.50", "14.00", "0.875", ""), "gpt-4.1-mini": azure("0.70", "2.80", "0.175", ""), "gpt-5": azure("2.50", "20.00", "0.25", ""), "gpt-5-mini": azure("0.45", "3.60", "0.045", ""), "gpt-5.1": azure("2.50", "20.00", "0.25", ""), "gpt-5.2": azure("3.50", "28.00", "0.35", ""), "gpt-5.3-codex": azure("3.50", "28.00", "0.35", ""), "gpt-5.4": azure("5.00", "30.00", "0.50", ""), "gpt-5.4-mini": azure("1.50", "9.00", "0.15", ""), "gpt-5.5": azureLonger(azure("12.50", "75.00", "1.25", ""), Price{}), "gpt-5.6-sol": azureLonger(azure("8.00", "40.00", "0.80", "10.00"), azure("16.00", "60.00", "1.60", "20.00")), "gpt-5.6-terra": azureLonger(azure("4.00", "24.00", "0.40", "5.00"), azure("8.00", "36.00", "0.80", "10.00")), "gpt-5.6-luna": azureLonger(azure("0.40", "2.40", "0.04", "0.50"), azure("0.80", "3.60", "0.08", "1.00")), "gpt-6-sol": azureLonger(azure("4.00", "20.00", "0.40", "5.00"), azure("8.00", "30.00", "0.80", "10.00")), }, }
Prices of the requests a tier other than the standard one served on Foundry, by the tier as the answer's service_tier names it and then by model id. Priority processing: the meters with "PP" or "pp" in their names, of a Global standard deployment, read from the Azure Retail Prices API on Dec 1, 2026; every model Microsoft meters it for, since a deployment set to priority serves it to a request that asks for none. Microsoft meters no long context priority for GPT-5.5, so one of its requests past the threshold costs what is not known; GPT-5.4 and GPT-4.1 send a request past 128K tokens on at standard, "charged at the standard tier rate" (learn.microsoft.com/en-us/azure/ foundry/openai/concepts/priority-processing, fetched the same day), which the answer then names
var Efforts = []string{"none", "minimal", "low", "medium", "high", "xhigh", "max"}
Efforts a model can be told to think with, least first: what a setting offers and an OpenAI compatible endpoint takes in reasoning_effort
var ErrNoCount = errors.New("The provider of this route counts no tokens itself.")
The route's provider counts no tokens of its own
var GeminiPrices = map[string]Price{ "gemini-4-carbon": {Input: "4.00", Output: "20.00", CacheRead: "0.20", URL: geminiPriced, Version: "google-pricing-2026-12-01"}, "gemini-4-argon": {Input: "4.00", Output: "20.00", CacheRead: "0.20", URL: geminiPriced, Version: "google-pricing-2026-12-01"}, "gemini-4-neon": {Input: "3.00", Output: "15.00", CacheRead: "0.15", URL: geminiPriced, Version: "google-pricing-2026-12-01"}, "gemini-4-hydrogen": {Input: "1.50", Output: "7.50", CacheRead: "0.075", URL: geminiPriced, Version: "google-pricing-2026-12-01"}, "gemini-3.8-flash": geminiRising("0.75", "3.75", "0.075", "1.50", "7.50", "0.15", "google-pricing-2026-12-01"), "gemini-3.7-flash": {Input: "0.75", Output: "3.75", CacheRead: "0.075", URL: geminiPublished, Version: "google-pricing-2026-09-02"}, "gemini-3.6-flash": geminiRising("0.75", "3.75", "0.075", "1.50", "7.50", "0.15", "google-pricing-2026-12-01"), "gemini-3.5-flash-lite": {Input: "0.30", Output: "2.50", CacheRead: "0.03", URL: geminiPriced, Version: "google-pricing-2026-12-01"}, "gemini-3.5-flash": {Input: "1.50", Output: "9.00", CacheRead: "0.15", URL: geminiPublished2, Version: "google-pricing-2026-07-07"}, "gemini-3.1-flash-lite": {Input: "0.25", Output: "1.50", CacheRead: "0.025", URL: geminiPriced, Version: "google-pricing-2026-12-01"}, "gemini-3-pro-preview": {Input: "2.00", Output: "12.00", CacheRead: "0.20", URL: geminiPublished2, Version: "google-pricing-2026-07-07"}, "gemini-3-flash-preview": {Input: "0.50", Output: "3.00", CacheRead: "0.05", URL: geminiPriced, Version: "google-pricing-2026-12-01"}, "gemini-2.5-flash": {Input: "0.15", Output: "0.60", CacheRead: "0.015", URL: geminiPublished2, Version: "google-pricing-2026-07-07"}, "gemini-2.5-flash-lite": {Input: "0.10", Output: "0.40", CacheRead: "0.01", URL: geminiPriced, Version: "google-pricing-2026-12-01"}, "gemini-2.0-flash": {Input: "0.10", Output: "0.40", CacheRead: "0.01", URL: geminiPublished2, Version: "google-pricing-2026-07-07"}, "gemini-3.1-pro": {Input: "2.00", Output: "12.00", CacheRead: "0.20", Threshold: 200000, Above: &Price{Input: "4.00", Output: "18.00", CacheRead: "0.40"}, URL: geminiPublished2, Version: "google-pricing-2026-07-07"}, "gemini-2.5-pro": {Input: "1.25", Output: "10.00", CacheRead: "0.125", Threshold: 200000, Above: &Price{Input: "2.50", Output: "15.00"}, URL: geminiPublished2, Version: "google-pricing-2026-07-07"}, "gemini-3.1-pro-preview": {Input: "2.00", Output: "12.00", CacheRead: "0.20", Threshold: 200000, Above: &Price{Input: "4.00", Output: "18.00", CacheRead: "0.40"}, URL: geminiPriced, Version: "google-pricing-2026-12-01"}, "gemini-3.1-flash-lite-preview": {Input: "0.25", Output: "1.50", CacheRead: "0.025", URL: geminiPublished2, Version: "google-pricing-2026-07-07"}, }
Prices Google publishes for its Gemini models, on AI Studio and Vertex alike. Standard tier, text, image and video input; the rows of geminiPriced fetched Dec 1, 2026
var GeminiTierPrices = map[string]map[string]Price{ "flex": { "gemini-4-carbon": {Input: "2.00", Output: "10.00", CacheRead: "0.10", URL: geminiPriced, Version: "google-flex-2026-12-01"}, "gemini-4-argon": {Input: "2.00", Output: "10.00", CacheRead: "0.10", URL: geminiPriced, Version: "google-flex-2026-12-01"}, "gemini-4-neon": {Input: "1.50", Output: "7.50", CacheRead: "0.075", URL: geminiPriced, Version: "google-flex-2026-12-01"}, "gemini-4-hydrogen": {Input: "0.75", Output: "3.75", CacheRead: "0.0375", URL: geminiPriced, Version: "google-flex-2026-12-01"}, "gemini-3.8-flash": geminiRising("0.375", "1.875", "0.0375", "0.75", "3.75", "0.075", "google-flex-2026-12-01"), "gemini-3.6-flash": geminiRising("0.375", "1.875", "0.0375", "0.75", "3.75", "0.075", "google-flex-2026-12-01"), "gemini-3.5-flash-lite": {Input: "0.15", Output: "1.25", CacheRead: "0.02", URL: geminiPriced, Version: "google-flex-2026-12-01"}, "gemini-3.1-flash-lite": {Input: "0.125", Output: "0.75", CacheRead: "0.0125", URL: geminiPriced, Version: "google-flex-2026-12-01"}, "gemini-3.1-pro-preview": {Input: "1.00", Output: "6.00", CacheRead: "0.20", Threshold: 200000, Above: &Price{Input: "2.00", Output: "9.00", CacheRead: "0.40"}, URL: geminiPriced, Version: "google-flex-2026-12-01"}, "gemini-3-flash-preview": {Input: "0.25", Output: "1.50", CacheRead: "0.05", URL: geminiPriced, Version: "google-flex-2026-12-01"}, "gemini-2.5-flash-lite": {Input: "0.05", Output: "0.20", CacheRead: "0.01", URL: geminiPriced, Version: "google-flex-2026-12-01"}, }, "priority": { "gemini-4-carbon": {Input: "7.20", Output: "36.00", CacheRead: "0.36", URL: geminiPriced, Version: "google-priority-2026-12-01"}, "gemini-4-argon": {Input: "7.20", Output: "36.00", CacheRead: "0.36", URL: geminiPriced, Version: "google-priority-2026-12-01"}, "gemini-4-neon": {Input: "5.40", Output: "27.00", CacheRead: "0.27", URL: geminiPriced, Version: "google-priority-2026-12-01"}, "gemini-4-hydrogen": {Input: "2.70", Output: "13.50", CacheRead: "0.135", URL: geminiPriced, Version: "google-priority-2026-12-01"}, "gemini-3.8-flash": geminiRising("1.35", "6.75", "0.135", "2.70", "13.50", "0.27", "google-priority-2026-12-01"), "gemini-3.6-flash": geminiRising("1.35", "6.75", "0.135", "2.70", "13.50", "0.27", "google-priority-2026-12-01"), "gemini-3.5-flash-lite": {Input: "0.54", Output: "4.50", CacheRead: "0.05", URL: geminiPriced, Version: "google-priority-2026-12-01"}, "gemini-3.1-flash-lite": {Input: "0.45", Output: "2.70", CacheRead: "0.045", URL: geminiPriced, Version: "google-priority-2026-12-01"}, "gemini-3.1-pro-preview": {Input: "3.60", Output: "21.60", CacheRead: "0.36", Threshold: 200000, Above: &Price{Input: "7.20", Output: "32.40", CacheRead: "0.72"}, URL: geminiPriced, Version: "google-priority-2026-12-01"}, "gemini-3-flash-preview": {Input: "0.90", Output: "5.40", CacheRead: "0.09", URL: geminiPriced, Version: "google-priority-2026-12-01"}, "gemini-2.5-flash-lite": {Input: "0.18", Output: "0.72", CacheRead: "0.018", URL: geminiPriced, Version: "google-priority-2026-12-01"}, }, }
Prices of the Gemini API's flex and priority tiers, by the tier as the answer names it and then by model id: the Flex and Priority tabs of geminiPriced, fetched Dec 1, 2026, text, image and video input; where the page gives a Flex model's context caching as "Same as Standard", the standard price. Gemini 3 Pro Image and Gemini 2.5 Flash Image take the tiers but bill by image, so a request of theirs at a tier costs what the page does not give per token, not known here
var Ladder = []string{"none", "minimal", "low", "medium", "high", "xhigh", "max", "ultra"}
Efforts from least to most, as every wire names them
var Reasons = map[string]ErrorKind{ "auth": ErrAuth, "auth_permanent": ErrAuth, "billing": ErrQuota, "rate_limit": ErrRateLimit, "upstream_rate_limit": ErrRateLimit, "upstream_blocked": ErrServer, "overloaded": ErrServer, "server_error": ErrServer, "timeout": ErrNetwork, "ssl_cert_verification": ErrNetwork, "context_overflow": ErrContextOverflow, "payload_too_large": ErrContextOverflow, "image_too_large": ErrContextOverflow, "long_context_tier": ErrContextOverflow, "image_corrupt": ErrInvalidRequest, "model_not_found": ErrModelNotFound, "model_entitlement": ErrModelNotFound, "provider_policy_blocked": ErrContentFilter, "data_policy_denied": ErrContentFilter, "content_policy_blocked": ErrContentFilter, "incomplete_response": ErrEmptyResponse, "format_error": ErrInvalidRequest, "role_alternation": ErrInvalidRequest, "invalid_encrypted_content": ErrInvalidRequest, "multimodal_tool_content_unsupported": ErrInvalidRequest, "reasoning_mandatory": ErrInvalidRequest, "thinking_signature": ErrInvalidRequest, "oauth_long_context_beta_forbidden": ErrInvalidRequest, "llama_cpp_grammar_pattern": ErrInvalidRequest, "cancelled": ErrUnknown, "unknown": ErrUnknown, }
Reasons a plugin may classify a failed request with, and the kind of failure each counts as
Functions ¶
func AccountTitle ¶
func AccountTitle(entry *providerv1.Provider, name string) string
Name the account of a listed provider with the name is shown by, its name when the provider lists no such account
func AffinityOf ¶
Key the requests of the context stick by, empty where the work they are made for names none
func AskedTier ¶
Tier the request fields ask for, by its name, in every shape TierFields writes: priority for the faster one (Priority Processing, fast mode, a fast deployment), flex, ultrafast; empty for none
func Attribution ¶
Attribution headers aggregators show the requests of icebath under
func AzureShare ¶
Share of the Global standard prices a deployment of the type bills at: every meter of a Data Zone deployment in the United States is 1.1 times its Global one; in the European Union so are those of GPT-4.1 and GPT-5, and those of GPT-6 are 1.2 times (the Azure Retail Prices API, the rows of eastus2 and westeurope, Dec 1, 2026). Empty for Global standard
func Bar ¶
Bracketed bar whose filled cells show the share, never empty above nothing nor full below all of it
func BaseHostMatches ¶
func BoundedTier ¶
Whether the tier asks for the fast one for a while rather than with every request, auto or cold
func Carry ¶
Values a session keeps over its profile's settings, by key, with the change carried over as the settings take it: the provider's own keys dropped or moved with it, its account cleared or renamed, and every value that picks a provider, a model or an account cleared or carried as the settings' are. A copy, and whether anything changed
func ClampEffort ¶
Nearest weaker effort of those supported, the override of a missing one when supported, the request as it is when supported or off the ladder; the weakest supported when none is weaker
func ClaudeFamily ¶
Family and version of a Claude model id
func ClaudeSamplingForbidden ¶
Whether a Claude model refuses sampling settings, as those after 4.5 do but for Opus and Sonnet 4.6
func ClaudeThinking ¶
Fields of an Anthropic Messages request that ask for the thinking the ask wants of a Claude or Kimi model: adaptive thinking at an effort, a manual budget with the temperature and output room it needs, thinking off where the model takes it, nothing when it asks nothing
func Clock ¶
Moment a limit lifts or a sign-in ends as a person reads it: the time alone today, else the day and the time
func CodexEfforts ¶
Effort vocabulary of an OpenAI or Codex Responses model generation
func Controlled ¶
Whether an added header of the name is left out: one icebath controls on every request, or one carrying a credential when the request has one of its own
func DashScopeThinking ¶
Field asking DashScope's compatible mode to keep the reasoning of the turns replayed to the model: preserve_thinking for the Qwen and Kimi models that take it, clear_thinking off for GLM 5
func EffortOptions ¶
Choices of a setting of the reasoning effort: the one given for no effort, then every effort
func FastDeployment ¶
Whether the fields send the request to the fast deployment of a Claude model, as Microsoft Foundry serves fast mode
func FastFields ¶
Request fields that ask for the tier on the route, nil when the model or the provider that bills for it does not offer it: only the first party endpoint of a model's maker may be sent them
func GeminiBase ¶
Native base of a Gemini address: the OpenAI suffix taken off, a Vertex OpenAI endpoint as its publishers/google path, an express base completed to it, the API version added when missing; AI Studio's v1beta for none
func GeminiSamplingDeprecated ¶
Whether a Gemini model ignores sampling settings, as 3.6 and later do
func GeminiSnake ¶
Gemini thinking config in the snake case the OpenAI compatible surfaces take, nil when it says nothing
func GeminiThinking ¶
Gemini thinkingConfig for an ask, nil for another model or no ask
func GeminiVersion ¶
Major and minor version of a Gemini model id, zero for an unversioned or other model
func LadderOptions ¶
Choices of a setting that names an effort of any level of the ladder, ultra among them, for a model whose provider takes it: thinking turned off, then each level from the least
func LimitHeader ¶
Whether a header of a provider's answer is one vendors state their rate limits or a wait in, which a client of the answer may read
func Lines ¶
Headers of a variable that holds them, one Name: Value a line, as ANTHROPIC_CUSTOM_HEADERS writes them: each line split at its first colon, both sides trimmed, blank lines skipped. An error naming the line by its place and the variable, never its value, for a line with no colon, no name, or a character a header can't carry
func MandatoryThinking ¶
Whether the model is a Claude model that always thinks, which no request can switch off
func NativeGemini ¶
Whether the address is Google's own Gemini API, AI Studio's or Vertex AI express mode, rather than an OpenAI compatible surface of it
func NestedReasoning ¶
Nested reasoning object of a route without a declared shape: nothing unasked, disabled when off, else the effort or medium
func OfficialCodex ¶
Whether the address is OpenAI's own Codex backend rather than a proxy of it
func Overridden ¶
Effort the per-model overrides give the model, an entry of the table named by any spelling of its id, as ParseEffort reads it; false when none names it with an effort that parses. Alpha's matching first: the spellings of the id in their order, then the keys that hold a slash in the order the settings write them, each by the spellings of the name after its last slash and of what follows its first; a value that does not parse gives way to the next match. Then the same again with case ignored and a date stamp after either id dropped
func OverriddenBy ¶
Entry of the per-model overrides that gives the model its effort, as Overridden finds it, with the effort; false when none does
func ParseEffort ¶
Effort a value of the settings names: none for thinking turned off (none, false, disabled, or an entry {enabled: false}), a level of the ladder in lower case, or the effort of an entry {enabled: true, effort: x} as written, which passes a tier a provider names its own way; false for nothing, true, an empty entry or a word that is no level. Alpha's rule
func PercentUsed ¶
Share used as a whole percent rounded down, a sliver reading as under one percent
func Queried ¶
The provider's Query parameters added to an address, those the address has kept, the provider's winning over one of the same name; the address as it is when there are none or it does not read
func QueryOf ¶
Query parameters of a provider's settings, none while one of them has no name, which refuses its routes in words
func Refill ¶
Wait until the windows an answer states let a request through again: the latest reset of the windows it has spent, else the earliest reset of those it states; false when it states no reset of a window
func RepairPrefix ¶
Model id with the vendor prefix it dropped put back, when exactly one id of the catalogue ends in it
func ResetIn ¶
Time until the reset a vendor wrote, in any of the forms vendors write it: an RFC 3339 time (Anthropic), a duration such as 6m0s or 20ms (OpenAI), milliseconds or seconds since the epoch (OpenRouter's milliseconds), a count of seconds (Azure), or an HTTP date; never below zero. False for an empty value or one of no such form
func ResetsIn ¶
When a window starts over, as resets in a length of time in words; resets soon once that is under a minute
func ResponsesEfforts ¶
Effort vocabulary of a Responses route: the model generation's, except GPT-6 Astra off OpenAI's own API and the Codex backend, which takes the legacy one
func RetryWait ¶
Wait before the next try of a refused request, as its headers say: the wait it asks for, else the refill of the windows it states; 0 when they say nothing
func SlowFields ¶
Request fields that ask for the slower, cheaper tier on the route, nil where the vendor offers none for the model or the tree does not know its value for it: OpenAI's own API, service_tier flex, for its GPT and o models but those it names as having none
func StaticTier ¶
Whether the tier is one a single request asks for: priority, ultrafast or flex
func StripOwn ¶
Model id without a provider prefix, slashed or coloned, that names one of the names given
func ThinkingToggle ¶
func ThinkingToggle(a Ask, efforts []string, overrides map[string]string, always bool) (extra, top map[string]any)
Moonshot or DeepSeek style thinking toggle in the body and the effort at its top: thinking disabled when turned off, the effort clamped onto the vocabulary when one is asked (with thinking enabled too when always is set), else thinking enabled
func TierFields ¶
Request fields that ask for the tier on the route, the slower one included, nil where the model there has no such tier: the rows of the vendors that sell a model's tiers on their own platforms (Google's Gemini API, Amazon Bedrock, Microsoft Foundry, Claude on Vertex AI), then those of the first party APIs of OpenAI, Anthropic and xAI
func Unprefixed ¶
Model id without a prefix naming the kind or one of its aliases
func Version ¶
func Version() string
Version of icebath as a person reads it, such as 1.4.2, or 1.4.3-dev.abcdef1 for a build of a commit no tag names
func Wait ¶
Wait an answer asks for before the next try, as its vendor writes it: retry-after-ms, then Retry-After, then the X-RateLimit-Reset OpenRouter puts on the error of a limit hit; false when it asks for none. The windows an answer states every time are not read here, as they say nothing of whether waiting helps: Anthropic's refusal at the spend cap states them and lifts only next month
func WithAffinity ¶
Context of work whose every request sticks by one key at a router that keeps a conversation on one backend, such as a task of the board: its write-up, the turns of its worker and the calls of its judge are then all kept on one. It is never the scope of the provider's caches, which stays each session's own
func WithVendor ¶
Model id with the vendor an aggregator names it under in front, as it is when it names one or none can be told
func WithoutTier ¶
The request fields with every field that names a tier taken out, so they ask for the usual one
func WrittenAddress ¶
Why an address as a person wrote it can't be the address of a server, judged by what it reads as, each ${NAME} read as the variable it names in the profile's environment, and named as it is written; a variable it names that is not set is said to be, never the value of one that is
Types ¶
type APIError ¶
type APIError struct {
Provider string
Model string
StatusCode int
Message string
RetryAfter time.Duration
Kind ErrorKind
Err error
// Error object of the provider's reply, with the type and code it names; nil and empty when it had none
Body map[string]any
Type string
Code string
// Reason a plugin classified the failure with, empty when none did, and what it decided: whether the request is tried again, the context
// compressed, the account rotated past and the session moved to its fallback, each nil to leave it to the kind; with what it adds of the
// failure
Reason string
Retry, Compress, Rotate, Fallback *bool
Context map[string]any
// The message is icebath's own account of what happened and what to do, such as a request it gave up waiting on, rather than the
// provider's words
Own bool
}
type APIMode ¶
type APIMode string
const ( ModeChatCompletions APIMode = "chat_completions" ModeAnthropicMessages APIMode = "anthropic_messages" ModeCodexResponses APIMode = "codex_responses" ModeGeminiNative APIMode = "gemini_native" ModeBedrockConverse APIMode = "bedrock_converse" // A program of this computer that answers over the Agent Client Protocol on its standard streams, such as the Copilot CLI ModeACP APIMode = "acp" // The Codex program running each turn of its own as an app server on its standard streams, the provider's Responses API behind it ModeCodexAppServer APIMode = "codex_app_server" )
func ModeForURL ¶
Request format an endpoint's address says it takes: its host's own, the Responses API of OpenAI's, Anthropic messages for an anthropic path or Kimi's coding endpoint; empty when the address says nothing
type AccountUsage ¶
type AccountUsage struct {
// Kind of the provider asked
Provider string
// Where the reading came from, such as usage_api
Source string
Fetched time.Time
Title string
Plan string
Windows []UsageWindow
// Lines of their own after the windows, such as a credit balance
Details []string
Unavailable string
// Stable non secret id of the account, empty when not known
Identity string
// Windows shown as bars under the plan's name, as for a plan sold by its usage windows
Bars bool
}
What a provider says of the limits of an account
func NewAccountUsage ¶
func NewAccountUsage(provider, source string, windows []UsageWindow, details []string) *AccountUsage
Reading of an account fetched now, titled as account limits
func UsageOf ¶
func UsageOf(message *providerv1.AccountUsage) *AccountUsage
Reading the provider service sent
func (*AccountUsage) Lines ¶
func (u *AccountUsage) Lines(markdown bool) []string
Lines of the reading: bars under the plan's name for a plan sold by its windows, else each window's share left and when it resets
func (*AccountUsage) Message ¶
func (u *AccountUsage) Message() *providerv1.AccountUsage
Reading as the provider service sends it
type Action ¶
type Action struct {
// Name the answer is remembered under, for the session or always; the description when empty
Key string
// What it is, as the person reads it
Description string
// What would run or change, as shown to the person
Target string
// Changes to files the action makes, which a surface that draws changes shows as such
Edits []Edit
}
An action a provider asks the person's leave for
type Added ¶
type Added struct {
Name, Value string
// Where it was read: a variable, or a setting of the provider by its title
From string
// The administrator set it, so no setting of the person's replaces it
Managed bool
}
A header or a query parameter a provider's requests carry beyond its kind's own, with where it was read
type Additions ¶
What a provider adds to every request beyond its kind's own: headers and query parameters, what was left out of them, and the variables set for the kind's own hosts that its address is not one of, each said in a sentence
type Ask ¶
type Ask struct {
// Whether the request asks anything
Set bool
// Thinking turned off
Off bool
// Effort asked for in lower case, empty for the model's own
Effort string
}
What a request asks of the model's reasoning: nothing, thinking off, or an effort
type Billing ¶
type Billing struct {
Label string
URL string
Hosts []string
// Page of the usage of a subscription, for accounts signed in with one
Plan string
}
Where a person adds credit for a vendor: its name, its billing page, and the hosts of its API when they differ from the kind's
type Bucket ¶
type Bucket struct {
// What the window counts, as a person reads it
Name string
Limit int
Remaining int
// Seconds until the window resets, as the provider said when it answered; 0 when it said nothing of it
Reset float64
Captured time.Time
}
One window of a provider's rate limits, such as its requests or its input tokens
type Call ¶
type Call struct {
Context context.Context
Route Route
// Model id the request sends
Model string
// Settings of the provider in the profile, and of the session the request is for
Settings config.View
Config *config.Config
// Session the request is for, empty for none, and the scope of the provider's caches it shares: the session, a cron run folded into its job
SessionID string
Scope string
// Key a router that keeps a conversation on one backend is told for the request: the one the work it is made for names (WithAffinity),
// else the scope
Affinity string
// Reasoning the request asks for, the kind's default when it asks none
Ask Ask
// What the provider's listings say of the model's reasoning
Thinking Thinking
// The request carries pictures
Images bool
// First request of a turn the person started
UserTurn bool
// Where the session comes from, such as cli, tui, cron or subagent; empty when not known
Source string
// Whether an Ollama server at the route's address reports thinking for the model; false when it reports none or is no Ollama
OllamaThinks func() bool
// Context window to ask an Ollama server for, 0 for the server's own
Window func() int
// Kind of provider registered under the name
Kind func(name string) (Spec, bool)
}
One request as the hooks of its kind see it, made by the wire sending it
type Change ¶
type Change struct {
Provider string
// Account of the provider the change is of, empty for the provider itself
Account string
// New name, empty when the provider or account was removed
To string
}
A provider of the profile or one of its accounts removed or renamed
type Counter ¶
Client whose provider counts the tokens of a request itself, as the request would be sent, such as Anthropic's count_tokens or OpenAI's input_tokens; ErrNoCount when the route's provider has no such counting
type Cut ¶
type Cut struct {
// The stream broke or closed early, rather than the model reaching its output limit
Stream bool
// The server closed the stream without an error and without saying the reply ended
CleanEOF bool
// Tools whose calls were still being written when the stream ended
Dropped []string
// The reply turned into a runaway loop of repeated text and its stream was stopped
Runaway bool
// The stream broke on a context overflow, so going on from the part that came cannot fit either
Overflow bool
}
Reply cut short, its finish reason "length": the stream broke or closed after part of it came, or it ran into a loop
type Edit ¶
One change to a file an action makes: what the file holds before, nil for one that is not there, and what it would hold, nil for one that goes
type Effortful ¶
type Effortful interface {
EffortKeys() (effort, overrides string)
}
Registrant that owns the settings of the effort a profile's model thinks with, the agent: the key of the profile's one effort and of the table of efforts by model, which a feature with no effort of its own follows, such as a helper task
type ErrorKind ¶
type ErrorKind string
const ( ErrAuth ErrorKind = "auth" ErrRateLimit ErrorKind = "rate_limit" ErrContextOverflow ErrorKind = "context_overflow" ErrInvalidRequest ErrorKind = "invalid_request" ErrModelNotFound ErrorKind = "model_not_found" ErrServer ErrorKind = "server" ErrNetwork ErrorKind = "network" ErrContentFilter ErrorKind = "content_filter" ErrEmptyResponse ErrorKind = "empty_response" // The account is out of credit or quota ErrQuota ErrorKind = "quota" ErrUnknown ErrorKind = "unknown" )
type EventKind ¶
type EventKind string
const ( EventTextDelta EventKind = "text_delta" EventReasoningDelta EventKind = "reasoning_delta" // Line the person is shown about the request, such as a stalled stream being dropped and asked again EventStatus EventKind = "status" // Line shown in place while the request waits on the provider, replaced by the next one and cleared by an empty one EventWait EventKind = "wait" // What the request is doing, for the session's liveness: never shown in the transcript EventActivity EventKind = "activity" // The model began a tool call of the name, its arguments still streaming EventToolStart EventKind = "tool_start" // A step the provider took itself, such as a command an agent program ran or what it gave back: stored in the session as it comes, // from Message, and never run again EventStep EventKind = "step" // What a step the provider takes does now, such as the last line a command printed: Text, of the call Call and the tool Tool EventProgress EventKind = "progress" )
type Follower ¶
type Follower interface {
Follow(ctx context.Context, cfg *config.Config, change Change) ([]string, error)
}
What keeps names of providers or of their accounts beyond the settings that declare what they pick, such as the sessions held to an account: told of every change, it clears what named a thing removed and carries a renamed one over, saying what it changed, a phrase each such as "2 sessions"
type HeaderSource ¶
type HeaderSource struct {
// Header it is sent as; empty for a variable that holds headers, one Name: Value a line, as ANTHROPIC_CUSTOM_HEADERS does
Header string
// Variable it is read from, and the provider's setting read before it, empty for none
Variable, Setting string
// Hosts a value of the variable is sent to, such as api.openai.com, every host of the provider when empty; a value of the provider's own
// setting goes wherever the provider sends, as the person said so
Hosts []string
}
A header a kind's providers send from a variable or a setting of the provider, such as OpenAI-Project from OPENAI_PROJECT_ID
type IcebathOverlay ¶
type Instance ¶
type Instance struct {
// Name in the profile
ID string
// Kind of the provider, with the title, base URL and default model the provider sets
Spec Spec
// Whether a plugin registers its kind
Known bool
// Models picked for it, every one it lists when empty
Models []string
// Its address and default model as the person wrote them, every ${NAME} kept, each beside what Spec reads it as for use; and the models
// picked for it as written, item by item with Models: what is shown of it and what a change of them starts from. Its title is only
// ever shown, so Spec holds it as written
Address, Model Written
Listed []string
// Account in use, empty while it has none: the one the profile holds it to, else the first the way it chooses would take. The name of
// one of its accounts, which what acts on it names it by
Account string
// Its accounts in the order they are tried
Accounts []string
// Held to the one account named in Account
Pinned bool
// Takes turns between its accounts marked for rotation; neither this nor Pinned takes every account in order
Rotate bool
// The address of its server is the person's to give, as its kind says before any address is given: Spec holds the address given, so
// it no longer tells
Own bool
// Settings of the provider, whose writes never make it again once it is removed
Settings config.View
}
Provider a profile has, kept under providers and its name there: a kind of provider with a title, base URL, default model, models and accounts of its own. A profile can have any number of the same kind
func (Instance) AccountFields ¶
Fields of one account of the provider, whose writes never make the account again once it is removed
func (Instance) AccountTitle ¶
Name an account of the provider is shown by: its title as written, else its name
func (Instance) Launch ¶
The program a provider of a kind that runs one starts, and the arguments it starts it with. A variable of the kind counts first, as the lookup has it, the arguments one split the way a shell splits words. Then what the provider's own settings say, then the kind itself. A program named by a path that starts at the home folder is taken from there
type Keeper ¶
type Keeper struct {
Sent func()
// Forgets the limit the route's account ran into, once the provider says it lifted, such as after a banked reset was spent
Lifted func()
// Route to send the refused request again with, its credential renewed or another account's; false when none would do better, which
// leaves the failure to the caller's own retries and fallbacks
Recover func(ctx context.Context, failure *APIError) (Route, bool)
}
What keeps the credential of a route: told of each request sent with it, and asked for the route to send a refused one again with
type Kept ¶
A provider of the profile as the settings file keeps it, read without looking through any section, as sections made of the profile's providers are: its key, the kind it is of with that kind's spec, the name it is shown by, and the model used when no other is picked, the one written for it, else the first model it offers, else the one its kind starts with
type Live ¶
type Live interface {
Registrant
Live() []Spec
}
Registrant whose kinds come and go as it runs, such as those the extensions of the profiles register: its Specs has none, and the kinds it offers are read again on every look after every fixed one's, as no index keeps them; one with a name or an alias a fixed kind has is left out. Reading them reads no setting and starts nothing
type Price ¶
type Price struct {
Input string
Output string
CacheRead string
CacheWrite string
// Paid once for each request
Request string
// Tokens of prompt past which every token of the request takes the Above prices, 0 for none
Threshold int
Above *Price
// Where the prices are published, and which edition of them these are
URL string
Version string
// The last moment these prices hold and the prices after it, for a vendor that published a change ahead; zero and nil for none
Until time.Time
Then *Price
}
Price of a model in USD for a million tokens, as decimal text; an empty field is not known
type Primary ¶
type Primary interface {
Primary() (provider, model string)
}
Registrant that owns the settings new chats take their provider and model from, the agent: the keys of the two, which a feature that sets the model of new chats writes, such as one that makes a model it downloaded to this computer the one in use
type Question ¶
type Question struct {
// Stable within the set, the key of its answer
ID string
// Short heading of the question, and the question itself
Header, Text string
// Choices to pick from, none for an open question that takes typed text
Choices []string
// Any number of the choices may be picked
Many bool
// The answer is a secret, such as a password: masked as it is typed and never shown again
Secret bool
}
A question a provider asks the person
type RateLimits ¶
type RateLimits struct {
// Windows the answer stated, in the order they are shown
Buckets []Bucket
Captured time.Time
// Provider that answered, by its name in the profile
Provider string
}
Rate limits a provider's answer stated in its headers, whichever vendor's they are
func ParseRateLimits ¶
Rate limits of an answer's headers, every vendor's windows read the one way, nil when it states none
type Registrant ¶
type Registrant interface {
Specs() []Spec
}
type Registry ¶
type Registry struct {
// contains filtered or unexported fields
}
func (*Registry) Add ¶
Adds a provider of the kind to the profile with the address of its server when one is given, written whole in one write: under the name given, else under the key its title makes, else under the kind's name, numbered when one has it already
func (*Registry) Billing ¶
Where the account of a route adds credit: its kind's vendor, else the vendor any kind names for the route's host; else the provider's name alone, without a page
func (*Registry) Connect ¶
func (r *Registry) Connect(cfg *config.Config, id, name, title, identity string, fields map[string]any) (string, error)
Keeps a credential in an account of the provider, written whole with the provider in one write so that no account stands without the credential that makes it one. The account named takes it in place of the credential it kept and of the limits it ran into, its title, place and rotation kept, and the title given when one is. With no account named, an account is made with it after the others, named as the person named it, else after who signed in, else for the way it signs in: API key for a key, the program whose sign-in it uses; its key made from that name by the one rule. It is the one in use when the provider had none. A variable or program the credential comes from is one the provider takes from again. The account's name
func (*Registry) CredentialEnv ¶
Variables every kind reads its credentials, its endpoint and the headers of its requests from, such as ANTHROPIC_CUSTOM_HEADERS, which can carry a gateway's key: icebath holds them for its own requests and never hands them a command
func (*Registry) EffortKeys ¶
Keys of the settings of the profile's effort and of its efforts by model, as the registrant owning them declares them, those of the registries nested in this one included; false when none does
func (*Registry) EffortOf ¶
Effort a model of the profile thinks with where nothing of its own names one: the per-model override, else the profile's one effort; false when neither names one
func (*Registry) First ¶
First provider of the profile whose kind is the one a plugin gives by the name, in the order Instances gives them, the providers of other kinds left unread; false when the profile has none
func (*Registry) Instance ¶
Provider of the profile with the name, or the first of the kind with it as a name or alias
func (*Registry) Instances ¶
Every provider of the profile in use, by title. Their settings are read in one reading of the profile, the sections of its settings made once for all of them, and each keeps the settings it was given to read and write through afterwards
func (*Registry) KeepKey ¶
Keeps the key an account read from a variable in the account itself, which stops reading the variable, in one write; the limits it ran into stay, as the key is the same
func (*Registry) Kept ¶
Every provider of the profile as the settings file keeps it, by the name it is shown by
func (*Registry) LaunchEnv ¶
Variables that name the program a kind that runs one starts and its arguments, which no generic writer may set, as they decide what runs
func (*Registry) Live ¶
Kinds the live registrants offer now, those of the registries nested in this one among them: of two of one name the first, one with a name or an alias a fixed kind has left out
func (*Registry) MoveAccount ¶
Moves an account of the provider to the place given from 0, the first tried, clamped to the places there are, every account's place written in one write; the place it took
func (*Registry) Options ¶
Values a setting naming a provider of the profile of cfg may take, read each time they are shown
func (*Registry) Overridden ¶
Effort the per-model overrides of the profile of the settings give the model, false when they give none
func (*Registry) Plugins ¶
Count of the plugins that give kinds, which moves only as one is registered, so what is made of every kind is made again then
func (*Registry) Primary ¶
Keys of the settings new chats take their provider and model from, as the registrant owning them declares them, those of registries nested in this one included; false when none does
func (*Registry) Register ¶
func (r *Registry) Register(registrant Registrant)
func (*Registry) Rekey ¶
Keeps a provider under the key a person gave in place of its own, its title as it is, in place as Rename keeps it. Every setting and everything else that named the provider carries over
func (*Registry) RekeyAccount ¶
Keeps an account of the provider under the key a person gave in place of its own, its title as it is, in place as RenameAccount keeps it. Every setting and everything else that named the account carries over
func (*Registry) Remove ¶
Removes a provider from the profile with its accounts, then clears every setting and everything else that named it
func (*Registry) RemoveAccount ¶
func (r *Registry) RemoveAccount(ctx context.Context, cfg *config.Config, id, name string) (Removed, error)
Removes an account of the provider, with everything it keeps, in one write with the provider's choice of account: the one in use from then on is the first left whose credential still works. The variable it read its key from is cleared from the profile's .env too, unless another account reads it; then every setting and everything else that named the account is cleared
func (*Registry) Rename ¶
func (r *Registry) Rename(ctx context.Context, cfg *config.Config, id, title string) (string, error)
Gives a provider the name a person typed, by the same rule: the name shown changes and the key the provider is kept under follows it, the kind's name for no name. The provider is renamed in place, keeping its place, its comments and every reference in the settings file, and its title is written alone. Every setting and everything else that named the provider carries over. Its key
func (*Registry) RenameAccount ¶
func (r *Registry) RenameAccount(ctx context.Context, cfg *config.Config, id, name, title string) (string, error)
Gives an account the name a person typed, the one rule of every rename: the name shown changes, and the key the account is kept under follows it to a free key made from the name. The account is renamed in place, keeping its place, its comments and every reference in the settings file; the provider's choice of account follows it when it named it, and its title is written alone. Every setting and everything else that named the account by its key carries over to the new one. The key it is kept under
func (*Registry) SetAddress ¶
Address of the provider's server, which must start http:// or https:// once it is read and is kept as written without a slash at its end; empty puts the kind's own back, refused for a kind that has none
func (*Registry) SetOffered ¶
Offers the provider's models in the model list, or leaves them out: the provider's place in the providers the model list hides, by its name in the profile, changed from the list as written so that every other item stays as the person wrote it
func (*Registry) SetOutside ¶
Turns the use of a credential the provider finds outside its accounts off or on: a variable holding a key, or the sign-in another program keeps on this computer, by its name, which an item of the list answers to as it is written or as it reads. The one control of that choice, kept in the provider's list of what it leaves out, which nothing else writes, changed from the list as written so that every other item stays as the person wrote it; whether it changed
func (*Registry) SetTurns ¶
Turns an account's taking turns on or off, in one write with the provider's choice of account: turning it on makes the provider take turns between the accounts that do, and turning the last one off makes it try every account in order again
func (*Registry) Spec ¶
Spec of the kind with the name, or with it as an alias, as the plugin that gives it gives it now
func (*Registry) Specs ¶
Every kind: the fixed ones in the order their plugins were registered, then those the live registrants offer now
func (*Registry) Untiered ¶
Where the speed a place asks for (its Speed setting, by its word) has no tier on the route its requests take, which then go at the usual tier: the provider and the model the place names, else the main ones of the profile, as Primary names their settings. The model and the provider's title for what is said of it; false for normal speed, a speed that asks for no tier with every request, or a route that can't be told from the settings
type Removed ¶
What a removal did besides removing the thing: the variables it cleared from the profile's .env, and what named the thing, a phrase each
type Request ¶
type Request struct {
Model string
Messages []*sessionsv1.Message
Tools []map[string]any
MaxTokens int
Reasoning Reasoning
SessionID string
// Scope of the provider's caches the request shares, the session's own when empty: the first session of the chain of summaries the
// session goes on from, so a summary that continues the conversation in a new session keeps the cache of the system prompt and the
// tools; a helper call made for a session carries the session's
CacheScope string
// Sampling temperature, the model's own when nil
Temperature *float64
// Shape the reply must take, free text when nil
Format *Format
// Fields put at the top of the request body as they are, over the ones the request sets, such as provider options a setting names
Extra map[string]any
// Start of the system prompt that stays the same from session to session, which a provider caching prompts in blocks caches on its
// own; empty when nothing is known to stay
StaticSystemPrefix string
// Backend the web_search tool of the request searches with, such as openai-native or xai, which a provider's own server side search
// stands in for; empty when the request has no web_search tool
WebSearch string
// Settings of the session the request is for, those of the profile in use when nil
Config *config.Config
// When the run the request is part of must end, which caps how long a silent stream is waited on; zero for no limit
Deadline time.Time
// First request of a turn the person started, rather than one the agent makes after tool calls
UserTurn bool
// Where the session comes from, such as cli, tui, cron, subagent or oneshot, which paces how long a prompt cache is worth keeping;
// empty when not known
Source string
// Handed each failure of the request as the wire classified it, before the wire acts on it, so a plugin's classification may change
// it; nil for none
Classify func(failure *APIError)
// What the session of the request does for a provider that runs a turn of its own, such as an agent program that runs commands and
// changes files itself; nil for a request of no session's turn
Session *Session
}
type Response ¶
type Response struct {
Message *sessionsv1.Message
FinishReason string
// Tokens the request took, nil when the provider said nothing of them
Usage *Usage
// Headers of the provider's answer, such as the rate limits it states
Header http.Header
// How the reply was cut before the model ended it, nil for a reply the model ended or stopped at its own length limit
Cut *Cut
// Model the provider says served the request, which a router may pick other than the one asked for; empty where the answer names
// none
Model string
// Faster tier the request asked for that the provider refused for the model on this account, such as Anthropic's fast mode with no
// capacity, the request then served at the usual tier; empty for none
Refused string
}
type Retry ¶
type Retry struct {
Wait time.Duration
Retries int
Reason string
Policy string
// The schedule is the kind's own, rather than the caller's
Own bool
}
How a request that failed is tried again: the wait before the next try, the retries it may take in all, why it waits as the person reads it, and the name of the schedule for the log
type Route ¶
type Route struct {
// Provider of the profile, by its name there
Provider string
// Kind of the provider, by the name of its spec
Spec string
Model string
BaseURL string
// BaseURL as the settings it was read from write it, every ${NAME} kept: what the route's address is shown, logged and kept as
Address Written
APIKey string
Headers map[string]string
Mode APIMode
Auth AuthKind
Local bool
// Account of the provider whose credential the route carries, empty for one from the environment or another program
Account string
// Signs a request whose provider takes a signature rather than a key, such as AWS SigV4; nil for every other route
Sign func(request *http.Request, body []byte) error
// Region the route's requests are signed for and served in, such as an AWS region; empty when its provider has none
Region string
// Address of another service of the route's provider in a region, by the service's name, resolved as the route's own address was with
// the person's choices, such as the control plane of Bedrock under FIPS; an error in words where none may be used. Nil for a provider
// of one address
Endpoint func(service, region string) (string, error)
// Keeps the route's credential as requests go out with it; nil when nothing keeps it
Keeper *Keeper
// Program a route that runs one starts and the arguments it starts it with, for a route that names them itself, such as one a
// subagent is given; one that names none runs what its provider says
Command string
Args []string
}
type Session ¶
type Session struct {
// Folder the session works in
Folder string
// Whether the command may run, as the session's rules and approvals decide before the agent's own commands: whether the person was
// asked, and nil when it may run, else the refusal as the model reads it
Command func(ctx context.Context, command string) (bool, error)
// Whether the action may go ahead, asked through the session's approvals unless an answer of theirs or the session's mode settles it:
// nil when it may, else the refusal as the model reads it
Approve func(ctx context.Context, action Action) error
// The person's answers to the questions by the id of each, an error when nobody can answer them here
Ask func(ctx context.Context, questions []Question) (map[string][]string, error)
// Guidance the person sent since it was last asked, each text as the model reads it, stored in the session as it is handed over; none
// when none waits
Guidance func(ctx context.Context) ([]string, error)
}
What the session of a request does for a provider that runs a turn of its own, such as an agent program that runs commands and changes files itself: its asks go through the session as the agent's own steps would, its approvals deciding and its questions waiting for the person, and the guidance the person sends while the reply runs reaches it as it comes
type Spec ¶
type Spec struct {
Name string
DisplayName string
Description string
SignupURL string
// Place among the well-known kinds, which a person adding a provider is offered first, 1 at the top. A kind with none is listed by its
// name with the rest
Rank int
// Base URL a provider of the kind starts with, and the variable that sets it for all of them
BaseURL string
BaseURLEnv string
ModelsURL string
Mode APIMode
Auth AuthKind
AuthType string
KeyEnv []string
Aliases []string
// Model a provider of the kind starts with
DefaultModel string
FallbackModels []string
Headers map[string]string
Local bool
Aggregator bool
Hidden bool
ModelListing bool
HealthCheck bool
Vision bool
VisionToolMessages bool
OmitTemperature bool
DefaultMaxTokens int
UnsupportedResponseFormats []string
ModelsDevID string
Hostnames []string
PerModelMode func(model string) APIMode
AmbientCredentials bool
// Settings each provider of the kind keeps besides its title, base URL, default model and models, keyed by their names below it
Settings []config.Setting
// Fields each account of a provider of the kind keeps, keyed by their names below it: an API key when none are named
Account []config.Setting
// Headers the kind's providers send from variables and from their settings, such as OpenAI-Project from OPENAI_PROJECT_ID, each checked
// and joined to every request by Additional
HeaderSources []HeaderSource
// Kind as one provider has it, from its settings once its base URL and default model are set, for a kind whose API or address
// depends on more of them
Resolve func(spec Spec, settings config.View) Spec
// Route of a request once its credential and model are known, for a kind whose API or address depends on them, such as the coding
// endpoint a Kimi coding key belongs to or the Bedrock API a model is served on; with the provider's settings, whose API setting, when
// set, is the person's choice of API
Route func(route Route, settings config.View) Route
// Taken before any other kind when nothing names a provider and its credential is found, as an OpenRouter key is
AutoFirst bool
// Taken when nothing names a provider and no other kind has a credential, once its own is found outside icebath, as AWS's is
AutoLast bool
// Its accounts sign in, rather than keep an API key, unless the person gives one: one with none is Not signed in rather than Not
// connected
SignIn bool
SupportsStreaming *bool
SupportsPromptCacheKey bool
NativeReasoningDetailsType string
ProcessCommand string
ProcessArgs []string
ProcessCommandEnvVars []string
ProcessArgsEnvVar string
ModelAliases map[string]string
Hostname string
FixedTemperature *float64
DefaultAuxModel string
ModelCapabilities map[string]map[string]any
AccountCard map[string]string
MetadataHostnames []string
MessageCarrierOpaque string
MessageCarrierText string
ReplaysToolCallSignatures bool
StaticModels []string
CatalogCredentialFiles []string
PickerAfter string
PickerGroup []string
CatalogAliases bool
Overlay *IcebathOverlay
OverlayAliases []string
RegistryAuthType string
RegistryAfter string
PortalBaseURL string
ClientID string
Scope string
Extra map[string]any
ResponsesDropReplayItemIDs bool
ResponsesOmitPromptCacheKey bool
ResponsesIssuer string
ResponsesDistrustCompletedStatus bool
ResponsesNoNativeCompaction bool
ResponsesReasoningFromProfile bool
// The models.dev registry describes the kind's models better than its curated list, which then is only what the catalog offers when
// the registry can't be read
ModelsDevPreferred bool
// Models it lists lead the catalog, the curated ones after them
LiveFirst bool
// Rows shaped as the models.dev registry's for models it has not indexed yet, by model id
ModelMetadata map[string]map[string]any
// Models whose ids are marked -vision take images though the registry doesn't know them
VisionMarked bool
// Its models listing states each model's context window, which is read before anything else knows it
ListsContext bool
// Its windows change with what it serves, so a window found is asked for again rather than kept
ProbeAlways bool
// Ids it still lists but no longer serves, left out of its catalog
Delisted []string
// Model a route of the kind lands on when none is picked and the online catalog names none
CatalogDefault string
// Context window the kind knows a model has on an endpoint, 0 when it doesn't; trusted before any probe
ContextLength func(model, baseURL string) int
// Published prices of the kind's models by id
Prices map[string]Price
// Prices of the requests a tier other than the standard one served, by the tier as the reply names it and then by model id
TierPrices map[string]map[string]Price
// tiers as one share of every model's price rather than model by model, such as a decimal 0.5 for half
TierShares map[string]string
// Share of the published prices the requests of one provider of the kind bill at, as its settings say, such as a Foundry deployment in
// a data zone at 1.1; empty for the published prices; nil for a kind whose prices are the same for every provider
Billed func(settings config.View, model string) string
// Domain of a first party API billed per token at the list prices models.dev keeps, for requests sent to it over https
ListPrices string
// Requests are covered by a subscription rather than billed
Included bool
// Pages where credit is added, for the vendors the kind reaches
Billing []Billing
// Limits of the account a route of the kind signs in with, asked in the environment of the profile the route was resolved for: nil
// without an account to ask about
AccountUsage func(ctx context.Context, cfg *config.Config, route Route) (*AccountUsage, error)
// Spends one banked reset of the account's limits in the environment of the profile the route was resolved for, unless they aren't
// spent and force is false; what came of it
ResetUsage func(ctx context.Context, cfg *config.Config, route Route, force bool) string
// Messages as the wire sends them, rewritten for the kind, such as with fields its schema refuses taken out
Messages func(call *Call, messages []map[string]any) []map[string]any
// Reasoning a request that asks none is sent with; an ask that isn't set for none
DefaultReasoning func(call *Call) Ask
// Fields the kind sets for the request's reasoning and its own options: those added to the body after the request's own, and those put
// over its top fields, where extra_headers holds headers of the request
Shape func(call *Call) (extra, top map[string]any)
// Fields added to the body of every request of the kind, such as its session or routing options
ExtraBody func(call *Call) map[string]any
// Output cap a request is sent with, given the one it asks for or 0; 0 sends none. Without the hook a request asking none takes the
// kind's DefaultMaxTokens
OutputCap func(call *Call, requested int) int
// Field the output cap goes in at the address, empty for the wire's own choice
OutputField func(baseURL, model string) string
// Headers of one request, over the route's
RequestHeaders func(call *Call) map[string]string
// Readies what answers the request before it goes out, such as a server of this computer started and the model loaded, telling the
// person how it goes through emit; the route to send it on, which may name another address or key. The settings are the session's. A
// failure is the request's, said in words a person reads. Called by the transport host for the clients of every API; nil readies nothing
Prepare func(ctx context.Context, cfg *config.Config, route Route, request *Request, emit StreamFunc) (Route, error)
// Efforts the kind's model takes, false when the kind declares none
Efforts func(ctx context.Context, model string) ([]string, bool)
// Reasoning field of a Responses request to the kind, nil to send none
ReasoningPayload func(call *Call) map[string]any
// Last changes the kind makes to the body of a Responses request, such as the speed tier its account offers
Finish func(call *Call, body map[string]any)
// Fields a reply carried beside its text that the kind wants back when the reply is replayed, of those kept under their names
Replay func(call *Call, kept map[string]string) map[string]string
// Whether tool calls are replayed with the thought signatures of their functions
FunctionSignatures func(model, baseURL string) bool
// Model id as the kind names it, such as with the vendor an aggregator wants in front; given the kind itself
Native func(spec Spec, model string) string
// Lines added to the error of a refusal at the address with the status and message, such as what the address can't serve
RejectionHint func(status int, baseURL, message string) []string
// Retry n, counted from 1, of a request the kind refused with the failure, given the caller's own wait: the wait, the retries it may
// take in all, why it waits and the schedule's name, such as a longer schedule for an overload the kind reports. Every caller reads it
// through Spec.Retry, and ok false keeps the caller's own
Backoff func(route Route, model string, failure *APIError, attempt int, wait time.Duration) (retry Retry, ok bool)
// Status line once the route's credential was renewed for the reason, unauthorized or stale; empty for the generic one
RefreshNotice func(reason string) string
// Reasoning fields of its replies it reads back: reasoning_content, reasoning, reasoning_details. Nil takes those of the kind claiming
// the address, else the default; empty replays none
Carriers []string
// Refuses a tool call turn whose replayed assistant message lacks its reasoning_content
EchoesReasoning bool
// Tool names the kind keeps for its own tools, which the agent's tools of those names are sent under other names for
ReservedTools []string
// Takes only nine character tool call ids, as Mistral does
ShortToolIDs bool
// Model a side job on images runs on, for a kind whose helper model can't see; and whether none of the kind's models see images
VisionHelper string
Blind bool
// Whether requests for the kind's model over the API carry prompt cache markers, and whether on their blocks as the Anthropic API
// places them; ok false leaves it to the wire
Caching func(model string, mode APIMode) (on, native, ok bool)
// Longest the kind keeps a prompt cache of the model when an hour is asked: 1h, or 5m for one that keeps it no longer
CacheTTL func(model string) string
// Its model ids keep their dots over the Anthropic API, where a Claude id's dots otherwise become dashes
DottedModels bool
}
Kind of provider a plugin registers: its API, how it signs in and its defaults. A profile has providers of these kinds, each with settings and accounts of its own
func (Spec) AccountFields ¶
Fields an account of the kind keeps
func (Spec) Additional ¶
What a provider of the kind with the settings adds to every request to the base address: the kind's sourced headers, such as OpenAI-Project from OPENAI_PROJECT_ID for OpenAI's own host, then the provider's own Headers over them, those the administrator set over everything; and the provider's Query parameters. Headers icebath controls are left out, and those carrying a credential when the request has one of its own (keyed); query parameters are left out of requests AWS signs (signed), as one added after the signature breaks it. Each left out is said in a sentence; an error in words for a header or parameter that can't be sent, which no request is sent with
func (Spec) KeyEnvNames ¶
func (Spec) Names ¶
Names a provider prefix of the kind's model ids may use: its own and its aliases
func (Spec) NativeModel ¶
Model id as the kind names it
func (Spec) Own ¶
Whether the address of a provider of the kind is the person's to give, as a server of their own's is
func (Spec) Retry ¶
func (s Spec) Retry(route Route, model string, failure *APIError, attempt int, wait time.Duration, retries int) Retry
Retry n, counted from 1, of a request on the route that the kind refused with the failure, given the caller's own wait and retries: the kind's schedule when its Backoff claims the failure and the provider named no wait of its own, never with fewer retries than the caller's, else the caller's
type StreamEvent ¶
type StreamEvent struct {
Kind EventKind
Text string
// Message of a step
Message *sessionsv1.Message
// Id of the tool call a progress line is of, and the tool's name
Call, Tool string
}
func (StreamEvent) Delivers ¶
func (e StreamEvent) Delivers() bool
Whether the event delivers part of the reply, text, reasoning or a step, which a request sent again would deliver twice
type StreamFunc ¶
type StreamFunc func(StreamEvent) error
type Thinking ¶
type Thinking struct {
Takes bool
Efforts []string
Mandatory bool
// Whether a listing said anything of the model
Known bool
}
What a provider's listing says of a model's reasoning: whether the model takes reasoning fields, the efforts listed for it, and whether it can't be turned off
type Usage ¶
type Usage struct {
Input int64
CacheRead int64
CacheWrite int64
Output int64
Reasoning int64
// Tier or speed that served the request when not the standard one, such as fast or ultrafast, which bills at its own prices
Tier string
}
Tokens a request took: the input not read from a cache, the input read from and written to the provider's cache, the output, and the part of the output spent reasoning
type UsageWindow ¶
type UsageWindow struct {
Label string
// Share used in percent, nil when the provider didn't say
Used *float64
// When the window starts over, nil when not known
Resets *time.Time
// What to show when the reset is not known
Detail string
// Whether the window caps the whole account or one family of its models
Model bool
}
One quota window of an account, such as its session or its week
func AccountWindow ¶
Window of the whole account
type Written ¶
Text of a setting as a person wrote it, every ${NAME} kept, and the text it is read as for use