OpenProgram Docs

Companies, ways and credentials

+ added  = kept  ✕ removed Company: MiniMax = the grouping table we maintain + new ways placed by name + corrected in config.json APIpay as you go API · Chinapay as you go Token Planplan Plan · Chinaplan = ways come from models.dev: address, protocol, billing, key variable Where credentials come from and are stored PastedSettings, CLI Tool settingssearch, image config.jsonmoved at start Sign-inOAuth, device Another CLICodex, others Helperrun at use API keyauth/_keys/<company>.json+ the company's, stored once Subscription sign-inauth/<way>/credentials.json= belongs to the way it was made on Key in an environment variable= never stored; hidden when already stored ✕ config.json keys put in the process env ✕ the same key stored once per way Grid: key × way= state kept in each way's own list API key ····a1f2 refused works unknown works · 80% left Variable MINIMAX_API_KEY unknown unknown unknown unknown + filled by use, or one cell by Check ✕ trying a key on every way in the background ✕ picking one way for a shared variable Model request = through the way picked, to its address = limit or quota: the next credential + every key refused: follows the key to a way Tools: search, image, speech + ask the store for the company's key + read the first key not refused everywhere ✕ reading os.environ themselves
  1. The company, MiniMax: the grouping table we maintain; a new way is placed by name and corrected in config.json
  2. its four ways come from models.dev: address, protocol, billing, key variable
  3. A pasted key, a key from a tool's settings, a key moved out of config.json: stored once for the company
  4. A sign-in, another CLI's login, a helper command: one way's only; a key in a variable is never stored
  5. the grid: refused, works or unknown for one key on each way, filled by use or by Check
  6. A model request goes through the way picked and follows its key to a way it works on when every key is refused
  7. Search, image and speech ask the store for the company's key and no longer read the environment

Three things

ThingWhat it isWho maintains it
CompanyWho issued the key: MiniMax, Moonshot AI, OpenCode. Groups its ways on one card.Our table (COMPANIES in auth/login/login_method_registry.py); an entry the table does not list is placed by _place
WayOne address to send requests to: its protocol, its models, whether it bills per use or by plan, the variable that holds its keymodels.dev, refreshed with the catalogue
CredentialA sign-in is one way's. An API key is the company's, stored once.The person

Where a key works

Nobody knows this when the key is saved, so nothing decides it then.

WhenWhat happens
Key savedStored for the company; a row on every key way, state unknown. Checked first only when the company has a single key way.
Request through a wayThe key goes to that way's address. A refusal marks that way's row and nothing else; another way's row stays as it was.
Check on a rowAsks that way about that key, then and there
Rename or replaceChanges the key itself, so every way shows it
RemoveRemoves the key and its row on every way

Nothing is asked in the background. A key with its own address or headers is no company key: it stays the one way's it was added on.

One request

CaseWhat happens
Every key refused on the way pickedThe request is sent again, same model, through another way of the company that lists one of those keys and has not refused it; a way the key has answered on first. It uses only those keys there, and the model need not be enabled on that way. The reply says so once.
Limit, spent quota, server errorStays on the way it is on, picked or moved to. Moving it could spend another plan's money. A plan's spent quota sent as a rate limit (MiniMax Token Plan) is read as a spent quota: no wait, no retry.
Pinned credential, or the caller's own keyNever moved

Sources

SourceLands inSeen by
Pasted on a way (Settings, openprogram providers keys <way> add, setup)Company key fileEvery key way of the company
Saved for a tool (search, image, speech settings)Company key fileThe tool; the company's ways too when it serves models
Environment variableNowhere. A read-only row env:<VAR>; hidden when it holds a key already stored.Every way and tool that names the variable
config.json api_keysMoved to the company its variable names, once, at start; a value already stored is dropped; the name leaves config.jsonAs a pasted key
A key in a way's own list, from beforeMoved to the company file; the way keeps its row and stateEvery key way
Sign-in (OAuth, device code)That way's listThat way
Another CLI's login (Codex, Gemini, GitHub, Qwen)That way's list, as a pointer to the other CLI's fileThat way
Helper commandThat way's list, as the commandThat way

Tools

A tool asks for its service's key (auth/services.py, service_key): the company's stored key, else the variable. It never reads os.environ itself.

ServiceReads the keys of
Tavily, Brave, Serper, Exa, You.com, Jina, Kagi, Firecrawl, Google PSE, fal, ElevenLabs, PlayHTItself: a company with no way
Perplexity, MiniMax, Kimi and Ollama searchThe model company. One key serves chat and search.

MiniMax and Kimi search have an international and a China address. The search tries one, then the other when the key is refused, and remembers which answered.

Google PSE's engine id is no secret: it is the setting search.google_pse_cx, else GOOGLE_PSE_CX.

Several keys: a tool reads the first, in stored order, that some way has not refused. A key saved in a tool's settings replaces a tool-only company's key; for a company that also serves models it is added and placed first.

Added, removed, kept

What
AddedCompany key files. Placement of unlisted catalogue entries. The service table. The one-time move. A lock that gives up after its timeout. A refused request following its key to another way. The person's own placement.
RemovedCopying config.json keys into the process environment. Tools reading os.environ. Picking one way for a shared variable. Trying a key against every way in the background. The same key stored once per way.
KeptOne list per way for sign-ins, order and state. Read-only environment rows. Per-way health, cooldown and blocked models. Failover among a way's credentials.
Placing an entry the table does not list
  1. Its id extends a listed company's id, or one of its ways', at a hyphen: it joins that company (minimax-cn-max-plan joins MiniMax)
  2. Several unlisted entries read the same key variable and one id extends another: they form a company of their own
  3. Otherwise it is a company of one way

A shared prefix alone joins nothing: two entries that read different variables are different companies.

The person's own word comes first: config.json provider_companies maps an unlisted entry's id to a company's, or to its own id to stand alone.

Decisions

DecisionFollowsWhy
One store for model and tool keysOpenCode, Oh My PiOne place to add, list and remove; search keys are not a second system
Environment variables are read, never writtenOpenCode, Codex, Claude CodeHermes writes its key file into the process environment, which is what config.json did here: every subprocess inherits every key
Ways and their key variables come from models.devOpenCode, Oh My PiIt has the widest coverage and is refreshed for us
A key is the company's, not one way'sNo peer: each stores a key under one catalogue entryThe person has one key and cannot say which entries take it. Stored per entry, the same key is pasted four times or sits on the wrong one.
The company table is oursNo catalogue has one. Cherry Studio's presetProviderId comes closest and covers three cases.Placement keeps a new entry from needing a release
A refused request follows its key to another wayNo peer. LiteLLM's router falls back across deployments on any error.Only a refusal moves, and only along the same key, so the same account pays and a limit never spills onto another plan
A moved request uses only the key it followsNo peerThe other way may hold a sign-in or another account's key. Using those would bill an account the person did not pick.
Secrets stay in owner-only files, not the system keychainOpenCode, Pi, Hermes, Oh My Pi. Codex and Claude Code use the keychain.The worker runs headless and over remote access, where a keychain prompt has nobody to answer it; the stable and dev instances each keep their own copy; one format on macOS, Windows and Linux.
MCP server and channel secrets stay with their server or accountOpenCode: mcp-auth.json beside auth.jsonEach belongs to one server or one bot account. There is no company and no second way to share it with.
Two lookups: a key, or whatever the way signs withPi: getApiKey returns a key or a sign-in's tokenA tool or key-only request needs a key; a model request takes a sign-in's token too. One function with a flag would say less than two names.
A service's non-secret value is a settingOpenCode: provider options in its configAn engine id is shown, edited and backed up like any setting; it needs no key file
Saving a tool's key again replaces itOpenCode: one credential per providerA tool has one key field; a company that also serves models keeps its other keys
The person can correct a placementNo peer has a company tablePlacement by name can be wrong, and a fix should not wait for a release
No check of a key against every wayAll peers: none validates on saveA check spends quota or a request on ways the person never uses. LiteLLM's sends a real chat.

Verification

tests/unit/providers/auth/test_company_keys.py: one key on every way, the secret in one file, per-way state, rename and removal, environment rows, both moves, tool services, placement, a request moved along its key. With a real MiniMax China key picked on either international way: 401 there, then the China way accepts the key.

Implementation status

All of the above is in place. The company card draws a key as one row with the ways it has answered on (One key, several ways); the model picker already lists each way with its state.

API key resolution

Last updated · 2026-11-25