OpenProgram Docs

Model Gateway

Outside agents (Claude Code, Codex, and any client of the same APIs) send their model calls to the Worker instead of to their vendor. The Worker answers them with the model the user picked among OpenProgram's providers, in the agent's own protocol.

Upstream calls go only through OpenProgram's configured providers and their own credentials. An Anthropic model is reached with an Anthropic API key, as everywhere in OpenProgram; the key or token an agent sends only opens the gateway and is never forwarded. No subscription sign-in is relayed: no ChatGPT login traffic, no Claude sign-in token.

The design is a port of magpie (yetone/magpie, MIT License), whose Go code covers about ninety agents. Where code is ported, the module names the magpie file it comes from.

PartWhere
Agent registryopenprogram/models/gateway/agents/: base.py (the interface), one module per agent (codex.py, claude_code.py, crush.py …), model_rows.py (the enabled models as an agent's own list spells them), engine.py (connect, disconnect, sync, status), lifecycle.py, running.py; for agents that are not file edits local_api.py, appdb.py, applink.py, keychain.py, userenv.py, shellfn.py, reach.py
Config editorsedit/: toml_text.py, jsonc.py, yaml_text.py, dotenv.py, mark.py; stash.py, <state>/gateway/harness-stash.json
Protocolsmessages.py, responses.py, responses_ws.py, compact.py, chat_completions.py, gemini.py, ollama.py, model_information.py
Shared piecesconversion.py (model refs, signatures, options), stream.py (one upstream call, errors)
Keys and attributionkeys.py, <state>/gateway/key; attribution.py; checked in owner_auth.py
Routesopenprogram/interfaces/server/routes/gateway.py
Launch overrideslaunch.py: codex_launch
Settingsharnesses.* in state/settings.py; GET/PUT /api/harnesses/models, POST /api/harnesses/restart, POST /api/harnesses/import; the Models card on Settings → Third-Party Harnesses

The agent registry

An agent is a description, not a driver (magpie agent.go, agents.go). Its module returns one Agent, or several from agents() (Qoder and Qoder CN, QwenPaw's agents); agents/__init__.py lists the modules in MODULES, in display order. Everything that touches files is the engine's, so a new agent is only its description.

FieldWhat it says
id, name, icon, aliases, kindHow it is named, found (find: id, alias, unique prefix) and shown
path, dir, bin, app, held_atIts config file and folder, its command, its desktop app; detection (installed) and a command that is gone while its folder is left (cli_gone, magpie gone.go). detect_only makes detect replace the look (a folder shared with another program, a plugin only), sign is another sign it is installed, bin_not turns away another program's command of the same name
fieldsThe settings OpenProgram sets: model, and quiet fields that follow it until set (Claude Code's Opus, Sonnet and Haiku tiers)
wire(at)The files connecting writes, as Write entries: a path, a format, dotted sets and deletes, keep (written, never restored), listing (its copy of the model list), or a whole file (format="file"). at gives the picks, the gateway's base for a protocol and the key
Write.membersEntries of a list shared with the user's own (a file that is one JSON list too), told apart by a field: written after the user's or where OpenProgram's were, and on disconnect only they are taken out; a list that was there before connect stays, empty or not (an AstrBot without provider_sources reads as one before 4.10). Two writes to one file apply in turn, so the model list syncs alone
Members.looseEntry fields the agent's own settings change: WorkBuddy's effort and on/off, OpenPencil's name and on/off, every Tuanjie Cowork field but where it points. Never drift
Write.ownsAn object that is OpenProgram's whole (its provider entry): the user's additions inside stay and are no drift at any depth; a delete inside it applies (OpenCode's model list once its plugin fetches it); disconnect takes it out whole, edited or not (magpie deletes its own entry)
Write.looseFields the user or the agent rewrites (* any key): a name, a key it encrypts, JetBrains' *.isRegistered. Never drift, so sync and rewire go on
Write.picksKeys the agent's own picker rewrites as one: Pi's /model, Aside's selections, omp's roles, Craft's default, LiveAgent's pairs. Never drift. Disconnect puts a pick back whole while its key on still names OpenProgram, else leaves it whole (magpie's Disconnect)
Write.baseWhat a missing file is taken to hold, as the agent would make it (omp's models.yml from models.json, magpie JSONToYAML): not recorded as OpenProgram's, so disconnect takes out only its provider
Members.kept, keyFields of OpenProgram's own entries the user may change (Droid's names and limits; magpie's droidKept): each entry is paired with what was last written by its key, and a field whose value differs from that, set or removed, is the user's and survives the next sync
Write.sharedA file several agents write (QwenPaw's provider file, one for all its agents): the first agent's record keeps the original, put back when no connected agent's stash names the file; an agent leaving earlier puts back only keys no other one wrote (OpenCode's model). A joining agent takes the originals of the keys the first wrote and the folders it made; the last to leave removes them
Agent.shared_usedAsked after the agent's own files are back: one of its own still uses the shared file, which then stays (a QwenPaw agent switched to OpenProgram's provider in QwenPaw; magpie qwenpawNamesMagpie). Its record, with what was there before, moves to <state>/gateway/left-shared.json; the next connect takes it up, so a later last disconnect removes the file or puts the original back
protocol, ua, named_key, path_named, path_keyedWhat it speaks, the User-Agent prefixes it sends, and whether it is given a key or an address of its own (attribution)
before_copy, notice, on_route, after, harnessA whole-file copy before the first write; advice shown after a change; work after connecting or disconnecting (the Codex app); a running app given each change live, a sync's too (Aside); whether OpenProgram also runs it in its own chats
unwire, loose, check, keepTakes the agent's own entries out of a list its app rewrites (magpie Unwire: NewMax, Paseo, ZCode, MiniMax Code) before the stash goes back; keys the app itself rewrites, never drift; why a connected agent is off the gateway; a keeper run every 10 seconds (Claude Science's daemon, OpenMausBot's list)
unwiredRun on disconnect once the stash is back: the agents in Pi's format take OpenProgram's entries out of enabledModels once its provider is gone, where they would name nothing (magpie piScopeWithout; omp's openprogram/** too), and a list left empty goes
detect, extra_agents(), Field.optionsIts own sign that it is here; rows found on this computer beside the main one (each other ~/.claude… folder, magpie claude_dirs.go); a field picked from choices, never moved by a model leaving the list (Codex's scope and background compaction, Kiro Crew's harness, Claude Desktop's gateway and Runs In), not shown while there is nothing to choose
launch, gatewayThe command that starts an agent that takes the gateway only from how it is started (status launch, agy); false for an agent whose model field is a choice among its own models (Cursor CLI, Devin). after also runs when a connect changes only the picks (agy's fast tools)
App.instance, App.reopenWhich running process of an app that runs twice is the one wired, and its own restart (Claude Desktop's copy: SIGTERM to the process on its folder, then its launcher)
edit.row_pathOne row of a SQLite key/value table read and written as a file's text, in one BEGIN IMMEDIATE transaction, the database never made; read with nothing written beside it, immutable=1 or a copy with its WAL (NewMax's settings row app)
live, detectWiring that is not a file edit (magpie's per-field Set with Unwire): connect, disconnect, sync, check and start hooks, given what they kept last time and returning what to keep, stored in the stash record. detect replaces the file, folder and command check
link, added, open_linkAn app that takes the gateway only through its own import link (magpie Import, Added): the link, whether the app has it (read, never written; unknown when unreadable), and how it is handed over. Such an agent has no fields
Field.multi, Field.with_catalogA choice of several options at once, one per line, shown as a menu of checks (Kimi Code's subagent pool); a model field whose options are the agent's own models offered beside OpenProgram's (DeepSeek Harness's DeepSeek models): either is picked, and a reseat moves only a pick of OpenProgram's
root_pathsPaths an agent asks for at its endpoint host's root, where the key in its address can't reach (Muse Code's /muse-code/models): served as its own path (attribution)
telemetry.pyAn agent's own switch for the usage data it sends its vendor (Crush, Goose, Kimi Code; magpie telemetry.go) as a kept choice: Off writes its documented keys, one the user set stays theirs, and Default takes out only what was written, connected or not

An agent with no model field and no link is a switch: it lists the gateway's models itself and is only turned on and off.

The engine connects (stash, then write every file, rolling back the ones written if one fails), disconnects (restore), syncs the model-list files alone, and reports status: installed, connected, drift, a running app behind the change. The Models card lists the registry's agents that are here or connected, plus Codex and Claude Code always.

A file whose settings come back as they were gets the user's own bytes back: the stash keeps its text from before the first write (up to 256 KB), as magpie's beforeMagpie does for its copies. A one-line JSON file is edited on one line.

The agents

AgentWhat connecting writes
CodexSee below; also [agents] default_subagent_model, [memories] models, an OpenProgram-only profile (openprogram.config.toml, codex -p openprogram), a Background Compaction field ([features.async_compaction], at Codex's own 65% or a share picked) with the remote-compaction capability, and a reopen of the Codex app when it shows its error page
Claude CodeSee below; a Subagents model; each other ~/.claude… folder with Claude Code's files is a row claude_code#<name>
Claude DesktopIts third-party inference-gateway mode: deploymentMode: "3p" in Claude/ and Claude-3p/claude_desktop_config.json, a Claude-3p/configLibrary/<id>.json profile with the gateway and its own key, applied in _meta.json. It takes only Anthropic-looking ids, so the gateway lists aliases and maps them back (desktop.py). Cowork's egress list is not touched
Claude Desktop: Runs InOn a Mac, a copy in a folder of its own (Claude-OpenProgram-3p), started by ~/Applications/Claude OpenProgram.app with --user-data-dir, beside the user's own signed-in Desktop (magpie claudedesktop_isolated.go)
Claude Desktop: GatewayThis computer, or its https address while it is reachable from Anywhere, for Desktop's SSH remote sessions; the SSH host allowlist stays the user's (magpie claudedesktop_gateway.go)
Claude ScienceNo file: its daemon is restarted (stop, serve --detached) with ANTHROPIC_BASE_URL on an address that carries its own key, and kept running. It still sends its Claude sign-in as the bearer; the gateway accepts it by the address, never checks or forwards it (science.py). The daemon gets no Anthropic key or OPENPROGRAM_* variable of OpenProgram's; one with a session running is replaced only once it is idle
T3 Code~/.t3/userdata/settings.json: a claudeAgent instance with the gateway env and the models, and a Codex instance with -c overrides; both carry its own key, marked sensitive, and the inline --settings blanks ANTHROPIC_API_KEY and the cloud switches
OpenMausBot~/.openmausbot/config.json: instances.openprogram, a claudeAgent with the gateway env; refused while the app runs, Restart offered
Kiro Crew~/.kiro/crew/config.json agent.acp_backend: a harness already connected (Codex, Claude Code …), connecting it too when needed
Paseo~/.paseo/config.json agents.providers.claude.additionalModels: the models, marked via OpenProgram, after the user's own; Claude Code must be connected too
NewMax~/.newmax/newmax.db, row app: a provider entry (Anthropic, its own key, at most 20 models) and its id in providerOrder; refused while NewMax runs
MiniMax Code~/.minimax/config.yaml: custom_provider.openprogram and defaultModel; models keyed by a flat id (deepseek~pro) the gateway takes back
ZCode~/.zcode/v2/config.json provider.openprogram and its rules in provider_config.json, keeping the API format, name and on/off set in ZCode and models set by hand; native web search on for each model whose provider searches, on Anthropic Messages, and left off where the user unticked it

Editors, running apps and import links

AgentsHow OpenProgram is put in (magpie file)
VS Code, VS Code Insiders, VSCodiumA group openprogram in chatLanguageModels.json and chat.defaultModel, in every profile; VSCodium's group follows its Copilot Chat's provider. A list there empty before connecting is left empty; the default model goes back on disconnect while it is still one of the group's (vscode.go)
Zoo CodeAn import file and zoo-code.autoImportSettingsPath in every VS Code profile (zoocode.go)
ZedA JSONC provider, OpenProgram's whole, and agent.default_model, a pick a sync leaves and disconnect puts back while it still names OpenProgram's provider; the key in the OS credential store under the API URL. An API URL through a proxy in front of the gateway is kept once the gateway answers there, and a billion-context /bili/ prefix follows a port move (zed.go, reach.go)
Cursor Private InferenceA switch: CURSOR_LOCAL_AGENT_* set for the user, set again as the Worker starts (a Linux environment.d file made 0600; OpenProgram's marker holds no key); its effort is the level the gateway asks when a request names none. Its /models gives each model api_types, the API it asks the model on, and capabilities (cursorlocal.go, cursorLocalModel)
AntigravityIts gateway block in both config files, and /models?format=antigravity for each model's window. A model with two or more levels is listed once a level, <id>:<level>, within the 32 entries the app keeps; the app starts on medium or the weakest, or on its effort. The model picked in the app goes back on disconnect while the gateway block still carries OpenProgram's key (antigravity.go, antigravity_models.go)
DimIts daemon's JSON-RPC while it runs, on Windows through Dim's pipe bridge, closed after a minute without an answer. With the daemon away, a dima function in the user's shell profiles (python -I -m openprogram dim run, the shell function launched agents share) starts dima with the gateway's variables until a sync reaches the daemon (dim.go)
Kun, Nowledge Mem, OpenHanako, Alma, Shelley, AvibeThe app's own local API while it runs (HTTP on loopback or a Unix socket); OpenHanako's files when it is closed; Avibe is a switch. Turning off puts back the default the app had while it is still OpenProgram's. Alma or Shelley turned off while uninstalled has OpenProgram taken out once it answers again (kun.go, nowledgemem.go, hanako.go, alma.go, shelley.go, avibe.go)
miniQsettings.json's provider, OpenProgram's whole, its model left as picked in miniQ, and the running daemon told over its WebSocket (miniq.go)
Cindy, AionUi, Cherry Studio, LodyAn import link confirmed in the app, handed over only when something opens its scheme; whether the app has it read from its database (not Lody's) (applink*.go, cindy.go, aionui.go, cherrystudio.go, lody.go)

Agents with a provider table

These agents take OpenProgram as a provider of their own beside the user's, ported from magpie's file of the same name. Their other providers and settings stay.

  • An entry at the gateway with this agent's key.
  • The enabled models in the agent's own format: window, output limit, images, reasoning levels; rewritten when the models change.
  • The default model pointed at the pick, spelled openprogram/<provider>/<model> where models are named by provider.
AgentConfigWritten
Crush~/.config/crush/crush.json, ~/.local/share/crush/crush.jsonproviders.openprogram (type openai, the model list); models.large, models.small in the data file
Goose~/.config/goose/config.yaml, ~/.config/goose/custom_providers/openprogram.jsona custom provider (engine openai, the model list); GOOSE_PROVIDER, GOOSE_MODEL
Kimi Code~/.kimi-code/config.toml, ~/.kimi/config.toml[providers.openprogram] (type kimi); one [models."openprogram/…"] per model; default_model; a subagent model; its pool, several models picked at once
jcode~/.jcode/config.tomlthe profile [providers.openprogram] with its models; [provider] default_provider, default_model
Mistral Vibe~/.vibe/config.tomla [[providers]] and one [[models]] entry per model; active_model
AtomCode~/.atomcode/config.toml[provider_accounts.openprogram]; one [models."openprogram/…"] per model; default_provider, default_model
Grok Build, Kigi~/.grok/config.toml, ~/.kigi/config.tomlone [model."openprogram/…"] per model on its provider's own API; [models] default; [features] campaigns = false
Grok Appagent-home/config.tomlits provider channel only (the file in its data folder); its route stays the App's
Reasonix Studio~/.reasonix/config.toml, ~/.reasonix/.enva [[providers]] entry with model_overrides; default_model, agent.planner_model; the key as OPENPROGRAM_REASONIX_API_KEY
Mister Morph~/.morph/config.yamlllm.* taken over: Responses at the gateway, the model and its window
PenguinHarness~/.penguin/data/<project>/.project_config.toml[providers.openprogram] (openai-responses), [[models]], default_model
Hermes Agent~/.hermes/config.yaml, ~/.hermes/profiles/*/config.yamlproviders.openprogram in every profile; model.provider, model.default; each profile's model as a field of the row
Raycast~/.config/raycast/ai/providers.yamlthe provider openprogram in providers, with its models; the model is picked in Raycast
Muse Code~/.config/muse/settings.jsonendpoint_transport at the gateway (Responses, auth none, the key in its address) and model; its model list from /muse-code/models
DeepSeek Harness, DS Bot~/.dshroutes in each profile's cordis.patch.yml and the start model; the key in .env and .credentials.yaml; a Gemini route where every dsh here is 0.2.2-rc.2 or later; the thinking effort; a compaction model the gateway moves dsh's compactions to; config.yaml for a dsh before profiles; DS Bot's home is its own data folder; dsh's own models as picks beside OpenProgram's, started on dsh's own provider; dsh's web search through the gateway
  • Fields besides the main model: Crush's small, Kimi's subagent, Reasonix's planner and DeepSeek Harness's compaction models, which follow it until set; each Hermes profile's model; each agent's reasoning effort or thinking level.
  • Prices where the agent counts cost; the telemetry switches of Crush, Goose and Kimi Code.
  • Lists shared with the user's own entries (Vibe, Reasonix, Penguin, Raycast) lose OpenProgram's entries on disconnect, even after the user edited them.
  • Not yet: WSL homes, which the registry doesn't have.

Editing an agent's own config

StepWhat happens
ReadThe file is parsed first. A file that does not parse is unknown: nothing is written and the card says why
StashThe original value of every key about to change, or that it was absent, is kept before the first write
Damaged or old stashA stash that does not parse stops everything: nothing is connected, restored or forgotten, and the card says why. A connect whose write fails puts back the files and the stash records it added. A record from before the registry (one file, its originals and what was written) is read as a one-file record, so turning it off still restores the user's own settings
WriteOnly those keys change, in TOML, JSON or JSONC, YAML or dotenv. Comments, key order, indentation and CRLF are kept; each result is parsed and compared with the intended change; the write is a temp file renamed over the original. A symlink stays one and its target is written; a file with other hard links is written in place (magpie edit.Target, hardLinked)
Lists of tablesIn TOML, a shared list ([[providers]], [[models]]) changes only OpenProgram's blocks, rewritten where the first of them was, else added at the end. A block ends at its last key, so a comment above the next table stays; the user's blocks and everything between blocks stay as written. A value over several lines keeps the comment after its closing bracket (magpie SetTOMLArrayTables)
MarkEach TOML, YAML or dotenv line OpenProgram writes carries a note above it (# openprogram: …) saying that turning it off in OpenProgram undoes it (magpie mark.go)
RestoreTurning it off, or going back to the agent's own setup, restores each value that still holds what OpenProgram wrote. A value changed since is drift: the card shows it and it is never restored over. Objects and files OpenProgram added are removed once empty
Whole-file copyA file written whole (DeepSeek Harness's patch lists) is copied before the first write, and a disconnect puts the copy back byte for byte while the file is as OpenProgram left it. The copy is refreshed, with OpenProgram's rows taken out, only when something else changed the file since
KeptCodex's [model_providers.openprogram] table is never removed, because a thread started on it cannot reopen without it; only model_provider goes back

Keeping agents in step

EventWhat happens
The enabled models changeEvery connected agent's model-list files are rewritten where they differ (magpie Sync). An empty list is never acted on
A model is no longer servedA field on it moves to the same model from another provider (same id, else same id once lower-cased with dots and underscores as dashes and the date dropped); a tier with none follows the main model again; a main model with none stays and is reported. An agent is never disconnected and its OpenProgram settings are never cleared (magpie reseat.go)
Who does itOnly the Worker, on a thread that is not killed mid-write, never a CLI command. The stable and the dev instance share ~/.codex and ~/.claude: an instance touches an agent's files only while every key it wrote, its address and its key still hold its values. A re-apply never forgets a key it wrote that is still in place, and the change time moves only when a file changed
The Worker's port changesAt start, agents whose recorded address differs are connected again with their picks (magpie Rewire). An app that keeps its own pick (Dim, Kun, Nowledge Mem, OpenHanako, Alma, Shelley, miniQ) gets only the new address and key: a model picked in it since stays
A desktop app read the old configIf its process started before the change, the card offers a restart: the app is asked to quit and opened again (magpie apprestart.go)
The command is goneThe card says so while its folder is left (magpie cliHeld)

Routes

PathClient
POST /gateway/anthropic/v1/messagesClaude Code; streamed and whole replies. Anthropic's web search tool: run by a provider that searches by itself, else answered with OpenProgram's own web search, up to six searches a reply, told as Anthropic's own search blocks
POST /gateway/anthropic/v1/messages/count_tokensEstimated locally (a CJK character 1, anything else ¼)
POST /gateway/openai/v1/responsesCodex; server-sent events
WS /gateway/openai/v1/responsesResponses over a WebSocket: each response.create frame is one turn, each event one frame; the socket keeps its last two replies for previous_response_id, answers an id it does not hold previous_response_not_found, answers a warmup (generate: false) with no call, and ends a turn on response.interrupt (magpie responses_ws.go). At most 32 frames wait behind a turn; one more closes the socket with an error frame
POST /gateway/openai/v1/responses/compactAsked on the provider's own route when the model's provider speaks the Responses API with an API key; otherwise a 400, on which Codex compacts on /responses. Only OpenProgram's API key for that provider is sent, never a sign-in token; the request is checked as on /responses and its usage is recorded as the agent's
POST /gateway/openai/v1/chat/completionsAgents that speak only Chat Completions
GET /gateway/*/v1/models[/{id}], GET /gateway/openai/v1The enabled models as provider/model, each with its window under the names clients read it by, its reply limit, its reasoning levels, its modalities and tool_call; an unknown id is a 404 (magpie modelObject, toolsTold); ?format=opencode or opencode2 is the list OpenCode's plugin fetches. Every route takes a model asked at a level, <model>:<level> (none to max, :off as none), over the body's effort; a model that has the whole id is that model (magpie askedAt)
/gateway/gemini/v1beta/models[/{model}:{method}]Gemini CLI and Google's SDKs: generateContent, streamGenerateContent, countTokens; the key as x-goog-api-key or ?key= (magpie gemini.go)
/gateway/ollama/api/{version,tags,show,chat,generate}, /gateway/ollama/v1/chat/completionsClients that take a custom endpoint only as an Ollama server (VS Code's and Visual Studio's Copilot); NDJSON replies (magpie ollama.go, ollama_chat.go). Under /gateway/ollama because the server root's /api is the app's

The existing /v1/chat/completions, which answers with an OpenProgram Agent, is a different endpoint (OpenAI-Compatible Endpoint).

One internal format

A request is read into the same Context, messages and SimpleStreamOptions the agent loop uses, sent through stream_simple, and the provider's events are written back in the client's protocol.

The provider adapters already convert both ways between these types and every upstream API, so the gateway adds only the client side. A call therefore gets the provider layer's credential rotation, retries and fault tolerance; the gateway adds no second retry layer.

QuestionDecision
Model namesExplicit provider/model refs (split_model_ref), optionally prefixed openprogram:; an unknown name is a 404, never an alias
Thinking signaturesThe model's own value (an Anthropic signature, a Responses reasoning item, a Gemini thoughtSignature) goes to the client wrapped with the model that made it and comes back only to that model. A Claude Code client of an Anthropic model gets Anthropic's own signature. None is made up; an unsigned thinking block never goes to Anthropic.
Codex freeform toolsapply_patch reaches the model as a function with one input string and the grammar in its description, and returns as custom_tool_call
Gemini requestssnake_case or camelCase; a function result is the user's side of the turn whatever role it came under, matched to its call by id, else to the first unanswered call of that name; OpenAPI schemas become JSON Schema
Ollama requestsRead as a Chat Completions request: bare base64 images, tool calls with object arguments and ids made up when missing, num_predict as the reply limit, the local runner's other options dropped; an empty request is a warmup answered done_reason: "load"
Cache markersA client's cache_control on tools and content is kept; the Anthropic adapter places and caps breakpoints as for any request
Client headersNothing beyond the body reaches the provider: no key, no anthropic-beta
ErrorsBefore the first byte: the protocol's error response; a context overflow reads so the agent compacts; a refused upstream credential is a 502, never a 401 that would send the agent to its own sign-in. After the first byte: the in-stream error, and nothing is sent again.

Keys and attribution

The owner token changes with every Worker start, so a config file could not hold it. The gateway key is random, kept owner-only in the state folder and survives restarts; backups keep gateway/ with the credentials.

QuestionDecision
An agent's own keyopgw-agent-<id>. and an HMAC of the id under the gateway key (after magpie TokenFor), given to every agent (engine.agent_key) and to Claude Code's launch files: no file holds the gateway key itself. Agents sharing one provider share a key (key_of: OpenChamber has OpenCode's). It does not reveal the gateway key, and only a registered agent's id is accepted
A key changedThe stash keeps a hash of the key each agent was given. One whose files hold another (connected before every agent had its own) is written whole again on its next sync, or at the Worker's start (lifecycle.rewire)
An agent's own address/gateway/agent/<id>/…, served as the rest of the path (magpie agentpath.go); /gateway/agent/<id>.<mac>/… carries its own key and lets it in whatever bearer it sends (path_keyed, Claude Science)
An agent that sends no keyCommand Code, fx, Empryo, Ante and OpenBot have no key field, or one they won't send. magpie lets them in keyless from loopback; here their own key is in their address, /gateway/agent/<id>.<mac>/… (path_keyed), so a web page in a browser on this computer still cannot spend the user's providers
An app's own windowCopilot for Obsidian calls from Obsidian's window (Origin: app://obsidian.md). On /gateway/ that origin is answered CORS, preflight included. Any other web page is refused (magpie cors.go)
Obsidian with no keyIts settings are in the vault, which gets synced and published, so no key is written there. /gateway/agent/obsidian/… (path_named) is let in keyless only over HTTP from a loopback peer to a loopback Host, nothing forwarded, Origin app://obsidian.md, as magpie lets Obsidian in
Where a key is acceptedOnly on /gateway/ paths, as Authorization: Bearer, x-api-key, or on Gemini paths x-goog-api-key and ?key=. The owner token works in the headers; ?key=, which URLs and logs keep, takes gateway keys only. Every gateway request needs one, from any address, except Obsidian's window and Muse's model list below
A path at the host's rootMuse Code asks for its model list at /muse-code/models, outside /gateway/, where the key in its address can't go. It is served as Muse's own path and let in with no key only while Muse is connected, from a loopback peer to one loopback Host, nothing forwarded (no Forwarded, X-Forwarded-* or X-Real-IP), with no Origin, as Obsidian's window, so no web page or proxy can read it
UsageRecorded as call_kind = "harness", labelled by the agent: its path, else its key, else its User-Agent, else the protocol

Two ways Codex and Claude Code use it

CodexClaude Code
Started by OpenProgram for a chat-c overrides: model_provider = "openprogram", the model_providers.openprogram table with env_key, model, model_context_window; the key in the environment--settings with a file of the chat's own in the state folder (magpie claude_launch.go, which keeps one): ANTHROPIC_BASE_URL, ANTHROPIC_AUTH_TOKEN, the tier variables, ANTHROPIC_SMALL_FAST_MODEL, a picked CLAUDE_CODE_SUBAGENT_MODEL, and an x-openprogram-launch header naming the file; ANTHROPIC_API_KEY and the cloud switches blank. Another model or tiers starts the process again. The user's settings.json is not written; what a session's /model or the opus-to-1M rewrite leaves there goes back after each turn (magpie ClaudeLaunchAfter)
Also in the Terminalconfig.toml: model_provider, model, model_catalog_json and the table with experimental_bearer_tokensettings.json: the same variables under env and the top-level model; CLAUDE_CODE_USE_BEDROCK/_VERTEX/_FOUNDRY removed while on

Claude Code's Explore and Plan declare model: inherit, which Claude Code reads before CLAUDE_CODE_SUBAGENT_MODEL; with a Subagents model set, the gateway moves their tool turns onto it (claude_subagent.py, magpie #7176), read from the chat's launch file when the request names one, else from the user's settings.json.

ANTHROPIC_MODEL is never set: it would override the model picked with /model. Nothing else is added to an agent's config: no MCP servers, permissions or instructions, and no prompt text names the gateway. Codex's join mode, which would pass ChatGPT sign-in traffic through, is not offered.

The Codex app

The Codex app inside ChatGPT.app runs its own codex app-server on the same ~/.codex, so the same config.toml reaches it (codex_app.py).

GapWhat OpenProgram does
Its model pickerLists model/list, which shows only Codex's own models for a provider it does not ship. The enabled models are written to openprogram-models.json beside config.toml and named by model_catalog_json; the chosen one comes first, and the file is rewritten when the enabled models change. Each entry is Codex's own metadata for an unknown model: the window OpenProgram knows or 272K, the model's thinking levels as its reasoning efforts, and the prompt.md instructions of the installed Codex's release, read once and kept
Reading the changeIts app-server reads the config only as it starts. Turning on or off ends the app's own app-server (in an app bundle, stdio, on this Codex home) with SIGTERM once no session file was written for 20 seconds, for up to 15 minutes; the app starts another and keeps its windows and chats. A new model alone restarts nothing

Agents on a Chat Completions provider entry

These agents take a provider of the user's own in a JSON file. Each module ports its magpie file (qwen.go, copilot_byok.go, … qwenpaw.go): OpenProgram's entry is named openprogram, the user's entries stay where they were, and what the agent's own settings pointed at is stashed and put back.

AgentConfigWritten
Qwen Code~/.qwen/settings.jsonentries in modelProviders.openai on an env key of its own; model, auth type
Copilot CLI~/.copilot/providers.json, settings.jsonBYOK provider and its models; model
Command Code~/.commandcode/providers.json, settings.jsonprovider openprogram, keyless; model
fx~/.fx/settings.jsonprovider openprogram, auth none, reasoning levels; provider and model
Empryo~/.empryo/config.jsonproviders entry; defaultModel
nanobot~/.nanobot/config.jsonproviders.openprogram; agents.defaults
Paimon~/.config/paimon/config.jsonproviders.litellm; model, context window
Ante~/.ante/catalog.json, settings.jsonprovider and preferred_models; provider and model
Cline~/.cline/data/settings/providers.json, models.json, globalState.jsonopenai-compatible provider and models; the VS Code extension's state
Qoder, Qoder CN~/.qoder/settings.json, ~/.qoder-cn/settings.jsonproviders.openprogram with each model's efforts; model
Open Code Review~/.opencodereview/config.jsoncustom_providers.openprogram; provider and model
Snow CLI~/.snow/profiles/openprogram.json, active-profile.json, config.jsona profile of its own, made active
Tuanjie Cowork~/.codely/settings.jsoncustomModelProviders and customModels entries
OpenPencilopenpencil/settings.json in the config foldera builtin_agents entry; refused while the app runs
WorkBuddy, WorkBuddy AI~/.workbuddy/models.json, ~/.workbuddy-ai/models.jsonmodel entries (a bare list or {models}); app restart
CodeBuddy~/.codebuddy/models.json, settings.jsonmodel entries; model
Copilot (JetBrains)~/.config/github-copilot/byok.jsonopenprogram-provider-config, -api-key, -models-config
Droid~/.factory/settings.jsoncustomModels, each on its provider's protocol; sessionDefaultSettings.model
Obsidianeach vault's .obsidian/plugins/copilot/data.jsonCopilot for Obsidian's provider, models and default
AstrBotdata/cmd_config.json under its rootprovider_sources and provider entries; default chat model
OpenClaw~/.openclaw/openclaw.jsonmodels.providers.openprogram; agents.defaults.model
QwenPaw~/.qwenpaw.secret/providers/custom/openprogram.json, each agent's agent.jsona custom provider; active_model per agent row

Not ported from these files: their effort fields (a field here is a model pick, which reseat moves), telemetry switches, WSL copies, own-model pickers and per-agent check messages.

The OpenCode format

opencode_format.py is OpenCode's config shape, after magpie's openCodeLike, opencode_v2.go and opencode_providers.go: a provider openprogram with @ai-sdk/openai-compatible, the gateway's Chat Completions and key, setCacheKey, and every enabled model with its window, image input, reasoning and its levels as variants (weakest first; none is an empty set, so OpenCode 2 does not invent low, medium and high).

Models are openprogram/<provider>/<model>. The provider is OpenProgram's own object (Write.owns); what the user adds stays and is no drift: a header, a setCacheKey, a variant, a limit.output they typed.

That last is magpie's outputsKept: the stash records each reply limit OpenProgram has wanted for a model, and a value that is none of them is the user's.

The provider is the model list a sync rewrites; the model picks are a second write on the same file, left as the user changes them. A small model unpicked again is the agent's own: the one OpenProgram wrote goes, with an object it added to hold it.

AgentWhat is written
OpenCode$OPENCODE_CONFIG_DIR or $XDG_CONFIG_HOME/opencode, the first of opencode.jsonc, opencode.json, config.json. For OpenCode 1 provider and small_model (only when a small model is picked); when the opencode on PATH is 2.x, OpenCode 2's words: providers (package, settings, compatibility, variants as a list) and agents.title.model; the move to OpenCode 2 carries the provider under provider over in OpenCode 2's words, the user's headers and variants with it (magpie openCodeFromV1). Plain key; told apart by its User-Agent
OpenCode's model listFrom 1.4.0 and 2.0.5 the provider is written without its models and plugins/openprogram-models.js beside it fetches /models?format=opencode (opencode2) as OpenCode starts, falling back to the list written. A variant or reply limit the user set stays and wins, judged against what a sync would write. A provider of the user's own on the gateway's baseURL that lists the model is named instead
OpenChamberdefaultModel, smallModelOverride in preferences.json (version 1, else left alone) and the copy in settings.json; defaultVariant is cleared only when the model changes; the provider and plugin in OpenCode's config, shared with OpenCode (Write.shared)
MiMo Code, DevEco CodeOpenCode 1's words in $MIMOCODE_HOME/config or ~/.config/mimocode; $DEVECO_CONFIG_DIR or ~/.config/deveco. DevEco Code gets a key of its own, since parts of it send OpenCode's User-Agent
JetBrains Air, Air in IDEsAn OpenProgram agent in acp.json (the app's config folder; ~/.jetbrains for the IDE plugin, seen once an IDE of 2026.2 or later is, by detect_only): opencode acp with OPENCODE_CONFIG naming openprogram-opencode.json beside it, which holds the provider, the model and enabled_providers narrowed to it. The opencode is found on PATH, in ~/.opencode/bin or in an IDE's ACP registry folder
OpenBotAn entry openprogram in openbot-custom-providers-v1.json (version 1, else left alone) beside the user's own (Write.members), at /gateway/agent/openbot.<mac>/openai/v1 with secret: null: at most 64 models it accepts. Its keys are sealed by the OS keychain, so its key is in its address (path_keyed). The user's name, harness or secret for the entry stays (Members.kept). Disconnect takes the entry out (magpie openBotUnwire) and keeps version; a file OpenProgram made goes once only that and an empty list are left

A model's price, where the catalog has one, is written as OpenCode's cost (a list of tiers for OpenCode 2). Not ported: Air in WSL.

Agents in Pi's format

Pi keeps the model a session starts on in settings.json and providers in models.json. agents/pi_like.py (magpie piLike, piModelOn) writes the provider openprogram there:

  • Chat at /v1, each model on the API its provider serves natively: Responses, Messages at the Anthropic root, Gemini at /v1beta.
  • Each model's window, reply limit, a thinkingLevelMap naming every level, and a prompt-cache lifetime.
  • The model joins enabledModels when that list exists and nothing in it takes the model in. Keys the user added to the block stay.
  • After a sync, an entry naming a model no longer given leaves enabledModels and comes back with the model; a list left empty goes and comes back (magpie scope_gone.go). What left is kept in the stash record (Wiring.record, saved by a sync too). The same holds for StepCode and omp.
  • On disconnect the pick goes back only while defaultProvider is still openprogram; then enabledModels loses every entry naming one of OpenProgram's models (magpie piScopeWithout).
  • The choice fields: effort (defaultThinkingLevel), and for Pi protocol, every model asked on Chat, Responses or Messages (magpie piProtocolField); a picked protocol replaces an api the user set on the provider.
AgentWhereWhat connecting writes
Pi, OmO, Prime Agent, mu~/.pi/agent, ~/.omo/agent, ~/.prime/agent, ~/.mu/agent (each moved by its own variable)defaultProvider/defaultModel and the provider, with a key that names each; Pi and mu leave Gemini's API out
StepCode~/.stepcode/config.toml, models.jsonThe same keys in TOML, the provider in models.json
Aside~/.aside/u/<account>: the one picked (account, offered while Aside has two or more; kept in aside-account.json beside the stash), else the active onedefaultModel with the thinking level picked, and the roles under modelCategories as {provider, modelId, thinkingLevel}; then given to the running Aside through aside repl (Agent.after), else read at its next start
Craft Agents~/.craft-agent/config.jsonA pi_compat connection with authType: none in llmConnections beside the user's (Write.members, its name theirs to change), made the default; Craft sends no key, so its own key is in its address (path_keyed); the model picked in Craft stays through a sync, and a default switched in Craft is the user's; disconnecting drops the default where the user's own connection has gone
Pencil~/.pencil/models.jsonThe provider alone, every model on Chat; the model is picked in Pencil
MothX~/.mothx/settings.jsonThe provider (openai-chat, thinkingFormat: openai), the default model and its thinking level; a sync writes the provider alone, so a model picked in MothX's /model stays
LiveAgentK-brain's config.json (JSONC)Three providers by native API, each OpenProgram's whole (Write.owns), keeping the user's names, request format and turned-off models; a model or provider deleted in LiveAgent stays out of later syncs, and once all of them are deleted a sync writes nothing (magpie liveAgentWired); refused while it runs. On disconnect a pick on one of them goes back, or, one LiveAgent made, is reset to K-brain's own (magpie liveAgentUnwire)
omp and its profiles~/.omp/agent/config.yml, models.yml; profiles/<name> as rows of their own (extra_agents())modelRoles (default and nine quiet roles, each with a thinking level of its own, else the one it had), openprogram/** in enabledModels, the provider with the efforts its version takes; defaultThinkingLevel, the advisor's review, wait and wake (advisor.*, as strings) and the protocol, a Messages model then on a thinking budget. An older models.json is moved to models.yml as omp would (Write.base); a role moved off OpenProgram in omp stays on disconnect

Gemini's API, and agents with their own models

Gemini CLI and Antigravity CLI speak Google's Gemini API to the gateway; Cursor CLI and Devin have no endpoint it can stand in for, so only their model is set, their model field being a choice among their own models (Agent.gateway false: reseat and rewire leave them alone).

AgentWhat connecting writes
Gemini CLI (gemini.py)~/.gemini/.env: GOOGLE_GEMINI_BASE_URL and GEMINI_API_KEY; settings.json: security.auth.selectedType = gemini-api-key, model.name. A key of its own. The sign-in choice and model are loose: its /auth and /model rewrite them, a reconnect on the same model keeps that pick, and disconnecting puts both back. Found by its command only (detect_only), since Antigravity shares ~/.gemini. OpenProgram's own Gemini CLI chats keep the person's sign-in: their process gets the stashed values back (GEMINI_CLI_SYSTEM_SETTINGS_PATH)
Antigravity CLI (agy.py)~/.gemini/antigravity-cli/openprogram-settings.json, whole: modelProvider = gemini, the model, a custom model per enabled model (openprogram/<ref>, one more per level for two or more of low, medium, high) and the user's own. settings.json stays the user's; agy starts with GEMINI_API_KEY, GOOGLE_GEMINI_BASE_URL, --settings and --model, with a key of its own (Agent.launch). A sync or same-model connect keeps agy's /model pick; another model on the row replaces it. Disconnect first takes that pick out of settings.json (unwire)
Antigravity CLI, starting itConnecting puts a function agy in each shell's profile between # >>> openprogram agy >>> lines (shellfn.py, magpie's shell_function: zsh, bash, fish, PowerShell where its policy runs a profile); it runs python -I -m openprogram agy run, so a cwd holding json.py or openprogram/ is never imported (PowerShell reads agy env). A linked profile stays linked. Disconnecting takes it out
Antigravity CLI, its choiceseffort: the level the gateway asks agy's requests for (agent_effort.py; a request that names a thinkingLevel keeps it). fasttools: the fast-tools plugin (agents/fasttools/, an MCP server OpenProgram runs as fast-tools mcp), written by after and kept starting this OpenProgram by keep. Both are kept fields: the user's own settings, held in kept_picks.py outside the stash: they outlive disconnecting, return with the next connect, and fast tools stays settable while disconnected (engine.set_kept)
Cursor CLI (cursor.py)~/.cursor/cli-config.json model.* and hasChangedDefaultModel. Found by that file or cursor-agent, not the editor's folder
Devin (devin.py)~/.config/devin/config.json agent.model. The model is one of the families of devin models list; the effort choice offers the levels the model has, and the pair is written as one variant id at the nearest level, ties going up. With no effort picked a family keeps the effort the old variant id was at

Taken from magpie

AreaTaken
AgentsThe agent as a description, one module each; per-agent keys and paths; resync, reseat and rewire; the app restart
Config filesSurgical editors for TOML, JSONC, YAML and dotenv with line notes; stash-before-write, drift, a damaged stash that stops every change; Codex's provider table that is never removed; the Codex app's catalog and its app-server restart
ProtocolsThe Responses WebSocket and /responses/compact; the Gemini and Ollama APIs; model metadata in /models; explicit model refs; Claude Code's tier variables without ANTHROPIC_MODEL; errors in the client's protocol with no fallback after the first byte
Not takenServing a Claude or ChatGPT subscription (running the claude binary, Codex's join mode, account pools); additions to an agent's config that were not asked for

Implementation status

AreaWhere it stands
AgentsCodex, Claude Code, the Anthropic-env family and Kiro Crew, the Chat Completions agents, the OpenCode format, Pi's format, Gemini's API and own-model agents and the editors, running apps and import links and the agents with a provider table are in the registry; the rest of magpie's list comes next, one module each
Not taken from magpieWSL hosts, Codex's WSL auto-wiring, the isolated Desktop's own Claude Code folder, its badged icon, and the live move of a connected Desktop between its own folders and the copy (Runs In changes while it is off); Pi's extension (extensions/magpie.ts) and Alma's image model, as the gateway serves no decision or image models
Not yetConfigs and shell functions (agy's, Dim's) inside WSL; offering a CLI update or install list; Ollama clients that send no key (they cannot authenticate yet); Codex's supports_websockets, which magpie does not set either; Gemini tool-call thought signatures through the Anthropic protocol; PDF documents; a reset of OpenProgram calling engine.disconnect_all
Web searchAnthropic's web_search server tool asks a provider that searches; for one that cannot, the gateway searches with OpenProgram's own web search, on /v1/messages only (magpie search.go)
Last updated · 2026-11-30