Based on AgentRun release · Synced .
Models
An agentic revision names its model as provider/model-id ("model" in its definition), or names none and runs on
this host's default, AGENT_MODEL. With no AGENT_MODEL, a model provider's key, the server's own or saved as a
tool key, gives the default, the first of: anthropic/claude-sonnet-5-5 with ANTHROPIC_API_KEY,
openai/gpt-6.1-sol with OPENAI_API_KEY, particle/particle-1 with PARTICLE_API_KEY, then
openrouter/openai/gpt-6.1-sol with OPENROUTER_API_KEY. Set AGENT_MODEL for another. Direct Particle runs on Pi;
claude-agent takes the Anthropic one and codex the OpenAI one. A workflow revision names no model: each model node names a tier (fast, default
or strong), and the host maps it, fast to AGENT_MODEL_FAST and strong to AGENT_MODEL_STRONG, each falling back
to AGENT_MODEL. Capabilities show the mapping in models ({source, route_prefix, fast, default, strong}):
source is gateway, providers, chatgpt or faux (the published document marks gateway and providers as
models/2, beyond the contract's managed, chatgpt, env and faux), and route_prefix is the routing prefix this server puts before a gateway's
model ids (agent-model), which a client takes off to show the gateway's own id, and null with any other source.
models also says ready, whether a revision that names no model runs here, and when it does not, needs: key (no
model provider's key and no ChatGPT sign-in, or none for the default's provider) or model (AGENT_MODEL names one this server does not
know); and priced, whether that model has a price here, which a run's max_cost_usd needs (false for a gateway
model with no price set that the catalog does not list in any form; null while ready is false, with no model to price). Where the models come from:
--faux MODULE: every model is the module's (below), with no key and no network:faux-1, or for a tier the model id its variable names.AGENT_MODEL_BASE_URL: every model id goes to that one gateway, with one trailing/v1taken off the base first, as for every harness (OpenRouter's ishttps://openrouter.ai/apiorhttps://openrouter.ai/api/v1): a Claude model on Anthropic's Messages API at<base>/v1/messages, where pi marks its prompt for Anthropic's cache (the Responses API carries no cache mark, so a gateway's bridge from it reads none), and every other model on OpenAI's Responses API at<base>/v1/responses. A model is Claude's when its id names Anthropic as its vendor (anthropic/claude-sonnet-5.5) or names none and pi-ai's catalog lists it under Anthropic (claude-opus-5-5); the gateway serves both APIs, as LiteLLM's proxy and OpenRouter do, withAGENT_MODEL_API_KEYas a bearer token on either. A revision'sprovider/model-idis sent whole, as a gateway like OpenRouter names its modelsvendor/model, andAGENT_MODEL,AGENT_MODEL_FASTandAGENT_MODEL_STRONGare sent as they are. For a gateway that wants the id alone,AGENT_MODEL_GATEWAY_IDS=baresends a revision's model without its provider.AGENT_MODEL_API_KEYis its key when it needs one.AGENT_MODEL_PRICEisinput,output,cacheRead[,cacheWrite]in USD per million tokens, so a run's cost estimate has a price;AGENT_MODEL_FAST_PRICEandAGENT_MODEL_STRONG_PRICEprice their tier's model, and default to it. With no price set, a model id pi-ai's catalog knows (gpt-6-luna, say) takes the catalog's list price; one it lists only with its version's separators written the other way (a gateway'sgpt-6-1-terrafor the catalog'sgpt-6.1-terra,claude-haiku-5.5forclaude-haiku-5-5) takes that entry's price, only when every entry of that form lists one price (else none), and the id sent to the gateway stays as named; any other has no price: its answers' cost is unknown, so the run'scost.usdisnull, never $0. A model the catalog lists at $0, or oneAGENT_MODEL_PRICE=0,0prices, is a known $0. A revision'sprovider/model-idtakes that provider's entry when it is paid; a bare id, a provider the catalog does not list for it, or one it lists at $0 takes the highest price any provider lists (one entry's whole price, the most input plus output; a $0 entry never wins over a paid one), as the gateway does not say whose model answers. A run withmax_cost_usdon a model with no price is refused before it starts: 409agent_not_runnable, whoseerror.fieldsentry namesdefinition.model, the reasonnot_set_up_here, "The model <id> has no price here, so a run's spend cap cannot be kept on it." and thefixnamingAGENT_MODEL_PRICE, as every 409agent_not_runnablenames each thing that keeps a run from starting; an agent saved with a default cap on one gets that as a warning. One without a cap runs, on every harness, with each request's cost unknown: codex's and opencode's proxy books it unknown, never $0, so the run'scost.usdisnulland/usagecounts it inunpriced_runs.- A model gateway saved in the console (Settings → Model keys → Use a model gateway), the same gateway kept in the
store instead of the environment, for a LiteLLM or other OpenAI-compatible proxy the owner already runs: its address
(the one rule
AGENT_MODEL_BASE_URLfollows), its key (optional; sealed under the seal key, never shown again, never in a run's environment), how it takes ids (as_named, orbareasAGENT_MODEL_GATEWAY_IDS=bare), and the default model of each tier (AGENT_MODEL,AGENT_MODEL_FAST,AGENT_MODEL_STRONG). Test asks the gateway'sGET <base>/v1/modelsfrom the server, with no redirect followed, and lists the ids to pick from. A save or removal takes effect at once, with no restart: capabilities read it, and the runner reads it at each claim. Over the API:GET,PUTandDELETE /v2/settings/model-gatewayandPOST /v2/settings/model-gateway/test; every one but the GET takes the owner's signed-in session, never the API token. Which wins:AGENT_MODEL_BASE_URLset where AgentRun starts makes the environment's gateway the one in force, whole, and the saved one is not read (itsPUTandDELETEare 409key_set_by_server); else the saved gateway is in force with its own key alone (never anAGENT_MODEL_API_KEYset without a base URL), and each ofAGENT_MODEL,AGENT_MODEL_FAST,AGENT_MODEL_STRONGandAGENT_MODEL_GATEWAY_IDSset where AgentRun starts wins over its saved field. A saved key goes only to the origin it was saved for: changing the address to another origin asks for the key again (orapi_key: null, no key). With no key saved, each run brings its own (model_key, below). Prices are read as forAGENT_MODEL_BASE_URL(AGENT_MODEL_PRICE, else the catalog). Removing it puts the provider keys back in force. - A ChatGPT plan signed in here (below), with no provider's key:
sourceischatgpt, and pi and codex run on the plan's models (chatgpt/<model-id>) with no key. - Otherwise pi-ai's providers serve them, each with its key from the environment (
OPENAI_API_KEY,ANTHROPIC_API_KEY,GEMINI_API_KEY,DEEPSEEK_API_KEY, Bedrock'sAWS_*keys, ...), and its catalog prices the run. TheAGENT_MODELvariables are thenprovider/model-idtoo. The launcher holds every key pi-ai reads, as it holds the rest, and a run's process is handed a model key only when its model needs it: a pi run its model's provider's (a run on GeminiGEMINI_API_KEY, one onopenrouter/...OPENROUTER_API_KEY; a workflow each of its tiers'), orAGENT_MODEL_API_KEYthrough the gateway; a codex runOPENAI_API_KEY, orAGENT_MODEL_API_KEYthrough the gateway; a claude-agent runANTHROPIC_API_KEY. No run gets another's. A workflow's decision nodes get their providers' keys on a descriptor of their own, whatever its model, and only those (Safety).
A definition is checked for what keeps it from running here when it is saved, with the same checks a run makes before it starts:
- What no setting of this host fixes refuses the save,
422 input_invalidby field, and nothing is written: a tool this host does not bind (definition.tools[i]),bashon an agent whose place is not a sandbox (in Mode 1), a model pi-ai does not know when no gateway is set (definition.model, saying why), empty instructions (definition.instructions), and a workflow that needs a tool call this host does not run, code, or a node tool other thanread,writeandedit(definition.workflow, one field per need). - What a setting of this host fixes saves, and the
201or200carries it inwarnings([{field, reason: "not_set_up_here", message}], empty when there is none): no key for the model's provider, no default model for a revision that names none, no model for a tier a workflow's nodes name, no key for the decision provider a workflow's typed questions name (decision workflows). A decision provider this server does not have refuses the save.
A run is refused before it starts, 409 agent_not_runnable, saying which, for any of these: a warning the host has not
fixed yet, or a revision saved before these checks. A run needs only the tiers it uses: an agentic one its model or the default, a workflow the tiers its nodes name, so a
workflow of fast nodes runs with AGENT_MODEL_FAST and no AGENT_MODEL. A run thinks at its effort (low, medium,
high), else at its agentic revision's thinking (low to max), else at the host's AGENT_THINKING (one of those
levels exactly), else at its harness's own default; it is never off (pi never asks a model the catalog does not list,
such as a local one, to stop reasoning: it thinks at its lowest level, its reasoning kept out of the answer), and a model node that names its own thinking level
keeps it. The level is fixed in the run's launch when it starts, and its metrics name the level its harness ran at: one
above the harness's highest runs at that highest (Codex and OpenCode stop at xhigh). An agentic run whose level is
low, medium or high also gets a short note on how to work, right after its instructions, on every harness
(src/effort-guidance.ts): low answers directly, medium plans briefly and checks once, high plans each part, fills
the gaps and reviews. A run with no level, or one above high, gets no note.
Per-run model keys (LiteLLM virtual keys)
A caller can hand each run its own model key, such as a LiteLLM
virtual key minted for that run, with model_key on POST /v2/runs, POST /v2/agents/{agent_id}/runs and
POST /v2/runs/{run_id}/messages. AgentRun uses that key for every model request tied to the run and never mints,
lists or revokes it: the caller owns the key's life.
Run without a server key: callers pass a per-run key. There is no setting. Point AGENT_MODEL_BASE_URL at the
gateway and give the server no model key of its own (no AGENT_MODEL_API_KEY, nothing saved in Settings → Model keys).
The server and its runners start, and capabilities read ready, with no standing key. Then:
- A run with
model_keyspends on that key alone. - A run without one, whose model goes to the gateway, is 422
model_key_requiredat its start, before any model call. - A message that would start a new turn (the run's last turn ended) without
model_keyis also 422model_key_required, and nothing is written.
A server that does hold a key spends it on a run that brings none, as before, and never on a run that brings its own.
Where the key goes: to the gateway at AGENT_MODEL_BASE_URL only, which every pi and codex model and every workflow
model node is sent to, and to Anthropic's Messages endpoint when ANTHROPIC_BASE_URL names the same origin (claude-agent
on the gateway). A key sent with a run whose model goes elsewhere (no gateway, a native run, a model routed to a
provider's own API) is 422 at model_key, never kept unused.
# Mint a virtual key for this run (LiteLLM's proxy, with its master key; your backend does this, never the agent).
KEY=$(curl -s https://litellm.example.com/key/generate \
-H "Authorization: Bearer $LITELLM_MASTER_KEY" -H 'content-type: application/json' \
-d '{"duration": "1h", "max_budget": 2, "metadata": {"run": "ticket-4521"}}' | jq -r .key)
# Hand it to the run.
curl -s http://127.0.0.1:7340/v2/agents/support/runs -H "Authorization: Bearer $AGENTRUN_TOKEN" \
-H 'content-type: application/json' \
-d "{\"input\": {\"content\": \"Triage ticket 4521\"}, \"model_key\": \"$KEY\"}"
# A follow-up turn gets a key of its own.
curl -s http://127.0.0.1:7340/v2/runs/$RUN_ID/messages -H "Authorization: Bearer $AGENTRUN_TOKEN" \
-H 'content-type: application/json' -d "{\"content\": \"And the refund?\", \"model_key\": \"$NEXT_KEY\"}"
# When the run's turn has ended (run.ended), revoke it.
curl -s https://litellm.example.com/key/delete -H "Authorization: Bearer $LITELLM_MASTER_KEY" \
-H 'content-type: application/json' -d "{\"keys\": [\"$KEY\"]}"
Custody, as for a per_run MCP server's mcp_auth:
- The key is taken out of the body before anything reads it. It is never in the run's saved body, its timeline, its
view, a log or an
Idempotency-Key's fingerprint. A retry with a new key answers the first request's run and keeps its first key. - It is sealed with the run under the server's seal key, bound to the gateway's origin then. A runner opens it at each claim, a reclaim after a runner's crash included. A gateway moved since never receives it.
- Each model route reads it per request through the kernel model proxy. The harness, its tools and its sandbox never see it, and the run's redactor cuts it from anything the run writes.
- A message's
model_keyreplaces the run's key from the next model request on: the runner reads it again when it takes the message, before the message reaches the session. That holds while the turn is still going, and for a run that started on the server's key and gets its first key from a message. If that read fails, it is tried again; if it keeps failing, the message waits untaken and is delivered again, never run on the key held before it or the server's. A stop or cancel sent after it still reaches the run. A message without one keeps the key the run holds.
The revoke-at-turn-end contract. The write that ends a run's turn erases its key, and the run reports the turn
ended (run.ended, the run's completed, failed or stopped status) only after that write. Every model request
tied to the turn finishes before then: the job, its subagents, its learned workflows' nodes, its end-of-run compile
turn. So a caller may revoke the key as soon as it sees the turn end, and no request of that run will
answer 401 for it. Model spend that would run after the turn ends is never sent on the run's key or the server's:
| Spend | With the run's key | Server holds no key, run brought none |
|---|---|---|
| A shadow audit, a learned workflow's replay check | Skipped, logged | Skipped, logged |
A grade's feedback round (PUT /runs/{id}/grade) |
A new turn with no key: the server's, else not opened | Not opened; the grade is kept |
| An owner's replay, an SDK run's compile turn | Tied to no run's key | 409 or skipped, in words |
| A trigger's firing | Starts a run with no key | 422 model_key_required for the firing |
Jev and the other decision providers run on their own keys (TYPESAFE_API_KEY, PARALLEL_API_KEY,
OPENROUTER_API_KEY), which are not model keys and which a run's key does not replace. On a run that brings its own
key, no model key is on the env its decision nodes run under, so Jev's route on an openrouter.ai gateway's key is off.
Direct Particle-1
Save a Particle key in Settings → Model keys → Particle, then select particle/particle-1 with the Pi harness.
Alternatively supply PARTICLE_API_KEY where AgentRun starts and set AGENT_MODEL=particle/particle-1 (or a workflow's
AGENT_MODEL_FAST / AGENT_MODEL_STRONG). Get an inference-enabled key from Particle's platform.
The key uses the existing sealed storage and provider-scoped handover; it is not placed in run environments. Saving
it checks GET /v1/models, which performs no generation. No OpenRouter key is required.
The provider sends native Chat Completions to https://api.particle.ai/v1/chat/completions, using request alias
particle-1. The official catalog lists text/image input, a 1,048,576-token combined
context and a 131,072-token output ceiling (the API's omitted-limit default is 32,000). Strict schema guarantees are
not advertised. AgentRun sends native tools and reasoning_effort; it does not reuse OpenRouter's reasoning object or
its measured text-tools caching workaround. Existing openrouter/particle-ai/particle-1 definitions and the code-review
template keep their OpenRouter route.
Supported scope is Pi agentic runs and workflow model nodes (including nested learned workflows) through Pi's
existing local proxy. Codex, Claude Agent and OpenCode do not support this direct provider. Particle's
Responses API is WebSocket-only; it does not implement HTTP POST /v1/responses.
Pointing AGENT_MODEL_BASE_URL at Particle's global or US API is therefore refused with setup instructions. This
integration currently uses the global endpoint and regular service only; it does not expose regional routing, Flex,
WebSocket steering, files or other Particle models.
The reasoning levels map low to low, medium/high/xhigh to high, and max to max.
Pi requests with thinking off explicitly send none, rather than inheriting the API's high default. Native tool
continuations retain the assistant's reasoning and tool-call IDs. Nested learned-workflow and llm side calls take
the model's limits and reasoning configuration from the live session port, preserving their requested effort.
An opaque hash of the Pi conversation ID becomes prompt_cache_key, within Particle's 256-byte limit. Side requests
without an ID share a key for the lifetime of their route. cacheRetention: "none" omits the explicit hint;
Particle may still derive affinity and cache the prompt. Read the returned cached-token count, since
affinity does not guarantee a cache hit.
Usage keeps the provider's token counts: uncached input is prompt tokens minus cached input, and reasoning is a
breakdown of completion tokens, never added to them again. Cost is an estimate at regular peak list prices:
$0.25 uncached input, $0.03 cached input and $1 output per million tokens. The same rates reserve the run's cap.
Off-peak discounts, Flex and account-specific pricing can change the bill;
Chat usage does not supply an authoritative dollar total. Missing or malformed usage, or a stream missing its terminal
[DONE], fails the request with unknown cost rather than reporting a free completion. Cancellation aborts the provider
request, but does not undo tokens already generated or guarantee final usage.
Provider and session transports disable retries. A Pi claim using Particle, including one of its subagent tiers, also disables automatic conversation retries for the whole claim. Errors are surfaced for the caller to decide; even a pre-admission 429 is not retried automatically. This changes request retry configuration, not recovery admission, dispatch, journal fencing, restart or cancellation behavior; the recovery models do not change.
Offline regressions cover streamed native tools, continuation, reasoning, cache accounting, missing usage, cancellation, errors, credential scoping and actual Pi conversation retries. A live pass against Particle's API (2026-11-18, twelve checks) saved a key, then completed a plain run, tool calls continued after the model's reasoning, a follow-up, a cancel, a capped run and a workflow's model nodes. Replies reported cached input tokens and no cache writes, and each priced run's cost equaled its tokens at list price. A later workflow run (2026-11-19, three requests) matched Particle's usage page: the same cached, uncached and output token counts, and the same cost to the six decimals the page shows. Not yet seen live: a rate limit or server error from Particle. The protocol fixtures alone are not evidence of live compatibility.
On a ChatGPT plan
A server needs no model key to start, on any of its deploys. With none, capabilities say models.ready: false and
needs: "key", and each harness's reason names the keys it takes. Codex's and pi's add "or sign in with ChatGPT
(Settings → Model keys) to run it on your ChatGPT plan" (after an expiry: "your ChatGPT sign-in expired: sign in again
(Settings → Model keys)"), and their entries say needs: ["key", "chatgpt"]; Claude Agent's and OpenCode's say
needs: ["key"]. The console's first screen then offers Continue with ChatGPT beside Add a key (also under
Settings → Model keys), and its "What runs here" reads needs: Codex and pi "run after Continue with ChatGPT". The owner
signs in with their ChatGPT plan, and pi and codex run on it with no key. Claude Agent, OpenCode, Jev decisions and paid
tools still need their own keys.
The sign-in is the owner's alone, over the owner's signed-in session (the API token gets 403, as for every secret):
POST /v2/settings/chatgpt/sign-inanswersauthorize_url, OpenAI's sign-in page, andexpires_at: one sign-in waits at a time, for 10 minutes, and starting again replaces it. Where the browser and the server share a computer (npx @parcha/agentrun), it finishes by itself. On a server that isn't this computer (Render, a container), the sign-in tab ends on a page that won't load: copy its whole address into the console, which sends it asPOST /v2/settings/chatgpt/sign-in/finish{"redirect_url": "..."}.GET /v2/settings/chatgptsaysstate:signed_out,pending(withauthorize_urlandexpires_at),signed_in(withemail,planand the plan'smodels) orexpired.DELETE /v2/settings/chatgptsigns out: it removes the sign-in here and revokes it at OpenAI, and answers{"revoked": true}when OpenAI confirmed it (or nothing was signed in, as when it only cancels a waiting sign-in). When OpenAI didn't confirm it, the answer is{"revoked": false, "message": "Signed out here. OpenAI didn't confirm the revocation: remove AgentRun in your ChatGPT settings."}. Signing in again revokes the sign-in it replaces, and a renewal that finishes after a sign-out revokes the tokens it got.
A curl call with the owner's session (the console's cookie: __Host-agentrun-session on https) sends this server's own
origin and content-type: application/json on every write, a DELETE with no body too: without them the cookie
does not count, and the server answers 401 (the console).
S=(-H "cookie: __Host-agentrun-session=$SESSION" -H "origin: $BASE" -H 'content-type: application/json')
curl -X POST "$BASE/v2/settings/chatgpt/sign-in" "${S[@]}"
curl -X POST "$BASE/v2/settings/chatgpt/sign-in/finish" "${S[@]}" -d '{"redirect_url":"<the address the sign-in tab ended on>"}'
curl "$BASE/v2/settings/chatgpt" "${S[@]}"
curl -X DELETE "$BASE/v2/settings/chatgpt" "${S[@]}" # 200 {"revoked": true}, or {"revoked": false, "message": "..."}
The sign-in is sealed in the store under the seal key, like a saved key. Any process that holds the store and the seal
key (the server, each runner) renews the sign-in, so it is as trusted as the server; the seal key already opens every
sealed key. Signed in, with no provider's key, capabilities
say models.source: "chatgpt" and a revision that names no model runs on chatgpt/gpt-6.1-sol where the plan lists it.
A run on the plan books its tokens and no dollars (cost.plan). Eligible usage in this app uses your ChatGPT plan.
Manage usage in your ChatGPT settings. A sign-in is for the person who runs this server: don't share it or let others
run agents on it.
On Claude Code's login on this machine
On a server one person runs on their own machine, Claude Agent can run on that person's Claude plan through the Claude
Code CLI's own login. The CLI holds the login and calls Anthropic itself. AgentRun never reads, copies, stores or relays
the login. It tells the CLI where the login is and asks it claude auth status, nothing else. Settings → Model keys
has the row Use Claude Code's login on this machine, over these routes:
PUT /v2/settings/claude-login{"only_me": true, "place": "agentrun"}turns it on.only_meis the owner's word that they alone run agents on this server.placeis where the login is:agentrun(the default) is AgentRun's own login directory in the data folder, which you sign in once;machineis this machine's own Claude Code login (~/.claude), which you opt into by name. A server where more than one person can start runs (more than one API token, the API-only profile) refuses it with403and one line saying why, and a turn-on saved before is dropped when such a server starts.GET /v2/settings/claude-loginsaysstate:off,signed_in(with theaccountthe CLI names: method, email, organization, plan),signed_out,no_cli(claude-agent's first run installs the pinned CLI),unknown, orother_machine.commandis the line that signs the CLI in at the login's place, for a terminal on the server's machine. Where the console is on that machine (a server on loopback with no public address),can_startis true andPOST /v2/settings/claude-login/loginstarts the pinned CLI's ownauth login, which opens a browser there.DELETE /v2/settings/claude-loginturns it off. The login stays as the CLI keeps it.
While it is on, a claude-agent run on an anthropic/<model> model goes on the login: its CLI gets no
ANTHROPIC_BASE_URL, ANTHROPIC_AUTH_TOKEN or key, no model proxy runs, and the CLI's sandbox denies its commands
reads of the login. A model named on a gateway or OpenRouter keeps its key, and so does a run started with its own
model_key. With no key at all, claude-agent's default
model is anthropic/claude-sonnet-5-5. A run whose login is signed out fails at its start and says so. It never
switches to a key. The run books its tokens and no dollars (cost.plan, on: "claude_code"), and the plan's own limits
apply. Only a run in a runner place, on the machine the mode was turned on for, goes on the login. A run placed in a
sandbox, or on another machine, uses the keys. The login is the server's user's, so a run on it needs runs under that
user: where each run is a user of its own (the image, run_isolation: "uid"), a claude-agent run that would go on the
login fails at its claim and says so. Set AGENTRUN_RUN_USER=same, or give the run a model_key.
The mode exists only on a server that listens on loopback (a local install, or one behind a local proxy). A server
bound to any other address, such as all interfaces in a container or on a hosting service, has it off
with nothing to set. AGENTRUN_CLAUDE_CODE_LOGIN overrides the default. off turns the mode off anywhere. on makes
it available past loopback, but a server with more than one API token still refuses it, and so does the API-only
profile. While the mode is off, the row is gone and every route above answers 404 naming its operation. A turn-on
saved earlier is dropped when the server starts, and claude-agent runs on the model keys.
