provider

package
v2.0.2 Latest Latest
Warning

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

Go to latest
Published: Dec 2, 2026 License: MIT Imports: 27 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Index

Constants

View Source
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

View Source
const (
	AuthTypeAPIKey          = "api_key"
	AuthTypeOAuthDeviceCode = "oauth_device_code"
	AuthTypeOAuthExternal   = "oauth_external"
	AuthTypeOAuthMiniMax    = "oauth_minimax"
	AuthTypeExternalProcess = "external_process"
	AuthTypeAWSSDK          = "aws_sdk"
	AuthTypeVertex          = "vertex"
	AuthTypeVirtual         = "virtual"
)
View Source
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

View Source
const DefaultPolicy = "default"

Name of the caller's own schedule in the log

View Source
const GeminiMaxOutput = 65535

Published Gemini output ceiling that thinking requests are raised to

View Source
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

View Source
const IdentityAuthor = "Nicholas W. Heyer"

Author icebath's own persona names

Variables

View Source
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

View Source
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

View Source
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

View Source
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

View Source
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

View Source
var ErrNoCount = errors.New("The provider of this route counts no tokens itself.")

The route's provider counts no tokens of its own

View Source
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

View Source
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

View Source
var Ladder = []string{"none", "minimal", "low", "medium", "high", "xhigh", "max", "ultra"}

Efforts from least to most, as every wire names them

View Source
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 Address

func Address(address string) error

Why text can't be the address of a server, nil when it can

func AffinityOf

func AffinityOf(ctx context.Context) string

Key the requests of the context stick by, empty where the work they are made for names none

func AskedTier

func AskedTier(extra map[string]any) string

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 Astra

func Astra(model string) bool

Whether the model is a GPT-6 Astra model

func AtLeast

func AtLeast(v, floor [2]int) bool

Whether a version is the floor or later

func Attribution

func Attribution() map[string]string

Attribution headers aggregators show the requests of icebath under

func AzureShare

func AzureShare(deployment, model string) string

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

func Bar(fraction float64, width int) string

Bracketed bar whose filled cells show the share, never empty above nothing nor full below all of it

func BareModel

func BareModel(model string) string

Lower case model id without any vendor prefix

func BaseHost

func BaseHost(base string) string

func BaseHostMatches

func BaseHostMatches(base, domain string) bool

func BasePath

func BasePath(base string) string

func BoundedTier

func BoundedTier(tier string) bool

Whether the tier asks for the fast one for a while rather than with every request, auto or cold

func Carry

func Carry(cfg *config.Config, values map[string]any, change Change) (map[string]any, bool)

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

func ClampEffort(effort string, supported []string, overrides map[string]string) string

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 Claude

func Claude(model string) bool

Whether the model is a Claude model

func ClaudeFamily

func ClaudeFamily(model string) (string, [2]int, bool)

Family and version of a Claude model id

func ClaudeSamplingForbidden

func ClaudeSamplingForbidden(model string) bool

Whether a Claude model refuses sampling settings, as those after 4.5 do but for Opus and Sonnet 4.6

func ClaudeThinking

func ClaudeThinking(ask Ask, model string, maxTokens int) map[string]any

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 Cleared

func Cleared(phrases []string) string

Sentence saying what a removal cleared, empty when it cleared nothing

func Clock

func Clock(at time.Time) string

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

func CodexEfforts(model string) []string

Effort vocabulary of an OpenAI or Codex Responses model generation

func Contains

func Contains(s string, parts ...string) bool

Whether the text holds any of the parts

func Controlled

func Controlled(name string, keyed bool) bool

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

func DashScopeThinking(model string) map[string]any

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

func EffortOptions(unset config.Option) []config.Option

Choices of a setting of the reasoning effort: the one given for no effort, then every effort

func FastDeployment

func FastDeployment(extra map[string]any) bool

Whether the fields send the request to the fast deployment of a Claude model, as Microsoft Foundry serves fast mode

func FastFields

func FastFields(model, kind, base, tier string) map[string]any

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

func GeminiBase(base string) string

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

func GeminiSamplingDeprecated(model string) bool

Whether a Gemini model ignores sampling settings, as 3.6 and later do

func GeminiSnake

func GeminiSnake(config map[string]any) map[string]any

Gemini thinking config in the snake case the OpenAI compatible surfaces take, nil when it says nothing

func GeminiThinking

func GeminiThinking(model string, a Ask) map[string]any

Gemini thinkingConfig for an ask, nil for another model or no ask

func GeminiVersion

func GeminiVersion(model string) (int, int)

Major and minor version of a Gemini model id, zero for an unversioned or other model

func Grok46

func Grok46(model string) bool

Whether the model is of the Grok 4.6 family

func HasPrefix

func HasPrefix(s string, prefixes ...string) bool

Whether the text starts with any of the prefixes

func Hostname

func Hostname(address string) string

Host of an address in lower case, empty when it has none

func KimiModel

func KimiModel(model string) bool

Whether the model is one of Kimi's or Moonshot's

func KnownMode

func KnownMode(mode string) bool

Request formats a setting may name

func LadderOptions

func LadderOptions() []config.Option

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

func LimitHeader(name string) bool

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

func Lines(text, variable string) ([][2]string, error)

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

func MandatoryThinking(model string) bool

Whether the model is a Claude model that always thinks, which no request can switch off

func ModelsURL

func ModelsURL(base string) string

func NamesTier

func NamesTier(extra map[string]any) bool

Whether the request fields name a tier themselves, any tier, normal included

func NativeGemini

func NativeGemini(address string) bool

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

func NestedReasoning(a Ask) map[string]any

Nested reasoning object of a route without a declared shape: nothing unasked, disabled when off, else the effort or medium

func OfficialCodex

func OfficialCodex(base string) bool

Whether the address is OpenAI's own Codex backend rather than a proxy of it

func Overridden

func Overridden(model string, overrides map[string]any, order []string) (string, bool)

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

func OverriddenBy(model string, overrides map[string]any, order []string) (string, string, bool)

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

func ParseEffort(value any) (string, bool)

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

func PercentUsed(fraction float64) string

Share used as a whole percent rounded down, a sliver reading as under one percent

func Queried

func Queried(address string, query url.Values) string

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

func QueryOf(settings config.View) url.Values

Query parameters of a provider's settings, none while one of them has no name, which refuses its routes in words

func Refill

func Refill(header http.Header, now time.Time) (time.Duration, bool)

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

func RepairPrefix(model string, catalogue []string) string

Model id with the vendor prefix it dropped put back, when exactly one id of the catalogue ends in it

func ResetIn

func ResetIn(value string, now time.Time) (time.Duration, bool)

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

func ResetsIn(at, now time.Time) string

When a window starts over, as resets in a length of time in words; resets soon once that is under a minute

func ResponsesEfforts

func ResponsesEfforts(model string, official bool) []string

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

func RetryWait(header http.Header, now time.Time) time.Duration

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 Rung

func Rung(effort string) int

Place of the effort on the ladder, -1 off it

func SlowFields

func SlowFields(model, kind, base string) map[string]any

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

func StaticTier(tier string) bool

Whether the tier is one a single request asks for: priority, ultrafast or flex

func StripOwn

func StripOwn(model string, names ...string) string

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 Tier

func Tier(word string) (string, error)

Tier a word asks for, empty for the normal tier; an error for a word that names none

func TierFields

func TierFields(model, kind, base, tier string) map[string]any

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 TierWord

func TierWord(tier string) string

Word a tier is shown by

func Unprefixed

func Unprefixed(s Spec, model string) string

Model id without a prefix naming the kind or one of its aliases

func UserAgent

func UserAgent(product string) string

User agent of a request from icebath under the product name

func Vendor

func Vendor(model string) string

Vendor a model id names or implies, empty when none can be told

func Vendored

func Vendored(_ Spec, model string) string

Model id with the vendor an aggregator names it under in front

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

func Wait(header http.Header, now time.Time) (time.Duration, bool)

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

func WithAffinity(ctx context.Context, key string) context.Context

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

func WithVendor(model string) string

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

func WithoutTier(extra map[string]any) map[string]any

The request fields with every field that names a tier taken out, so they ask for the usual one

func WrittenAddress

func WrittenAddress(cfg *config.Config, address string) error

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
}

func (*APIError) Error

func (e *APIError) Error() string

func (*APIError) Retryable

func (e *APIError) Retryable() bool

func (*APIError) Unwrap

func (e *APIError) Unwrap() error

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

func ModeForURL(address string) APIMode

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
	// Why the account's limits can't be read, empty when they could
	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

type Additions struct {
	Headers, Query  []Added
	Refused, Unsent []string
}

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

func (Additions) Header

func (a Additions) Header() map[string]string

The headers of the additions by name

func (Additions) Shown

func (a Additions) Shown() string

Header names of the additions as a line a person reads, each with where it came from; empty for none

func (Additions) Values

func (a Additions) Values() url.Values

The query parameters of the additions

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

func Effort

func Effort(effort string) *Ask

Ask for thinking at the effort

func (Ask) Clamped

func (a Ask) Clamped(supported []string) Ask

Ask with its effort clamped onto the supported vocabulary

func (Ask) Object

func (a Ask) Object() map[string]any

Ask as the reasoning object OpenAI compatible routers take: enabled, and the effort when one is asked

func (Ask) Requested

func (a Ask) Requested() string

Explicit effort of the ask, empty when it asks none or turns thinking off

type AuthKind

type AuthKind string
const (
	AuthNone     AuthKind = "none"
	AuthAPIKey   AuthKind = "api_key"
	AuthOAuth    AuthKind = "oauth"
	AuthAWSSigV4 AuthKind = "aws_sigv4"
	AuthGCPOAuth AuthKind = "gcp_oauth"
)

func AuthKindOf

func AuthKindOf(authType string) AuthKind

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

func (Bucket) Left

func (b Bucket) Left(now time.Time) float64

Seconds left until the window resets, counted from when it was captured

func (Bucket) Percent

func (b Bucket) Percent() float64

Share of the window used, in percent, 0 without a limit

func (Bucket) Used

func (b Bucket) Used() int

What the window has used, never below zero

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 Client

type Client interface {
	Route() Route
	Stream(ctx context.Context, request *Request, fn StreamFunc) (*Response, error)
}

type Counter

type Counter interface {
	Count(ctx context.Context, request *Request) (int, error)
}

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

type Edit struct {
	Path          string
	Before, After *string
}

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"
)

func KindOf

func KindOf(status int) ErrorKind

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 Factory

type Factory func(route Route) (Client, error)

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 Format

type Format struct {
	Name   string
	Schema map[string]any
	Strict bool
}

JSON schema a reply must follow

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 IcebathOverlay struct {
	Transport       string
	IsAggregator    bool
	AuthType        string
	ExtraEnvVars    []string
	BaseURLOverride string
	BaseURLEnvVar   string
}

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

func (i Instance) AccountFields(name string) config.View

Fields of one account of the provider, whose writes never make the account again once it is removed

func (Instance) AccountTitle

func (i Instance) AccountTitle(name string) string

Name an account of the provider is shown by: its title as written, else its name

func (Instance) Label

func (i Instance) Label() string

func (Instance) Launch

func (i Instance) Launch(lookup func(name string) (string, bool)) (string, []string, error)

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

func (Instance) Offered

func (i Instance) Offered(cfg *config.Config) bool

Whether the model list offers the provider's models

func (Instance) Takes

func (i Instance) Takes(source string) bool

Whether a credential found outside the accounts is one the provider uses, by the variable or program it comes from

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

type Kept struct {
	ID, Kind, Label, Model string
	Spec                   Spec
}

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

func (Price) At

func (p Price) At(moment time.Time) Price

The prices in force at the moment: Then once Until passed, and so on down a vendor's published changes

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 Provider

type Provider struct {
	Registry
}

func New

func New(cfg *config.Config) *Provider

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

func ParseRateLimits(header http.Header, provider string, now time.Time) *RateLimits

Rate limits of an answer's headers, every vendor's windows read the one way, nil when it states none

func (*RateLimits) Lines

func (l *RateLimits) Lines(now time.Time) []string

Lines of the windows that have a limit under a title saying whose they are and how old: how much each has used and when it resets, then a warning for each nearly spent; none before any answer stated limits

type Reasoning

type Reasoning struct {
	Effort string
}

func (Reasoning) Ask

func (r Reasoning) Ask() Ask

What the request's reasoning asks: none, false and disabled turn thinking off, a level asks for it

type Registrant

type Registrant interface {
	Specs() []Spec
}

type Registry

type Registry struct {
	// contains filtered or unexported fields
}

func (*Registry) Add

func (r *Registry) Add(cfg *config.Config, kind, id, title, address string) (Instance, error)

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

func (r *Registry) Billing(route Route) 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

func (r *Registry) CredentialEnv() []string

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

func (r *Registry) EffortKeys() (effort, overrides string, ok bool)

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

func (r *Registry) EffortOf(cfg *config.Config, model string) (string, bool)

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

func (r *Registry) First(cfg *config.Config, kind string) (Instance, bool)

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) Follow

func (r *Registry) Follow(follower Follower)

func (*Registry) Instance

func (r *Registry) Instance(cfg *config.Config, name string) (Instance, bool)

Provider of the profile with the name, or the first of the kind with it as a name or alias

func (*Registry) Instances

func (r *Registry) Instances(cfg *config.Config) []Instance

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

func (r *Registry) KeepKey(cfg *config.Config, id, name, key string) error

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

func (r *Registry) Kept(values *config.Config) []Kept

Every provider of the profile as the settings file keeps it, by the name it is shown by

func (*Registry) LaunchEnv

func (r *Registry) LaunchEnv() []string

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

func (r *Registry) Live() []Spec

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

func (r *Registry) MoveAccount(cfg *config.Config, id, name string, place int) (int, error)

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

func (r *Registry) Options(cfg *config.Config) func() []config.Option

Values a setting naming a provider of the profile of cfg may take, read each time they are shown

func (*Registry) Overridden

func (r *Registry) Overridden(cfg *config.Config, model string) (string, bool)

Effort the per-model overrides of the profile of the settings give the model, false when they give none

func (*Registry) Plugins

func (r *Registry) Plugins() int

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

func (r *Registry) Primary() (provider, model string, ok bool)

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

func (r *Registry) Rekey(ctx context.Context, cfg *config.Config, id, to string) error

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

func (r *Registry) RekeyAccount(ctx context.Context, cfg *config.Config, id, name, to string) error

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

func (r *Registry) Remove(ctx context.Context, cfg *config.Config, id string) (Removed, error)

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

func (r *Registry) SetAddress(cfg *config.Config, id, address string) error

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

func (r *Registry) SetOffered(cfg *config.Config, id string, on bool) error

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

func (r *Registry) SetOutside(cfg *config.Config, id, source string, on bool) (bool, error)

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

func (r *Registry) SetTurns(cfg *config.Config, id, name string, on bool) error

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

func (r *Registry) Spec(name string) (Spec, bool)

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

func (r *Registry) Specs() []Spec

Every kind: the fixed ones in the order their plugins were registered, then those the live registrants offer now

func (*Registry) Untiered

func (r *Registry) Untiered(cfg *config.Config, name, model, word string) (string, string, bool)

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

func (*Registry) UseAccount

func (r *Registry) UseAccount(cfg *config.Config, id, name string) error

Uses the account for the provider from now on: one by name, Rotation for the accounts that take turns, or none for every account in order. Taking turns is refused while no account takes turns

type Removed

type Removed struct {
	Variables []string
	Named     []string
}

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

func (Retry) Line

func (r Retry) Line(attempt int) string

Line shown while retry n waits, such as "The provider is limiting requests. Trying again in 4 seconds, retry 2 of 3."

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
}

func (Route) Shown

func (r Route) Shown() string

Address of the route as a person reads it, as the settings it was read from write it, every ${NAME} kept

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
	// Share of a model's standard price a request a tier served costs, by the tier as the reply names it, for a vendor that prices its
	// 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

func (s Spec) AccountFields() []config.Setting

Fields an account of the kind keeps

func (Spec) Additional

func (s Spec) Additional(settings config.View, base string, keyed, signed bool) (Additions, error)

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 (s Spec) KeyEnvNames() []string

func (Spec) Keyed

func (s Spec) Keyed() bool

Whether accounts of the kind keep an API key

func (Spec) Label

func (s Spec) Label() string

func (Spec) Names

func (s Spec) Names() []string

Names a provider prefix of the kind's model ids may use: its own and its aliases

func (Spec) NativeModel

func (s Spec) NativeModel(model string) string

Model id as the kind names it

func (Spec) Own

func (s Spec) Own() bool

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

func (Spec) Temperature

func (s Spec) Temperature(model string, wanted *float64) *float64

Temperature a request to the kind's model is sent with: none for models that take only their own or refuse one, the kind's fixed one, else the one asked for

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

func (Usage) Add

func (u Usage) Add(other Usage) Usage

Usage of two requests together, served at the tier of the first that names one

func (Usage) Prompt

func (u Usage) Prompt() int64

Every token of the prompt, cached or not

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

func AccountWindow(label string, used *float64, resets *time.Time, detail string) UsageWindow

Window of the whole account

type Written

type Written struct {
	As   string
	Read string
}

Text of a setting as a person wrote it, every ${NAME} kept, and the text it is read as for use

func (Written) Put

func (w Written) Put(text string) string

The text as a person reads it: where it is what the setting is read as, or starts with it as an address made from it does, the setting is put back in its place as it is written, so no variable's value is shown, logged or kept for a reference to it. Any other text is as it is

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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