Documentation
¶
Overview ¶
Package provider holds the model vendors magpie can reach: where each one lives, which protocols it speaks, the API key the user typed in, and which of its models should show up in the agents' pickers.
Provider keys are never read from environment variables. A provider is exactly what the user entered, kept in ~/.config/magpie/providers.json (mode 0600).
Index ¶
- Constants
- Variables
- func APIError(b []byte, fallback string) string
- func AccountCapOf(id, user string) int
- func AccountModelsOf(id, ref string) (string, []string, error)
- func Add(p Provider) (string, error)
- func AddCopy(p Provider, from string) (string, error)
- func AddKey(id, name, key string, proto Protocol) error
- func AddKeys(id string, keys []string, proto Protocol) (added, had int, err error)
- func Adopt(ctx context.Context, id string) error
- func AgentUser(agent string) string
- func Allowances(agent string) map[string]Allowance
- func AntigravityBase(id string) (base, effort string, ok bool)
- func AntigravitySentID(model, effort string) string
- func AntigravityVariants(model string) (map[string]string, bool)
- func AnyPriceKey(model string) string
- func ApplyImage(pid, model string, images bool, known *bool) (bool, *bool)
- func AskClaudeUsage()
- func AskUsage()
- func AuthHeaders(p Provider, proto Protocol) map[string]string
- func AutoGroupID(model string) string
- func AutoGroupOf(pid, model string) string
- func AutoGroupsOn() bool
- func AutoResets(agent, user string) bool
- func AutoStandIn(id string) (string, bool)
- func AzureBase(raw string) (string, bool)
- func AzureHost(host string) bool
- func BackAt(q SubscriptionQuota, now time.Time) time.Time
- func Balance(ctx context.Context, p Provider) (amount string, ok bool, err error)
- func BalanceNumber(s string) (float64, bool)
- func BoundCallID(id string) string
- func CCSwitchSkillOrigin(dir string) (repo, branch string, ok bool)
- func CCSwitchSkillsDir() string
- func CanFast(p Provider, model string) bool
- func CancelSignIn(id string)
- func Changed()
- func CheckQueue(limit, wait int) error
- func CheckinDay(t time.Time) string
- func ClaudeCodeMovedOff(user string) bool
- func ClaudeFast(model string) bool
- func ClaudeInWSL() string
- func ClaudeLoginVersion(user string) string
- func ClaudeSignInRequired(message string) bool
- func ClaudeWarmed() map[string]time.Time
- func CleanLevels(in []string) ([]string, error)
- func CleanPatterns(in []string) ([]string, error)
- func ClineClient(h http.Header)
- func CloudflareClef(model string) bool
- func CodexAutoReset(user string) bool
- func CodexDaemonStale() string
- func CodexListTag() string
- func CodexListed() []catalog.Model
- func CodexNativeHidden() map[string]bool
- func CodexNativePicked() (map[string]bool, bool)
- func CodexNativeWindow(restore bool) func(slug string) (n, most int, ok bool)
- func CodexOrder() (map[string]int, bool)
- func CodexOwn(e Entry) bool
- func CodexSignedIn() (string, bool)
- func CodexUsedUp(ctx context.Context) bool
- func CodexWarmed() map[string]time.Time
- func CommandCodeGenerate(ctx context.Context, p Provider) (api, key string, ok bool)
- func CommandCodeOutputOf(model string) int
- func CompactSet(id string) int
- func CompactSetIn(s settings.Settings, id string, find func(string) (Group, []Member, bool)) int
- func CompactsOf(providerID string) map[string]int
- func Confidence(ps map[string]any) float64
- func CopilotHost(s string) (string, error)
- func CopilotRefusal(body []byte) bool
- func CursorBase(id string) (base, effort string, ok bool)
- func CursorClientVersion() string
- func CursorToken() (string, error)
- func CursorVariants(model string) (map[string]string, bool)
- func DecideAnswer(via string, b []byte) []byte
- func DecideAsk(via, model string, body []byte) []byte
- func DecideRouteStatus(err error) int
- func Delete(id string) error
- func DeleteGroup(id string) error
- func DeleteGroups(ids []string) error
- func DetectBase(base string, proto Protocol) string
- func DevinAuth() (key, server string, err error)
- func DevinAuthAt(home string) (key, server string, err error)
- func DevinCredentialsPath() string
- func DevinNoWait(ctx context.Context) context.Context
- func DevinOffered(families []DevinFamily) []catalog.Model
- func DevinPick(families []DevinFamily, model, effort string) string
- func DevinSplit(families []DevinFamily, id string) (model, effort string)
- func DevinVariant(ctx context.Context, model, effort string) string
- func DismissCodexDaemon()
- func DropContext(p Provider, model string) (bool, error)
- func DropModelOutput(id string) (string, bool, error)
- func DropModelPrice(key string) (bool, error)
- func DropUpstreamName(key string) (bool, error)
- func EdgeBlocked(b []byte) bool
- func EffectivePrice(providerID, model string) (catalog.Price, bool)
- func EffectivePriceIn(s settings.Settings, providerID, model string) (catalog.Price, bool)
- func EffortFamily(id string) string
- func EffortsOf(m catalog.Model) []string
- func ErrorType(b []byte) string
- func FactoryBaseForTest(api, eu string) func()
- func Families() []string
- func FaviconFor(ctx context.Context, base, name string) (string, error)
- func FetchIcon(ctx context.Context, rawURL string) (string, error)
- func FetchNew(timeout time.Duration)
- func FetchNewBehind(timeout time.Duration)
- func FetchNewSoon(timeout time.Duration)
- func FetchingNew() bool
- func FileError() error
- func FindGroup(id string) (Group, []Member, bool)
- func FlatName(namespace, name string) string
- func ForgetAccount(id string) error
- func ForgetAccounts()
- func ForgetBalances()
- func ForgetLogin(agent, user string) error
- func FreeID(id string) string
- func GrokHome() string
- func GrokUser(home string) (string, bool)
- func GroupFinder() func(id string) (Group, []Member, bool)
- func GroupFor(id string) (string, bool)
- func GroupMember(g Group, in string) (string, error)
- func HandOver(ctx context.Context, accounts bool) map[string]error
- func HasMiniMax() bool
- func HasTrae() bool
- func HasUpstreamName(key string) bool
- func HasWorkBuddy() bool
- func HeldSettings() settings.Settings
- func HiddenModels(agent string) map[string]bool
- func Hold() (release func())
- func HostOf(u string) string
- func IDs() []string
- func IconDir() string
- func IconFile(name string) string
- func IconForCatalog(catalogID string) string
- func ImageOverride(pid, model string) (bool, bool)
- func ImportFromApps(picks []AppPick) ([]string, error)
- func InUseLogin(agent string) string
- func Intents(rules []Rule, q RuleRequest) []string
- func IsDecider(id string) bool
- func IsPattern(s string) bool
- func KeepClaudeWindowsWarm(ctx context.Context, send func(ctx context.Context, configDir string) error)
- func KeepCodexWindowsWarm(ctx context.Context)
- func KeepLoginsAlive(ctx context.Context)
- func KeepMiniMaxCheckedIn(ctx context.Context)
- func KeepOnAnAccountWithRoom(ctx context.Context)
- func KeepResetsFromRunningOut(ctx context.Context)
- func KeepRetiringMoved(ctx context.Context)
- func KeepTraeCheckedIn(ctx context.Context)
- func KeepWorkBuddyCheckedIn(ctx context.Context)
- func KeyID(key string) string
- func KiloClient(h http.Header, key, session string)
- func KimiCodeSearch(p Provider) string
- func KiroModel(id string) (context int, images bool)
- func Labels(es []Entry) []string
- func LastServed() map[string]time.Time
- func ListHeader(name string) bool
- func ListedWindow(m catalog.Model) int
- func LoginUsage(ctx context.Context, agent string) map[string]SubscriptionQuota
- func LoginUsageVia(f func(ctx context.Context, agent string) map[string]SubscriptionQuota)
- func MakerPrice(model string) (catalog.Price, bool)
- func Mask(s string) string
- func MatchRule(rules []Rule, q RuleRequest) int
- func MemberEffort(id string) (model, effort string)
- func MemberFast(id string) (member string, fast bool)
- func MemberGroups() map[string][]string
- func MergeList(h http.Header, name, add string)
- func MergeName(model string) string
- func MergeQuotaHistory(data []byte, now time.Time) error
- func Mirror(ps []Provider, gs []Group) error
- func MirrorGroupOrder(order []string) error
- func MirrorOrder(order []string) error
- func MirrorSearchAPIs(as []SearchAPI) error
- func ModelName(pid, model string) (string, bool)
- func ModelOrder(agent string) []string
- func Movable(id string) bool
- func MovableIDs() []string
- func Move(ctx context.Context, id string) error
- func MoveBack(ctx context.Context, id string) error
- func MovePackage(id string) string
- func MoveRetiring(ctx context.Context) map[string]error
- func Moved(id string) bool
- func MovedOnto(name string) []string
- func NextLogin(ctx context.Context, agent string) (from, to string, back, ok bool)
- func NoteClaudeLimits(user string, ls []ClaudeLimit)
- func NoteClaudeSignInFailure(user, version, message string)
- func NoteServed(p Provider, at time.Time)
- func ObjectRoot(ps map[string]any) bool
- func OffersUltra(model string) bool
- func OnAccountIDs() []string
- func OnPlugins() []string
- func OnRenewed(f func(agent, user string))
- func OpenCodeClient(h http.Header, session string)
- func OpenReadOnly(path string) (*sql.DB, error)
- func OutputsOf(providerID string) map[string]int
- func ParseCap(s string) (int, error)
- func ParseDay(s string) (string, bool)
- func ParseDays(v string) ([]string, error)
- func ParseLimit(s string) (*int, error)
- func ParseTokens(v string) (int, error)
- func Path() string
- func PatternMatches(pattern, id string) bool
- func PlanTerm(until *time.Time, renew string) string
- func PluginAPIKey(ctx context.Context, id string, method int, inputs map[string]string, ...) (string, error)
- func PluginID(id string) string
- func PluginIcon(pp plugin.Provider) string
- func PluginListError(pp plugin.Provider, key string) string
- func PluginOf(id string) (plugin.Provider, bool)
- func PriceKey(pid, model string) (string, bool)
- func PriceRateOK(r float64) string
- func PricedName(model string) string
- func ProbeClaudeVia(f func(ctx context.Context, configDir, model string) error)
- func ProxyOf(id string) string
- func ProxyOfLogin(id, user string) string
- func QoderAuthURL() (url string, flow *qoderFlow, err error)
- func QoderCompleteSignIn(ctx context.Context, fl *qoderFlow) (user string, err error)
- func QoderCredential(ctx context.Context, user string) (*qoder.Credential, error)
- func QoderCredentialOf(ctx context.Context, agent, user string) (*qoder.Credential, error)
- func QoderModel(ctx context.Context, user, key string) (qoder.ModelInfo, error)
- func QoderModelOf(ctx context.Context, agent, user, key string) (qoder.ModelInfo, error)
- func QoderSignedIn() bool
- func QuietAccount(id string) error
- func QuotaHistoryData() []byte
- func QuotaHistorySince(days string, now time.Time) time.Time
- func RefreshUsage(ctx context.Context, provider, user string)
- func RemoveKey(id, keyRef string) error
- func RemoveKeys(id string, refs []string) (removed int, err error)
- func RemovePlugin(ctx context.Context, name string) error
- func RemoveSearchAPI(vendor string) error
- func RemovedGroups() []string
- func Rename(from, to string) error
- func RenameGroup(from, to string) error
- func RenameKey(id, keyRef, name string) error
- func Renamed() map[string]string
- func RenamedRef(ref string) string
- func ResetClock(at, now time.Time) string
- func RestartCodexDaemon(ctx context.Context) error
- func Restore(ps []Provider) (added, replaced int, err error)
- func RestoreGroups(gs []Group) error
- func RestoreSearchAPIs(as []SearchAPI) error
- func RuleWords(line string) []string
- func Save(p Provider) error
- func SaveGroup(g Group) error
- func SaveStepFunPaste(ctx context.Context, site, text string) error
- func SaveStepFunSession(ctx context.Context, site, access, refresh, webID string) error
- func SawCodexClient(h http.Header)
- func SentNameIn(wires map[string]string, pid, model, effort string) string
- func SentNameOnIn(wires map[string]string, pid, account, model, effort string) string
- func ServedID(p Provider) string
- func ServesModel(p Provider, model string) bool
- func SetAccountCap(id, ref string, cap int) error
- func SetAccountConcurrency(id, ref string, limit *int) error
- func SetAccountModels(id, ref string, models []string) error
- func SetAccountOrder(id string, order []string) error
- func SetAffinity(id, affinity string) error
- func SetAutoGroups(on bool) error
- func SetCodexAgentsV1(on bool) error
- func SetCodexAutoReset(user string, on bool) error
- func SetCompactAt(n int) error
- func SetContext(p Provider, model string, n int) error
- func SetFullContext(on bool) error
- func SetGoogleProject(agent, user, project string) error
- func SetGroupOrder(ids []string) error
- func SetHiddenModels(agent string, ids []string) error
- func SetKeepLogin(id string, keep bool) error
- func SetKeepLoginAs(id, user string) error
- func SetKeyOn(id, keyRef string, on bool) error
- func SetKeyProtocol(id, keyRef string, proto Protocol) error
- func SetKeyWeight(id, keyRef string, weight int) error
- func SetLoginOn(agent, user string, on bool) error
- func SetModelAPI(ref, api string) error
- func SetModelCompacts(providerID string, cs map[string]int) error
- func SetModelEfforts(ref string, efforts []string) error
- func SetModelImage(ref string, images *bool) error
- func SetModelName(ref, name string) error
- func SetModelOrder(agent string, ids []string) error
- func SetModelOutput(id string, n int) error
- func SetModelOutputs(providerID string, outs map[string]int) error
- func SetModelPrefs(pid string, prefs map[string]ModelPref) error
- func SetModelPrice(id string, p *catalog.Price) error
- func SetModelSame(ref, same string) error
- func SetOff(id string, off bool) error
- func SetOrder(ids []string) error
- func SetPlainNames(on bool) error
- func SetPluginOff(ctx context.Context, name string, off bool) error
- func SetQueue(id string, limit, wait int) error
- func SetRouting(id, routing string) error
- func SetSearchAPI(a SearchAPI) error
- func SetSink(id string, sink bool) error
- func SetSuffixMode(mode string) error
- func SetUpstreamName(ref, name string) error
- func ShowAccount(id string) error
- func ShowGroup(id string) error
- func Shows(names []string, e Entry) bool
- func SignOutStepFun(site string) error
- func Slug(name string) string
- func SpendExpiringCodexResets(ctx context.Context)
- func SpentShareOf(routing string) float64
- func SplitKeys(text string) []string
- func StaleAllowance(agent, user string)
- func StepFunBookmarklet() string
- func StepFunOrigin(site string) string
- func StepFunSignInURL(site string) string
- func StepFunSignedIn(site string) bool
- func StepFunSite(p Provider) string
- func StoreIcon(data []byte) (string, error)
- func StoreIconFile(path string) (string, error)
- func StoredGroupOrder() ([]string, error)
- func StoredOrder() ([]string, error)
- func SubmitSignInCallback(id, raw string) error
- func SuffixMode() string
- func SwitchGroup(id string, on bool) error
- func SwitchLogin(agent, user string) error
- func SwitchWhenSpent(ctx context.Context, agent string) (string, error)
- func TakesBalanceToken(p Provider) bool
- func TakesZhipuTeam(p Provider) bool
- func ThenUses(rules []Rule, q RuleRequest, n int, use string) []string
- func TookOpenedURL(args []string) bool
- func TuckAccount(id string, on bool) error
- func UpstreamName(p Provider, model string) string
- func UpstreamNameAs(p Provider, model, sent string) string
- func UpstreamNameAsIn(wires map[string]string, pid, model, sent string) string
- func UpstreamNameIn(wires map[string]string, pid, model string) string
- func UsageClaudeVia(f func(ctx context.Context) (string, error))
- func UseKey(id, keyRef string) error
- func UsedUp(q SubscriptionQuota) bool
- func Verification(b []byte) (link string, ok bool)
- func VerifyMessage(said, link string) string
- func Via(ctx context.Context, id string) context.Context
- func ViaLogin(ctx context.Context, id, user string) context.Context
- func ViaSignedIn(ctx context.Context, id string) context.Context
- func VisibleTo(agent string) ([]string, bool)
- func WatchQuotas(ctx context.Context, wake <-chan struct{}, send func(QuotaAlert))
- func WithAutoPicks(ctx context.Context, onPick func(model string)) (context.Context, func() []AutoPick)
- func WithAutoPrompt(ctx context.Context, prompt string) context.Context
- func WithCapped(m map[string]SubscriptionQuota) map[string]SubscriptionQuota
- func WithMemberEffort(model, effort string) string
- func WorkBuddyBaseForTest(cn, ai string) func()
- func ZedBody(body []byte) []byte
- func ZedCloud() string
- func ZedProviderOf(user, model string) string
- func ZedToken(ctx context.Context, user string, renew bool) (string, error)
- type Account
- type Allowance
- func (a Allowance) CapHeld(model string, cap int, now time.Time) (held bool, used float64, back time.Time)
- func (a Allowance) Count(model string, now time.Time) (amount, of float64, unit string)
- func (a Allowance) For(model string, now time.Time) (used float64, renews []time.Time)
- func (a Allowance) Full(model string, share float64, now time.Time) time.Time
- func (a Allowance) Pace(model string, now time.Time) (pace float64, due time.Time)
- func (a Allowance) Pooled(model string, share float64, now time.Time) bool
- func (a Allowance) Renewal(model string, now time.Time) []time.Time
- func (a Allowance) Restarts(now time.Time) time.Time
- type AppImport
- type AppPick
- type AppSource
- type AutoPick
- type BalancePart
- type ClaudeLimit
- type CodexWarm
- type DailyCredits
- type DayCredits
- type Detection
- type DevinFamily
- type Entry
- func Catalog() []Entry
- func CatalogFor(agent string) (shown, hidden []Entry)
- func Deciders() []Entry
- func EntryOf(id string) (Entry, bool)
- func InOrder(agent string, es []Entry) []Entry
- func ListedFor(agent string) (listed, kept []Entry)
- func Served() []Entry
- func ServedEntryOf(id string) (Entry, bool)
- func Unlisted() []Entry
- type Exclusion
- type Group
- type ImportedAccount
- type KeyAccount
- type KeyInfo
- type KeyRest
- type Kind
- type KiroAuth
- type Limit
- type Login
- type Member
- type Migration
- type ModelDetection
- type ModelPref
- type MoveCandidate
- type MoveWhy
- type Moving
- type PatternHit
- type PresetDef
- type Protocol
- type Provider
- func Accounts() []Provider
- func All() []Provider
- func Find(id string) (*Provider, error)
- func FromPreset(id string) (Provider, error)
- func Hidden() []Provider
- func ParseImport(link string) (Provider, error)
- func Resolve(id string) (Provider, string, bool)
- func RouteDecider(model string) (Provider, string, error)
- func Stored() ([]Provider, error)
- func SwitchedOff(id string) (Provider, bool)
- func (p Provider) APIs(model string) []Protocol
- func (p Provider) AccountCap(user string) int
- func (p Provider) AccountConcurrencyOf(ref string) (int, bool)
- func (p Provider) AccountRefOf(ref string) (string, bool)
- func (p Provider) AccountRefs() []string
- func (p Provider) AccountServes(ref, model string) bool
- func (p Provider) AlsoOn() []Provider
- func (p Provider) AskSystemOne(ctx context.Context, model string) error
- func (p Provider) AsksDecideModels() bool
- func (p Provider) AutoNext(ctx context.Context) string
- func (p Provider) Available() []catalog.Model
- func (p Provider) Base(proto Protocol) string
- func (p Provider) Catalogs() []string
- func (p Provider) Chosen(id string) bool
- func (p Provider) ClinePin(model string) string
- func (p Provider) ClinePinnable() bool
- func (p Provider) Concurrency() int
- func (p Provider) ContextOf(model string) int
- func (p Provider) DecideModelURL(ctx context.Context, model string) (string, error)
- func (p Provider) DecideOnly() bool
- func (p Provider) DecideURL(ctx context.Context) (string, error)
- func (p Provider) DecideVia() string
- func (p Provider) Decides() bool
- func (p Provider) DecidesModel(model string) bool
- func (p Provider) DecisionModels() []catalog.Model
- func (p Provider) Detect(ctx context.Context, base, model string) ([]Detection, error)
- func (p Provider) DetectDecide(ctx context.Context, model string) Detection
- func (p Provider) DetectModels(ctx context.Context, base string, models []string) ([]ModelDetection, []Detection, error)
- func (p Provider) Do(client *http.Client, req *http.Request) (*http.Response, error)
- func (p Provider) Efforts(model string) []string
- func (p Provider) Explain(msg string, status int, body []byte) string
- func (p Provider) Exposed() []catalog.Model
- func (p Provider) Fetch(ctx context.Context) ([]catalog.Model, error)
- func (p Provider) Fetched() (time.Time, bool)
- func (p Provider) Host() string
- func (p Provider) IsAzure() bool
- func (p Provider) IsBedrock() bool
- func (p Provider) IsCline() bool
- func (p Provider) IsKilo() bool
- func (p Provider) IsOpenCode() bool
- func (p Provider) IsPlugin() bool
- func (p Provider) IsRemoteMagpie() bool
- func (p Provider) Jev() string
- func (p Provider) KeyList() []KeyInfo
- func (p Provider) KeysOn() []KeyAccount
- func (p Provider) Known(model string) []string
- func (p Provider) LaneLimit() int
- func (p Provider) Levelless(model string) bool
- func (p Provider) List(ctx context.Context) ([]catalog.Model, error)
- func (p Provider) ListError() string
- func (p Provider) ListPrice(model string) (catalog.Price, bool)
- func (p Provider) Listed() (time.Time, bool)
- func (p Provider) ListedAPIs(model string) []Protocol
- func (p Provider) LoginRanks() map[string]int
- func (p Provider) ModelAPI(model string) (Protocol, bool)
- func (p Provider) ModelEfforts() map[string][]string
- func (p Provider) ModelNames() map[string]string
- func (p Provider) ModelTest() string
- func (p Provider) Native(model string) Protocol
- func (p Provider) On() bool
- func (p Provider) OpenCodeFree(model string) bool
- func (p Provider) Origin(ctx context.Context) string
- func (p Provider) OwnPaused() bool
- func (p Provider) PluginConcurrency() int
- func (p Provider) PluginProvider() string
- func (p Provider) Prepare(body []byte) []byte
- func (p Provider) ProxyChoice() string
- func (p Provider) Ready() bool
- func (p Provider) Refetch(ctx context.Context) ([]catalog.Model, []string, error)
- func (p Provider) RejectsTemperature(model string) bool
- func (p Provider) ReplyLimit(m catalog.Model) int
- func (p Provider) ResolveAuto(ctx context.Context, model string) (context.Context, string, error)
- func (p Provider) ResponsesFirst(model string) bool
- func (p Provider) RestKey(k KeyInfo) string
- func (p Provider) Retries() bool
- func (p Provider) Retry(ctx context.Context, sent []byte, status int, body []byte) bool
- func (p Provider) Serves(k KeyAccount, model string) bool
- func (p Provider) Sign(ctx context.Context, req *http.Request, proto Protocol, body []byte) error
- func (p Provider) Speaks() []Protocol
- func (p Provider) Test(ctx context.Context) []Result
- func (p Provider) TestModels(ctx context.Context, models []string) []Result
- func (p Provider) UpstreamNames() map[string]string
- func (p Provider) Via(ctx context.Context) context.Context
- func (p Provider) Where() string
- func (p Provider) WindowOf(m catalog.Model) int
- func (p Provider) WithKey(k KeyAccount) Provider
- type Quota
- type QuotaAlert
- type QuotaHistory
- type QuotaLine
- type QuotaPoint
- type QuotaSpan
- type QuotaWindow
- type Region
- type Renewal
- type ResetCredits
- type ResetOutcome
- type Result
- type Rule
- type RuleRequest
- type SearchAPI
- type SearchVendor
- type SessionIdentity
- type SignInState
- func SignInStatus(id string) (SignInState, bool)
- func StartPluginSignIn(id string, method int, inputs map[string]string) (SignInState, error)
- func StartSignIn(agent string) (SignInState, error)
- func StartSignInAt(agent, site string) (SignInState, error)
- func WaitSignIn(ctx context.Context, id string) (SignInState, error)
- type SignedInError
- type SubscriptionQuota
- func Allotted(ctx context.Context) []SubscriptionQuota
- func KeyBalances(ctx context.Context) []SubscriptionQuota
- func PlanQuotas(ctx context.Context) []SubscriptionQuota
- func Quotas(ctx context.Context) []SubscriptionQuota
- func SubscriptionUsage(ctx context.Context) []SubscriptionQuota
- func WithCheckins(qs []SubscriptionQuota) []SubscriptionQuota
- type TimeWindow
- type WorkBuddyCheckin
- func CheckInMiniMax(ctx context.Context) []WorkBuddyCheckin
- func CheckInTrae(ctx context.Context) []WorkBuddyCheckin
- func CheckInWorkBuddy(ctx context.Context) []WorkBuddyCheckin
- func MiniMaxCheckins() []WorkBuddyCheckin
- func TraeCheckins() []WorkBuddyCheckin
- func WorkBuddyCheckins() []WorkBuddyCheckin
- type ZhipuTeam
Constants ¶
const ( MinCap = 1 MaxCap = 99 )
MinCap and MaxCap bound an account's cap, in percent: none is no cap.
const ( MaxLimit = 1000 MaxQueueLimit = 10000 MaxQueueWait = 3600 )
MaxLimit bounds a limit on requests at once; MaxQueueLimit how many may wait, MaxQueueWait how long one waits, in seconds.
const ( CloudflareJev = "typesafe/jev" CloudflareClefModel = "@cf/cloudflare/clef" CloudflareClefFlash = "@cf/cloudflare/clef-flash" )
const ( ViaSystemOne = "systemone" ViaVercel = "vercel" ViaVercelEval = "vercel-eval" ViaCloudflare = "cloudflare" )
The ways a decision API is asked, by where it is (DecideVia): TypeSafe's own System One; Vercel's AI Gateway, at its TypeSafe API (System One's questions and answers, with its own name for Jev) or, where an older setup points, at the AI SDK's evaluation models (a boolean for a noul and probabilities for a confidence); or Workers AI (System One's questions and answers, in Cloudflare's envelope and at an account's address).
const ( DetectMax = 30 DetectWide = 8 )
A detection of many models asks at most DetectMax of them, DetectWide requests at a time, each waiting detectWait for its answer.
const ( AffinitySession = "session" AffinityTurn = "turn" AffinityOff = "off" )
const ( MoveMoving = "moving" // under way, or cut short (put back at the next try) MovePlugin = "plugin" // the plugin has the id MovedBack = "back" // the user moved it back: it stays built-in MoveFailed = "failed" // the last try failed: the built-in carries on )
A migration's states.
const ( MiniMaxCodeID = "minimax-code" MiniMaxCodeGlobalID = "minimax-code-global" )
MiniMaxCodeID is the MiniMax Code plugin's provider (the China site), MiniMaxCodeGlobalID its international site's.
const ( SuffixOn = "on" SuffixOwn = "own" SuffixOff = "off" )
The ways the agents' lists name models (SuffixMode): every name with its provider's after it, as by default; all but the names the user gave models (#92); or none (#335).
const ( Ordered = "order" Rotate = "rotate" LeastUsed = "usage" Pace = "pace" // Weighted spreads a provider's requests over its keys by each key's // weight (KeyAccount.Weight, #841), smoothly: 3 and 1 go a, a, b, a… Weighted = "weight" )
The routings besides the default, smart, in order.
const ( CheckinClaimed = "claimed" // claimed by magpie CheckinDone = "done" // in already, pressed in WorkBuddy or before CheckinIneligible = "ineligible" // the account can't take part CheckinInactive = "inactive" // no event running, or it has ended CheckinFailed = "failed" // no answer; tried again later that day )
What came of a day's check-in, WorkBuddyCheckin.Outcome.
const AntigravityRisk = "Google may suspend an Antigravity account it sees used outside Antigravity. Use one you can afford to lose."
AntigravityRisk is what magpie says before an Antigravity account is added.
const AutoFallback = "fallback"
AutoFallback is an Auto pick that is the model the account may pick by hand, Copilot having no Auto session to give it (copilotAutoFallback).
const AzurePreset = "azure"
AzurePreset is the preset's id.
const BailianDecision = "decision-model-preview"
BailianDecision is Alibaba Cloud Bailian's decision model, asked on the same System One API as Jev (#647).
const BlockedHint = "the provider's network firewall blocked requests from this IP; wait a while, or switch to another network or proxy"
BlockedHint is what a vendor's edge firewall blocking magpie's address means, in plain words: Alibaba Cloud's (ESA, in front of zcode.z.ai) answers a 405 HTML page, "Sorry, your request has been blocked due to unusual activity", linking errors.aliyun.com. Nothing in the request is at fault and magpie changes nothing about it: the address is.
const ClaudeRisk = "" /* 228-byte string literal not displayed */
ClaudeRisk is what magpie says before a Claude account is added, as the window does.
const ClineVersion = "3.5.54"
ClineVersion is the Cline desktop release magpie says it is to the Cline API.
const CodexDaemonRestart = "codex app-server daemon restart"
CodexDaemonRestart is the command that restarts Codex's app-server, for the user to run themselves.
const CommandCodeMaxOutput = 200_000
CommandCodeMaxOutput is the most max_tokens Command Code takes at /alpha/generate, for any model: more is refused ("Too big: expected number to be <=200000 at params.max_tokens"). models.dev gives some of its models more (DeepSeek V4's 384000, MiniMax M3's 512000).
const CommandCodePlanID = "commandcode-plan"
CommandCodePlanID is the subscription's id, and its sign-in's.
const ContextSmallest = -1
Group is a routing group. ContextSmallest is a group's Context when agents are told the window of its smallest member.
const ConversationHeader = "X-Magpie-Conversation"
ConversationHeader carries the conversation a request belongs to, to a plugin's chat.headers hook as its session; it goes no further.
const CopilotAuto = "auto"
CopilotAuto is the model id that has Copilot pick the model.
const DrawersHeader = "X-Magpie-Drawers"
DrawersHeader asks a magpie's model list for its image models as well.
const EffortAuto = "auto"
EffortAuto is a group whose classifier picks each turn's reasoning effort (Group.Effort).
const FastWord = "fast"
FastWord is the last part of a member typed to be sent fast.
const FreshPace = 100 / (7 * 24.0)
FreshPace is the pace of an account with a whole week ahead of it: what one not known counts as.
const GroupPrefix = "group/"
GroupPrefix starts a group's id in the catalog: "group/<id>".
const JevLatest = "jev-latest"
JevLatest is the Jev a decision provider is asked with when the user picked none: TypeSafe's latest stable one.
const KiloVersion = "7.8.3"
KiloVersion is the Kilo CLI release magpie says it is to the Kilo Gateway.
const Manual = "manual"
Manual is a group's routing when the user picks which member it uses, as CC Switch has one provider on at a time (#317): every request goes to the member picked (Group.Pick), over its own keys or accounts; the others, and the rules, wait until another is picked or the group is routed otherwise. The pick is changed on the group's card, in a click.
const MaxIcon = 1 << 20
MaxIcon is the largest picture magpie keeps for a provider.
const MaxIntent = 200
MaxIntent is how long an intent may be, in characters.
const MaxKeyWeight = 1000
MaxKeyWeight is the most a key's weight can be.
const MiMoID = "mimo-app"
MiMoID is the MiMo subscription's id, as a provider and in logins.json.
const OpenCodeAnonymousKey = "public"
OpenCodeAnonymousKey is the key OpenCode asks Zen with when no one is signed in to it, which Zen's free models answer.
const OpenCodeStub = "Not available in this session. Never call this tool."
OpenCodeStub describes a tool offered only for Zen's free tier to see, which the client doesn't have.
const OpenCodeVersion = "1.18.34"
OpenCodeVersion is the OpenCode release magpie says it is to OpenCode's gateway. Zen's free tier turns away anything older than 1.18.0 (426 "OpenCode 1.18.0 or newer is required to use the free tier").
const OpenRouterJev = "~typesafe/jev-latest"
Cloudflare's own decision models on Workers AI (ARNO on Discord): Clef and Clef Flash answer System One's questions as Jev does, but each is run at its own address (…/ai/run/@cf/cloudflare/clef) and takes the request as it is, its model named "clef" or "clef-flash", where Jev is a run of typesafe/jev with the questions as its input. OpenRouterJev is Jev as OpenRouter names it, the latest one.
const QoderCNID = qoder.CNProviderKey
QoderCNID is the Qoder CN subscription's id, the same as Qoder CN's agent.
const RegexpPrefix = "re:"
RegexpPrefix starts a member that is a regular expression over the whole "provider/model" id: "re:openrouter/.*:(free|beta)".
const RemoteMagpiePreset = "remote-magpie"
RemoteMagpiePreset is the preset's id.
const Scheme = "magpie"
Scheme is the URL scheme magpie registers with the system.
const SignInHeader = "X-Magpie-Sign-In"
SignInHeader is how a plugin says what its answer means for the account's sign-in, whatever its status, so it can answer with the status its built-in did: "expired" marks the account lapsed, as a built-in whose vendor refused the sign-in marked it, though the status be a 502; "kept" leaves the account as it is, as a built-in answering a 401 of the vendor's without its sign-in refused did; "renewed" clears the mark, as a built-in whose sign-in renewed took it off whatever the request then met. Without it a 401 marks the account and a success clears the mark.
SpentShare is the share of an allowance past which an account is all but used up: Smart routing keeps it for when no other can take a request, and the agent signed in to it is signed in to another.
const TraeCNID = "trae-cn"
TraeCNID is the Trae CN plugin's provider.
const UnknownRuleWord = "unknown "
UnknownRuleWord starts the error for a word ParseRule doesn't know.
const VideomakersHeader = "X-Magpie-Videomakers"
VideomakersHeader asks a magpie's model list for its video models as well: a magpie that doesn't send it would take grok-imagine-video, whose id says "imagine", for an image model.
const WBRefusedHint = "" /* 147-byte string literal not displayed */
WBRefusedHint is what the user can do about WorkBuddy's "Illegal API invocation from an unapproved channel": both builds (the CodeBuddy plan) answer it to a chat whose system prompt is Codex's or Claude Code's own (#182), whatever the headers. magpie never rewrites that prompt; the agent is told to use WorkBuddy from another agent instead.
const WorkBuddyAIID = "workbuddy-ai"
WorkBuddyAIID is WorkBuddy AI's subscription, the international build's.
const WorkspaceID = "{WorkspaceId}"
WorkspaceID stands in a decision API's address for the user's Bailian workspace id (#647), which the editor and `workspace=` fill in.
const ZCodeStartBlockedHint = "" /* 248-byte string literal not displayed */
ZCodeStartBlockedHint is what the Start Plan's "request has been blocked due to unusual activity" (HTTP 405, code 3012 "method not allowed") means (#425): zcode.z.ai looks at what a request carries and turns away one that isn't the ZCode app's own, its system prompt and all, as zcode2api found, so magpie sends it as the app does (zcode_client.go). One turned away still is Alibaba Cloud's firewall blocking the address (BlockedHint), or ZCode checking for something magpie doesn't send.
Variables ¶
var ( ZCodeZaiBase = "https://api.z.ai/api/anthropic" ZCodeBigModelBase = "https://open.bigmodel.cn/api/anthropic" )
Where ZCode's coding plan and its sign-in are; vars so tests can point them elsewhere.
var Affinities = []string{"", AffinitySession, AffinityTurn, AffinityOff}
Affinities are how long a conversation stays with the key or account that answered it: "" auto, as long as what the vendor cached of it is worth keeping; for the whole session; within a turn only, free to move when the user speaks again; or never.
var AllBuilt atomic.Int64
AllBuilt counts the times All built the list anew, for tests.
var ClaudeHandedOver func(user string)
forgetClaudeDir removes a saved account's config directory altogether. ClaudeHandedOver is told of a saved Claude account switched in to Claude Code itself, whose directory forgetClaudeDir has just removed: a Claude Code still running there (the gateway's, waiting for its conversation's next turn) holds the refresh token that is Claude Code's own now, and a refresh of it there would leave Claude Code's copy refused, the account signed out (0xAncientTwo on X). The gateway sets it.
var CodexBase = "https://chatgpt.com/backend-api/codex"
CodexBase is where a ChatGPT account's Codex requests go; a var so tests can point it elsewhere.
var CopilotTokenURL = "https://api.github.com/copilot_internal/v2/token"
CopilotTokenURL trades the GitHub OAuth token for a short-lived Copilot session token; a var so tests can point it elsewhere.
var CopilotUserURL = "https://api.github.com/copilot_internal/user"
CopilotUserURL says where an account's Copilot API is; a var so tests can point it elsewhere.
var CursorExecutable = func() string { for _, name := range []string{"cursor-agent", "agent"} { if p, err := exec.LookPath(name); err == nil && (name == "cursor-agent" || isCursorAgent(p)) { return p } } home, _ := os.UserHomeDir() for _, p := range []string{filepath.Join(home, ".local", "bin", "cursor-agent"), "/usr/local/bin/cursor-agent", "/opt/homebrew/bin/cursor-agent"} { if st, err := os.Stat(p); err == nil && !st.IsDir() { return p } } return "" }
CursorExecutable finds the cursor-agent CLI; a var so tests can fake it.
var Described func() bool
Described is set by the gateway: whether an image sent to a model that can't see is described to it by one that can (Settings › Vision). Agents are then told every model takes images; told a model is text-only, they turn the user's image away before magpie is asked (Codex: "does not support image input").
var DevinExecutable = func() string { if p, err := exec.LookPath("devin"); err == nil { return p } home, _ := os.UserHomeDir() for _, p := range []string{filepath.Join(home, ".local", "bin", "devin"), "/usr/local/bin/devin", "/opt/homebrew/bin/devin"} { if st, err := os.Stat(p); err == nil && !st.IsDir() { return p } } return "" }
DevinExecutable finds the devin CLI; a var so tests can fake it.
var Efforts = []string{"low", "medium", "high", "xhigh", "max"}
Efforts are the reasoning levels a rule can ask for, lowest first.
var ErrMiMoSignIn = errors.New("the Xiaomi MiMo sign-in has expired — sign in again")
ErrMiMoSignIn is an account Xiaomi no longer signs in: it must be signed in again.
var ErrNoURL = errors.New("type the base URL first")
ErrNoURL is a detection with no URL to ask at.
var ErrQoderSignIn = errors.New("Qoder sign-in")
ErrQoderSignIn is under every error that says the Qoder sign-in itself is gone — not signed in, unreadable, or its refresh refused — as against a refresh that timed out or never reached Qoder, which may pass.
var ErrUnreadable = errors.New("providers.json can't be read")
ErrUnreadable is a providers.json that is there but can't be read or decoded: never an empty catalog, to list as none, back up or write over.
var ErrZedSignIn = errors.New("the Zed sign-in has expired — sign in again")
ErrZedSignIn is an account Zed no longer takes: it must be signed in again.
var GitHubUserURL = "https://api.github.com/user"
GitHubUserURL says whose a GitHub token is; a var so tests can point it elsewhere.
var GrokBase = "https://cli-chat-proxy.grok.com/v1"
GrokBase is the CLI's backend; a var so tests can point it elsewhere.
var GrokExecutable = func() string { home, _ := os.UserHomeDir() path := append(filepath.SplitList(os.Getenv("PATH")), registryPath()...) for _, c := range grokCandidates(runtime.GOOS, home, GrokHome(), appdir.Getenv("GROK_BIN_DIR"), path) { if isFile(c.path) && (c.own || isGrokBuild(c.path)) { return c.path } } return "" }
GrokExecutable finds the Grok Build CLI; a var so tests can fake it.
var KiroExecutable = func() string { if p, err := exec.LookPath("kiro-cli"); err == nil { return p } home, _ := os.UserHomeDir() for _, p := range []string{filepath.Join(home, ".local", "bin", "kiro-cli"), "/Applications/Kiro CLI.app/Contents/MacOS/kiro-cli", "/usr/local/bin/kiro-cli", "/opt/homebrew/bin/kiro-cli"} { if st, err := os.Stat(p); err == nil && !st.IsDir() { return p } } return "" }
KiroExecutable finds kiro-cli, which refreshes its own sign-in; a var so tests can fake it. The installer puts it in ~/.local/bin, and on macOS inside Kiro CLI.app as well.
var Levels = []string{"none", "minimal", "low", "medium", "high", "xhigh", "max"}
Levels are the reasoning levels a model whose own aren't known can be given.
var MemberEfforts = []string{"none", "minimal", "low", "medium", "high", "xhigh", "max"}
MemberEfforts are the levels a group's member may be fixed at, lowest first: the words agents and vendors use for reasoning effort.
var OnSubscriptionUsage func()
OnSubscriptionUsage is told when a refresh has landed, for what shows a stale copy meanwhile (the menu bar's text) to read the new one.
var OpenCodeTools = []string{"bash", "read"}
OpenCodeTools are the tools Zen's free tier wants offered, by name.
var Protocols = []Protocol{Chat, Responses, Anthropic}
Protocols in the order magpie prefers them when it has to translate.
var Retiring = []string{}
Retiring are the built-ins magpie moves onto their plugins by itself, at start-up; the rest move only when the user asks.
var SearchVendors = []SearchVendor{
{ID: "tavily", Name: "Tavily", Base: "https://api.tavily.com", KeysURL: "https://app.tavily.com/home"},
{ID: "brave", Name: "Brave Search", Base: "https://api.search.brave.com", KeysURL: "https://api-dashboard.search.brave.com/app/keys"},
{ID: "exa", Name: "Exa", Base: "https://api.exa.ai", KeysURL: "https://dashboard.exa.ai/api-keys"},
{ID: "firecrawl", Name: "Firecrawl", Base: "https://api.firecrawl.dev", KeysURL: "https://www.firecrawl.dev/app/api-keys"},
{ID: "searxng", Name: "SearXNG"},
}
SearchVendors are the search APIs magpie can ask, in the order offered.
var Weekdays = []string{"sun", "mon", "tue", "wed", "thu", "fri", "sat"}
Weekdays are the days a TimeWindow names, as time.Weekday counts them.
Functions ¶
func APIError ¶
APIError pulls the human message out of an error body when there is one. A firewall's block page is put in plain words (BlockedHint); Google's "verify your account" refusal also says what to do about it, with the link it gave.
func AccountCapOf ¶ added in v0.1.809
AccountCapOf is AccountCap of the provider id, 0 when there is none.
func AccountModelsOf ¶ added in v0.1.610
AccountModelsOf is the models the account or key ref of the provider id alone serves, and the account or key as AccountModels knows it; no models when it serves all the provider's.
func Add ¶ added in v0.1.50
Add saves a provider the user just added, beside those already here: an id in use — the preset's, or the one its name slugs to — moves on to the next free one (anthropic-2), and a name in use gets the same number, so a second key of a vendor, or one key for another workspace, is a provider of its own rather than one replacing the first. It answers the id saved.
func AddCopy ¶ added in v0.1.455
AddCopy adds p, a copy the user made of the provider from (#268), beside it: what the form doesn't carry — the keys, the balance token, how requests spread over the keys, where they fall back to — is from's where p leaves it out. The same key on the same host is taken, the copy being asked for (another model list, another endpoint). A signed-in account is never copied: its sign-in is the agent's.
func AddKey ¶ added in v0.1.14
AddKey saves one more key for a provider, on: it takes requests after the ones before it. It becomes the first when the provider has none.
func AddKeys ¶ added in v0.1.930
AddKeys saves several keys at once, on, after the ones the provider has, with the protocol given: those it has already are passed over. added is how many were new, had how many it had.
func Adopt ¶ added in v0.1.642
Adopt puts the built-in id onto its plugin before any account of it is signed in: the plugin installed, and the subscription signs in through it from now on, as a moved one does. One with accounts is moved instead.
func AgentUser ¶ added in v0.1.683
AgentUser is who an agent is signed in to itself, as its own files say, for an agent whose vendor a plugin serves too; "" when not known.
func Allowances ¶ added in v0.1.29
Allowances is each of an agent's accounts' allowance by user, as last known, asked for again in the background when that was over a minute ago. Only the very first ask waits, and not for long. An account missing is one not known yet.
func AntigravityBase ¶ added in v0.1.299
AntigravityBase is the model magpie offers for one of Antigravity's ids at a level ("gemini-3.7-flash-low" is gemini-3.7-flash at low), and that level; ok is false for an id that is itself a model magpie offers, or that no family has. Picks and agents' models saved before the families were one model still name these ids.
func AntigravitySentID ¶ added in v0.1.560
AntigravitySentID is the id a request for model goes out under at that effort on an Antigravity account: the variant of the family the effort picks, at the level of that family nearest the effort asked for; with no effort asked for, the family's own default. One of the family's own variant ids — an id a pick or an agent's model list kept from before the families were one model — goes as it is when no effort is asked for, and at the level the effort picks otherwise, since the effort the client asks for wins, as it does for the family. Any other id goes as it is.
The gateway sends the envelope under this and the ledger judges what the vendor answered against it, so there is one of it rather than one each: a reply naming the id a call went out under is that model answering, and read against the family instead every level of it reads as another model having swapped in, in the routing view and in the ledger alike.
func AntigravityVariants ¶ added in v0.1.299
AntigravityVariants are Antigravity's ids a model magpie offers stands for, by level, "" the default; ok is false for a model that stands for none, which goes to Antigravity as it is.
func AnyPriceKey ¶ added in v0.1.581
AnyPriceKey is the key a price for a model from any provider is stored at: its id lower-cased, the way a session's bare model is looked up.
func ApplyImage ¶ added in v0.1.413
ApplyImage is what magpie tells of model: the user's answer when they gave one, else images as the vendor's list has it (known is that list's explicit answer, nil when it didn't say).
func AskClaudeUsage ¶ added in v0.1.558
func AskClaudeUsage()
AskClaudeUsage is the user asking to see Claude's usage — opening the Usage page, refreshing it, `magpie quota` — so Claude Code's /usage is run at once rather than when the next unasked reading is due (claudeUsageWait); the next SubscriptionUsage waits for it.
func AskUsage ¶ added in v0.1.791
func AskUsage()
AskUsage has the next SubscriptionUsage wait for a new reading rather than hand back the last one, as AskClaudeUsage does, without having Claude Code's /usage run: magpie quota wait reads again each time it wakes, and only a wait for Claude needs Claude read.
func AuthHeaders ¶
AuthHeaders is how a request to the vendor proves who it is. Anthropic's own API wants x-api-key alone, and so does Bedrock's, which turns away a request with both (#176); other compatible vendors take either, so both. Azure OpenAI takes a key in api-key alone: a Bearer there is an Entra ID token, and the key sent as one is turned away.
func AutoGroupID ¶ added in v0.1.603
AutoGroupID is the id of the group magpie finds for a model, however a vendor spells it: "auto-claude-opus-5-5" for claude-opus-5.5.
func AutoGroupOf ¶ added in v0.1.673
AutoGroupOf is the id of the group magpie finds for a provider's model: AutoGroupID of the model the user said it is the same as (settings' ModelSameAs), else of its own id.
func AutoGroupsOn ¶ added in v0.1.603
func AutoGroupsOn() bool
AutoGroupsOn reports whether magpie finds groups on its own: a model more than one provider serves is a group of them (autoGroups). It is on until the user turns it off.
func AutoResets ¶ added in v0.1.514
AutoResets says whether agent's account user spends its resets by itself; only a Codex account does.
func AutoStandIn ¶ added in v0.1.603
AutoStandIn is the model a request for a group magpie found goes to while such groups are off (SetAutoGroups): its model, from the first provider that serves it, as "provider/model". An agent set to the group, or a session begun on it, keeps working, on one provider. ok is false for any other id, a group the user has of that id, or while found groups are on.
func AzureBase ¶ added in v0.1.419
AzureBase is the v1 API base of the resource an endpoint names, as it was pasted from the portal or another app — the bare resource (https://r.openai.azure.com), …/openai, …/openai/v1, a classic deployment's URL with its api-version, or only the resource's name — and ok false when it names no Azure resource.
func BackAt ¶ added in v0.1.791
func BackAt(q SubscriptionQuota, now time.Time) time.Time
BackAt is when a used-up account has room again: when the last of the windows that stop it (usedUp's) starts again, a window's seconds to go counted from now. Zero when one of them doesn't say.
func Balance ¶ added in v0.1.37
Balance asks the vendor what is left on the provider's key in use. ok is false when there is no way to ask it.
func BalanceNumber ¶ added in v0.1.540
BalanceNumber is the amount a balance as a vendor tells it holds: "$12.34", "¥1,024.50", "CNY 8", "12.3k credits". A share ("45%"), or text with no number, is none.
func BoundCallID ¶ added in v0.1.887
BoundCallID is a call's id as the ChatGPT backend takes one: as it is when it fits its 64 characters, else the sha256 of it (trimmed, as calls and their outputs are paired), 64 hex characters. Foreign providers can join two ids into one longer than that (#732, congee949: 86 and 87); the same id gives the same hash on every request, so a call and its output stay paired, and two ids that differ are never cut down alike.
func CCSwitchSkillOrigin ¶ added in v0.1.83
CCSwitchSkillOrigin is the GitHub repository (owner/name) and branch CC Switch installed the skill in its folder dir from, as its database records it.
func CCSwitchSkillsDir ¶ added in v0.1.83
func CCSwitchSkillsDir() string
CCSwitchSkillsDir is the folder CC Switch keeps the skills it installs in.
func CanFast ¶ added in v0.1.577
CanFast reports whether model, as p serves it, has a fast mode magpie can ask for: a ChatGPT account's GPT models (Codex's Fast), Cursor's models with a -fast one, an OpenAI key's GPT and o-series models on its Responses API (priority processing), and an Anthropic key's Opus models with fast mode. A Claude subscription runs Claude Code itself, and a relay or a cloud (Bedrock, Vertex) may refuse the field, so neither is.
func CancelSignIn ¶ added in v0.1.14
func CancelSignIn(id string)
CancelSignIn stops waiting for the browser.
func Changed ¶ added in v0.1.705
func Changed()
Changed drops what is held: a provider, an account, a plugin or a setting was written.
func CheckQueue ¶ added in v0.1.1009
CheckQueue says what is wrong with a queue's bound or wait, nil when nothing is.
func CheckinDay ¶ added in v0.1.778
CheckinDay is the day (Beijing, "2006-01-02") WorkBuddy's check-in counts t in: a WorkBuddyCheckin of that Day is today's.
func ClaudeCodeMovedOff ¶ added in v0.1.648
ClaudeCodeMovedOff says Claude Code itself is signed in to another account than user now: what a Claude Code run in its own home says of the account it is on is no longer user's. false when it can't be told.
func ClaudeFast ¶ added in v0.1.577
ClaudeFast reports whether a Claude model has fast mode.
func ClaudeInWSL ¶ added in v0.1.834
func ClaudeInWSL() string
ClaudeInWSL is the WSL distro the gateway runs Claude Code in, when there is none on Windows itself and one was found there; "" otherwise. It never waits on WSL: until a look has been made, one starts and "" comes back.
func ClaudeLoginVersion ¶ added in v0.1.788
ClaudeLoginVersion is the credential the saved Claude account user has now, which a run started on it goes by (NoteClaudeSignInFailure).
func ClaudeSignInRequired ¶ added in v0.1.788
ClaudeSignInRequired says message is Claude Code's, or magpie's, word that a Claude sign-in is gone and has to be made again: not a failure of the moment, as a network error or another Claude Code holding the refresh is ("Failed to refresh OAuth token: another Claude Code process is refreshing it").
func ClaudeWarmed ¶ added in v0.1.223
ClaudeWarmed is when magpie last started a window of each Claude account, by user as kept (lower-cased).
func CleanLevels ¶ added in v0.1.477
CleanLevels are the reasoning levels a group names for itself (Group.Levels) as they are kept: lowercase, each once, lowest first. Only the levels magpie knows are taken.
func CleanPatterns ¶ added in v0.1.826
CleanPatterns are a group's patterns as they are kept: trimmed, each once, every one one magpie can read.
func ClineClient ¶ added in v0.1.630
ClineClient makes a request to the Cline API carry the desktop app's headers.
func CloudflareClef ¶ added in v0.1.859
CloudflareClef reports whether model is one of Cloudflare's Clef models.
func CodexAutoReset ¶ added in v0.1.507
CodexAutoReset says whether the Codex account user spends a reset by itself once its week is used up.
func CodexDaemonStale ¶ added in v0.1.368
func CodexDaemonStale() string
CodexDaemonStale answers the account Codex's app-server is still signed in to when Codex has been switched to another since it started, "" when it isn't running or is on the account Codex is.
func CodexListTag ¶ added in v0.1.460
func CodexListTag() string
CodexListTag names the list Codex is handed, for its ETag: magpie's models, the account's own taken out of it, the order they are in, the windows set on them, and whether its OpenAI models say multi-agent V1 (settings.CodexAgentsV1), so any of them changing has Codex ask for the list again.
func CodexListed ¶ added in v0.1.54
CodexListed is the catalog as a Codex signed in to ChatGPT is handed it, after the backend's own models: all but a ChatGPT account's in magpie, which the backend lists already. A group answers for its first member but is not that provider's.
func CodexNativeHidden ¶ added in v0.1.460
CodexNativeHidden is the ChatGPT account's own model slugs the user took out of Codex's list (HiddenModels): the backend lists them, and the gateway drops them from its /models answer as it does the ones not picked.
func CodexNativePicked ¶ added in v0.1.292
CodexNativePicked is the set of the ChatGPT account's own model slugs the user kept, and whether they narrowed that list at all. The backend lists every model the account can reach; when the user has picked among them on the codex provider, the gateway keeps its /models answer to those (see codexModels). Not narrowed — the account's list is left whole.
A provider switched off picks nothing, as it serves no agent anything (Provider.Off): its picks are kept for when it is switched on again and are not a narrowing now.
func CodexNativeWindow ¶ added in v0.1.757
CodexNativeWindow is the context window Codex is handed for one of the ChatGPT account's own models, by the backend's slug, and the most it may be raised to (0: as the entry says): the window the user set on the codex provider (Provider.ContextOf), as /v1/models says it (#674). ok is false for a model the user set none for, whose entry keeps the backend's window — unless restore, for an entry not fresh from the backend: Codex's models_cache.json keeps what magpie last handed it, a window since taken away among it, so such an entry takes the account's own list's again.
func CodexOrder ¶ added in v0.1.952
CodexOrder is where each model of Codex's list goes when the user put them in an order of their own on the Agents page (#855), by the slug Codex knows it by — a ChatGPT account's own by its bare one, as the backend lists it — and whether they did. A model it doesn't name keeps its place after them.
func CodexOwn ¶ added in v0.1.952
CodexOwn reports whether e is one of a ChatGPT account's own models, which the ChatGPT backend lists to Codex by its bare slug (e.Model).
func CodexSignedIn ¶ added in v0.1.507
CodexSignedIn is the ChatGPT account Codex is signed in to now.
func CodexUsedUp ¶ added in v0.1.44
CodexUsedUp reports whether the ChatGPT account Codex is signed in to has used up its allowance for now; false when that isn't known.
func CodexWarmed ¶ added in v0.1.182
CodexWarmed is when magpie last started a window of each ChatGPT account, by user as kept (lower-cased).
func CommandCodeGenerate ¶ added in v0.1.434
CommandCodeGenerate says whether p is a Command Code account on the Go plan, which is asked at api+"/alpha/generate" in the CLI's own format rather than on the Provider API, with key; ok is false for every other account and provider.
func CommandCodeOutputOf ¶ added in v0.1.612
CommandCodeOutputOf is the most a reply of a Command Code model may be asked for: the model's own limit, as models.dev gives it, within CommandCodeMaxOutput.
func CompactSet ¶ added in v0.1.979
CompactSet is the threshold the user set on a model, by its catalog id ("provider/model", magpie/ and a [1m] mark taken off), or on its provider; for a group, the smallest its models have, so none of them outgrows its own. 0 when none is set: settings.Compact then answers.
func CompactSetIn ¶ added in v0.1.1048
CompactSetIn is CompactSet for a caller that already holds the settings and the group finder: an agent's list is built for hundreds of models at magpie's start, and reading both again for each is what EffectivePriceIn saves the same loop.
func CompactsOf ¶ added in v0.1.979
CompactsOf is the thresholds the user set on a provider's models, by model id, "*" for all of them: what its editor's Compact at shows.
func Confidence ¶ added in v0.1.862
Confidence is how sure a set of probabilities is of its likeliest, as System One gives it: 0 with every option as likely, 1 with one certain (its 0.87 of three options is 0.8).
func CopilotHost ¶ added in v0.1.795
CopilotHost is where a Copilot account signs in, from what a user typed ("acme.ghe.com", "https://acme.ghe.com/", "github.com"): "" for github.com, "<name>.ghe.com" for an enterprise on GHE.com. Nothing else is taken, so a GitHub token is never sent to a host of the user's choosing.
func CopilotRefusal ¶ added in v0.1.914
CopilotRefusal is Copilot saying the account may not call the model it was asked for, which Auto, having picked it, picks another for.
func CursorBase ¶ added in v0.1.297
CursorBase is the model magpie offers for one of Cursor's ids at an effort ("grok-4.7-low" is grok-4.7 at low, "grok-4.7-low-fast" grok-4.7-fast at low), and that effort; ok is false for an id that is itself a model magpie offers, or that no family has. Picks and agents' models saved before the families were one model still name these ids.
func CursorClientVersion ¶ added in v0.1.198
func CursorClientVersion() string
CursorClientVersion is the cursor-agent the API is told it is talking to, "cli-<version>": the installed one, as the API turns away a version it no longer supports.
func CursorToken ¶ added in v0.1.198
CursorToken is the token to call Cursor's API with. One about to run out is renewed by cursor-agent, which does that whenever it runs.
func CursorVariants ¶ added in v0.1.268
CursorVariants are Cursor's ids a model magpie offers stands for, by effort, "" the default; ok is false for a model that stands for none, which goes to Cursor as it is.
func DecideAnswer ¶ added in v0.1.862
DecideAnswer is a gateway's answer as System One gives it: out of Cloudflare's envelope, or, from Vercel's evaluation models (its TypeSafe API answers as System One does), a boolean's probability as a noul, a confidence from the probabilities where there is none, and its usage named as System One names it.
func DecideAsk ¶ added in v0.1.862
DecideAsk is a System One request (body) as via takes it: Vercel's TypeSafe API takes it as it is; its evaluation models name the model in a header and ask a noul as a boolean; Workers AI takes the state and questions as the input of a run of the model, and a Clef there takes the request as it is, its model named as Clef names itself.
func DecideRouteStatus ¶ added in v0.1.411
DecideRouteStatus is the HTTP status a System One request gets for err from RouteDecider: 400 when the model is named badly, 404 when magpie has no such Jev provider.
func Delete ¶
Delete removes a provider. An account, a built-in's or a plugin's, is only hidden from magpie (its accounts and model picks kept, shown again from Hidden or by signing in); signing out is each account's Remove.
func DeleteGroup ¶ added in v0.1.38
DeleteGroup removes a group of the user's; one magpie found is hidden, to come back with ShowGroup. A group another has in it, or classifies with, stays until it is taken out of that one.
func DeleteGroups ¶ added in v0.1.912
DeleteGroups removes several groups at once, as DeleteGroup does each (lc on Discord: they could only be removed one at a time). It is all or none: refused, before any is removed, when one isn't there or a group left holds one as a member or classifier; one held only by another of them goes after it.
func DetectBase ¶ added in v0.1.663
DetectBase is base as proto takes it: an endpoint pasted whole (…/v1/chat/ completions) cut to its base, then the root for Anthropic, which adds /v1/messages itself, and …/v1 for OpenAI's two when base is a bare host — the editor's respellURL, in Go.
func DevinAuth ¶ added in v0.1.175
DevinAuth is the key the CLI signed in with and the server its API is on, read from credentials.toml; WINDSURF_API_SERVER_URL moves the server, as it does the CLI's.
func DevinAuthAt ¶ added in v0.1.386
DevinAuthAt is DevinAuth for the account signed in in home, "" for the CLI's own.
func DevinCredentialsPath ¶ added in v0.1.45
func DevinCredentialsPath() string
DevinCredentialsPath is where the CLI keeps its sign-in.
func DevinNoWait ¶ added in v0.1.424
DevinNoWait marks a context whose caller must not wait on the devin CLI: the window's state, drawn after every click. DevinFamilies then answers with what it knows (or an error while nothing is known) and asks the CLI in the background, so the next state has it.
func DevinOffered ¶ added in v0.1.380
func DevinOffered(families []DevinFamily) []catalog.Model
DevinOffered is Devin's list as an agent's picker offers it: each family one model with the efforts its variants are at, as the provider lists it (devinModels), and Adaptive and Fusion — which Devin's own agent runs, though the API doesn't serve them — as the one model each.
func DevinPick ¶ added in v0.1.380
func DevinPick(families []DevinFamily, model, effort string) string
DevinPick is the id to give Devin's config for a model and effort picked as magpie offers them (DevinSplit the other way round): a family's variant at the effort, or the nearest it has; the family's own id with no effort, so that it keeps following the family's default; a fast run's variant at the effort, or at the family's default one. Any other id goes as it is.
func DevinSplit ¶ added in v0.1.380
func DevinSplit(families []DevinFamily, id string) (model, effort string)
DevinSplit is an id Devin's config holds taken apart as magpie offers it: the model (a family, or a family's fast run) and the effort the id is at. A family's own id is at none — it follows the family's default — and an id no family has at an effort (glm-5-2-1m, one Devin no longer lists) is itself, at none.
func DevinVariant ¶ added in v0.1.175
DevinVariant is the model to ask Devin's API for: a family's name follows its newest model, which the API takes only as one of its variants — the one at the effort asked for, or at the nearest effort the family has; with none asked, the family's default. A family's fast run (claude-opus-5-5-fast) is likewise its fast variant at that effort (claude-opus-5-5-high-fast). A variant's own id (swe-2-medium, one an agent was set to) goes as it is, whatever effort is asked: its id is the effort it runs at.
func DismissCodexDaemon ¶ added in v0.1.368
func DismissCodexDaemon()
DismissCodexDaemon stops saying the app-server is on another account.
func DropContext ¶ added in v0.1.532
DropContext takes a window off one of a provider's models and reports whether there was one there to take away, as DropModelPrice and DropModelOutput do: a removal over a window that is not there leaves the provider in the state it was already in, but only the caller can tell the user so, and a ✓ over a window that was never set says there was one. Nothing is saved in that case, and so the agents are not told either — a provider saved over a window that did not change rewrites every agent's model lists for nothing, which is the one round the removal itself earns.
Save is what tells the agents here (store), so it is the save, and not a Touched of its own, that has to happen exactly once.
func DropModelOutput ¶ added in v0.1.532
DropModelOutput takes a user's reply limit away under the key it is stored at, and hands that key back, so a caller left without a provider to name it by can still say which entry it cleared. It does not ask whether the provider is still there: a reply limit outlives the provider it was set for, and that provider can be deleted — the entry then sits in the settings answering for a model nothing serves, and a removal that resolved the provider first would leave the user no way to take it away, the file being the only other place it is in. Which key that is comes from the spelling as given before anything is looked up (outputKeyOf), so that a provider which has since taken the name of one that is gone is not the one the entry is cleared under. A key holding no limit is no error: there is nothing there to take away, which is the state the entry is left in either way, and writing it out again would rewrite the settings and every agent's model lists over a limit that did not change.
It reports whether there was a limit there to take away, as DropModelPrice does, and by neither saving nor telling the agents when there was none: only the caller can put that to the user, and a ✓ over a limit that was never set says the model had one.
func DropModelPrice ¶ added in v0.1.504
DropModelPrice takes a user's price away under the key it is stored at, without asking whether the provider is still there, and reports whether there was one there to take away. A price outlives the provider it was set for: that provider can be deleted, and `magpie model prices` still lists the price and usage is still counted at it, so a removal that resolved the provider first would leave the user no way to take it away. Which of the keys a price is ever kept under this one is, is PriceKey's to say.
A key holding no price is still no error — there is nothing there to take away, which is the state it is left in either way — but saying so is what tells a mistyped id from a price that was cleared: `magpie model price -- reset` over a price still in the file would have the user believe it gone.
func DropUpstreamName ¶ added in v0.1.560
DropUpstreamName takes a name off under the key it is stored at, and says whether there was one to take. A name outlives the provider it was given for: that provider can be deleted, and the name is then in force for whichever provider takes that id next — its requests would go out renamed to a vendor that never heard of it, and nothing would say so — so a removal that resolved the provider first would leave the user no way to take away the one name doing that. A key holding no name is not an error: there is nothing there to take away, which is the state it is left in either way, and false says so to a caller that has something else to say.
Which key a ref is taken at is wireKey's: the name comes off from where it is really kept, rather than from under whichever provider the ref names now.
func EdgeBlocked ¶ added in v0.1.570
EdgeBlocked says whether an error body is a firewall's block page rather than the vendor's API answering, or one already put in plain words.
func EffectivePrice ¶ added in v0.1.504
EffectivePrice is what a call to a provider's model costs the user: the price they set for that model, or for every model of that provider, or for that model from any provider (settings' ModelPrices), else the provider's own list price, else its maker's, either at the provider's price rate (PriceRate). The second return is false only when no price is known at all, which is not the same as a price of zero: that one is set, deliberately.
A price here is the provider's tariff, not the model's: the same model through two relays is two prices, and neither is what models.dev lists.
func EffectivePriceIn ¶ added in v0.1.504
EffectivePriceIn is EffectivePrice at the settings given, for a caller pricing a whole list of models at one read of the file rather than one read per model: every model of that list is priced at the same copy, so the list is one snapshot of the prices rather than a reading per row, and a price changed while it is read takes effect in the next call.
func EffortFamily ¶ added in v0.1.603
EffortFamily is the model an id with an effort word after it is a level of ("gemini-3.8-flash-medium" is gemini-3.8-flash), and the id itself when it has none.
func EffortsOf ¶ added in v0.1.137
EffortsOf is the reasoning levels one of a provider's listed models has, before any the user left out.
func ErrorType ¶ added in v0.1.579
ErrorType is the kind of error a vendor's body names — the error's type (rate_limit_error, usage_limit_reached), else its code — or "" when it names none: what to set beside the status when a request failed.
func FactoryBaseForTest ¶ added in v0.1.685
func FactoryBaseForTest(api, eu string) func()
FactoryBaseForTest points Factory's API at api, and its EU region at eu, until the returned function runs. A provider built after the call uses them. Tests outside this package use it.
func Families ¶ added in v0.1.111
func Families() []string
Families are the families providers and groups are tagged with, sorted.
func FaviconFor ¶ added in v0.1.186
FaviconFor finds the site behind a provider's base URL and keeps its icon like a picture picked by hand (#12). The API's own host is asked first, then the domains it sits under (api.deepseek.com, then deepseek.com), since an API host seldom has a page of its own. On each, the home page's <link rel="icon"> pictures come before /favicon.ico. Only public https hosts are reached, as for an import link's icon.
A new-api or one-api site names its logo only in /api/status, which its page's script reads to set the tab's icon; the page itself names none, or the panel's own /logo.png, and its /favicon.ico is the panel's too, the same on every such site (wiixdede on X: every relay got new-api's icon). Its logo is taken from there, or one its page was given by hand, and one with neither gets name's first letters on a tile.
func FetchIcon ¶ added in v0.1.21
FetchIcon downloads the picture an import link named and keeps it like any other, returning the Icon value that points at it. It runs when the user confirms the import, never at parse time; the URL is re-checked here so a crafted request can't point magpie at anything but a public https picture, and the read stops one byte past MaxIcon so a huge body is refused rather than buffered.
func FetchNew ¶ added in v0.1.402
FetchNew asks each signed-in account whose vendor list magpie hasn't fetched yet for it, each for at most timeout. Start-up does this for the accounts there then; an account signed in while magpie runs (in magpie or in the agent's own app) otherwise showed magpie's built-in list, fewer models than the vendor serves, until Refresh was clicked (#204). One that fails is asked again after newFetchRetry, not each time.
func FetchNewBehind ¶ added in v0.1.651
FetchNewBehind is FetchNew in the background, started at once unless one started so is still running: for the Providers page, which waited on it (#541: ten seconds and more of placeholders, an account at a time and behind start-up's own run). FetchingNew says when it is done.
func FetchNewSoon ¶ added in v0.1.591
FetchNewSoon is FetchNew in the background, for a page that shouldn't wait on vendors (the panel, whose model picker otherwise kept an account's fallback list until the Providers page was opened). It does nothing while one runs or within newSoonEvery of the last.
func FetchingNew ¶ added in v0.1.651
func FetchingNew() bool
FetchingNew reports whether a FetchNew is under way (start-up's, or one started behind a page): accounts' lists may be on their way still.
func FileError ¶ added in v0.1.587
func FileError() error
FileError is why providers.json can't be read, nil when it can or isn't there: for what lists the providers to say so, not "none yet".
func FindGroup ¶ added in v0.1.38
FindGroup looks a group up by its catalog id ("group/<id>") and resolves its members; one not ready now is left out.
func FlatName ¶ added in v0.1.572
FlatName is the name a namespaced tool is offered to a model under, which takes one flat name: namespace__name, as Codex names an MCP server's tools. A name longer than the 64 characters APIs allow is cut and made unique by a hash of the whole.
func ForgetAccount ¶ added in v0.1.770
ForgetAccount signs a subscription's accounts out of magpie for good, the way past a removal (#694: a removed Qoder came back with its old account each time it was added back, and nothing took it away). A plugin's sign-ins leave plugin-auth.json (the plugin host's signOut when one runs, else under plugin-auth.json.lock) and logins.json, and a moved built-in's backup of them goes too, so moving back doesn't bring them either; a built-in's saved accounts go as each account's Remove takes them. An agent's own sign-in, which magpie only reads, is hidden as Remove hides it. Signing in again starts afresh.
func ForgetAccounts ¶ added in v0.1.362
func ForgetAccounts()
ForgetAccounts makes the next look at the accounts read them afresh, for a caller that changed a sign-in behind magpie's back (a test's home).
func ForgetBalances ¶ added in v0.1.90
func ForgetBalances()
ForgetBalances has the next KeyBalances ask again, after a provider's key or balance token changed.
func ForgetLogin ¶ added in v0.1.11
ForgetLogin drops a remembered account. The one an agent is signed in to now can't be forgotten while it has another to be signed in to; it would only be remembered again (SignedInError). Codex's last one is signed out instead, as `codex logout` does (mamba on Discord: a single Codex account couldn't be removed at all).
func FreeID ¶ added in v0.1.399
FreeID is id, or id-2, id-3… whichever no provider or subscription has.
func GrokHome ¶ added in v0.1.22
func GrokHome() string
GrokHome is where the CLI keeps its sign-in and settings.
func GroupFinder ¶ added in v0.1.133
GroupFinder is FindGroup for looking up many: every provider's models are read once, when the first group is looked up, not again for each.
func GroupFor ¶ added in v0.1.136
GroupFor is the group a model's id without a provider in it names, as "group/<id>": the group of that id, else the group of that model however a vendor spells it ("grok-4.7" is the group grok-4-7 or auto-grok-4-7). A request for the model is the group's then, as it would be for the group's own id; ok is false when no group has it. An id with a provider in it ("a/m") names that provider's model, never a group.
func GroupMember ¶ added in v0.1.136
GroupMember is the group's member a typed model names: its id, its model id without the provider, or the model's last name — each with the effort fixed on the member ("m:high") or, when only one member is of that model, without it.
func HandOver ¶ added in v0.1.661
HandOver gives each deprecated built-in whose plugin the user has installed, at the version its move needs, and which that plugin serves, its id, so one subscription is never listed twice: the built-in, and the plugin's under "<id>-plugin" (ARNO on Discord: Qoder CN twice once the Qoder plugin's 0.2.0 served it, as nothing gave it the id). One with no accounts is the plugin's at once, as Adopt makes it; with accounts too, one that has some is moved (Move: each tried through the plugin, all put back on any failure, the built-in carrying on). One the plugin has accounts of its own for already is left as it is, since its models are in use as <id>-plugin's and the id changing would leave agents asking for a provider gone; the add sheet lists it once regardless. One the user moved back stays built-in, and a failed move waits moveRetry. No plugin is installed for it: the user's own install is what says to.
func HasMiniMax ¶ added in v0.1.910
func HasMiniMax() bool
HasMiniMax says whether a MiniMax Code account is signed in, on either site.
func HasTrae ¶ added in v0.1.784
func HasTrae() bool
HasTrae says whether a Trae CN account is signed in.
func HasUpstreamName ¶ added in v0.1.560
HasUpstreamName reports whether a name is kept under exactly the key it is given, the provider's part spelled as it is. No other spelling of the provider is tried: a caller deciding whether to remove a name by this key has to know that this key is the one a name is kept under, which is the one question wireKey's order is about.
A key spelled as an agent spells one — with magpie/ in front of it, and the spaces a ref is typed with — is that same key, as it is for a removal (DropUpstreamName): a name kept under it is there whichever way it is spelled, and a check that answered for one spelling only would say a name was not kept where it is. The one caller has had that prefix taken off already (splitModelRef), so nothing depends on it yet.
func HasWorkBuddy ¶ added in v0.1.356
func HasWorkBuddy() bool
HasWorkBuddy says whether a WorkBuddy (China) account is signed in.
func HeldSettings ¶ added in v0.1.908
HeldSettings is the settings as heldSettings reads them, for a look outside the package made many times in one request.
func HiddenModels ¶ added in v0.1.460
HiddenModels are the ids of the entries taken out of agent's lists.
func Hold ¶ added in v0.1.705
func Hold() (release func())
Hold keeps the catalog built once until release is called, for a request that only reads; a write meanwhile (Changed) drops it.
func IconDir ¶ added in v0.1.10
func IconDir() string
IconDir is where pictures given to providers are kept.
func IconFile ¶ added in v0.1.10
IconFile is the path of a stored picture, for a name as StoreIcon made it; "" for anything else, so a request can't reach outside the folder.
func IconForCatalog ¶
IconForCatalog names the logo of the vendor behind a models.dev provider id, or "" when no preset covers it.
func ImageOverride ¶ added in v0.1.413
ImageOverride is the user's answer for whether pid's model takes images.
func ImportFromApps ¶ added in v0.1.25
ImportFromApps adds what the user picked, reading the sources again so keys never pass through the window. It answers the names added.
func InUseLogin ¶ added in v0.1.504
InUseLogin is the account of an agent's the gateway goes to first: the one the agent is signed in to, unless it is paused or has used its allowance up — then the next one on that still has room — else the first other one on; "" when the agent has none. Kept signed in to one of the user's choosing, it is the first in the order that is in use.
func Intents ¶ added in v0.1.95
func Intents(rules []Rule, q RuleRequest) []string
Intents are the intents the classifier is to choose among for q: those of the rules that match it but for their intent, up to the first that matches outright (a rule after it could never be the first to match). None when no rule before that one has an intent — the classifier then isn't asked. Each is given once, as the first rule has it.
func IsDecider ¶ added in v0.1.142
IsDecider reports whether a classifier ("provider/model") is a decision provider's model.
func IsPattern ¶ added in v0.1.826
IsPattern reports whether a member as typed is a pattern rather than a model's id: a regular expression ("re:…") or a glob with "*" in it. No vendor's model id has a "*" in it, so a glob can't be taken for one.
func KeepClaudeWindowsWarm ¶ added in v0.1.223
func KeepClaudeWindowsWarm(ctx context.Context, send func(ctx context.Context, configDir string) error)
KeepClaudeWindowsWarm starts the Claude accounts' windows as they reset, while settings say to, each with one request send makes.
func KeepCodexWindowsWarm ¶ added in v0.1.182
KeepCodexWindowsWarm starts the ChatGPT accounts' windows as they reset, while settings say to, two minutes after it starts and every codexWarmEvery after that, until ctx ends.
func KeepLoginsAlive ¶ added in v0.1.75
KeepLoginsAlive renews the saved sign-ins that are due, a minute after it starts and every hour after that — a computer that slept through a day catches up within the hour of waking — until ctx ends.
func KeepMiniMaxCheckedIn ¶ added in v0.1.910
KeepMiniMaxCheckedIn checks the MiniMax Code accounts in each day while settings say to, as KeepTraeCheckedIn does Trae CN's.
func KeepOnAnAccountWithRoom ¶ added in v0.1.402
KeepOnAnAccountWithRoom runs SwitchWhenSpent for Codex and Claude Code a minute after it starts and every loginSwitchEvery after that, until ctx ends.
func KeepResetsFromRunningOut ¶ added in v0.1.701
KeepResetsFromRunningOut spends the Codex resets about to run out unused (SpendExpiringCodexResets), three minutes after it starts and every resetExpiryClose after that, until ctx ends.
func KeepRetiringMoved ¶ added in v0.1.506
KeepRetiringMoved moves the built-ins being retired, and hands over those whose plugin the user installed (HandOver), run by the magpie serving the gateway (one magpie, never two at once): a little after it starts, then every hour, so a failed move is tried again once moveRetry has gone. It also keeps each moved built-in's plugin up to date.
func KeepTraeCheckedIn ¶ added in v0.1.784
KeepTraeCheckedIn checks the Trae CN accounts in each day while settings say to, as KeepWorkBuddyCheckedIn does WorkBuddy's.
func KeepWorkBuddyCheckedIn ¶ added in v0.1.356
KeepWorkBuddyCheckedIn checks the WorkBuddy accounts in each day while settings say to: two minutes after it starts, every wbCheckinEvery after that, and as the Beijing day turns, until ctx ends.
func KeyID ¶ added in v0.1.14
KeyID is the fingerprint a key is named by, in lists and in the gateway.
func KiloClient ¶ added in v0.1.635
KiloClient makes a request to the Kilo Gateway carry what the Kilo CLI sends it (Kilo-Org/kilocode packages/opencode/src/session/llm/request.ts and kilocode/const.ts, packages/kilo-gateway/src/headers.ts): Kilo Code's attribution and User-Agent, the editor it runs in, its mode, and the session as the task, which the gateway keys its prompt cache on. session names the conversation, made into one of the CLI's ids (ses_…) as for OpenCode; none leaves the session headers out. A provider with no key sends no Authorization at all: the gateway answers a free model to a caller with no credential as anonymous (by IP, 200 requests an hour), and refuses a bearer it can't verify with 401 (Kilo-Org/cloud web-shared/src/lib/tokens.ts, ai-gateway/handlers/llm-proxy.ts). Kilo's clients still send "Bearer anonymous", which the gateway reads as none only until no released client sends it, so it is not copied here.
func KimiCodeSearch ¶ added in v0.1.779
KimiCodeSearch is where a Kimi Code plan's key searches the web, as kimi-cli's SearchWeb does (auth/platforms.py: the plan's search_url is its base_url, /coding/v1, with /search), "" for a provider that isn't a Kimi Code plan with a key.
func KiroModel ¶ added in v0.1.141
KiroModel is what Kiro last said of one of its models: how many tokens a prompt may hold, and whether it takes images; zero and false when it hasn't said.
func Labels ¶ added in v0.1.516
Labels are how an agent's list names each of es, in order: as Label, or, when the user wants names plain (settings' PlainNames, #335), by the name alone — but for two or more the list would call the same, as a routing group found for a model is called with that model left in the list, which keep their provider's after it to tell them apart. With their own names plain (PlainOwnNames, #92), a name the user gave — a model's, or a routing group's they made (#868: "· routing group" was what an agent's narrow menu cut off) — is that name just as they wrote it, but for two the list would call the same, and the rest keep Label's.
func LastServed ¶ added in v0.1.664
LastServed is when each ServedID last answered: what this process noted and what the file holds, whichever gateway wrote it.
func ListHeader ¶ added in v0.1.1030
ListHeader is a header whose value is a comma-separated list the request has its own of, which a provider's header of the same name adds to: anthropic-beta, the betas an agent asks on each request.
func ListedWindow ¶ added in v0.1.816
ListedWindow is the window a provider's model takes before the user says one: its vendor's list's, else the one models.dev gives a model of its id. A vendor models.dev doesn't list (a custom provider, a proxy, a plugin whose list says none, as Cline's) serves models it knows from others, under the vendor's prefix too: cline-free/mimo-v2.6-flash is mimo-v2.6-flash.
func LoginUsage ¶ added in v0.1.14
func LoginUsage(ctx context.Context, agent string) map[string]SubscriptionQuota
LoginUsage is the allowance used by each of an agent's accounts, by user. What was read less than a minute ago, here or for the Usage page, comes from the cache; the rest is asked for at once, as long as ctx allows.
func LoginUsageVia ¶ added in v0.1.778
func LoginUsageVia(f func(ctx context.Context, agent string) map[string]SubscriptionQuota)
LoginUsageVia has tests stand in for LoginUsage's readings.
func MakerPrice ¶ added in v0.1.411
MakerPrice is a model's list price as the first vendor among the presets that makes the models it serves lists it; for a call whose provider has gone since.
func MatchRule ¶ added in v0.1.94
func MatchRule(rules []Rule, q RuleRequest) int
MatchRule is the first of rules the request matches, -1 for none.
func MemberEffort ¶ added in v0.1.379
MemberEffort splits a group's member into the model it names and the effort fixed on it ("" for none): "a/m:high" is a/m at high, unless a has a model "m:high" of its own. A group in the group ("group/<id>") takes none; one typed with one comes back split, for SaveGroup to refuse.
func MemberFast ¶ added in v0.1.577
MemberFast splits a member typed with ":fast" after it into the member and true: "a/m:high:fast" is a/m:high, fast, unless a has a model "m:high:fast" of its own.
func MemberGroups ¶ added in v0.1.572
MemberGroups are the routing groups each model is in, as "group/<id>", by the model's "provider/model" id; a member fixed at an effort counts as its model, and a group removed is none. A provider kept for routing groups (Provider.Unlisted) reaches agents through these alone: a model of it in none of them is used by nothing.
func MergeList ¶ added in v0.1.1030
MergeList writes name in h as the items h has under it, in any case, followed by those of add: comma-separated, each once, empty ones left out, under name as written.
func MergeName ¶ added in v0.1.673
MergeName is the name the groups magpie finds merge a model by, when the user said nothing of it: its id as vendors agree on it (sameModel).
func MergeQuotaHistory ¶ added in v0.1.722
MergeQuotaHistory merges another computer's history (as QuotaHistoryData gave it there) into this one's.
func Mirror ¶ added in v0.1.76
Mirror makes the providers and groups exactly these, as sync brings them from another computer: one not among them goes, one that came without keys keeps the keys it has here.
func MirrorGroupOrder ¶ added in v0.1.843
MirrorGroupOrder makes the groups' order the one another computer has, as sync brings it, the way MirrorOrder does the providers': its ids first, then the ones named here alone. None leaves the order here as it is.
func MirrorOrder ¶ added in v0.1.638
MirrorOrder makes the providers' order the one another computer has, as sync brings it: its ids first, as it has them, then the ones named here alone (a signed-in account only this computer has), in the order they have here. None, as from a magpie before the order was synced or one never arranged, leaves the order here as it is.
func MirrorSearchAPIs ¶ added in v0.1.587
MirrorSearchAPIs makes the search APIs exactly these, as sync brings them; one that came without a key keeps the key it has here.
func ModelOrder ¶ added in v0.1.952
ModelOrder is the order the user put agent's models in (OrderedModels), by entry id; none when they never did.
func MovableIDs ¶ added in v0.1.628
func MovableIDs() []string
MovableIDs are the built-ins that have a plugin to move to, by id: the page marks them deprecated, moved or not.
func Move ¶ added in v0.1.506
Move puts the built-in id's accounts onto its plugin (see above). An error leaves the built-in as it was.
func MoveBack ¶ added in v0.1.506
MoveBack gives the id back to the built-in: its accounts as they were set aside, with what the plugin has of them now (newer tokens, accounts signed in to since), in the plugin's order; then the plugin signs out.
func MovePackage ¶ added in v0.1.506
MovePackage is the plugin the built-in id moves to.
func MoveRetiring ¶ added in v0.1.506
MoveRetiring moves the built-ins being retired that have accounts, at start-up: once, or again moveRetry after one failed. One the user moved back stays.
func MovedOnto ¶ added in v0.1.538
MovedOnto are the built-ins moved onto the plugin named (its spec or package name).
func NextLogin ¶ added in v0.1.402
NextLogin is the account agent should be signed in to instead of the one it is on: the account magpie moved it off, once that has room again (back); else, when the one it is on is spent, the first of its other accounts that are on in magpie, in the order they were saved, whose allowance is known and not spent. ok is false when the agent should stay.
func NoteClaudeLimits ¶ added in v0.1.199
func NoteClaudeLimits(user string, ls []ClaudeLimit)
NoteClaudeLimits keeps what Claude Code said of user's allowance as it answered, in place of the windows of the same names last read, and has routing weigh the account by it.
func NoteClaudeSignInFailure ¶ added in v0.1.788
func NoteClaudeSignInFailure(user, version, message string)
NoteClaudeSignInFailure keeps a run's refusal on the saved Claude account user, when the run started on the credential the account still has (version): one started on an older credential says nothing of this one. The run's own error stays in the request's trace.
func NoteServed ¶ added in v0.1.664
NoteServed records that p just answered a request, at at.
func ObjectRoot ¶ added in v0.1.718
ObjectRoot makes a tool's input schema a plain object at the root, with no anyOf, oneOf or allOf there: Grok's backend wants one, and so do Anthropic's models behind Factory ("input_schema does not support oneOf, allOf, or anyOf at the top level", #646). allOf's branches are all merged, properties and required alike. Of anyOf's and oneOf's object branches the properties are merged, a field each of them requires stays required, and the other branches go. It reports whether it changed anything.
func OffersUltra ¶ added in v0.1.733
OffersUltra reports whether Codex offers its Ultra on the model, by the id a vendor serves it under: openai/gpt-6.1-sol on a relay, a dated snapshot.
func OnAccountIDs ¶ added in v0.1.399
func OnAccountIDs() []string
OnAccountIDs are the user's own providers saved on a subscription's id, which hide that subscription once it is signed in (All lists the one saved): made before the id was a subscription's, as a WorkBuddy key was before WorkBuddy's plan was one. MoveOffAccountIDs moves them.
func OnPlugins ¶ added in v0.1.506
func OnPlugins() []string
OnPlugins are the built-ins moved onto their plugins.
func OnRenewed ¶ added in v0.1.289
func OnRenewed(f func(agent, user string))
OnRenewed has f told when an account's usage windows were started again (a Codex reset spent), so what sat out waiting for them can come back.
func OpenCodeClient ¶ added in v0.1.615
OpenCodeClient makes a request to OpenCode's gateway (Zen or Go) carry what OpenCode itself sends there (packages/opencode/src/session/llm/ request.ts, for a provider whose id starts with "opencode"): its User-Agent, the session in x-opencode-session, the turn in x-opencode-request, and x-opencode-client and x-opencode-project. Zen's free models are served to no one else ("OpenCode's free tier can only be used from within OpenCode"). session names the conversation; one already in OpenCode's form (ses_…) goes as it is, any other becomes one, the same for the same conversation, which Zen routes and caches by.
func OpenReadOnly ¶ added in v0.1.92
OpenReadOnly opens another app's SQLite database without writing to it.
func OutputsOf ¶ added in v0.1.876
OutputsOf is the reply limits the user set on a provider's models, by model id, "*" for all of them: what its editor's Max output shows.
func ParseCap ¶ added in v0.1.809
ParseCap reads a cap as the CLI takes it: "70", "70%", or off (none, 0, -) for no cap.
func ParseDay ¶ added in v0.1.570
ParseDay reads a day of the week, "mon" or "Monday", as Weekdays has it.
func ParseDays ¶ added in v0.1.570
ParseDays reads days of the week: "mon-fri", "sat,sun", "mon,wed-fri"; a range may run past Sunday (fri-mon).
func ParseLimit ¶ added in v0.1.1009
ParseLimit reads a limit as the CLI takes it: a whole number, 0 or off for no limit, default for the provider's (nil).
func ParseTokens ¶ added in v0.1.136
ParseTokens reads 200000, 200k, 1.5m.
func PatternMatches ¶ added in v0.1.826
PatternMatches reports whether a pattern matches a "provider/model" id.
func PlanTerm ¶ added in v0.1.209
PlanTerm says when a plan's paid time ends, "renews Oct 18", "expires Oct 18" or "until Oct 18" when the vendor doesn't say which; "" when it isn't known.
func PluginAPIKey ¶ added in v0.1.479
func PluginAPIKey(ctx context.Context, id string, method int, inputs map[string]string, key string) (string, error)
PluginAPIKey signs in to a plugin's provider with a key, as its "api" method does, beside the accounts signed in already; it gives the provider's magpie id.
func PluginID ¶ added in v0.1.479
PluginID is the id magpie gives the provider OpenCode calls id: the same, unless a preset or a built-in subscription has it (google, openai, anthropic), or a provider of the user's own made before the plugin was installed (zenmux, #867), when it is id-plugin — but for a built-in moved onto the plugin, whose id the plugin has now.
func PluginIcon ¶ added in v0.1.553
PluginIcon is the icon a plugin's provider shows: the picture its plugin gives it (the auth hook's icon, or package.json's magpie.icon), kept as a picture given by hand is, else the one the plugin market gives it.
func PluginListError ¶ added in v0.1.1001
PluginListError is why the plugin couldn't list the account at key's models, "" when it did or kept the list it had: what it shows instead is its short defaults (Cursor's Auto alone).
func PluginOf ¶ added in v0.1.479
PluginOf is the plugin provider magpie's provider id is, when it is one.
func PriceKey ¶ added in v0.1.504
PriceKey is the key a price for pid's model is stored at, and whether the provider naming that key is still there at all.
The spelling that was given comes first, because a price outlives the provider it was set for and nothing rewrites the key when that provider goes: "b/vendor/m" can still be where a price is held while a provider of some other id answers to "b" as its display name. Resolving that name first would take the second provider's price away instead — none is stored under it, so nothing would change, the caller would be told it had, and the price the user meant would stay in the file to be counted at. Only where nothing is stored under the spelling is the provider looked for, by the id it has or the one it was renamed from: that is where SetModelPrice keeps a price set through a display name, and the same resolution EffectivePrice reads it back under.
func PriceRateOK ¶ added in v0.1.901
PriceRateOK says what is wrong with a provider's price rate, "" when nothing: from 0 (none) to 1000, in steps of 0.001.
func PricedName ¶ added in v0.1.418
PricedName is the catalog ID used for a list-price estimate. Prefer a directly listed model before falling back to a documented alias.
func ProbeClaudeVia ¶ added in v0.1.551
ProbeClaudeVia sets how a Claude account's test runs Claude Code.
func ProxyOf ¶ added in v0.1.418
ProxyOf is the own proxy of the provider or signed-in account with id, "" when it follows the global one.
func ProxyOfLogin ¶ added in v0.1.427
ProxyOfLogin is the proxy requests made on behalf of the account user of the subscription id go through (gakki: one Codex account through one proxy, another through another): the account's own, or else the subscription's (ProxyOf); "" follows the global one.
func QoderAuthURL ¶ added in v0.1.392
QoderAuthURL starts a sign-in on the global site.
func QoderCompleteSignIn ¶ added in v0.1.392
func QoderCredential ¶ added in v0.1.392
QoderCredential returns an independent snapshot for the selected account on the global site.
func QoderCredentialOf ¶ added in v0.1.528
QoderCredentialOf is QoderCredential for the site agent names ("qoder" or "qoder-cn").
func QoderModel ¶ added in v0.1.392
QoderModel accepts only an enabled model in this account's own model list.
func QoderModelOf ¶ added in v0.1.528
QoderModelOf is QoderModel for the site agent names.
func QoderSignedIn ¶ added in v0.1.392
func QoderSignedIn() bool
func QuietAccount ¶ added in v0.1.204
QuietAccount stops reminding the user of an account they removed: its "Add it back" line goes, and it is offered only from the Add sheet.
func QuotaHistoryData ¶ added in v0.1.722
func QuotaHistoryData() []byte
QuotaHistoryData is this computer's history as kept, for the usage sync to share.
func QuotaHistorySince ¶ added in v0.1.722
QuotaHistorySince is the start of a range days long (as a query gives it) to now: all that is kept when not a number of days.
func RefreshUsage ¶ added in v0.1.935
RefreshUsage reads the card of provider (of account user, "" for every account it has) again, whether a subscription's, a plan's or a key's balance, and keeps it with the others, which aren't asked. The next Quotas has it.
func RemoveKey ¶ added in v0.1.14
RemoveKey forgets a key. The last key in use stays: turn another on first.
func RemoveKeys ¶ added in v0.1.1029
RemoveKeys forgets several keys at once (361 on Discord: hundreds of keys, some dead): those named that it has. The first key, when it is among them, gives its place to the next one on that stays. One key in use always stays: removing every key in use is refused.
func RemovePlugin ¶ added in v0.1.538
RemovePlugin removes the plugin named, the built-ins moved onto it moved back to themselves first.
func RemoveSearchAPI ¶ added in v0.1.587
RemoveSearchAPI takes the vendor's search API away.
func RemovedGroups ¶ added in v0.1.92
func RemovedGroups() []string
RemovedGroups are the found groups the user removed, whether or not magpie finds them now: each is a record in providers.json ({"id", "hidden": true}) that keeps it removed when two providers serve its model again.
func Rename ¶ added in v0.1.125
Rename gives a provider another id, the one its models are picked by (<id>/<model>). What magpie keeps that names it by id follows: the routing groups it is in and their rules and classifiers, the other providers' fallbacks, and which agents are shown it. The old id stays with it (Was), so an agent still running on a config that names it the old way reaches it, and its usage so far is counted with it; the agents' own files are the agent package's to rewrite (agent.RenameProvider). A signed-in account keeps the id of its agent.
func RenameGroup ¶ added in v0.1.105
RenameGroup gives a group another id, the one agents pick it by (group/<id>). A group magpie found becomes the user's under the new id, the found one kept removed so it doesn't come back beside it. The groups that have it in them, and their rules, name it by the new id.
func RenamedRef ¶ added in v0.1.125
RenamedRef is ref with the provider it names by an id the provider had named by the id it has now.
func ResetClock ¶ added in v0.1.211
ResetClock is when a window starts again, on the clock: "14:30" today, "tomorrow 09:00", "Wed 14:30" within the week, else "Oct 3 14:30".
func RestartCodexDaemon ¶ added in v0.1.368
RestartCodexDaemon has Codex restart its app-server, which reads the sign-in again: `codex app-server daemon restart`, run with the codex CLI magpie finds and the Codex home it signs Codex in through. The Codex sessions attached to it are ended.
func Restore ¶ added in v0.1.28
Restore puts providers from a backup in. Each replaces the one here with its id; one that came without keys keeps the keys already here. It returns how many were new and how many replaced one here.
func RestoreGroups ¶ added in v0.1.76
RestoreGroups puts groups from a backup in, each replacing the one here with its id.
func RestoreSearchAPIs ¶ added in v0.1.587
RestoreSearchAPIs puts search APIs from a backup in, each replacing the one of its vendor here; one that came without a key keeps the key here.
func RuleWords ¶ added in v0.1.136
RuleWords splits a typed line into its words, a "quoted" part in one: intent="a quick question".
func SaveGroup ¶ added in v0.1.38
SaveGroup adds or replaces a group of the user's. Changing one magpie found makes it the user's.
func SaveStepFunPaste ¶ added in v0.1.389
SaveStepFunPaste keeps the session the user pasted for the site: what the bookmarklet copied, or the Oasis-Token cookie as the browser's developer tools show it (the access token, three dots, the refresh one).
func SaveStepFunSession ¶ added in v0.1.389
SaveStepFunSession keeps the session the sign-in page ended in, once the platform has taken it: a page that isn't signed in yet has an anonymous one, which is refused here.
func SawCodexClient ¶ added in v0.1.441
SawCodexClient notes the version a Codex client's request says it is — its `version` header, else the one in its User-Agent (codex_cli_rs/0.159.0, Codex Desktop/0.159.0) — when the request is Codex's (it names an originator, or its User-Agent is codex_…).
func SentNameIn ¶ added in v0.1.560
SentNameIn is the name a call on the provider's model goes out under at that effort: the name the vendor would be asked for now, which is the one magpie knows the model by unless the user gave one. It is UpstreamNameAs for the id that call asks for, which is not the model magpie knows everywhere: on an Antigravity account it is the variant of it that effort picks, so a name given for the provider asks for each level by its own id, and a ledger reading a record back reads the vendor's reply against the name that really went out — the same one the gateway sent — rather than against the family it is one level of.
The effort is the one the gateway sent, already fitted to the model's own levels, which is what a record keeps of it, so a level of the model's own is one of its variants and goes out as that one. An effort that is no level of the family names the same id the gateway asked for all the same: the level of the family's own nearest (AntigravitySentID), which is where the envelope went out.
It is SentNameOnIn for the caller that has nothing but the id — a record in the ledger, which keeps the id the call went out on and nothing else. A provider that is an account is built with that account's own id as its own (googleProvider and the rest of the account providers), so the id says which account it was, and a provider of the user's own is no account's whatever its id is. A record's provider need not even be signed in now, which is why nothing here goes looking for the account behind the id: the id a call went out on is all a record has and all it can be read by.
func SentNameOnIn ¶ added in v0.1.560
SentNameOnIn is SentNameIn for a caller holding the provider itself, and so the account behind it: the call goes out on that account, and it is the account the id the effort picks is a question about. A provider's id is that account's own id today (googleProvider and the rest of the account providers build each one with it), so passing the id for the account reads the same — but the two are one id by construction rather than by rule, and a provider of the user's own has no account at all whatever its id is. So the route, which is holding the provider, asks about the account and lets the gateway's dispatch (codeAssistID, on the same agent) be the one rule.
func ServedID ¶ added in v0.1.664
ServedID names who answers for p, as its Quota is found by: an account by its agent and user ("codex@a@b.c"), a key by its provider and the key's id ("deepseek#k1a2b3c"), else the provider.
func ServesModel ¶ added in v0.1.560
ServesModel is whether the provider really serves model, listed or exposed: the question SetUpstreamName asks before it keeps a name for one, and the same one, since a name given for a model the provider does not serve is a request magpie would never send it. It is the answer a caller told to take a name off needs as well: a model the provider has nothing like is not asked for by any name, so reporting which one is in force for it would say magpie asks for a model it does not know.
func SetAccountCap ¶ added in v0.1.809
SetAccountCap caps the account ref of the subscription id at cap percent of its windows; 0 lifts the cap.
func SetAccountConcurrency ¶ added in v0.1.1009
SetAccountConcurrency gives the account or key ref of the provider id its own limit on requests at once, 0 for none; nil gives it the provider's again.
func SetAccountModels ¶ added in v0.1.610
SetAccountModels gives the account or key ref of the provider id the models it alone serves; none gives it every model the provider has again.
func SetAccountOrder ¶ added in v0.1.605
SetAccountOrder changes the order used by routing, not just its presentation. The first enabled account becomes first through the same switch used by Make first, unless the agent is kept signed in to another (KeepLoginAs). Disabled accounts can be moved, but never silently enabled by a drag.
func SetAffinity ¶ added in v0.1.38
SetAffinity changes how long a provider's conversations stay with the key or account that answered them.
func SetAutoGroups ¶ added in v0.1.603
SetAutoGroups turns the groups magpie finds on its own on or off, all of them at once (蓝猫 on Discord: they could only be removed one by one). Off, none is listed or served; the groups the user made or changed, one found included, stay, and so do the records of those removed, so that on again brings back the found groups as they were. A found group one of the user's has in it, or classifies with, keeps them on until it is taken out, as DeleteGroup keeps it: the user's group would lose it unsaid.
func SetCodexAgentsV1 ¶ added in v0.1.715
SetCodexAgentsV1 turns settings.CodexAgentsV1 on or off, and has Codex's lists written and asked for again.
func SetCodexAutoReset ¶ added in v0.1.507
SetCodexAutoReset turns that on or off for user.
func SetCompactAt ¶ added in v0.1.979
SetCompactAt has every model without a threshold of its own compacted at n tokens, Full window turned off; 0 is the working window again (settings.WorkingWindow).
func SetContext ¶ added in v0.1.532
SetContext is how long a request one of a provider's models takes, in tokens, over what the vendor's list and models.dev say; 0 takes the user's away, which DropContext does, and "*" is every model of that provider. As with a reply limit, setting one has to name a model the provider serves, and a removal may name one it no longer does.
This is the provider's own Contexts, kept as the one value both the gateway advertises and the routing rules read — a context is a routing input, not only a number agents are shown: at 95% of a held member's window a request moves to a member that takes more (internal/gateway/rules.go). Saving it tells the agents (catalog.Touched), as for any change of the catalog: a window is a number they keep in files of their own — Pi's contextWindow, OpenCode's limit — and read at start-up, so a session already running keeps the window it began with while the gateway's own /models is right at once.
func SetFullContext ¶ added in v0.1.836
SetFullContext turns settings.FullContext on or off: Codex and Claude Code are told a model's whole window, or the working one, again.
func SetGoogleProject ¶ added in v0.1.63
SetGoogleProject names the Google Cloud project an account's requests go to, "" to let Code Assist pick; Code Assist Standard and Enterprise need one.
func SetGroupOrder ¶ added in v0.1.843
SetGroupOrder saves the order the routing groups are listed in, by id. Every id must be a group's, once; the ones left out follow those named, as they are now, and the whole order is kept, so a group made or found later goes after them all.
func SetHiddenModels ¶ added in v0.1.460
SetHiddenModels takes these entries out of agent's lists, and puts back every other; none shows it every model its visibility gives it. The agents that keep the models in files of their own are told.
func SetKeepLogin ¶ added in v0.1.641
SetKeepLogin keeps Codex or Claude Code signed in to the account the user made first (Provider.KeepLogin), or lets magpie move it on again. Either way it is no longer kept on one of the user's choosing (KeepLoginAs): it is signed in to the first again.
func SetKeepLoginAs ¶ added in v0.1.672
SetKeepLoginAs keeps Codex or Claude Code signed in to user, one of its saved accounts, and signs it in to it now; the order the gateway tries the accounts in stays as it was, the first still first.
func SetKeyProtocol ¶ added in v0.1.15
SetKeyProtocol says which one protocol a key works with; empty is any.
func SetKeyWeight ¶ added in v0.1.933
SetKeyWeight sets a key's share of the requests under Weighted routing; 0 takes it back to the default, 1.
func SetLoginOn ¶ added in v0.1.14
SetLoginOn puts a saved account in use beside the agent's own, or takes it out. The account the agent is signed in to is always in use.
func SetModelAPI ¶ added in v0.1.663
SetModelAPI says which one of a provider's APIs a model is asked on — chat, responses or anthropic — for a relay whose one key serves some of its models on one and others on another (01huadalang on Discord: 有的供应商 一个 api 里有很多模型但是不同协议); "" leaves it to the vendor's list and the URLs the provider has, as before. It must be an API the provider has a URL for: a preset's or a subscription's as well as a custom provider's, when it has more than one (01huadalang: OpenCode Go's deepseek-v4.1-flash answers on Responses too, and magpie asked it on chat alone).
func SetModelCompacts ¶ added in v0.1.979
SetModelCompacts makes a provider's thresholds cs, by model id, "*" for all of them, as its editor's Compact at says: those it leaves out are taken away, and every one set has to be a model the provider serves, as for a reply limit (SetModelOutputs). Codex's and Claude Code's lists are written again when anything changed.
func SetModelEfforts ¶ added in v0.1.137
SetModelEfforts keeps only these of a provider's model's reasoning levels in the lists magpie hands out; none, or all it has, offers them all again. They must be levels the model has — or, for a model whose levels aren't known, any of Levels, which it is given; none takes them away.
func SetModelImage ¶ added in v0.1.413
SetModelImage says whether a provider's model takes images, in place of what its vendor's list says. nil gives that answer back.
func SetModelName ¶ added in v0.1.137
SetModelName names a provider's model, spelled "provider/model"; an empty name gives it back its own. The agents that keep the models in files of their own are told (catalog.Touched), as for any other change of the catalog.
func SetModelOrder ¶ added in v0.1.952
SetModelOrder lists agent's models in this order, by entry id: the ones it names first, as it names them, then every other as before; none puts them back in magpie's own order. Only agent's lists follow it.
func SetModelOutput ¶ added in v0.1.532
SetModelOutput is the most a reply of a provider's model may hold, in tokens, over what the vendor's list and models.dev say; 0 takes the user's away, which DropModelOutput does. The id is spelled "provider/model", or "provider/*" for every model of that provider; setting one has to name a model the provider serves, as one no lookup would ever match reads as set and is not. A removal may name a model that has since gone, or a provider that has: that is the entry left to be cleared.
The agents are told of it (catalog.Touched), as for any change of the catalog: a reply limit is a number they keep in files of their own — Pi's maxTokens, OpenCode's limit — and read at start-up, so one only the gateway knew would leave every agent a reply limit behind.
func SetModelOutputs ¶ added in v0.1.876
SetModelOutputs makes a provider's reply limits outs, by model id, "*" for all of them, as its editor's Max output says (ARNO on Discord: a model's maxTokens was wrong, and only the context window could be set in the editor): those it leaves out are taken away, and every one set has to be a model the provider serves, as for SetModelOutput. Nothing is saved, nor the agents told, when nothing changed.
func SetModelPrefs ¶ added in v0.1.648
SetModelPrefs makes the changes to a provider's models, by model id, as SetModelName, SetModelEfforts, SetModelImage, SetModelAPI and SetModelSame do, and tells the agents once, after them all, rather than once a change. It stops at the first that fails, telling the agents of those made before it.
func SetModelPrice ¶ added in v0.1.504
SetModelPrice is what a provider's model costs the user, in USD per million tokens, kept in settings' ModelPrices the way a name is. A nil price takes the user's away, leaving the model at what its provider lists and only then at its maker's on models.dev; a price of zero is not that, but a model served at no cost. A price no vendor could charge is refused, naming the part that is wrong.
Unlike the other model preferences this does not tell the agents. What a call costs is not what an agent picks a model by, and the model lists magpie keeps in the agents' own files are not its to rewrite over a number in a cost report.
func SetModelSame ¶ added in v0.1.673
SetModelSame says which model a provider's model, spelt "provider/model", is the same as, for one a vendor names its own way (Volcengine Ark's dated ids, kyzhouxu on #583): the routing groups magpie finds merge it with that model from every other provider (autoGroups). The name is a model's id as any vendor spells it ("deepseek-v4.1-flash", or with a vendor's prefix); "" — or a name that is the model's own however spelt — merges it by its own id again. The agents are told, the groups they are shown having changed.
func SetOff ¶ added in v0.1.346
SetOff switches a provider off, or on again (see Provider.Off). Saving it brings the model lists written into agents' files up to date.
func SetOrder ¶ added in v0.1.627
SetOrder saves the order the providers are listed and tried in, by id. Every id must be a provider's, once; the ones left out follow those named, as they are now, so a provider added later goes after them all.
func SetPlainNames ¶ added in v0.1.516
SetPlainNames has the agents' model lists name models by their names alone (see Labels), or with their providers' again, and the agents told.
func SetPluginOff ¶ added in v0.1.538
SetPluginOff turns the plugin named off, the built-ins moved onto it moved back to themselves first, or back on.
func SetQueue ¶ added in v0.1.1009
SetQueue sets how many requests may wait for each of the provider's keys or accounts, and how long one waits, in seconds; 0 is no bound.
func SetRouting ¶ added in v0.1.25
SetRouting changes how a provider's requests spread over its keys or accounts.
func SetSearchAPI ¶ added in v0.1.587
SetSearchAPI adds a search API, last, or changes the one of its vendor where it is; a change with no key keeps the key it has.
func SetSink ¶ added in v0.1.777
SetSink sends a provider's keys or accounts rate limited with quota left to the back of its order, or lets them keep their place (Provider.Sink).
func SetSuffixMode ¶ added in v0.1.595
SetSuffixMode has the agents' model lists name models as mode says (see Labels), and the agents told when it changes.
func SetUpstreamName ¶ added in v0.1.560
SetUpstreamName is the name to send a provider for one of its models; an empty name takes the user's away and sends the one magpie knows. A name is only given for a model the provider really serves: a relay lists the model under the id magpie knows it by and asks for it under the vendor's own, and one it does not list is a request magpie would never send, so naming it is refused here, as a price and a limit are for the same id. A "*" stands for every model of the provider rather than for one, and a removal is exempt, so an entry left for a model that has since gone can still be taken away.
A provider magpie asks through an agent's own backend has no model field to put a name in — the request goes out carrying the id the agent knows — so a name given for one of its models would never be sent (asksOwnBackend).
The ref is taken as the provider it names, by its id now, and the name is kept under that id: a ref is as likely to be spelled with an id the provider had before a rename (Was) or with the name it is shown by, and every lookup of a wire name goes by the id the provider has (UpstreamName). A name under any other spelling of the provider is one no lookup will ever match — a name the provider is never asked for, and a removal that takes away nothing.
The key is checked here, where it is given, and not as the whole settings are written: a hand-edited key no lookup will ever match is a no-op of the user's own making, and must not keep every other setting from being saved.
Kept in settings, and saved without telling the agents, like a price: which model an agent picks, and what it is called, have not changed — only the name the request goes out under.
A removal goes to DropUpstreamName, which works off the key rather than off this provider, so that taking a name away is the same operation whether or not the provider it was given for is still there.
A blank name is a removal, and whether there was a name there to take away is DropUpstreamName's to say, not this one's: a caller with something of its own to say about a name that was not there — `magpie model wire -- reset`, which tells a mistyped id from a model already asked for by the name magpie knows it by — asks DropUpstreamName for the removal itself, the way `magpie model price --reset` asks DropModelPrice. A caller that only wants the model left as it is has nothing to tell the user either way, which is why a blank name is an error and not a second answer.
func ShowAccount ¶ added in v0.1.31
ShowAccount brings back the signed-in account of an agent the user had removed from magpie.
func ShowGroup ¶ added in v0.1.38
ShowGroup brings back a group magpie found that the user had removed.
func SignOutStepFun ¶ added in v0.1.389
SignOutStepFun forgets the site's sign-in.
func SpendExpiringCodexResets ¶ added in v0.1.701
SpendExpiringCodexResets goes over the Codex accounts the user lets spend their resets and spends one about to run out unused (see check).
func SpentShareOf ¶ added in v0.1.641
SpentShareOf is the share past which routing counts an account spent: SpentShare, but In order sends requests to the first until a window of it is used up or the vendor refuses it, so there an account at 98% is still tried in its turn (#530).
func SplitKeys ¶ added in v0.1.930
SplitKeys is the keys in text pasted at once: one a line, or separated by commas, semicolons or spaces, trimmed of quotes, each once.
func StaleAllowance ¶ added in v0.1.38
func StaleAllowance(agent, user string)
StaleAllowance makes the next Allowances ask the vendor again for user's allowance rather than trust what it last said: the account just answered that it has run out.
func StepFunBookmarklet ¶ added in v0.1.389
func StepFunBookmarklet() string
StepFunBookmarklet is the bookmarklet the user runs on a StepFun platform page they are signed in on: it renews the session as the page does, on either site, and copies it to be pasted into magpie.
func StepFunOrigin ¶ added in v0.1.389
StepFunOrigin is the site's platform.
func StepFunSignInURL ¶ added in v0.1.389
StepFunSignInURL is the page the user signs in on, for the site.
func StepFunSignedIn ¶ added in v0.1.389
StepFunSignedIn reports whether magpie has a sign-in on the site.
func StepFunSite ¶ added in v0.1.389
StepFunSite is which of StepFun's platforms the provider's key is for, "ai" or "com", or "" for another vendor.
func StoreIcon ¶ added in v0.1.10
StoreIcon keeps a picture (PNG, JPEG, GIF, WebP, ICO or SVG) and returns the Icon value that points at it. The same picture is stored once.
func StoreIconFile ¶ added in v0.1.10
StoreIconFile is StoreIcon for a picture on disk.
func StoredGroupOrder ¶ added in v0.1.843
StoredGroupOrder is the order the user put the groups in, as saved; as with Stored, a file that can't be read is an error.
func StoredOrder ¶ added in v0.1.638
StoredOrder is the order the user put the providers in, as saved; as with Stored, a file that can't be read is an error.
func SubmitSignInCallback ¶ added in v0.1.415
SubmitSignInCallback finishes a browser sign-in whose callback could not reach this machine — the address the browser ended on, pasted — or a plugin's with the code its page showed.
func SuffixMode ¶ added in v0.1.595
func SuffixMode() string
SuffixMode is how the agents' lists name models: SuffixOn, SuffixOwn or SuffixOff.
func SwitchGroup ¶ added in v0.1.989
SwitchGroup switches a group of the user's on or off (Group.Disabled). A group magpie found is the catalog's, so it is removed rather than switched off; and one that classifies for another stays on, or that group's rules would have no one to ask.
func SwitchLogin ¶ added in v0.1.11
SwitchLogin signs an agent in to a remembered account. Sessions of the agent that are already running keep the account they started with until they restart; so does Codex's background app-server, which new Codex sessions attach to (CodexDaemonStale says when it is).
func SwitchWhenSpent ¶ added in v0.1.402
SwitchWhenSpent signs agent in to the next of its accounts when the one it is on is spent, or back to the one it moved off once that has room (NextLogin), and answers the account it signed it in to, "" when it stayed.
func TakesBalanceToken ¶ added in v0.1.90
TakesBalanceToken says the provider's vendor tells the account's balance to a token of its own (BalanceToken), which the editor then asks for.
func TakesZhipuTeam ¶ added in v0.1.431
TakesZhipuTeam says p is a key of Zhipu's or Z.ai's, whose editor then offers the team's organization and project (#236).
func ThenUses ¶ added in v0.1.196
func ThenUses(rules []Rule, q RuleRequest, n int, use string) []string
ThenUses are the members the rules after the n-th (from 1) that also match q send to, each once and in the rules' order, leaving out use: who a request a rule sent to use fails over to before the group's others (#112).
func TookOpenedURL ¶ added in v0.1.574
TookOpenedURL is magpie run as the browser of a `claude auth login` it started: the page is written down for magpie's window to open, and nothing else runs.
func TuckAccount ¶ added in v0.1.773
TuckAccount hides a removed account from the Add sheet's "Removed from magpie" too (on), or lists it there again (off). Tucked, it is quiet as well: no reminder line either (#116).
func UpstreamName ¶ added in v0.1.560
UpstreamName is the name to send a provider for one of its models: the one the user gave, for the model or for every model of that provider, else the name magpie knows the model by. Every "*" in the name the user gave is that model, wherever it stands: "vendor-c/*" for a provider's every model sends vendor-c/model-3 for model-3, so one name covers a relay that namespaces its models and still asks for each of them by its own, and "vendor/*/pro" sends vendor/model-3/pro. A name with no "*" in it is that one name for every model of the key, which is the right answer only for a relay that does serve them all alike.
The two are deliberately different things. Everything a user or an agent sees — the catalog, the routing groups' membership, what a call is recorded and priced as — is in magpie's name for the model, so a rename upstream never renames a model here. Only the request that goes out carries the vendor's name, and what a reply says answered is compared with it, so a model asked for by the name the vendor serves it under is not read as another one.
func UpstreamNameAs ¶ added in v0.1.560
UpstreamNameAs is UpstreamName for a request that goes out asking for sent, which is not always the model magpie knows: an Antigravity account is asked for the variant of it the effort picks, and that is the id the body carries. The two levels of the lookup are kept apart, since they are about different things. A name given for the model itself is the model's, whichever variant answers for it, so a "*" in it is that model and not the variant: the vendor is asked for the model by the name its owner gave, as it is everywhere else in magpie, and not for a "*" it never heard of. A "*" in the provider's own name is whatever the request is going out under, so one name for a provider asks for gemini-3.7-flash-high and gemini-3.7-flash-low each by its own, rather than for the one id whatever level the effort picked.
func UpstreamNameAsIn ¶ added in v0.1.560
UpstreamNameAsIn is UpstreamNameAs over a settings' ModelWires already read. A name that is only whitespace is no name, as it is in UpstreamNameIn: the lookup falls through to the level below it, and a request with no name at all goes out under the id it was built with.
func UpstreamNameIn ¶ added in v0.1.560
UpstreamNameIn is UpstreamName over a settings' ModelWires already read, for a caller that walks a whole ledger of models in a row. A name that is only whitespace — one an older magpie stored, or one hand-edited into the file — is no name, as it is where one is given.
func UsageClaudeVia ¶ added in v0.1.558
UsageClaudeVia sets how Claude Code's /usage runs.
func UseKey ¶ added in v0.1.14
UseKey makes one of a provider's keys the first, and turns it on; the one it replaces stays on, next in line.
func UsedUp ¶ added in v0.1.791
func UsedUp(q SubscriptionQuota) bool
UsedUp is usedUp for the CLI's magpie quota wait, so what it waits out is what stops an account here.
func Verification ¶ added in v0.1.304
Verification says whether an error body is Google's refusal of an account it wants verified first — Cloud Code Assist's 403 whose details say VALIDATION_REQUIRED with a validation_url in their metadata (#152) — and the https link to verify it at, when the body has one.
func VerifyMessage ¶ added in v0.1.304
VerifyMessage is a verification refusal as the agent and the app show it: the vendor's words, then what to do.
func Via ¶ added in v0.1.418
Via is ctx for requests made on behalf of the provider or signed-in account with id (see Provider.Via).
func ViaLogin ¶ added in v0.1.427
ViaLogin is ctx for requests made on behalf of the account user of the subscription id (ProxyOfLogin).
func ViaSignedIn ¶ added in v0.1.427
ViaSignedIn is ctx for requests made with the sign-in an agent has now (Codex's own, relayed as it came): through the proxy of the account it is signed in to.
func VisibleTo ¶ added in v0.1.111
VisibleTo is what agent's lists are narrowed to, and whether they are.
func WatchQuotas ¶ added in v0.1.540
func WatchQuotas(ctx context.Context, wake <-chan struct{}, send func(QuotaAlert))
WatchQuotas reads every allowance and balance while an alert is set, and hands send each one due, until ctx ends. wake, when it gets a value, has it look at once (an alert just turned on).
func WithAutoPicks ¶ added in v0.1.921
func WithAutoPicks(ctx context.Context, onPick func(model string)) (context.Context, func() []AutoPick)
WithAutoPicks has the Auto picks a request is sent with noted: the func returns them. onPick, when set, is told each model the request goes as, for the reply to name the one it went as last.
func WithAutoPrompt ¶ added in v0.1.914
WithAutoPrompt carries the prompt of the request Copilot's Auto picks a model for: POST /auto picks for a prompt.
func WithCapped ¶ added in v0.1.809
func WithCapped(m map[string]SubscriptionQuota) map[string]SubscriptionQuota
WithCapped is m with Capped set on each window an account's usage cap counts, for the GUI to mark the cap and say an account is held at it as routing does — a window one model's own counts for that model, so it is marked as the rest are; the windows are copied, the cache's left as they are.
func WithMemberEffort ¶ added in v0.1.379
WithMemberEffort is the member id of model at effort: the model itself for "".
func WorkBuddyBaseForTest ¶ added in v0.1.755
func WorkBuddyBaseForTest(cn, ai string) func()
WorkBuddyBaseForTest points WorkBuddy's API at cn, and WorkBuddy AI's at ai, until the returned function runs. A provider built after the call uses them. Tests outside this package use it.
func ZedBody ¶ added in v0.1.632
Zed's cloud reads an OpenAI model's request into its own Responses types (zed-industries/zed, crates/open_ai/src/responses.rs) before it goes on to OpenAI, and turns the whole request away over anything they don't name: "failed to parse OpenAI Responses API request: unknown variant `developer`, expected one of `user`, `assistant`, `system`, `tool`" on Codex's developer messages. What they take:
- input items tagged by type: message, function_call, function_call_output, custom_tool_call, custom_tool_call_output, reasoning, compaction, compaction_trigger;
- a message's role: user, assistant, system, tool; its content a list;
- a reasoning item's content a list, if there (serde's default is for a missing field, not a null one);
- tools of type function or custom;
- include: reasoning.encrypted_content alone;
- reasoning.summary: auto, concise, detailed.
ZedBody is a Responses request fitted to those, Codex's above all; a request in another API (one with no input list) goes as it came.
func ZedCloud ¶ added in v0.1.423
func ZedCloud() string
ZedCloud is where the gateway asks an account's models.
func ZedProviderOf ¶ added in v0.1.423
ZedProviderOf is the provider (anthropic, open_ai, google, x_ai) whose API a model is asked in, as the account's list said, else guessed from its id.
Types ¶
type Account ¶
type Account struct {
Agent string `json:"agent"` // the agent's id: codex, copilot
User string `json:"user"` // who is signed in: an email, a GitHub login
Plan string `json:"plan,omitempty"` // the subscription, when the agent says
// Stream is set when the backend only streams; magpie then translates
// a non-streaming request instead of relaying it.
Stream bool `json:"-"`
// Home is where a Grok, Kiro or Devin account keeps its sign-in: the
// agent's own (the CLI's home for Grok, "" for Kiro and Devin), or one
// of magpie's for a further account (grok_accounts.go, kiro_accounts.go,
// devin_accounts.go).
Home string `json:"-"`
// contains filtered or unexported fields
}
Account is the signed-in agent behind a provider.
func (*Account) AgentsOwn ¶ added in v0.1.648
AgentsOwn says the account is the one the agent itself is signed in to, run in the agent's own home with what it keeps there, not with a sign-in magpie hands it. Which account that is moves with a switch (SwitchLogin): a Claude Code started on it before goes on as whatever Claude Code is signed in to by then, as it reads its keychain again every half minute.
func (*Account) Levels ¶ added in v0.1.635
Levels are the reasoning levels the account's own list gives the model — a Free ChatGPT plan's may be fewer than a Plus one's — and ok is false when that list wasn't fetched, doesn't have the model or gives it none.
func (*Account) Lists ¶ added in v0.1.35
Lists reports whether the account's plan has the model, as far as magpie knows: one whose list was never fetched is taken to have them all.
func (*Account) StandIn ¶ added in v0.1.623
StandIn says the account is a saved one served in the place of the agent's own sign-in, which is signed out.
func (*Account) Token ¶ added in v0.1.14
Token is the access token of a saved account in use beside the agent's own — for a Claude account, the config directory Claude Code runs on it in; ok is false for the agent's own, which the agent signs itself. A Claude account that can't be used, Anthropic having refused its sign-in, is an error, whichever it is (claude_auth.go).
func (*Account) UsageAgent ¶ added in v0.1.514
UsageAgent is the agent an account's allowance is asked for by (LoginUsage, Allowances): a plugin's accounts by their provider's.
type Allowance ¶ added in v0.1.29
type Allowance []Limit
Allowance is an account's allowance windows as last known.
func (Allowance) CapHeld ¶ added in v0.1.809
func (a Allowance) CapHeld(model string, cap int, now time.Time) (held bool, used float64, back time.Time)
CapHeld says whether an allowance, as last known, has a window counting model at or past cap percent at now: the account is held by its cap. used is the share of the fullest such window, back when the last of them renews (zero when one doesn't say). A window whose reset has passed is empty again; no cap (0) holds nothing.
func (Allowance) Count ¶ added in v0.1.738
Count is the count of the window For's share is of — the fullest that counts model — when the vendor counts it (WorkBuddy's credits): how much of of is used, in unit; of is zero when it isn't counted so. A window whose reset has passed is empty again.
func (Allowance) For ¶ added in v0.1.38
For is what an allowance leaves a request for model at now: the share used of the fullest window that counts it, and when those windows renew, the biggest first — the longest, the week before the five hours in it. A window whose reset has passed is empty again, its next reset not known.
func (Allowance) Full ¶ added in v0.1.38
Full is when an account used up for model can take it again: the last reset of its windows that are full, zero when none is or it isn't known.
func (Allowance) Pace ¶ added in v0.1.644
Pace is the share of its week an account has left for model, per hour until that week renews: the rate it would have to be used at to spend the week just in time, so the account with the highest has the most to lose at its reset. Of several budget windows that count the model (Opus's own beside the general), the tightest; due is when that one renews, zero when it isn't known. A window not started, or whose reset isn't known, is taken to run its whole span from now; one that doesn't say how long it runs (a plugin may not) is a budget, for as long as its reset says, else a week. The hours until a reset are never taken as fewer than one, or a window a minute from renewing would outweigh all the rest. An account whose vendor tells no budget window, only a short one (Claude Enterprise's five hours), has nothing longer to keep for: what its five hours have left is lost at their reset, so it goes by that, per hour until then — the whole span when not started (#576): ahead of nearly every week, behind only one with more of it to lose sooner. Where the reading may leave a week out (a Claude account only heard of as Claude Code answered, partial) it is instead taken to have a week not started with the share its fullest window has used: those go by what they have used, among the rest as the fresh are. An account whose windows an auto-used reset starts again sooner than they renew (Restarts) goes by that instead, and due is then that time: what it has left is lost there.
func (Allowance) Pooled ¶ added in v0.1.1046
Pooled says whether a refusal of model for its allowance leaves the account's other models alone: the windows that count model and are full at share are each of some models only (Opus's own week, Cursor's Other Models pool) — or, none known full, no window of the whole account counts it, only pools. Then it is that model which is out, not the account: Cursor's Other Models used up leaves Auto and Composer in theirs (Xiaopodev on X).
func (Allowance) Renewal ¶ added in v0.1.670
Renewal is For's renews as routing ranks them: a window not started, or whose reset has passed, that says how long it runs is taken to renew that long from now — a five hours not started renews within five hours, the soonest of an account that has nothing longer (#576).
func (Allowance) Restarts ¶ added in v0.1.792
Restarts is when an auto-used reset starts the account's windows again, as the Codex reset about to run out is spent (expiringResetSpent): resetExpiryLead before it runs out, or now when the account is held up past then. What they have left then is lost, as at their own reset, so Weekly pace and Smart take it for their renewal when it comes sooner (#717, #718). Zero when none will be.
type AppImport ¶ added in v0.1.25
type AppImport struct {
Ref string `json:"ref"` // stable within its source
From string `json:"from,omitempty"` // where in the app: Claude Code, Codex…
Provider Provider `json:"provider"`
// Status is "new", "same" (magpie has it already: same endpoint and
// key) or "taken" (its id is another provider's here).
Status string `json:"status"`
Existing string `json:"existing,omitempty"` // the magpie provider it matches or collides with
// KeyOf is a magpie provider at the same address with another key:
// this one can join it as one more key instead of being a provider
// of its own.
KeyOf string `json:"keyOf,omitempty"`
Off string `json:"off,omitempty"` // why it isn't picked by default
Skip string `json:"skip,omitempty"` // why it can't be imported at all
}
AppImport is one provider an app holds, as magpie would add it.
type AppPick ¶ added in v0.1.25
type AppPick struct {
Source string `json:"source"`
Ref string `json:"ref"`
Mode string `json:"mode,omitempty"`
}
AppPick is one entry the user chose, and how it comes in: as a provider ("add", beside any with its id), in place of the one with its id ("replace"), or as one more key of the provider KeyOf names ("key").
type AppSource ¶ added in v0.1.25
type AppSource struct {
ID string `json:"id"` // cc-switch, alma
Name string `json:"name"` // as the app calls itself
Path string `json:"path"` // the file read
Found bool `json:"found"`
Error string `json:"error,omitempty"`
Items []AppImport `json:"items"`
}
AppSource is one app magpie can import from, with what it holds.
func ImportSources ¶ added in v0.1.25
func ImportSources() []AppSource
ImportSources reads every app magpie can import from.
type AutoPick ¶ added in v0.1.921
type AutoPick struct {
Model string `json:"model"`
Via string `json:"via"`
Skipped string `json:"skipped,omitempty"`
Refused string `json:"refused,omitempty"`
API string `json:"api,omitempty"`
Session bool `json:"session,omitempty"`
}
AutoPick is a model Copilot's Auto picked for a try of a request: where the pick came from, why not from /auto when it didn't, and Copilot's refusal of it, which the route shows (#256: a Student plan's picks were refused, the tries logged as "auto"). API is the path it was sent to (/responses, /chat/completions), Session whether Auto's session token went with it.
type BalancePart ¶ added in v0.1.587
type BalancePart struct {
Label string `json:"label,omitempty"`
Text string `json:"text"`
Percent *float64 `json:"percent,omitempty"`
}
BalancePart is one amount of a balance field, for a card to show each of several on a line of its own, its label apart from its figure, rather than all of them run together: Percent is its share, 0 to 100, when it was asked as one ("%" after it), for a meter.
type ClaudeLimit ¶ added in v0.1.199
ClaudeLimit is one allowance window as Claude Code tells it: its kind (five_hour, seven_day, seven_day_opus, seven_day_sonnet, seven_day_overage_included), the share used, 0–1, and when it renews, in Unix seconds (0 when not said).
type CodexWarm ¶ added in v0.1.182
type CodexWarm struct {
User string `json:"user"`
Windows []string `json:"windows"`
Err string `json:"error,omitempty"`
}
CodexWarm is what came of looking at one account: the windows it was sent a request for, and why that failed.
type DailyCredits ¶ added in v0.1.664
type DailyCredits struct {
// Since is the day magpie first read the account's credits: the days
// before it aren't known, not unused.
Since string `json:"since"`
// Days are the days of the last creditsShown with credits used, oldest
// first.
Days []DayCredits `json:"days"`
}
DailyCredits is what an account's credits went to day by day.
type DayCredits ¶ added in v0.1.664
DayCredits is one day's credits used ("2006-01-02", the local day).
type Detection ¶ added in v0.1.663
type Detection struct {
Result
// Base is the URL the provider keeps for it, as the editor's fields
// take it: …/v1 for OpenAI's two, the root for Anthropic's.
Base string `json:"base"`
}
Detection is what one API answered at the URL it was asked at.
type DevinFamily ¶ added in v0.1.45
DevinFamily is one entry of `devin models list`: a name that follows the family's newest model, and the pinned variants under it.
func DevinFamilies ¶ added in v0.1.45
func DevinFamilies(ctx context.Context) ([]DevinFamily, error)
DevinFamilies is the CLI's model list, kept a few minutes: the picker and the provider ask for it often and `devin models list` spawns a process that takes seconds (switching Claude Code's model took 5–10s while every state asked it anew). A list past its time is served as it is while it is read again in the background; only a caller with nothing known yet waits, and not one marked DevinNoWait.
type Entry ¶
type Entry struct {
ID string `json:"id"` // what the agent sends magpie
Model string `json:"model"` // what magpie sends the vendor
Name string `json:"name"` // the user's name for it, when they gave one (SetModelName)
Default string `json:"default,omitempty"` // the model's own name, when the user gave it another
Efforts []string `json:"efforts,omitempty"`
Provider Provider `json:"-"` // a group's: its first member's
Group string `json:"group,omitempty"` // set on a routing group (group.go)
Named bool `json:"-"` // a routing group the user made or changed: its name is theirs (Labels)
Icons []string `json:"-"` // a group's: its providers' icons, one per provider
Images bool `json:"images,omitempty"` // takes images as input (a group's: a member does)
ImageInput *bool `json:"-"` // explicit answer, nil when unknown
// Context is the tokens a prompt may hold, when known (a group's: the
// least of its members')
Context int `json:"context,omitempty"`
// Output is the most tokens a reply may hold, when known (a group's:
// the least of its members')
Output int `json:"output,omitempty"`
// Family is the provider's or group's tag (see Visible).
Family string `json:"family,omitempty"`
// Free is set on a model its subscription serves at no cost to it.
Free bool `json:"free,omitempty"`
// Rate and RateWas are the credits a request costs its subscription,
// as a multiple, and before a discount running now (catalog.Model's).
Rate float64 `json:"rate,omitempty"`
RateWas float64 `json:"rateWas,omitempty"`
// unless the group names its own (Group.Levels).
Shared []string `json:"-"`
// Reasoning is set on a model that thinks, levels or not: one with a
// thinking switch alone has it and no Efforts (a group's: every
// member thinks).
Reasoning bool `json:"reasoning,omitempty"`
// AgentsV2 is set on a model offering Codex's Ultra that no ChatGPT
// account answers for (a group's: none of its members): Codex is told
// multi-agent V2 for it, so Ultra hands work to its agents, whose
// tasks a magpie-served lead writes as text.
AgentsV2 bool `json:"-"`
}
Entry is one model as the agents see it.
func Catalog ¶
func Catalog() []Entry
Catalog lists the routing groups, then every exposed model of every ready provider not kept unlisted. A provider switched off has none in it.
func CatalogFor ¶ added in v0.1.111
CatalogFor is the catalog as agent is shown it, and what is kept from it (none when its lists aren't narrowed): its visibility's, less the models taken out of its lists one by one (HiddenModels).
func Deciders ¶ added in v0.1.142
func Deciders() []Entry
Deciders are the models of the decision providers ready now, as a group's classifier names them.
func EntryOf ¶ added in v0.1.532
EntryOf is the model as the agents see it, by the id they ask for. It is the catalog's own entry, so the window and reply limit it carries are the ones a request is routed and metered against, with whatever the user set already applied.
func InOrder ¶ added in v0.1.952
InOrder is es in agent's order: the entries ModelOrder names first, as it names them, then the rest as they come — a model added since goes after. Codex's own, a ChatGPT account's models, lead the rest, as Codex's list has them before magpie's.
func ListedFor ¶ added in v0.1.460
ListedFor is the catalog agent's visibility gives it, the models it may pick to show or not among, and what the visibility keeps from it.
func Served ¶ added in v0.1.77
func Served() []Entry
Served is the catalog with the unlisted providers' models as well: every model a routing group can be made of, or a request can name.
func ServedEntryOf ¶ added in v0.1.532
ServedEntryOf is the model a limit may be set on, by the id the user typed: any model its provider serves, not only the catalog's own entry. The setters ask serves — the provider's own models deciding, switched off or not — so a provider kept unlisted, still served through a routing group, takes a window and a reply limit all the same, and a provider switched off is served again as soon as it is on, keeping what it was given. Both keep it in the entry they answer with, so a query that said "is not a model this provider serves" about such an id would contradict the command run right after it, which stores one.
func Unlisted ¶ added in v0.1.572
func Unlisted() []Entry
Unlisted are the models Served has and Catalog doesn't: those of the providers kept for routing groups (Provider.Unlisted), which agents aren't offered.
func (Entry) Label ¶ added in v0.1.137
Label is how an agent's list names the entry: its name (the user's own, when they gave one, else the vendor's) with its provider's after it, or "routing group" for a group's — dropped only when a name of the user's own already carries the provider's, so it isn't said twice.
type Exclusion ¶
type Exclusion struct {
Agent string `json:"agent"`
Provider string `json:"provider,omitempty"` // set when the user removed it; saving it brings it back
// Name is the removed provider's, for a sign-in no agent names: a
// plugin's, whose Agent is "plugin" (#694)
Name string `json:"name,omitempty"`
Why string `json:"why"`
// SignedOut: the agent has accounts saved in magpie but isn't signed
// in where magpie looks, and so none of them is offered.
SignedOut bool `json:"signedOut,omitempty"`
// Users names those saved accounts (no secrets), so they can be
// removed from magpie while none of them is offered.
Users []string `json:"users,omitempty"`
// Quiet: the user asked not to be reminded of it; only the Add sheet
// offers it back.
Quiet bool `json:"quiet,omitempty"`
// Tucked: hidden from the Add sheet too, but for its "Show N hidden"
// and a search by name (#116).
Tucked bool `json:"tucked,omitempty"`
}
Exclusion is a sign-in magpie found but will not offer as a provider.
type Group ¶ added in v0.1.38
type Group struct {
ID string `json:"id"`
Name string `json:"name"`
Members []string `json:"members"` // "provider/model[:effort]" or "group/<id>", in order (see MemberEffort)
// Match are patterns its models are found by as well (#766): a glob
// over the "provider/model" id with * in it ("openrouter/*:free"), or
// a regular expression after "re:". Kept apart from Members, so the
// group follows the catalog: read, it has the models they match now
// after those it names (see withMatches).
Match []string `json:"match,omitempty"`
// Matched are the members the patterns match now, as Members has them
// after its own. Derived each time the group is read, never stored.
Matched []string `json:"matched,omitempty"`
Routing string `json:"routing,omitempty"` // as Provider.Routing, over all the members' keys and accounts; or Manual
Affinity string `json:"affinity,omitempty"` // as Provider.Affinity
// Sink is Provider.Sink over the group's members' accounts and keys
// together: one rate limited with quota left goes behind every other
// member's. Not for "rotate" or Manual.
Sink bool `json:"sink,omitempty"`
// FirstToken is how many seconds a member's streamed reply may take to
// its first content — text, reasoning or a tool call — before the next
// member is asked instead, nothing of it having reached the agent; 0
// waits as long as it takes. The last one left is always waited for,
// and the slow one doesn't rest.
FirstToken int `json:"firstToken,omitempty"`
// Off are the members switched off: kept where they are in the
// order, with their rules, but sent nothing until switched on again,
// so trying a group without one doesn't mean taking it out.
Off []string `json:"off,omitempty"`
// Pick is the member a Manual group sends every request to, as the
// user picked it on the group's card; "" is its first. It is kept
// while the group routes otherwise, for when it is manual again.
Pick string `json:"pick,omitempty"`
// Rules send the requests they match to one member first, in order:
// the first that matches decides (see Rule).
Rules []Rule `json:"rules,omitempty"`
// Classifier is the model ("provider/model") asked which of the rules'
// intents a user's message is, or a group ("group/<id>", never this
// one) whose models are asked in turn, failing over as for any request.
// Rules with an intent need one; a small, fast model without reasoning
// does.
Classifier string `json:"classifier,omitempty"`
// Effort "auto" has the classifier — Jev, from TypeSafe's decision API,
// or any model, asked in words — judge how hard each turn is to think
// about as it begins, and the turn asks its model for that much
// reasoning, where the agent asked for some (see EffortAuto).
Effort string `json:"effort,omitempty"`
// Context is how long a request the user says the group takes, in
// tokens: agents are told it rather than its largest member's.
// ContextSmallest tells them its smallest member's, whichever that is
// as the members change (Mikan on Discord), so the agent compacts
// before any member would turn the conversation away.
Context int `json:"context,omitempty"`
// Levels are the reasoning levels agents are offered for the group,
// lowest first, when the user names them (#295): rather than those
// every member has, so that a member with few doesn't take the rest
// from the others. A member without the level a request asks for is
// sent the one it has nearest, as ever. Empty offers the members'
// shared levels.
Levels []string `json:"levels,omitempty"`
// Fast are the members (as Members spells them) sent in their
// vendor's fast mode, where the model has one (see CanFast). Kept
// beside Members, not in their ids, so a version before it still
// routes to them, only not fast.
Fast []string `json:"fast,omitempty"`
// Family is a tag the group goes by in which agents are shown it
// (settings' Visible), with its id.
Family string `json:"family,omitempty"`
// Auto is set on a group magpie found: one model served by several
// providers. It is derived, never stored.
Auto bool `json:"auto,omitempty"`
// Hidden is stored for a found group the user removed.
Hidden bool `json:"hidden,omitempty"`
// Disabled is a group of the user's switched off (PAMI on Discord):
// kept on the Routing page as it is, but not offered to agents, a
// request to it turned away with a word of why, and skipped where
// another group has it in it, until switched on again (SwitchGroup).
// Only SwitchGroup changes it: a save keeps it as it was.
Disabled bool `json:"disabled,omitempty"`
}
func DisabledGroup ¶ added in v0.1.989
DisabledGroup is the group of the user's a model id names ("group/<id>", or a model's as GroupFor takes it) when it is switched off.
func Groups ¶ added in v0.1.38
func Groups() []Group
Groups lists the user's groups, then those magpie found, hidden ones too (marked so), in the order the user put them in (SetGroupOrder) where they did: the Routing page, the gateway's model list, the CLI and the TUI all list them so.
func GroupsWith ¶ added in v0.1.102
GroupsWith are the groups that have the group id in them as a member.
func StoredGroups ¶ added in v0.1.76
StoredGroups is the groups as saved: the user's own, and the found ones the user removed. As with Stored, a file that can't be read is an error.
func (Group) Live ¶ added in v0.1.498
Live is the group as the gateway routes it: a manual group's rules wait (the member picked is all it sends to), though they are kept.
func (Group) Picked ¶ added in v0.1.498
Picked is the member a manual group sends to: the one the user picked while it is in the group, else its first.
func (*Group) RenameMember ¶ added in v0.1.577
RenameMember has the group's member from go by to (its effort changed): its rules, its pick, its fast mode and its being off follow it.
func (Group) Ruled ¶ added in v0.1.142
Ruled reports whether the group decides anything as a user's turn begins: a rule to put a member first, or the turn's effort.
func (*Group) SetMemberFast ¶ added in v0.1.577
SetMemberFast sends the group's member id fast, or not, where it is in the group.
type ImportedAccount ¶ added in v0.1.326
type ImportedAccount struct {
// User is the account's email, or "#n" (its place in the file) when
// the file doesn't say and Google wasn't asked or didn't answer.
User string `json:"user"`
// Status: "added", "updated" (in magpie already, now with this
// sign-in), "exists" (in magpie already with this very sign-in),
// "failed".
Status string `json:"status"`
Plan string `json:"plan,omitempty"`
Error string `json:"error,omitempty"`
}
ImportedAccount is what became of one account in an import.
func ImportFactoryKeys ¶ added in v0.1.638
func ImportFactoryKeys(ctx context.Context, texts []string) ([]ImportedAccount, error)
ImportFactoryKeys adds Factory accounts by their API keys, found in the pasted texts, each checked with whoami first, and says what became of each.
func ImportGoogleAccounts ¶ added in v0.1.326
func ImportGoogleAccounts(ctx context.Context, agent string, files []string) ([]ImportedAccount, error)
ImportGoogleAccounts brings in the accounts in exports from other tools (see above), each file's text one element of files, and says what became of each.
func ImportLogins ¶ added in v0.1.401
ImportLogins brings in ChatGPT (agent "codex") or Claude ("claude") accounts from other tools' files (see above), each file's text one element of files, and says what became of each.
type KeyAccount ¶ added in v0.1.14
type KeyAccount struct {
Name string `json:"name,omitempty"`
Key string `json:"key"`
Off bool `json:"off,omitempty"`
// Protocol, when set, is the only one the key works with: some relays
// give out one key for Anthropic and another for OpenAI. Empty is any.
Protocol Protocol `json:"protocol,omitempty"`
// Weight is the key's share of the requests when the provider's
// routing is Weighted (#841): one with 3 takes three for every one a
// key with 1 takes. None, or 0, counts as 1.
Weight int `json:"weight,omitempty"`
}
KeyAccount is a saved key after the first. Off keeps it without using it.
func (KeyAccount) WeightOf ¶ added in v0.1.933
func (k KeyAccount) WeightOf() int
WeightOf is the key's weight as Weighted routing counts it: 1 when none.
type KeyInfo ¶ added in v0.1.14
type KeyInfo struct {
ID string `json:"id"` // a fingerprint, to name it in a switch
Name string `json:"name,omitempty"`
Masked string `json:"masked"`
Active bool `json:"active"` // the first, where requests go
On bool `json:"on"` // in use: the first, or next in line
Protocol Protocol `json:"protocol,omitempty"` // the only one it works with
Weight int `json:"weight,omitempty"` // its share when routing is Weighted
// Rest is why the gateway passes it over now, after a failure, and
// until when; nil while it takes requests.
Rest *KeyRest `json:"rest,omitempty"`
}
KeyInfo describes one of a provider's keys without giving it away.
type KeyRest ¶ added in v0.1.930
type KeyRest struct {
Why string `json:"why"`
Status int `json:"status"`
Until time.Time `json:"until"`
Key string `json:"key"`
}
KeyRest is a key's rest as the gateway keeps it: failQuota, failRate…, the status it answered, until when, and the key to lift it by.
type KiroAuth ¶ added in v0.1.141
type KiroAuth struct {
Token string
TokenType string // the tokentype header: API_KEY, EXTERNAL_IDP, or none
Profile string // the profile ARN
Region string // where the account's API is
}
KiroAuth is what a call to Kiro's API is made with.
func KiroAuthOf ¶ added in v0.1.141
KiroAuthOf is a Kiro account's credentials: those of the key saved on the provider, of the account magpie signed in in home, or of Kiro's own sign-in when both are "". A token about to expire is refreshed first; stale, after Kiro turned one down, refreshes it now.
type Limit ¶ added in v0.1.38
type Limit struct {
Used float64 // share used, 0–100
Resets time.Time // zero when not known
Span time.Duration // how long the window runs; zero when not known
Model string // the only models it counts, by a word in their ids
// Amount of Of in Unit: the window's own count, used, when the vendor
// counts it so (QuotaWindow.Amount)
Amount, Of float64
Unit string
// ResetRunsOut is when the reset the account spends by itself before
// it runs out does (resetRunsOut): spent then, it starts this window
// again — at Restarts, which routing takes for the window's renewal
// when it is the sooner. Zero when none will be spent so.
ResetRunsOut time.Time
// contains filtered or unexported fields
}
Limit is one window of an allowance.
type Login ¶ added in v0.1.11
type Login struct {
Agent string `json:"agent"`
User string `json:"user"`
Plan string `json:"plan,omitempty"`
Seen time.Time `json:"seen"`
Active bool `json:"active"` // the agent is signed in to this one now
On bool `json:"on"` // in use: the active one, or next in line
// Lapsed says the vendor refused to refresh a saved account's sign-in:
// it has to be signed in again before it can be used.
Lapsed string `json:"lapsed,omitempty"`
// Own is the agent's own sign-in, which magpie only reads: removed, it
// is hidden rather than deleted (side_logins.go).
Own bool `json:"own,omitempty"`
// Paused is the account the agent is signed in to, passed over by the
// gateway while another is on (savedLogin.Paused).
Paused bool `json:"paused,omitempty"`
// Returns is the account magpie signed the agent out of when it was
// spent, and signs it back in to once it has room again (#408).
Returns bool `json:"returns,omitempty"`
// contains filtered or unexported fields
}
Login is a remembered subscription account, without its secrets.
type Member ¶ added in v0.1.38
type Member struct {
ID string // the group's member it is: the model, or the group in the group it is of
// Path is the members from the group's own down to the model: [ID] for
// a model the group names itself, ["group/fast", "a/m"] for one of
// its group fast, and so on down.
Path []string
// Via are the groups in the group it is of, the outermost first: the
// group each of Path's members but the last names.
Via []Group
Provider Provider
Model string // what the vendor is asked for
// Effort is the reasoning the member is fixed at ("provider/model:low"),
// asked of the model whatever the agent or the group's classifier
// asked; "" follows the group.
Effort string
// Fast is set on a member the group sends in its vendor's fast mode
// (Group.Fast), where its model has one.
Fast bool
}
Member is one of a group's models as it resolves now.
type Migration ¶ added in v0.1.506
type Migration struct {
State string `json:"state"`
Package string `json:"package,omitempty"`
At time.Time `json:"at"`
Err string `json:"error,omitempty"`
// Accounts are the plugin's accounts the move made or took over.
Accounts []movedAccount `json:"accounts,omitempty"`
// Backup is the built-in's accounts as logins.json kept them.
Backup []savedLogin `json:"backup,omitempty"`
// Kept is what else of the built-in's the move set aside (Kiro's key).
Kept json.RawMessage `json:"kept,omitempty"`
// Installed is whether the move installed the plugin: going back takes
// it away again when it serves nothing else.
Installed bool `json:"installed,omitempty"`
// Host is the built-in's API host, which the plugin's provider shows.
Host string `json:"host,omitempty"`
// Why is a failed move's reason, for the page to say in the user's
// language.
Why *MoveWhy `json:"why,omitempty"`
}
Migration is where one built-in's move stands.
func MigrationOf ¶ added in v0.1.506
MigrationOf is where the built-in id's move stands.
type ModelDetection ¶ added in v0.1.671
ModelDetection is what each API answered for one model (01huadalang on Discord: 应该能看出来选择的模型支持情况…有的仅支持 response 有的双协议).
type ModelPref ¶ added in v0.1.648
type ModelPref struct {
Name *string `json:"name,omitempty"`
Efforts *[]string `json:"efforts,omitempty"`
Images *bool `json:"images,omitempty"`
OwnImages bool `json:"ownImages,omitempty"`
API *string `json:"api,omitempty"`
Same *string `json:"same,omitempty"`
Price *catalog.Price `json:"price,omitempty"`
OwnPrice bool `json:"ownPrice,omitempty"`
}
ModelPref is what the provider editor's Names & levels changed of one model, sent with its Save: each part left nil is as it was. Name "" gives the model its own name back, Efforts [] all its levels, OwnImages the vendor's answer for whether it sees images, API "" every API the provider has for it, Same "" its own id to merge it with other vendors' by (see SetModelSame), and OwnPrice its list price again in place of Price, what the user said it costs (SetModelPrice, #819).
type MoveCandidate ¶ added in v0.1.552
type MoveCandidate struct {
ID string `json:"id"`
Name string `json:"name"`
Package string `json:"package"`
Accounts int `json:"accounts"`
}
MoveCandidate is a built-in with accounts its plugin could run instead.
func MoveCandidates ¶ added in v0.1.552
func MoveCandidates() []MoveCandidate
MoveCandidates are the built-ins not on their plugins that have accounts to move, by name.
type MoveWhy ¶ added in v0.1.552
MoveWhy is why a move didn't go through: Code names the case, Args fill in its sentence.
offline magpie couldn't reach npm (or Bun's download) to install the plugin
install npm couldn't install it: line
lapsed every account of name needs signing in again
unserved the plugin doesn't serve models (their names) for user (with
its plan), though the built-in does
account user doesn't work through the plugin: error
type Moving ¶ added in v0.1.506
type Moving struct {
User string
First, On bool
// Lapsed is an account the vendor already refused: it goes along, but
// isn't tried.
Lapsed bool
// Plan is the plan the account showed, kept beside it until the
// plugin tells it anew.
Plan string
// Own is the agent's own sign-in (its CLI's, its app's), which the
// plugin reads where the agent keeps it, as the built-in did.
Own bool
Auth map[string]any
}
Moving is one of a built-in's accounts on its way to the plugin.
type PatternHit ¶ added in v0.1.826
PatternHit is one of a group's patterns and how many of the models served now it matches.
func PatternHits ¶ added in v0.1.826
func PatternHits(g Group) []PatternHit
PatternHits are the group's patterns, each with the number of models it matches now — those the group names itself as well — so that one that matches nothing is said, not left an empty group.
type PresetDef ¶
type PresetDef struct {
ID string `json:"id"`
Name string `json:"name"`
Icon string `json:"icon"`
Kind Kind `json:"kind"`
Chat string `json:"chat,omitempty"`
Responses string `json:"responses,omitempty"`
Anthropic string `json:"anthropic,omitempty"`
Decide string `json:"decide,omitempty"` // a decision API: the provider only routes (see decide.go)
Catalog string `json:"catalog,omitempty"`
Website string `json:"website,omitempty"`
KeysURL string `json:"keysUrl,omitempty"`
NoKey bool `json:"noKey,omitempty"` // local servers: a key is optional
KeyHint string `json:"keyHint,omitempty"` // the key field's placeholder, when it says more than NoKey's
Sponsored bool `json:"sponsored,omitempty"` // shown first, with a tag
Note string `json:"note,omitempty"` // one line under the name
Short string `json:"short,omitempty"` // the add sheet's name for it, when Name is long
Regions []Region `json:"regions,omitempty"` // base-URL choices (a relay's regional endpoints, a vendor's plans)
// RegionLabel names what the Regions choose between, "Region" if unset.
RegionLabel string `json:"regionLabel,omitempty"`
// HeaderHints name optional request headers the vendor documents, which
// the editor offers to add; their values are the user's to fill in.
HeaderHints []string `json:"headerHints,omitempty"`
// Only, for a plan behind a key that also buys much else, is what its
// models' ids start with: the rest of the vendor's list is left out.
// Models are the plan's, for when the list has none of them.
Only string `json:"only,omitempty"`
Models []string `json:"models,omitempty"`
// NoList: the vendor has no list of models to ask for (Bedrock's
// runtime serves no /models), so Models are its list
NoList bool `json:"noList,omitempty"`
// Endpoint, for a vendor reached at the user's own resource (Azure
// OpenAI), is an example of its address: the preset gives no URL, and
// the editor asks for the one the user's resource is at, with
// EndpointHint under it.
Endpoint string `json:"endpoint,omitempty"`
EndpointHint string `json:"endpointHint,omitempty"`
// EndpointNeeded is what the editor says when no endpoint was given.
EndpointNeeded string `json:"endpointNeeded,omitempty"`
// Hosts: a vendor serving other makers' models as well as its own
// (Groq, Ollama Cloud, Azure), whose list is no maker's word on theirs
Hosts bool `json:"-"`
}
PresetDef describes one preset.
type Protocol ¶
type Protocol string
Protocol is a wire API magpie can speak to an upstream.
const CodeAssist Protocol = "codeassist"
CodeAssist is Google's Code Assist API, which magpie only speaks upstream, to a Gemini CLI or Antigravity account. Not in Protocols: no other provider serves it.
type Provider ¶
type Provider struct {
ID string `json:"id"`
Name string `json:"name"`
// Was are ids the provider had before it was renamed (see Rename):
// a model still picked by one of them reaches it.
Was []string `json:"was,omitempty"`
Icon string `json:"icon,omitempty"`
Preset string `json:"preset,omitempty"` // preset this was created from, if any
Key string `json:"key"` // API key, as typed by the user
// KeyName names the key in use, and Keys are the provider's other
// accounts: keys saved to switch to (see keys.go).
KeyName string `json:"keyName,omitempty"`
Keys []KeyAccount `json:"keys,omitempty"`
// KeyProtocol, when set, is the one protocol the first key is good
// for: a relay that hands out one key for Anthropic and another for
// OpenAI (see KeyAccount.Protocol).
KeyProtocol Protocol `json:"keyProtocol,omitempty"`
// KeyWeight is the first key's weight (see KeyAccount.Weight).
KeyWeight int `json:"keyWeight,omitempty"`
// Base URLs, one per protocol the vendor serves natively. magpie appends
// the usual paths: chat/responses bases end in /v1 (OpenAI style),
// the Anthropic base is the root (what ANTHROPIC_BASE_URL takes).
Chat string `json:"chat,omitempty"`
Responses string `json:"responses,omitempty"`
Anthropic string `json:"anthropic,omitempty"`
// Decide is the base of a decision API (TypeSafe's System One, which
// Jev answers), for routing groups' choices of model and effort. The
// provider may also serve conversations on the other endpoints.
Decide string `json:"decide,omitempty"`
// Fallback is where a request goes when this provider can't take it —
// out of quota, rate limited, overloaded or down — before any of the
// reply has been sent: models as agents pick them (provider/model),
// tried in order.
Fallback []string `json:"fallback,omitempty"`
// Routing is how requests spread over the keys or accounts it has on:
// "" smart, the first while it has quota to spare, then whichever has
// the most; "order" in order, the next one only when the one before
// can't take it; "rotate" each in turn; "usage" the least used first;
// "pace" the one with the most remaining allowance per hour until
// its window resets first, so less allowance is lost at reset.
// The window can be shorter than a week. "weight" by each key's
// weight, a key with 3 taking three requests to one with 1's.
// Whichever it is, one out of credit, out of quota, rate limited or
// failing is passed over for as long as that lasts.
Routing string `json:"routing,omitempty"`
// Sink sends a key or account that a 429 rate limited while it still
// had quota to the back of the order Routing gives (01huadalang): it
// is tried again only after every one not rate limited since — so the
// load goes round, rather than back to the first each time its rest
// ends. Off, the default, it keeps its place. Not for "rotate", which
// goes round already. See gateway.sink.
Sink bool `json:"sink,omitempty"`
// Affinity is how long a conversation stays with the key or account
// that answered it, so the vendor's prompt cache it filled is read
// again rather than lost (see Affinities): "" auto, "session",
// "turn", "off".
Affinity string `json:"affinity,omitempty"`
// KeepLogin, on Codex's or Claude Code's subscription, keeps the agent
// signed in to the account the user made first: magpie doesn't sign it
// in to another when that one runs low or out (#524). The gateway still
// spreads its requests over the accounts that are on, as Routing says.
KeepLogin bool `json:"keepLogin,omitempty"`
// KeepLoginAs, with KeepLogin, is the account the agent is kept signed
// in to whichever is first in the order the gateway tries them: the one
// the user uses the agent as, while the first is only the one whose
// allowance is spent first (#524). Empty, it is the first.
KeepLoginAs string `json:"keepLoginAs,omitempty"`
// MaxConcurrency is how many requests may be out at the vendor at once
// on each of its keys or accounts (Discord, Lemon: a Codex account is
// risk-controlled past five or six at once); the rest wait their turn,
// in the order they came (see Concurrency). nil follows what a
// plugin's provider says it takes, else none; 0 is no limit.
MaxConcurrency *int `json:"maxConcurrency,omitempty"`
// AccountConcurrency is, for one account or key, its own limit over
// MaxConcurrency (#892): an account by its name in lower case, a key
// by its KeyID; 0 there is no limit for it. One not in it takes the
// provider's (see LaneLimit).
AccountConcurrency map[string]int `json:"accountConcurrency,omitempty"`
// QueueLimit is how many requests may wait for a slot of each key or
// account at once (#892); one more is turned away as the queue being
// full. 0 is no bound.
QueueLimit int `json:"queueLimit,omitempty"`
// QueueWait is how long, in seconds, a request waits for a slot before
// it is turned away as having waited too long (#892). 0 waits as long
// as it takes.
QueueWait int `json:"queueWait,omitempty"`
// PriceRate is what the provider charges against the official price
// (ITea312, #819): a relay that bills 0.8× or 1.5× of it. It scales the
// provider's list price, else its maker's, wherever a cost is counted;
// a price the user set for one of its models stands as set. 0 is the
// price as listed; at most three decimals (PriceRateOK).
PriceRate float64 `json:"priceRate,omitempty"`
// Headers are extra HTTP request headers sent to the vendor, exactly as
// the user typed them. They ride on every request magpie makes to a plain
// key+URL provider — forwarded calls, connectivity tests, and model-list
// fetches — applied after the auth headers, so the user can override those
// when a gateway insists on a private scheme. Signed-in agent accounts
// ignore them: their auth is the agent's own.
Headers map[string]string `json:"headers,omitempty"`
// Searches says the vendor answers a web search tool offered on its
// Anthropic or Responses API by itself (web_search_20250305,
// web_search): a relay in front of Anthropic's or OpenAI's API, which
// magpie can't tell from its host. A request offering one then goes to
// it as the client sent it, rather than given magpie's search (#359).
Searches bool `json:"searches,omitempty"`
// PinUpstream, on the Cline API, has its DeepSeek models answered only
// by DeepSeek's own API (White Immortal on Discord): Cline routes a
// model through an AI gateway that may serve it from any host, and
// DeepSeek's own keeps its prompt cache. See ClinePin.
PinUpstream bool `json:"pinUpstream,omitempty"`
// Proxy is the proxy magpie's requests to this provider go through
// (#237: Codex through one, a vendor at home without): "" follows
// the global one (Settings' Proxy, the environment's, the system's),
// "direct" none, anything else the proxy's address (http://, https://,
// socks5://; host:port means http). Signed-in accounts keep it too.
Proxy string `json:"proxy,omitempty"`
// AccountProxies is, for a subscription holding several accounts
// (Codex's, Claude Code's…), the proxy of each account that has one
// of its own, by its name in lower case, as Proxy takes one; an
// account not in it follows Proxy (see ProxyChoice).
AccountProxies map[string]string `json:"accountProxies,omitempty"`
// AccountModels is, for a provider holding several accounts or keys,
// the models each one the user narrowed serves, and no others (#474):
// an account by its name in lower case, a key by its KeyID. One not in
// it serves every model the provider does (see account_models.go).
AccountModels map[string][]string `json:"accountModels,omitempty"`
// AccountCaps is, for a subscription, the share (1–99) of its usage
// windows each account the user capped is used to at most, by its name
// in lower case: past it, routing takes the account for used up until
// the window renews (see account_caps.go). One not in it has no cap.
AccountCaps map[string]int `json:"accountCaps,omitempty"`
// BalanceURL, when set, is where the vendor tells what is left on a
// key, asked with the key the way a chat request carries it; BalancePath
// picks the amount out of the JSON reply (see balance.go). The vendors
// magpie knows need neither.
BalanceURL string `json:"balanceURL,omitempty"`
BalancePath string `json:"balancePath,omitempty"`
// BalanceToken is what a vendor tells the whole account's balance to,
// where a key is told only what is left on itself: AiHubMix's system
// access token, or a new-api relay's for its /api/user/self named in
// BalanceURL (see TakesBalanceToken). It is asked with nothing else but
// the provider's headers, when the endpoint is one named.
BalanceToken string `json:"balanceToken,omitempty"`
// ZhipuTeam, for a Zhipu or Z.ai key on a team's GLM Coding Plan, is
// the team's organization and project, from the BigModel console: the
// team's windows are told to the key only with them (see
// zhipuKeyTeamWindows). nil for a key of the user's own plan.
ZhipuTeam *ZhipuTeam `json:"zhipuTeam,omitempty"`
// ModelsURL, when set, is where the vendor lists its models, for one
// that lists them away from the base URL requests go to (Xiaomi MiMo's
// plans are served at their own hosts, the list at api.xiaomimimo.com).
ModelsURL string `json:"modelsURL,omitempty"`
// Models the user chose to expose. Empty means "the preset's picks, or
// everything the vendor lists when that list is short".
Models []string `json:"models,omitempty"`
// Unlisted keeps the provider's own models out of the list agents see:
// it serves only through the routing groups it is in, and by its
// "provider/model" ids.
Unlisted bool `json:"unlisted,omitempty"`
// Off switches the provider off without removing it: its keys and
// settings stay, but agents aren't given its models, no request,
// routing group or fallback goes to it, and its balance isn't asked,
// until it is switched on again (#163) — for a key out of quota.
Off bool `json:"off,omitempty"`
// Contexts is how long a request the user says a model takes, in
// tokens, over what the vendor or models.dev says: by model id, "*"
// for all the provider's models. Agents are told it.
Contexts map[string]int `json:"contexts,omitempty"`
// Family is a tag the provider's models go by in which agents are
// shown them (settings' Visible), with the provider's id.
Family string `json:"family,omitempty"`
Catalog string `json:"catalog,omitempty"` // models.dev id, for names and reasoning levels
Website string `json:"website,omitempty"`
KeysURL string `json:"keysUrl,omitempty"`
// IconURL is a picture the vendor named in an import link, to be fetched
// once the user confirms. It is only a carrier between parsing and that
// fetch: Save drops it, so it never reaches providers.json.
IconURL string `json:"iconUrl,omitempty"`
// Hidden is set on an account the user removed from magpie; the
// agent stays signed in, magpie just leaves it alone.
Hidden bool `json:"hidden,omitempty"`
// Quiet is set on a removed account whose "Add it back" line the user
// dismissed: it is offered again only from the Add sheet (#116).
Quiet bool `json:"quiet,omitempty"`
// Tucked is set on a quiet one the user hid from the Add sheet too:
// it is listed there only behind "Show N hidden", or when searched
// for by name (#116).
Tucked bool `json:"tucked,omitempty"`
// Account is set when the provider is an agent the user signed in to
// (see account.go); it is derived, never stored.
Account *Account `json:"-"`
}
Provider is one configured vendor.
func All ¶
func All() []Provider
All lists the configured providers in the order they were added, then the signed-in agents. An entry in the file with no URL is only the model picks for one of those accounts. A request that holds the catalog (Hold) builds it once: each build reads every agent's sign-in, a keychain item or a CLI's among them, and Codex's /models asked for it seven times over, past the 5 s Codex waits for the list (#746).
func FromPreset ¶
FromPreset builds a provider from a preset; the caller adds the key. An id the preset carried before builds it at the region that id was.
func Hidden ¶ added in v0.1.9
func Hidden() []Provider
Hidden lists the signed-in accounts the user removed from magpie.
func ParseImport ¶ added in v0.1.8
ParseImport reads an import link into the provider it describes.
func Resolve ¶
Resolve maps an id an agent sent to a provider and the vendor's model id. It accepts catalog ids, "provider/model" for any model (exposed or not), and the bare model id when exactly one provider serves it. A group's id resolves to its first member.
func RouteDecider ¶ added in v0.1.411
RouteDecider is the decision provider a System One model names, and the model that provider is asked with. The name's prefix is the provider (gptload-jev/jev-latest, vercel-jev/typesafe-ai/jev). A bare Jev id goes to the only provider that can answer it, as that provider names Jev.
func Stored ¶ added in v0.1.28
Stored is the providers as providers.json keeps them: keys included, signed-in accounts only as the model picks the user made for them. A file that can't be read is an error, never none: a backup or a sync carrying none would take every provider away where it is put back.
func SwitchedOff ¶ added in v0.1.346
SwitchedOff is the provider switched off in magpie that a model id names: as "provider/model", or a model only switched-off providers list. A request for it is refused as that, not as a model magpie doesn't know.
func (Provider) APIs ¶ added in v0.1.40
APIs lists the APIs model is served on, as the provider's last model list said: Copilot serves its GPT models on Responses alone and its Claude models on Chat and Anthropic's. nil is not known, and every API the provider speaks may be tried. One the user set for the model (SetModelAPI) is the only one.
func (Provider) AccountCap ¶ added in v0.1.809
AccountCap is the share (1–99) of its windows the account user of p is used to at most, 0 when it has no cap. An account made afresh beside the agent's own (AlsoOn) carries none of the provider's settings: they are read from providers.json then.
func (Provider) AccountConcurrencyOf ¶ added in v0.1.1009
AccountConcurrencyOf is the account's or key's own limit, and whether it has one (else it takes the provider's).
func (Provider) AccountRefOf ¶ added in v0.1.1009
AccountRefOf is the account or key of p that ref names, as its limit is kept: an account's name, a key's KeyID (by its id or name).
func (Provider) AccountRefs ¶ added in v0.1.610
AccountRefs are the provider's accounts, or keys, as AccountModels knows them: a signed-in account's name, a key's KeyID.
func (Provider) AccountServes ¶ added in v0.1.610
AccountServes says whether the account or key ref (a signed-in account's name, a key's KeyID) is let serve model: true when it has no list of its own.
func (Provider) AlsoOn ¶ added in v0.1.14
AlsoOn is a signed-in agent's other accounts that are on, each as a provider of its own, in the order they were saved.
func (Provider) AskSystemOne ¶ added in v0.1.723
AskSystemOne sends model the smallest System One question at p's decision API, and says why it wasn't answered.
func (Provider) AsksDecideModels ¶ added in v0.1.838
AsksDecideModels reports whether each of p's decision models can be sent a System One question of its own (TestModels): where the API is System One's, TypeSafe's or a gateway's that serves it as it is (Vercel's TypeSafe API, OpenRouter's), or Workers AI's, which DecideAsk wraps it for (ARNO on Discord: cloudflare-jev's models couldn't be tested from their right-click); not Vercel's evaluation models, which name the model in headers of their own.
func (Provider) AutoNext ¶ added in v0.1.914
AutoNext is the model Copilot's Auto picks now for a request ctx resolved for it (ResolveAuto), "" for any other: once Retry has said a refused pick is worth sending again, the one it goes as.
func (Provider) Available ¶
Available lists every model the vendor is known to serve: the list fetched from the vendor itself when there is one, over the models.dev catalog (or, for an account, whatever the agent's own sign-in can see).
func (Provider) Catalogs ¶ added in v0.1.13
Catalogs are the models.dev ids the provider's models are looked up in, first match wins: a gateway that resells several vendors names them all ("openai, deepseek").
func (Provider) ClinePin ¶ added in v0.1.934
ClinePin is the upstream a request for model is pinned to on p (PinUpstream): "deepseek" for a DeepSeek model of the Cline API, "" for anything else. Cline's free models are served where Cline puts them, so they never are.
func (Provider) ClinePinnable ¶ added in v0.1.959
ClinePinnable reports whether p's requests reach Cline's API and can be pinned to an upstream (PinUpstream): the ClinePass provider, one on cline.bot, or the Cline plugin's (@magpie-community/opencode-cline-auth), whose requests magpie writes before the plugin sends them on.
func (Provider) Concurrency ¶ added in v0.1.633
Concurrency is how many requests the gateway lets be out at the vendor at once on each of the provider's keys or accounts, 0 for no limit: the user's MaxConcurrency when they set one, else what the plugin giving the provider says it takes (its auth hook's maxConcurrency, or its package.json's magpie.maxConcurrency), else none.
func (Provider) ContextOf ¶ added in v0.1.107
ContextOf is the context the user set for the provider's model: its own, else the provider's "*"; 0 when none is set.
func (Provider) DecideModelURL ¶ added in v0.1.859
DecideModelURL is where a question for model is posted: DecideURL, or, for a Clef on Workers AI, its own run under it.
func (Provider) DecideOnly ¶ added in v0.1.686
DecideOnly reports whether the provider has no conversation endpoint.
func (Provider) DecideURL ¶ added in v0.1.218
DecideURL is where a question for p's decision API is posted. Workers AI's is under an account: the one its base names, else the one the token belongs to, looked up once.
func (Provider) DecideVia ¶ added in v0.1.218
DecideVia is the way p's decision API is asked, known by its host or by the gateway's own path (Vercel's /typesafe or /v4/ai, Cloudflare's /client/v4).
func (Provider) DecidesModel ¶ added in v0.1.686
DecidesModel distinguishes Jev from the conversation models a gateway also serves. A dedicated decision API may use any model name.
func (Provider) DecisionModels ¶ added in v0.1.928
DecisionModels are the decision models a provider that serves conversations too lists apart from them (OpenRouter's), for its editor to show beside its chat models; nil for any other provider.
func (Provider) Detect ¶ added in v0.1.663
Detect asks each of Chat, Responses and Anthropic at the URL p has for it, else at base as it takes it (DetectBase), the smallest request, and says what each answered, in that order. model is asked on all three; with none, one from p's list is picked for each — a Claude model on Anthropic's, an OpenAI one on Responses — and with no list, the vendor is asked for one first (a GET of its models, which costs nothing). Only those URLs are asked, and only a key's provider: a sign-in's API is its agent's.
func (Provider) DetectDecide ¶ added in v0.1.723
DetectDecide asks the System One API at p's decision URL (…/systemone pasted whole is cut to its root) the smallest question for model, or the one p is asked with when none is given, and says how it answered.
func (Provider) DetectModels ¶ added in v0.1.671
func (p Provider) DetectModels(ctx context.Context, base string, models []string) ([]ModelDetection, []Detection, error)
DetectModels asks each of models (the first DetectMax, an image model left out: it is asked on the images API) on each of Chat, Responses and Anthropic at the URL p has for it, else at base as it takes it, and says what each answered, model by model; and, by API, the first answer from a model it served, else the first model's — what Detect says for one. A probe not started before ctx ends says so, unasked.
func (Provider) Do ¶ added in v0.1.479
Do sends req, through the account's own transport when it has one (a plugin's), the client the account asks for this request when it asks for one (ZCode's Start Plan: zcodeStartClient), and client otherwise.
func (Provider) Efforts ¶ added in v0.1.59
Efforts are the reasoning levels the model takes, when known: its own, or those the user gave it when it has none known.
func (Provider) Explain ¶ added in v0.1.447
Explain is the error a refusal is passed on as: msg, with what the user can do about it when the account knows.
func (Provider) Exposed ¶
Exposed lists the models magpie offers to agents for this provider: the user's picks; else the preset's; else everything, when that is few.
func (Provider) IsAzure ¶ added in v0.1.419
IsAzure reports whether the provider is Azure OpenAI: made from its preset, or at a resource's host.
func (Provider) IsBedrock ¶ added in v0.1.364
IsBedrock reports whether the provider is Amazon Bedrock's runtime: made from its preset, or at its host.
func (Provider) IsCline ¶ added in v0.1.630
IsCline reports whether the provider is the Cline API: made from the ClinePass preset, or at Cline's host.
func (Provider) IsKilo ¶ added in v0.1.635
IsKilo reports whether the provider is the Kilo Gateway: made from its preset, or at Kilo's API host.
func (Provider) IsOpenCode ¶ added in v0.1.7
IsOpenCode reports whether the provider is OpenCode's gateway (Zen or Go), which routes and caches by conversation and turns away requests that do not name one in x-opencode-session.
func (Provider) IsRemoteMagpie ¶ added in v0.1.527
IsRemoteMagpie reports whether the provider is another magpie.
func (Provider) Jev ¶ added in v0.1.218
Jev is the model a decision provider is asked with when the user picked none: TypeSafe's latest stable one, or the one Jev a gateway serves.
func (Provider) KeyList ¶ added in v0.1.14
KeyList is a provider's keys, in the order requests try them.
func (Provider) KeysOn ¶ added in v0.1.14
func (p Provider) KeysOn() []KeyAccount
KeysOn is the keys in use, first to last: the first key, then every saved one that's on.
func (Provider) LaneLimit ¶ added in v0.1.1009
LaneLimit is how many requests may be out at once on p's key or account, 0 for no limit: its own (AccountConcurrency), else the provider's (Concurrency). An account made afresh beside the agent's own (AlsoOn) carries none of the provider's settings: they are read from providers.json then.
func (Provider) Levelless ¶ added in v0.1.404
Levelless reports whether the model is known to have no reasoning levels to pick from, as against not known to have any: its vendor or its maker lists it with a thinking switch alone, or nothing (Xiaomi's mimo-v2.6-flash), and the user gave it none.
func (Provider) List ¶ added in v0.1.673
List asks the vendor which models it serves, as Fetch does, and keeps nothing: a provider still being added (#578, the add form's Fetch models) is shown its vendor's list to pick from before it is saved.
func (Provider) ListError ¶ added in v0.1.1001
ListError is why a plugin's account lists only the plugin's defaults, "" for any other provider.
func (Provider) ListPrice ¶ added in v0.1.411
ListPrice is a model's list price as its vendor's models.dev entry gives it, else as its maker's does (#224): a subscription (Codex's ChatGPT account, Copilot) or a relay with no models.dev id of its own is priced at gpt-6-astra's or gemini-3.8-flash's maker's price, as a Claude account is at Anthropic's.
func (Provider) Listed ¶ added in v0.1.552
Listed is when the models listed now were had from the vendor: fetched for a built-in, listed by its plugin for a plugin's.
func (Provider) ListedAPIs ¶ added in v0.1.731
ListedAPIs are the APIs model is served on as its vendor says, whatever the user set: what APIs gives with nothing set (the editor's Auto).
func (Provider) LoginRanks ¶ added in v0.1.672
LoginRanks is, for the account Codex or Claude Code is signed in to while it is kept signed in to one of the user's choosing (KeepLoginAs), each of the agent's accounts' place in the order the gateway tries them, the one signed in to at its own place among them; nil otherwise, when the one signed in to is the first.
func (Provider) ModelAPI ¶ added in v0.1.663
ModelAPI is the API the user said p's model is asked on, when p has a URL for it still.
func (Provider) ModelEfforts ¶ added in v0.1.137
ModelEfforts are the reasoning levels the user kept of the provider's models, by model id.
func (Provider) ModelNames ¶ added in v0.1.137
ModelNames are the names the user gave the provider's models, by model id.
func (Provider) ModelTest ¶ added in v0.1.636
ModelTest says why p's models can't each be sent a test request ("" when they can): "decide" for a decision API whose models can't each be sent a System One question (AsksDecideModels), whose endpoint Test asks it for them; "own-api" for a sign-in reached through its agent's own API (Cursor, Devin, Kiro, Zed, Qoder, a Google sign-in), which the gateway translates every request for, so a probe has no endpoint to go to.
func (Provider) Native ¶ added in v0.1.300
Native is the API model is best asked on at this provider: one it serves the model on itself, so a request on it is relayed as it is rather than translated — Responses for a ChatGPT sign-in, or an OpenAI model on OpenAI's API or Copilot's; Chat where that is served. "" when every request is translated anyway: a sign-in served through its agent's own API (Claude Code's binary, Cursor, Devin, Kiro, Code Assist).
func (Provider) On ¶ added in v0.1.346
On is whether the provider takes requests: ready, and not switched off.
func (Provider) OpenCodeFree ¶ added in v0.1.616
OpenCodeFree says whether model is one of OpenCode Zen's free ones on p, which Zen serves only to what looks like OpenCode: besides the headers OpenCodeClient sets, a streamed request offering tools named bash and read (lowercase, by name alone; checked against Zen, October 2026). The gateway asks them so whoever the client is (gateway/zenfree.go), and the Test button's probe so (zenFreeProbe). A free model is one whose id ends in -free, or one models.dev's opencode prices at nothing, as big-pickle, whose id doesn't say so (361 on Discord: it answered 403 "OpenCode's free tier can only be used from within OpenCode"); openCodeFreeIDs are such ones known without the catalog.
func (Provider) Origin ¶ added in v0.1.755
Origin is the scheme and host p's requests go to, for a URL of the vendor's own outside its API (WorkBuddy's /v3/config beside its /v2): a plugin's where its loader sends them, which p.Do then takes there through the plugin; any other's its API's. "" when it has none.
func (Provider) OwnPaused ¶ added in v0.1.455
OwnPaused says the provider is the account a Claude Code or Codex agent is signed in to, paused while another of its accounts is on (#263): the gateway passes over it, the agent staying signed in to it.
func (Provider) PluginConcurrency ¶ added in v0.1.633
PluginConcurrency is what the plugin giving the provider says it takes at once, as it lists it now; 0 for none, or for a provider no plugin gives.
func (Provider) PluginProvider ¶ added in v0.1.584
PluginProvider is the id OpenCode knows the plugin's provider p is by (grok, kiro), whatever magpie names it; "" for one no plugin gives.
func (Provider) ProxyChoice ¶ added in v0.1.427
ProxyChoice is the proxy requests made on the provider's behalf go through, as netproxy.With takes it: for one account of a subscription that holds several, that account's own (AccountProxies), else the provider's (Proxy); "" follows the global one. An account in use beside the agent's own is made afresh by some agents (AlsoOn), without the provider's settings: those are read from providers.json.
func (Provider) Ready ¶
Ready reports whether the provider can be used: it has a key, needs none, or is a signed-in agent.
func (Provider) Refetch ¶ added in v0.1.769
Refetch is Fetch, and says which of the user's picks it dropped: those the list fetched before had and the one fetched now doesn't. The new list replaces the old one, and a pick made from the old list goes with it — kept, it stayed among the models agents see, as if typed in by hand, though the vendor serves it no more (akic404 on Discord: a remote magpie offering far fewer models, and one of its providers renamed, still listed every old "ws-ba5my…/qwen3.6-max" here after a Refresh). A pick the old list didn't have was typed in by hand, and stays; a fetch that fails, or that answers no model at all, changes nothing.
func (Provider) RejectsTemperature ¶
RejectsTemperature reports whether the model is known to refuse temperature and top_p. The answer comes from the catalog — models.dev plus the vendor's own list — so a model released after this binary was built is handled without a code change.
func (Provider) ReplyLimit ¶ added in v0.1.916
outputOf is the most a reply of a model may hold, as the user said it: the model's own, else the one given for every model of its provider, else 0 for the vendor's own list and models.dev to answer. It mirrors ContextOf, which the user sets on the provider itself. ReplyLimit is the most a reply of the provider's model may hold, in tokens, as agents are told it and the Gateway's model list shows it: the user's Max output, else the vendor's list's, else models.dev's.
func (Provider) ResolveAuto ¶ added in v0.1.444
ResolveAuto turns a request for a model the account picks itself (Copilot's Auto) into one for the model it picked: ctx then carries what the request is signed with. Any other model comes back as it was.
func (Provider) ResponsesFirst ¶ added in v0.1.300
ResponsesFirst: an OpenAI model on OpenAI's API, Copilot's, PipeLLM's or Bedrock's, which is best asked on the Responses API though Chat serves it too.
func (Provider) RestKey ¶ added in v0.1.930
RestKey is what the gateway rests the key k of a provider by: the provider's id while it has one key on, else the id and the key's.
func (Provider) Retries ¶ added in v0.1.438
Retries is whether the account can mend a refusal (Retry), so the refusal's body is worth reading before it is passed on.
func (Provider) Retry ¶ added in v0.1.438
Retry is whether a request (sent) the backend refused with status and body is worth sending once more, the account having mended what it named.
func (Provider) Serves ¶ added in v0.1.38
func (p Provider) Serves(k KeyAccount, model string) bool
Serves reports whether key k can be asked for model: false only when the vendor's lists say another of the provider's keys sees it and k doesn't.
func (Provider) Sign ¶
Sign authenticates a request to the provider, refreshing what needs it. Plain providers get their key; accounts get the agent's tokens.
func (Provider) Test ¶
Test sends the smallest possible request to each endpoint the vendor serves, signed with a key made for it and asking for a model that key sees, and reports what came back.
func (Provider) TestModels ¶ added in v0.1.163
TestModels sends each of models the smallest request, a few at a time, on the endpoint it's served on and with a key that sees it: whether each answers, not only whether the vendor does. Results are in models' order.
func (Provider) UpstreamNames ¶ added in v0.1.560
UpstreamNames are the names the user gave the provider's models, by model id, with the one given for all of them under "*" — each as it will be sent, trimmed, "*" and all, which is what a list of them shows. A name that is only whitespace is none, and is not listed.
func (Provider) Via ¶ added in v0.1.418
Via is ctx for requests made on the provider's behalf: they go through its own proxy (ProxyChoice), or the global one when it has none.
func (Provider) Where ¶ added in v0.1.122
Where is what the provider's calls go to, as usage keeps it: the API's host, and for a subscription who is signed in there too. The id alone can't tell: it can be given to another vendor or account later.
func (Provider) WindowOf ¶ added in v0.1.816
WindowOf is the window one of the provider's models takes, as agents are told it and requests are routed on it: the one the user set (ContextOf) over ListedWindow. The catalog's entries and the Providers page's model lists both read it, so the page shows the window agents are told.
func (Provider) WithKey ¶ added in v0.1.15
func (p Provider) WithKey(k KeyAccount) Provider
WithKey is p using key k: its endpoints narrowed to k's protocol when k has one. It has none left when p doesn't serve that protocol.
type Quota ¶ added in v0.1.114
type Quota struct {
Provider string `json:"provider"`
Name string `json:"name"`
Kind string `json:"kind"` // subscription, plan (bought with a key) or balance (a key's money)
Plan string `json:"plan,omitempty"`
User string `json:"user,omitempty"`
Windows []QuotaSpan `json:"windows"`
Balance string `json:"balance,omitempty"`
Error string `json:"error,omitempty"`
AsOf *time.Time `json:"asOf,omitempty"` // the cached reading's time, nil for a new one
// ReadAt is when the windows or balance shown were read, nil when not
// known; a Claude account's can be well before now (claudeReadAt).
ReadAt *time.Time `json:"readAt,omitempty"`
// Until is when the plan's paid time ends, renewed then when Renew is
// "auto", over when "off", either when "".
Until *time.Time `json:"until,omitempty"`
Renew string `json:"renew,omitempty"`
// Resets are a Codex account's rate-limit resets, when it holds any.
Resets *ResetCredits `json:"resets,omitempty"`
// LastServedAt is when the account, plan or key last answered a
// request through the gateway, nil when it hasn't in the last 30 days
// (served.go); Last is on the latest of them (#570).
LastServedAt *time.Time `json:"lastServedAt,omitempty"`
Last bool `json:"last,omitempty"`
}
Quota is one account's or key's allowance as magpie quota --json and the gateway's GET /v1/magpie/quotas tell it, for an agent choosing where to send its work: Provider is the first part of the models' ids (provider/model) for a key's plan or balance, the agent for a subscription.
type QuotaAlert ¶ added in v0.1.540
type QuotaAlert struct {
Provider string
Name string // the card's name, as the Usage page shows it
User string // the account or key, when the provider has several
Window string // the window's name
Used float64
ResetsAt *time.Time
Balance string // the balance as the vendor tells it
// Kind is "" for the alerts above; "renews" for a long window renewing
// within the reminder's hours with much of it left, "expires" for
// reset credits running out by then, Credits of them (#720)
Kind string
Credits int
}
QuotaAlert is one thing to tell the user: a window used past the share (Window set) or a balance at or under the amount (Balance set).
type QuotaHistory ¶ added in v0.1.722
type QuotaHistory struct {
Provider string `json:"provider"`
User string `json:"user"`
Lines []QuotaLine `json:"lines"`
}
QuotaHistory is one account's windows over time. User is lowercased.
func QuotaHistories ¶ added in v0.1.722
func QuotaHistories(since time.Time, provider, user string) []QuotaHistory
QuotaHistories is every account's windows' points since since, the accounts and windows in name order; provider and user, when given, pick one provider's, or one account's.
type QuotaLine ¶ added in v0.1.722
type QuotaLine struct {
Name string `json:"name"`
Points []QuotaPoint `json:"points"`
}
QuotaLine is one window's points, oldest first.
type QuotaPoint ¶ added in v0.1.722
type QuotaPoint struct {
At time.Time `json:"at"`
Left float64 `json:"left"`
Start *time.Time `json:"start,omitempty"`
ResetsAt *time.Time `json:"resetsAt,omitempty"`
}
QuotaPoint is one reading of a window: at At, Left percent was left; the window began at Start and starts again at ResetsAt, when told.
type QuotaSpan ¶ added in v0.1.114
type QuotaSpan struct {
Unlimited bool `json:"unlimited,omitempty"`
Name string `json:"name"`
Used float64 `json:"used"`
Remaining float64 `json:"remaining"`
ResetsAt *time.Time `json:"resetsAt,omitempty"`
Display string `json:"display,omitempty"` // the vendor's own count, "1.2k / 3k"
// Amount of Limit in Unit: the window's count, used, when the vendor
// counts it so ("credits")
Amount float64 `json:"amount,omitempty"`
Limit float64 `json:"limit,omitempty"`
Unit string `json:"unit,omitempty"`
Pool string `json:"pool,omitempty"` // the shared pool the window draws on ("Gemini")
}
QuotaSpan is one window of an allowance: how much of it is used and left, in percent, and when it starts again.
type QuotaWindow ¶
type QuotaWindow struct {
Unlimited bool `json:"unlimited,omitempty"`
Name string `json:"name"`
Used float64 `json:"used"`
ResetsAt *time.Time `json:"resetsAt,omitempty"`
ResetSecs int64 `json:"resetSecs,omitempty"`
Display string `json:"display,omitempty"`
// Amount of Limit is the window's own count in Unit, when the vendor
// counts it so (WorkBuddy's credits): Used is Amount as a share of
// Limit. The GUI says it as used or left, as it says the share (#659).
Amount float64 `json:"amount,omitempty"`
Limit float64 `json:"limit,omitempty"`
Unit string `json:"unit,omitempty"`
// Family is the model family a per-model window belongs to (Antigravity's
// "Gemini 3.1 Pro (High)" is Gemini's), for the GUI to show one figure a
// family, the tightest; each window is still here, and routing reads
// them one by one.
Family string `json:"family,omitempty"`
// Pool is the group of models that share one allowance (Antigravity's
// "Gemini", "Claude & GPT"): on the group's own windows, a 5-hour and
// a weekly, which name no Model, and on each per-model window drawing
// on it, for the GUI to show the group's windows in place of its
// models'.
Pool string `json:"pool,omitempty"`
// For routing (see Allowances): how long the window runs, zero when
// not known; the only models it counts, by a word in their ids
// ("opus"), when it doesn't count them all; and Aside when using it up
// doesn't stop the account — on-demand spending past the allowance,
// or Copilot's code completions, which no request here makes.
Span time.Duration `json:"-"`
Model string `json:"-"`
Aside bool `json:"-"`
// Capped is set, for the GUI only (WithCapped), on a window an
// account's usage cap counts: neither Aside nor unlimited. One model's
// own counts for that model (CapHeld), so it is marked like the rest.
Capped bool `json:"capped,omitempty"`
// CapsSome is set beside Capped on a window that counts some models
// only — one model's own, or a pool's — so the cap holds the account
// for those alone, and the GUI says which.
CapsSome bool `json:"capsSome,omitempty"`
// contains filtered or unexported fields
}
QuotaWindow is one rolling allowance reported by a subscription provider.
func PooledWindows ¶ added in v0.1.613
func PooledWindows(ws []QuotaWindow) []QuotaWindow
PooledWindows are ws as a page of text shows them: a pool's own windows, named with their pool ("Gemini · 7 days"), in place of the per-model windows drawing on it; ws as it is when it has no pool. A model's window goes only for a pool window of its span: one whose pool has only its 7 days stays, the 5 hours it reads being the only ones to be had (#745).
func (QuotaWindow) Count ¶ added in v0.1.738
func (w QuotaWindow) Count(left bool) string
Count is the window's own count as the GUI says it, beside its share: "355 / 500 credits" used, or what is left of it when left (#659); the vendor's Display when it doesn't count in amounts.
type Region ¶
type Region struct {
ID string `json:"id"`
Name string `json:"name"`
Chat string `json:"chat,omitempty"`
Responses string `json:"responses,omitempty"`
Anthropic string `json:"anthropic,omitempty"`
// Lists is set on a region that serves a model list although the
// preset as a whole has none to ask for (NoList): a provider at its
// endpoints is asked for it. KeysURL, when the region's keys are made
// on another page than the preset's, is where its Get-a-key link goes.
Lists bool `json:"lists,omitempty"`
KeysURL string `json:"keysUrl,omitempty"`
// Website, when the region's docs are another page than the preset's,
// is where the editor's link goes.
Website string `json:"website,omitempty"`
// Catalog, for a region whose models another models.dev entry names
// than the preset's (Tencent Cloud's pay as you go, beside its plan's
// none), is that entry's id.
Catalog string `json:"catalog,omitempty"`
// Models are a plan's, for a region that is one beside pay as you go
// (PresetDef.Models, for the region alone).
Models []string `json:"models,omitempty"`
// Decide is the region's decision API, for a preset that routes groups
Decide string `json:"decide,omitempty"`
}
Region is one base-URL option of a preset that offers several. The first is the default; picking another in the editor swaps the endpoints.
type Renewal ¶ added in v0.1.75
type Renewal struct {
Agent string `json:"agent"`
User string `json:"user"`
// Renewed is false when it wasn't due; Err is why it failed, and Lapsed
// whether the sign-in is gone (the vendor refused it) or may yet renew.
Renewed bool `json:"renewed"`
Err string `json:"error,omitempty"`
Lapsed bool `json:"lapsed,omitempty"`
}
Renewal is what came of renewing one saved account.
type ResetCredits ¶ added in v0.1.282
type ResetCredits struct {
Count int `json:"count"`
Until *time.Time `json:"until,omitempty"`
// ByWindow: each reset is for one window, FiveHour of the five hours'
// and Weekly of the week's, and is spent on the vendor's own page (a
// GLM Coding team plan's, zcode_team.go), not from magpie
ByWindow bool `json:"byWindow,omitempty"`
FiveHour int `json:"fiveHour,omitempty"`
Weekly int `json:"weekly,omitempty"`
}
ResetCredits is how many rate-limit resets an account holds and the soonest one of them runs out; Until is nil when none does, or when that couldn't be read.
func (ResetCredits) Words ¶ added in v0.1.425
func (r ResetCredits) Words() string
Words are the resets counted: "2 resets", or by window, "2 five-hour resets · 1 weekly reset".
type ResetOutcome ¶ added in v0.1.282
ResetOutcome is what spending a reset did: Code is the vendor's word for it (reset, nothing_to_reset, no_credit, already_redeemed; for Claude already_used, not_limited, cooldown, ineligible, unavailable too) and Windows how many windows started again.
func AutoUseCodexReset ¶ added in v0.1.507
func AutoUseCodexReset(ctx context.Context, user string) (ResetOutcome, error)
AutoUseCodexReset spends one of the Codex account user's resets (the one Codex is signed in to when "") if the user turned that on for it, its weekly window is used up, it holds one, and none was spent by itself in this week yet. Code is "" when none was tried; the caller asks again only on "reset".
func UseCodexReset ¶ added in v0.1.282
func UseCodexReset(ctx context.Context, user string) (ResetOutcome, error)
UseCodexReset spends one of the rate-limit resets of the Codex account user (the one Codex is signed in to when ""), starting its current usage windows again: the one that runs out first, so none that would last longer goes before it. It can't be undone: callers ask first. The account's usage is read afresh after.
func (ResetOutcome) Text ¶ added in v0.1.282
func (o ResetOutcome) Text() string
Text says an outcome in words.
type Result ¶
type Result struct {
Account string `json:"account,omitempty"`
Protocol Protocol `json:"protocol"`
OK bool `json:"ok"`
Status int `json:"status,omitempty"`
Millis int64 `json:"ms"`
Model string `json:"model,omitempty"`
Error string `json:"error,omitempty"`
}
Result is what a probe of one endpoint came back with.
type Rule ¶ added in v0.1.94
type Rule struct {
Use string `json:"use"` // the member, as the group names it: "provider/model"
// Tokens: the request is at least this long, in tokens — the larger of
// an estimate from its size and what the vendor counted for the
// conversation's last request.
Tokens int `json:"tokens,omitempty"`
// Images: the request carries an image, in this turn or before.
Images bool `json:"images,omitempty"`
// Effort: the agent asked for reasoning at least this level (one of
// Efforts), or "on" for any reasoning at all.
Effort string `json:"effort,omitempty"`
// Agents: the request is from one of these agents (usage.AgentOf ids).
Agents []string `json:"agents,omitempty"`
// Intent: the user's message at the turn's start is of this kind, as
// the group's Classifier judges it — "writing or fixing tests",
// "a quick question". When the classifier can't say, it doesn't match.
Intent string `json:"intent,omitempty"`
// Compact: the agent is compacting its conversation — asking a model to
// summarize it so it can go on in less room (Claude Code's /compact,
// Codex's, OpenCode's, Pi's…) — which a cheaper, faster model can do
// in place of the one the conversation is on.
Compact bool `json:"compact,omitempty"`
// Time: the turn begins within these hours of the day, local time — a
// vendor's peak-price hours sent to another, say.
Time *TimeWindow `json:"time,omitempty"`
}
Rule sends the requests it matches to one of its group's members first. Every condition set must hold; a rule sets at least one.
func ParseRule ¶ added in v0.1.136
ParseRule makes a rule of k=v words; the model is resolved among the group's members. classifier is the group's classifier when one was given, at the place asked for (from 1) when one was.
func (Rule) Conditions ¶ added in v0.1.94
Conditions says what a rule matches, for a list or a trace.
func (Rule) Matches ¶ added in v0.1.94
func (r Rule) Matches(q RuleRequest) bool
Matches reports whether the request is one the rule is for.
func (Rule) MatchesBesidesIntent ¶ added in v0.1.95
func (r Rule) MatchesBesidesIntent(q RuleRequest) bool
MatchesBesidesIntent is Matches but for the rule's intent: whether the classifier's answer is all it waits on.
type RuleRequest ¶ added in v0.1.94
type RuleRequest struct {
Tokens int
Images bool
Thinking bool // the agent asked for reasoning
Effort string // at what level, when it said
Agent string
// Intent is the one of the rules' intents the classifier said the
// user's message is; "" when none, or it wasn't asked.
Intent string
// Compact: the request is the agent compacting its conversation.
Compact bool
// At is when the request came, for a rule's hours; a zero time is in
// none.
At time.Time
}
RuleRequest is what a rule looks at in a request.
type SearchAPI ¶ added in v0.1.587
type SearchAPI struct {
Vendor string `json:"vendor"` // one of SearchVendors
Key string `json:"key,omitempty"`
// URL is where it is: a SearXNG's own, or another address for one of
// the others (a Firecrawl run by the user); empty is the vendor's.
URL string `json:"url,omitempty"`
}
SearchAPI is a web search API the user gave magpie a key to.
func SearchAPIs ¶ added in v0.1.587
func SearchAPIs() []SearchAPI
SearchAPIs are the search APIs that can be asked, in the order they are tried.
func StoredSearchAPIs ¶ added in v0.1.587
func StoredSearchAPIs() []SearchAPI
StoredSearchAPIs are the search APIs as saved, keys and all.
func (SearchAPI) Base ¶ added in v0.1.587
Base is the address it is asked at, without a slash at its end.
type SearchVendor ¶ added in v0.1.587
type SearchVendor struct {
ID, Name string
Base string // its address, "" for one the user runs
KeysURL string // where its keys are made
}
SearchVendor is a search API magpie can ask.
func SearchVendorOf ¶ added in v0.1.587
func SearchVendorOf(id string) (SearchVendor, bool)
SearchVendorOf is the vendor by its id.
type SessionIdentity ¶ added in v0.1.579
type SessionIdentity struct {
Agent, AccountID, UserID, OrganizationID, User string
// OfficialLogin describes this account's recorded login method, not the
// route or credentials used for any particular historical request.
OfficialLogin bool
}
SessionIdentity is an account's public identity, without its credentials.
func SessionIdentities ¶ added in v0.1.579
func SessionIdentities(codexDir string) []SessionIdentity
SessionIdentities reads the agent's current identity and remembered identities. Callers must match the IDs recorded in a session; presence alone is not evidence that the account served that session's requests.
type SignInState ¶ added in v0.1.14
type SignInState struct {
ID string `json:"id"`
Agent string `json:"agent"`
URL string `json:"url"` // the vendor's page, to open or copy
Code string `json:"code,omitempty"` // what to type there, for a device code
State string `json:"state"` // installing, waiting, done, failed or canceled
PasteCallback bool `json:"pasteCallback,omitempty"` // a callback URL can also finish this sign-in
// PasteCode is a plugin's sign-in finished by the code its page shows
PasteCode bool `json:"pasteCode,omitempty"`
// PasteKey is a sign-in an API key made on KeysURL also finishes
// (Command Code's, whose page posts its key where a pasted address
// can't carry it)
PasteKey bool `json:"pasteKey,omitempty"`
KeysURL string `json:"keysURL,omitempty"`
Instructions string `json:"instructions,omitempty"` // a plugin's words for its page
// Installing is the CLI being installed before the sign-in can start
Installing string `json:"installing,omitempty"`
User string `json:"user,omitempty"` // the account, once done
Plan string `json:"plan,omitempty"` //
Using bool `json:"using,omitempty"` // the agent was signed in to it too
// Again is an account listed already: its sign-in was renewed rather
// than a new account added (#413)
Again bool `json:"again,omitempty"`
Error string `json:"error,omitempty"`
}
SignInState is where a sign-in stands, for the window to show.
func SignInStatus ¶ added in v0.1.14
func SignInStatus(id string) (SignInState, bool)
SignInStatus reports on a sign-in StartSignIn began.
func StartPluginSignIn ¶ added in v0.1.479
StartPluginSignIn begins signing in to a plugin's provider (OpenCode's id) with its OAuth method, the method's questions answered: the page to open, then either the plugin notices on its own or the code the page shows is pasted back (SubmitSignInCallback). SignInStatus follows it, as it does a built-in sign-in; its Agent is the provider's magpie id. The account goes beside those signed in already, or replaces the one it is. A built-in moved onto its plugin installs the CLI it runs through first, as the built-in's sign-in did.
func StartSignIn ¶ added in v0.1.14
func StartSignIn(agent string) (SignInState, error)
StartSignIn begins adding an account to an agent: open the returned URL in a browser and the rest happens on its own; SignInStatus follows it.
An agent signed in with a CLI that isn't installed has it installed first: the sign-in is then "installing", and gets its URL when that is done.
func StartSignInAt ¶ added in v0.1.425
func StartSignInAt(agent, site string) (SignInState, error)
StartSignInAt is StartSignIn on one of the sites an agent signs in on: ZCode's "zai" (the default) or "bigmodel".
func WaitSignIn ¶ added in v0.1.14
func WaitSignIn(ctx context.Context, id string) (SignInState, error)
WaitSignIn blocks until a sign-in is over, for the command line.
type SignedInError ¶ added in v0.1.1025
type SignedInError struct{ Agent, User string }
SignedInError is ForgetLogin's refusal of the account an agent is signed in to now while it has another: that one is signed in to first (its Use), and this one removed then. The GUI says it in the reader's language (code signed_in).
func (*SignedInError) Error ¶ added in v0.1.1025
func (e *SignedInError) Error() string
type SubscriptionQuota ¶
type SubscriptionQuota struct {
Provider string `json:"provider"`
Name string `json:"name"`
Icon string `json:"icon"`
Plan string `json:"plan,omitempty"`
AccessSKU string `json:"accessSku,omitempty"`
User string `json:"user,omitempty"` // the account, so two of one vendor tell apart
Windows []QuotaWindow `json:"windows"`
Balance string `json:"balance,omitempty"` // what is left on an API key, instead of windows
// BalanceParts are the Balance's amounts each apart, when the balance
// field the user wrote has several or a percent (cardParts)
BalanceParts []BalancePart `json:"balanceParts,omitempty"`
// Until is when the plan's paid time ends: it renews then when Renew
// is "auto", is over when "off", and either when "" (the vendor
// doesn't say which).
Until *time.Time `json:"until,omitempty"`
Renew string `json:"renew,omitempty"`
Error string `json:"error,omitempty"`
// AsOf is when an allowance shown in place of one that couldn't be
// read was read (see keepLast); nil for a reading just made.
AsOf *time.Time `json:"asOf,omitempty"`
// ReadAt is when what is shown was read: a key's balance, kept a
// minute (KeyBalances), or an account's allowance, which a cache (a
// minute's, or a Claude account's until Claude Code tells it again)
// can hand back long after; nil when not known.
ReadAt *time.Time `json:"readAt,omitempty"`
// Resets are the rate-limit resets a Codex account holds, nil when it
// holds none (codex_resets.go).
Resets *ResetCredits `json:"resets,omitempty"`
// Daily is a WorkBuddy account's credits used day by day, as magpie
// counted them from its readings (credits_daily.go).
Daily *DailyCredits `json:"daily,omitempty"`
// Checkins is set on a WorkBuddy (China) or Trae CN account whose
// daily check-in is pressed for, CheckinBy whose ("" WorkBuddy's,
// "trae" Trae CN's), and Checkin is how its last one went, nil before
// the first; never cached, added as the page asks (WithCheckins).
Checkins bool `json:"checkins,omitempty"`
CheckinBy string `json:"checkinBy,omitempty"`
Checkin *WorkBuddyCheckin `json:"checkin,omitempty"`
// contains filtered or unexported fields
}
SubscriptionQuota is provider-reported allowance usage. This is separate from Dial's local token log: vendors expose percentages, not token totals.
func Allotted ¶ added in v0.1.791
func Allotted(ctx context.Context) []SubscriptionQuota
Allotted is Quotas without the keys' balances: the accounts and plans whose allowance runs out and starts again, which is what magpie quota wait waits on; no key's balance is asked for.
func KeyBalances ¶ added in v0.1.37
func KeyBalances(ctx context.Context) []SubscriptionQuota
KeyBalances is the balance of every provider magpie can ask one of, the key in use and each other key it has on — or its account's, once, when it has a token for that — as cards beside the subscriptions' allowances. What was asked less than a minute ago is not asked again, unless the providers were saved since (ForgetBalances).
func PlanQuotas ¶ added in v0.1.86
func PlanQuotas(ctx context.Context) []SubscriptionQuota
PlanQuotas is the windows of every plan magpie has a key for, each key on a card of its own when a provider has several. What was asked less than a minute ago is not asked again.
func Quotas ¶ added in v0.1.114
func Quotas(ctx context.Context) []SubscriptionQuota
Quotas is what is left everywhere magpie can ask: the signed-in subscriptions' windows, the plans bought with a key, and the keys' balances, as the Usage page shows them. The vendors are asked at once; what doesn't answer before ctx ends comes back with an error.
func SubscriptionUsage ¶
func SubscriptionUsage(ctx context.Context) []SubscriptionQuota
SubscriptionUsage returns rolling quotas for signed-in first-party agents. Results are cached because these private account endpoints are aggressively rate limited when several CLI sessions are active. Once there is something cached it comes back at once, and a stale copy is refreshed in the background; only the very first call waits, for as long as ctx allows.
func WithCheckins ¶ added in v0.1.773
func WithCheckins(qs []SubscriptionQuota) []SubscriptionQuota
WithCheckins is qs with each WorkBuddy (China) account's card told it is checked in each day and how its last check-in went, for the Usage page to say on the card (#694: having to look in Settings to know whether it checked in is wrong). It holds for a moved account too: magpie checks those in through the plugin's fetch. qs, which may be the usage cache, is left as it is; nothing is asked.
type TimeWindow ¶ added in v0.1.570
type TimeWindow struct {
From string `json:"from"`
To string `json:"to"`
Days []string `json:"days,omitempty"`
}
TimeWindow is hours of the day, local time: From until To, "HH:MM" each, past midnight when To comes before From (22:00–08:00), the whole day when they are the same. Days, when set, are the days it holds on ("mon" … "sun"); a window past midnight is of the day it begins on, so Friday's 22:00–08:00 takes Saturday's early hours too.
func ParseTimeWindow ¶ added in v0.1.570
func ParseTimeWindow(v string) (*TimeWindow, error)
ParseTimeWindow reads hours of the day: 09:00-18:00, 22:00-08:00.
func (TimeWindow) DaysText ¶ added in v0.1.570
func (w TimeWindow) DaysText() string
DaysText is the window's days for a list: "Mon–Fri", "Sat,Sun", "Mon,Wed–Fri"; "" for every day.
func (TimeWindow) Holds ¶ added in v0.1.570
func (w TimeWindow) Holds(at time.Time) bool
Holds reports whether at is within the window, on the machine's clock.
func (TimeWindow) Text ¶ added in v0.1.570
func (w TimeWindow) Text() string
Text is the window as a rule's conditions show it: "09:00–18:00 Mon–Fri".
type WorkBuddyCheckin ¶ added in v0.1.356
type WorkBuddyCheckin struct {
User string `json:"user,omitempty"` // as listed now; never kept
Day string `json:"day"`
At time.Time `json:"at"`
Outcome string `json:"outcome"`
Credit float64 `json:"credit,omitempty"`
Streak int `json:"streak,omitempty"`
Msg string `json:"msg,omitempty"`
// Offline is a failure that never reached WorkBuddy, and Tries how
// many before it the same day did the same.
Offline bool `json:"offline,omitempty"`
Tries int `json:"tries,omitempty"`
// By is the vendor whose check-in it is: "" WorkBuddy's, "trae"
// Trae CN's; never kept.
By string `json:"by,omitempty"`
// Asked is true of one checked in on this run, not one read back.
Asked bool `json:"-"`
}
WorkBuddyCheckin is what came of a WorkBuddy account's check-in on Day (Beijing): the credits it gave and the streak it made, or why none.
func CheckInMiniMax ¶ added in v0.1.910
func CheckInMiniMax(ctx context.Context) []WorkBuddyCheckin
CheckInMiniMax checks each MiniMax Code account in use in for today now, those not in yet, and says how each stands.
func CheckInTrae ¶ added in v0.1.784
func CheckInTrae(ctx context.Context) []WorkBuddyCheckin
CheckInTrae checks each Trae CN account in use in for today now, those not in yet, and says how each stands.
func CheckInWorkBuddy ¶ added in v0.1.356
func CheckInWorkBuddy(ctx context.Context) []WorkBuddyCheckin
CheckInWorkBuddy checks each WorkBuddy (China) account in use in for today now, those not in yet, and says how each stands.
func MiniMaxCheckins ¶ added in v0.1.910
func MiniMaxCheckins() []WorkBuddyCheckin
MiniMaxCheckins is each MiniMax Code account's last check-in, as kept, by its name now; asks nothing.
func TraeCheckins ¶ added in v0.1.784
func TraeCheckins() []WorkBuddyCheckin
TraeCheckins is each Trae CN account's last check-in, as kept, by its name now; asks nothing.
func WorkBuddyCheckins ¶ added in v0.1.356
func WorkBuddyCheckins() []WorkBuddyCheckin
WorkBuddyCheckins is each WorkBuddy (China) account's last check-in, as kept, by its name now; asks nothing.
func (WorkBuddyCheckin) Checked ¶ added in v0.1.356
func (r WorkBuddyCheckin) Checked() bool
Checked says whether the day's credits are in, claimed now or before.
Source Files
¶
- account.go
- account_caps.go
- account_models.go
- account_order.go
- antigravity_models.go
- antigravity_pool.go
- azure.go
- backup.go
- balance.go
- checkin.go
- claude_auth.go
- claude_dirs.go
- claude_limits.go
- claude_probe.go
- claude_signin.go
- claude_usage_cli.go
- claude_warmup.go
- cli_identity.go
- cline.go
- cline_usage.go
- codex_autoreset.go
- codex_daemon.go
- codex_expiring.go
- codex_models.go
- codex_request.go
- codex_resets.go
- codex_switch.go
- codex_warmup.go
- commandcode_plan.go
- compact.go
- concurrency.go
- copilot_accounts.go
- copilot_auto.go
- copilot_cli.go
- copilot_entitlement.go
- copilot_ghe.go
- copilot_refused.go
- copilot_signin.go
- credits_daily.go
- cursor.go
- cursor_models.go
- cursor_picker.go
- cursor_usage.go
- decide.go
- decide_wire.go
- detect.go
- devin.go
- devin_accounts.go
- devin_images.go
- devin_usage.go
- factory.go
- factory_client.go
- factory_key.go
- factory_signin.go
- factory_usage.go
- favicon.go
- forget_account.go
- google.go
- google_import.go
- grok.go
- grok_accounts.go
- grok_install.go
- grok_usage.go
- group.go
- group_order.go
- groupeffort.go
- groupfast.go
- groupmatch.go
- grouprule.go
- hold.go
- icon.go
- import_codex.go
- importapps.go
- importurl.go
- install.go
- install_other.go
- keep_login_as.go
- keepalive.go
- keys.go
- kilo.go
- kiro.go
- kiro_accounts.go
- kiro_signin.go
- login_import.go
- login_usage.go
- logins.go
- logins_on.go
- migrate.go
- migrate_factory.go
- migrate_kiro.go
- migrate_mimo.go
- migrate_qoder.go
- migrate_side.go
- migrate_workbuddy.go
- migrate_zcode.go
- migrate_zed.go
- mimo.go
- mimo_signin.go
- mimo_usage.go
- minimax_checkin.go
- modelprefs.go
- models.go
- opencode_client.go
- planquota.go
- plugin_accounts.go
- plugin_icon.go
- plugin_usage.go
- plugins.go
- pluginsignin.go
- presets.go
- provider.go
- provider_order.go
- proxy.go
- qoder.go
- qoder_usage.go
- quota_alert.go
- quota_history.go
- quota_last.go
- quota_refresh.go
- quotas.go
- remote_magpie.go
- rename.go
- routing.go
- ruleparse.go
- search_api.go
- served.go
- session_identity.go
- side_logins.go
- signin.go
- stepfun_plan.go
- subscription_usage.go
- test.go
- trae_checkin.go
- ultra.go
- version.go
- visible.go
- warmup_daily.go
- workbuddy.go
- workbuddy_checkin.go
- workbuddy_models.go
- zcode.go
- zcode_client.go
- zcode_device.go
- zcode_models.go
- zcode_os_other.go
- zcode_start.go
- zcode_team.go
- zed.go
- zed_body.go
- zed_signin.go
- zed_usage.go