Requirements
- Node 20 or newer
- A HostYourAI account with a router key (API keys page), or a key for a router of your own (see "Your own router")
- OpenCode, installed separately (one command, below)
Install
One command installs hyai and the agent (OpenCode, the version hyai was last
tested with). It needs Node 20 or newer and uses npm, nothing runs as root:
curl -fsSL https://hostyourai.com/cli/install.sh | sh
Read the script first if you like: it is short. By hand it is the same two lines:
npm install -g https://hostyourai.com/cli/hyai-code-latest.tgz
npm install -g opencode-ai@1.18.31
If hyai is not found afterwards, the npm global folder is not on your PATH:
npm prefix -g shows the folder, its bin has to be on PATH.
hyai itself never installs the agent for you. If it is missing, hyai prints
these commands and stops.
Update
hyai update # install the newest version, if there is one
hyai update --check # only say whether a newer version is out
hyai update reads https://hostyourai.com/cli/latest.json (also when you use a
router of your own), downloads the tarball named there from the same host,
checks its SHA-256 and installs it with npm install -g. It never uses sudo.
When npm cannot write its global folder, or hyai runs from a checkout (update
that with git pull), it stops and prints the command to run by hand:
npm install -g https://hostyourai.com/cli/hyai-code-latest.tgz
Versions before 0.10.0 have no hyai update; run that command once.
hyai --version shows what you have, and hyai doctor says when a newer
version is out. What changed per version: CHANGELOG.md, also
at https://hostyourai.com/code/changelog. Every release has a fixed tarball
(hostyourai.com/cli/hostyourai-code-<version>.tgz) and its SHA-256 in
https://hostyourai.com/cli/latest.json.
Login
Create a router key at https://hostyourai.com/app/api-keys, then:
hyai login
The input stays hidden. The key is checked against the router (a read of the model list, nothing else) and only stored when the router accepts it.
hyai logout removes it.
Your own router
hyai also works with a router of your own, built with hyai-route (for example
https://acme.route.hostyourai.com). Keys for such a router start with hyr-;
keys for HostYourAI start with hyai-rt-. Tell hyai where your router lives
when you log in:
hyai login --router https://acme.route.hostyourai.com
You can give the root of the router, its /v1 address or the /ui page you
use in the browser: hyai turns each of them into the API address
(https://acme.route.hostyourai.com/v1). The key is checked against that
router and stored together with the address. A local router works too:
hyai login -r http://127.0.0.1:4000.
If you run plain hyai login with a hyr- key, hyai asks for the router
address instead of sending the key to hostyourai.com. In a script it stops and
prints the command to run. A key is never sent to the other kind of router:
when the key and the address do not belong together, hyai login stops
before any request and stores nothing. To go back to HostYourAI:
hyai login --router https://hostyourai.com.
hyai doctor shows which router you use and fails, with the fix, when the key
and the router do not belong together. HYAI_BASE_URL in your shell wins over
the stored address, as before.
Set up your router from Claude Code
A router of your own has an MCP server for its admin side (teams, models, keys, users).
hyai mcp prints the command that adds it to Claude Code and an mcpServers block for other
MCP clients, with your router's address filled in:
hyai mcp # the key is a placeholder
hyai mcp --key # with your stored key printed in; nothing is written to a file
hyai mcp --json # only the mcpServers block
The tools can do what your key may do: an admin's key sets up everything, a team manager's key their own teams.
Session notice and managed settings
Two things a team or company arranges once, for everyone who works on its router.
Session notice
A team or company can have hyai show a short notice before the agent starts, for example where the session's data goes. An admin writes the company's notice in the router's Settings (Session notice); a team adds its own in Control: Teams, the team, Setup. When both are set, hyai shows the company's notice above the team's.
hyai, hyai run claude, hyai run codex, hyai run opencode and
hyai run t3 print the notice before the tool starts. When the team ticked
"ask to confirm", you press Enter once per session to start. Without a
terminal (a script, CI) the notice goes to stderr and the tool starts by
itself. hyai keeps the last notice it saw, per router and key, so it still
shows when the router is briefly out of reach.
Managed settings for Claude Code
A company that manages Claude Code through its MDM (Jamf, Intune, Kandji) installs a managed settings file on each machine:
| System | File |
|---|---|
| macOS | /Library/Application Support/ClaudeCode/managed-settings.json |
| Linux | /etc/claude-code/managed-settings.json |
| Windows | C:\Program Files\ClaudeCode\managed-settings.json |
Managed settings win over everything hyai run claude sets for a session.
hyai whoami and hyai doctor read the file (they never write it) and name
each setting that works against hyai run claude:
modelPicker.replaceBuiltInOptions: the managed picker replaces the one hyai passes, so the team's models are missing from/model.availableModelswithout the team's models.apiKeyHelper: Claude Code takes its key from that script instead of your router key.ANTHROPIC_BASE_URL,ANTHROPIC_AUTH_TOKEN,ANTHROPIC_API_KEY,ANTHROPIC_CUSTOM_HEADERSorANTHROPIC_MODELunderenv: they override what hyai sets per launch.forceLoginMethodset toconsole: Claude Code signs in with an API key instead of your Claude subscription.- a fixed
model: every session starts on it, whatever you pick with hyai.
When the file is there and nothing conflicts, both commands say so. The fix is on the team's side: the team admin opens Control (Teams, the team, Setup, "Managed settings for Claude Code") and gets a snippet with the team's models, for your IT admin to put in the MDM.
Settings
hyai config first shows what your router says about this key (account,
team and role, route, key name), then every setting on this computer with its
value and what it does. A model setting that does not start is marked with
what starts instead. hyai whoami shows only the router part.
The settings:
| Setting | What it does | Default |
|---|---|---|
model |
The model hyai code starts on, for example zai-org/GLM-5.3, or hyai/auto to let the router pick per request |
the best warm model |
small_model |
The model the agent uses for small jobs such as session titles | a fast model from the small model list |
base_url |
The router address (endpoint) hyai and the agent talk to. Your key is sent here | https://hostyourai.com/api/v1 |
agent |
The agent hyai starts: opencode, codex, claude, pi or t3 |
opencode |
hyai config set base_url https://acme.route.hostyourai.com # another router (endpoint)
hyai config unset base_url # back to the default
hyai config get base_url # one value, for scripts
HYAI_BASE_URL=https://acme.route.hostyourai.com hyai # this session only
base_url takes the same address forms as hyai login --router: the root of a
router, its /v1 address or its /ui page. It must be https:// (plain
http:// only for localhost). After changing it, hyai doctor checks that the
router answers and accepts your key. HYAI_BASE_URL wins over the stored
value. hyai config --help has the full list.
First session
cd your-project
hyai
hyai on its own is short for hyai code, and hyai -c continues the last
session.
hyai code reads the live model list, writes the agent configuration, prints
one line that says which model it starts on and why, and opens the agent in the
current directory. Everything you put after code goes to the agent as typed:
hyai code --continue # continue the last session
hyai code run "explain this repo" # one non-interactive turn
hyai code -m hostyourai/Qwen/Qwen3.8-27B
Another agent
hyai is not tied to one agent. The model choice, the key and the warm-only rule
are the same for every agent; hyai run starts the one you name:
hyai run claude # Claude Code; asks when your route offers two ways
hyai run claude -p "fix the failing test"
hyai run codex # Codex CLI; the same
hyai run codex exec "fix the failing test"
hyai run opencode # the same as hyai code
hyai run pi # Pi, on the team's models
hyai run t3 # T3 Code, with Claude Code, Codex, OpenCode and Pi inside it
Pi
Pi (MIT) runs on the team's models only. hyai gives it an
agent directory of its own per router, ~/.local/share/hyai/pi/<router>, with
a models.json that lists the router's models (provider hostyourai) and a
default model; your own ~/.pi/agent (logins, extensions, default model) is
never touched or loaded. Sessions are kept there too. The key is not written
there: models.json names $HYAI_API_KEY, which hyai sets for the session.
Pi's update check and catalogue refresh are off (PI_OFFLINE=1,
PI_SKIP_VERSION_CHECK=1) unless you set them in your shell. A provider key in
your shell (OPENAI_API_KEY and the like) still adds that provider's models in
Pi's /model; the hostyourai/... ones are the router's. Pi has no
OpenTelemetry, so it reports no sessions or tools; the router still logs every
request.
T3 Code
T3 Code (MIT, by T3 Tools) is a desktop,
web and phone interface that runs the coding agents installed on your machine.
It has no model access of its own, so hyai run t3 does not wrap it: it starts
T3 Code (t3) with the agents underneath set up exactly the way hyai run claude, hyai run codex and hyai set them up. Install T3 Code with
curl -fsSL https://t3.codes/install.sh | sh (or brew install --cask t3-code),
and the agents you want to use in it.
hyai run t3 # HostYourAI in your T3 Code app (Mac, asks first), else the browser
hyai run t3 serve # the same, without the app or the browser
On a Mac with the T3 Code desktop app installed, a plain hyai run t3 asks
once whether to add HostYourAI to that app. On yes it adds two providers to
the app's own settings, HostYourAI (Claude Code) and HostYourAI
(Codex), with the team's models, next to your own Claude and Codex, and
(when Pi is installed) a third, HostYourAI (Pi), on the agent directory
above, and
opens the app; pick them in a thread's model menu. No extra server runs. T3
keeps a key it did not get through its own Settings form in its settings file,
so your router key is stored in ~/.t3/userdata/settings.json (readable only
by you); hyai says so before it asks. Run hyai run t3 again to refresh the
models or the key; remove the providers in T3 under Settings, Providers.
On no (or without a terminal to ask in), hyai runs the T3 server in the
terminal and hands it to the app with a one-time pairing link (t3 pair):
the app asks "Add the backend at http://localhost:...?" and shows it as a
separate environment. Ctrl-C in the terminal stops it. Any argument after
t3 goes to T3 as before; HYAI_T3_APP=browser keeps the browser tab, and
HYAI_T3_APP=/path/to/T3 Code.app picks another app.
- Claude Code and Codex are decided one by one, with the same rule as above: on your own login when your team allows it, else on the team's models. So Claude Code can run on your own subscription while Codex runs on the team's models.
- The team's models (and Autopilot, or the team's route) appear in T3's model picker under Claude and Codex. On your own login they sit next to your own Claude or OpenAI models. Thread titles, commit messages and branch names move to a team model when T3's default for them would not run here.
- OpenCode inside T3 runs on the team's models, with the same config as
hyai. Turn OpenCode on in T3 (Settings, Providers) to use it. - Pi inside T3 runs on the team's models, on the same agent directory as
hyai run pi; hyai turns it on unless you switched it on or off in T3. - T3 runs on a data folder of its own,
~/.local/share/hyai/t3, so a T3 app or background service you already use keeps its own server, threads and settings. hyai only writes the model lists and those two defaults there; everything you change in T3 stays. SetT3CODE_HOMEor pass--base-dirto use another folder; hyai then leaves its settings alone. - The key is never written to a file. It travels in the environment of the T3
server, which hands it to the agents. Your own Codex launch arguments (in
T3, or in
T3CODE_CODEX_LAUNCH_ARGS) come after hyai's and win. - In the router's Logs and Usage these requests show as T3 Code.
Your own Claude or ChatGPT login, or the router's models
Claude Code and Codex can run two ways: on the router's own models (your router key pays), or on your OWN login (a Claude subscription or Anthropic key, a ChatGPT sign-in or OpenAI key; the vendor bills you) with the router in between. Your team's route decides; there is no question and no flag.
| Where your key works | hyai run claude / hyai run codex |
|---|---|
| a team router whose route has an Own subscription step for the agent | starts on your own login; when that step's budget is used, the router hands over to the next step |
| a team without a route (a model list) with Own Claude or Codex subscription switched on | starts on your own login |
| the same, but the agent was never signed in on this machine | starts on the team's models, and says how to sign in |
| a team router without that step | starts on the team's models, and says why |
| an EU-only key or team router | starts on the router's EU models, and says why |
| hostyourai.com | starts on its EU models: the platform does not pass a vendor login on |
On your own subscription, /model lists your own Claude or OpenAI models first and the team's models (or its route) under them. A team model runs on the team's models; your own stays on your account.
On your own login, hyai only points the agent at the router and adds your
router key as the x-hyai-key header, so the router knows who is calling
without ever holding your vendor credential; the hint headers that carry the
kind of work are switched on for you, and your own model settings stay
untouched. For Codex, sign in once first (codex login).
What the agent did, in the router (telemetry)
Every agent hyai starts reports what it did to the router it talks to, with the
same key: sessions, turns, tools, permission decisions, tokens, timings and
errors as OpenTelemetry, never the prompts, answers or file contents. The
router keeps it next to its own request log and normalises the three agents'
vocabularies into one export (gen_ai.*), so one dashboard covers Claude
Code, Codex and OpenCode alike. On by default, on your own login too; off
with hyai config set telemetry off (or HYAI_TELEMETRY=off). What the
telemetry may carry of the conversation itself is a separate setting,
telemetry_content (off by default: prompts, tools or full), and the router
drops content anyway until your organisation has agreed otherwise. org and
environment name your organisation and the environment; telemetry_url
points at a collector of your own instead of the router (https, or http on
localhost; the router key is not sent there, so the collector needs its own
access rules). Codex is configured
through its [otel] section on the command line (nothing written to
~/.codex), OpenCode through its own OpenTelemetry switch in the config hyai
writes, Claude Code through its OTEL_* variables.
Today: opencode (the default), codex and claude. All three were tested end
to end on the real router. For Codex nothing is written to ~/.codex: the
provider is passed on the command line and the key through the environment. For
Claude Code nothing is written to ~/.claude either: the router address, the
key, the model and the real context window of that model go through the
environment, and an ANTHROPIC_API_KEY in your shell is left out of the session
so the router key is used. Claude Code is Anthropic's own software; you install
it and accept its terms yourself. Each agent is an
independent project that you install yourself; hyai run <agent> prints the
install command when it is missing. hyai config set agent codex makes it the
default for hyai and hyai code.
The model picker inside the agent (/model) lists the router's models, not the
agent's own: hyai hands Claude Code a settings file of its own and Codex a model
catalogue of its own, both written to ~/.cache/hyai/, never to ~/.claude or
~/.codex. In Claude Code a row shows the model's name, the id that --model
takes, where it runs and its context window; rows you added yourself
(modelPicker in your own ~/.claude/settings.json, or
ANTHROPIC_CUSTOM_MODEL_OPTION) stay under the team's. One thing to know in Claude Code: in its picker, Enter saves the
choice as your default in your own ~/.claude/settings.json, which your regular
claude would then try to use. Press s to switch for this session only, or
set a default with hyai config set model <id>.
Other commands:
hyai models # models usable right now, with the router's prices
hyai doctor # checks Node, key, router, models and the agent
hyai config get # show settings
hyai help
Your own dedicated instance
If your account runs a dedicated GPU instance, the router lists its model for
your key and hyai uses it, in every agent. It comes first: when you have your
own box, hyai starts on it and says so ("running on your own dedicated
instance"). Your traffic then goes to hardware that serves only you, it is paid
per hour and the tokens cost nothing on top. A model that only exists as
dedicated is offered too, as long as it runs on your box. hyai config set model <id> still wins when you want a shared model for a session, and hyai models
shows which rows are yours. hyai never starts or stops an instance.
Closed models next to ours, on your own key
In a hyai session every request goes to the router, so the agent's own models
(Claude in Claude Code, GPT in Codex) only work there when the router can serve
them. It can, under your own contract: link your own Anthropic or OpenAI key to
your HostYourAI account (Instances, own key). Those models then show up in
hyai models and in the /model picker of every agent, next to the open
models, marked "your own provider key". The provider bills you for them, not
HostYourAI. hyai never picks such a model for you; the open models stay the
default. Without a linked key they are left out, because choosing one would
only give an error.
How the model is chosen
Only models that the router reports as usable right now are ever offered to the
agent: warm (available: true), billed per token, a chat model that can call
tools. A model that is not warm is never selected, not as a default and not as
a fallback, because a request to a cold model can make the platform start a
rented GPU. A model running on your own dedicated instance counts as usable.
The default model:
- Your own setting, if it is still usable:
hyai config set model <id>. - Otherwise a model on your own dedicated instance, when you have one.
- Otherwise the first usable model from the ordered preference list in
src/preferences.js. - If none of those is warm, the first usable model in the router's list.
The one line at startup tells you which of these applied. The small model that
the agent uses for light tasks such as session titles is chosen the same way
(hyai config set small_model <id>), and falls back to the main model.
Autopilot (hyai/auto) lets the router pick the model per request and bills
the rate of the model it picked. It is listed in the agent's model picker, and
it is never chosen for you. To make it your default:
hyai config set model hyai/auto
Settings: model, small_model, base_url (default
https://hostyourai.com/api/v1, set by hyai login --router), agent
(default opencode).
Where the key lives
In order of precedence:
HYAI_API_KEYin the environment. It always wins and is never stored.- On macOS: the login keychain (service
com.hostyourai.code), written and read with the systemsecuritycommand. - Elsewhere, or when the keychain is not available:
~/.config/hyai/config.json, file mode 0600 in a directory with mode 0700.XDG_CONFIG_HOMEis respected. SetHYAI_KEYSTORE=fileto force this.
The key is never printed, never written into your project and never written
into the agent's configuration. The generated configuration lives in
~/.cache/hyai/opencode/opencode.json and only holds the reference
{env:HYAI_API_KEY}. The key itself reaches the agent through the environment
of the child process.
During a session the agent only talks to the router. OpenCode's own update
check, model catalogue and language server downloads are turned off by hyai
(OPENCODE_DISABLE_AUTOUPDATE, OPENCODE_DISABLE_MODELS_FETCH,
OPENCODE_DISABLE_LSP_DOWNLOAD). Set one of them to 0 in your shell to turn
it back on. What the agent does on your behalf (shell commands, MCP servers you
add) is of course yours.
One thing to know: opencode debug config prints the resolved configuration,
with the key filled in. Do not paste that output into an issue or a chat.
Your own agent configuration still counts
The hyai configuration is handed to OpenCode through OPENCODE_CONFIG. OpenCode
merges it after your global config (~/.config/opencode/opencode.json) and
before the opencode.json and .opencode/ folder of your project, so your
project keeps the last word: its instructions, agents, commands, MCP servers and
permissions work as usual.
Two defaults that hyai sets, and that a project config can change:
enabled_providers: ["hostyourai"]. Without it the agent also lists models from other services, and a session could run outside the router unnoticed.share: "disabled". Sharing a session uploads it to a third party.
If OPENCODE_CONFIG was already set in your shell, hyai replaces it for the
session and says so.
Using an EU only key
Tick "EU only" when you create the router key. Nothing changes on your side: for
such a key the router only lists models that have a sovereign EU source warm
right now, and hyai models and hyai code follow that list. The list can be
shorter than with a regular key.
Troubleshooting
Start with hyai doctor. It prints a pass or FAIL line per check and exits
non-zero when something fails.
- "No router key found": run
hyai login, or setHYAI_API_KEY. - "The router did not accept this key": the key was revoked or rotated, or
HYAI_API_KEYin your shell holds an old one. It wins over the stored key. Ahyr-key only works on your own router and ahyai-rt-key only on HostYourAI; see "Your own router". - "No model is usable right now": nothing in your key's list is warm at this
moment (more likely with an EU only key or a key with a model list). hyai
does not fall back to a cold model. Check
hyai modelsand try again later. - "your setting ... is not usable right now": your preferred model went cold. hyai picked another one for this session and kept your setting.
- The agent shows 0.00 as cost: hyai does not copy prices into the agent, because it would then calculate spend on its own. What you were charged is on your HostYourAI dashboard.
- A model from your project's
opencode.jsonis "not found": the project names a model that is not usable right now. Only usable models are declared. - macOS asks for keychain access: that is the
securitycommand reading the entry hyai created. Choose "Always Allow", or useHYAI_KEYSTORE=file. - The agent binary is somewhere unusual: set
HYAI_AGENT_BINto its path.
Set HYAI_DEBUG=1 for a stack trace on errors. Questions: info@hostyourai.com.
Licence and attribution
hyai code is made by HostYourAI B.V., Groningen, the Netherlands, and published
under the MIT licence (LICENSE).
The coding agent is OpenCode, an independent open source project published
under the MIT licence: https://github.com/anomalyco/opencode. hyai code does not
bundle or modify it. It is installed by you and started by hyai code. OpenCode
is not made by, endorsed by or affiliated with HostYourAI. Its licence text is
in THIRD_PARTY_NOTICES.md.