Coding agents¶
Point a coding agent at the LLM proxy so it uses your Hawk model access, attributed to you, instead of a personal API key. Setup writes the tool's own configuration — no wrapper, no shell alias — so the tool keeps working when an editor launches it.
hawk login # once per deployment on this machine
hawk proxy setup-client claude-code # writes Claude Code's own config
claude # no wrapper, no flags
What it writes¶
To ~/.claude/settings.json — or $CLAUDE_CONFIG_DIR/settings.json, which is
where Claude Code keeps its user configuration when that variable is set
(--scope selects a project file instead):
apiKeyHelper, and the env keys ANTHROPIC_BASE_URL, HAWK_API_URL,
CLAUDE_CODE_API_KEY_HELPER_TTL_MS, HAWK_VERSION_CHECK and — where they apply —
ANTHROPIC_MODEL, ANTHROPIC_SMALL_FAST_MODEL, CLAUDE_CODE_MAX_CONTEXT_TOKENS.
Nothing else in the file is touched, except an ANTHROPIC_API_KEY or
ANTHROPIC_AUTH_TOKEN in the same env block, which would beat the
apiKeyHelper and 401 every request: setup removes it, and remove puts it
back. If you have exactly one usable model it is pinned for you; otherwise pass
--model (hawk models -i claude lists yours). ANTHROPIC_SMALL_FAST_MODEL is
written only when you pass --small-fast-model, or when that one usable model
is the only thing you could run background work on — otherwise Claude Code
picks its own background model rather than billing that work at --model rates.
The pinned API and Anthropic URLs keep the helper on the selected deployment and Claude Code on the selected proxy when run from another directory. To move Claude Code to a different deployment or proxy, log in there and re-run setup.
hawk auth access-token exports a token for the selected deployment. Hawk checks
destinations for its own authenticated requests; the consuming tool controls where
it sends an exported token. The helper does not inspect provider endpoint variables
or the tool's configuration.
To see what your agent actually sent and received, see Your own Middleman traffic.
Checking and undoing¶
hawk proxy setup-client claude-code --dry-run # print the diff, write nothing
hawk proxy setup-client doctor # check without configuring
hawk proxy setup-client status # what is configured, and where
hawk proxy setup-client remove claude-code # put back what was there before
doctor stops at the first check that fails and names the remedy:
$ hawk proxy setup-client doctor
[OK ] hawk command /home/you/.local/bin/hawk
[FAIL] environment no deployment to configure against
Run `hawk login` against the deployment you want, or pass --api-url.
Error: environment: no deployment to configure against
Both commands finish by running an apiKeyHelper and sending its token to the
proxy — the two steps Claude Code itself takes — so a helper that cannot run is
caught here rather than at first use. doctor runs the configuration that is
already there, naming the file it checked, and falls back to what setup would
write only when nothing is configured.
Setup backs up any file it is about to change, under ~/.config/hawk-cli/backups/,
and tells you where. remove puts your original back and deletes the backup.
Restricted profiles¶
A profile gives a tool a narrower login than yours, so an agent can read what you
allow and nothing else. Set HAWK_PROFILE and log in once with a scope:
export HAWK_PROFILE=agent
hawk login --public # read public transcripts
hawk login --provider anthropic # call Anthropic's models, read what they may read
--public and --provider NAME are exclusive. A provider scope reads what the
cross-lab rules let that provider's models read, and calls the provider's models
in groups your login can call; --public calls public models. The server refuses
a provider that serves no model you can read or call. Either scope also carries
your code groups, so a --public profile reads public-model runs whose code is
restricted to a group you hold. The groups are worked out again each time the profile gets a new token (about every 15 minutes), so new
models and groups you gain access to appear without logging in again.
hawk login with a scope uses your full login to create a session on the server and
stores the profile under ~/.config/hawk-cli/profiles/<name>/. It needs your
full login on the machine already (run hawk login --full first) and never logs
you in itself, so a remote machine can't end up holding your full login. A later
hawk login reuses the stored scope; hawk login --full renews your full login
while HAWK_PROFILE stays set.
HAWK_PROFILE can be exported, set in a project .env, or set in
~/.config/hawk-cli/env. While it is set, every command, hawk auth access-token
and hawk.client.HawkClient use the profile's delegated token (valid 30 minutes,
renewed for as long as the session lasts, 12 hours). They never fall back to your
full login: a missing, expired or deleted profile is an error asking you to run
hawk login. hawk auth status shows the active profile.
A profile belongs to the deployment it was created against: using it with another
HAWK_API_URL is an error, and its token only goes to the proxy that deployment
advertises. A HAWK_MIDDLEMAN_URL naming another proxy is an error under a profile.
Refused under a profile: HAWK_ACCESS_TOKEN set at the same time,
hawk auth refresh-token and hawk local. Job commands such as hawk eval-set,
hawk logs and hawk status are not available under a profile yet.
hawk list jobs defaults to --all.
Sessions¶
hawk auth sessions list # profile, scope, host, created, last used, expires
hawk auth sessions delete ID
hawk logout # with HAWK_PROFILE set: end its session, delete the profile
The session commands use your full login. With HAWK_PROFILE set, hawk logout
keeps your full login. It removes the profile, so the next login needs a scope
again. Without HAWK_PROFILE, hawk logout logs the machine out instead: it
removes your full login, or ends a devbox login (see below).
A deleted session stops getting new tokens at once. The CLI uses a cached token until it has under 16 minutes left, so commands stop within about 15 minutes; a key helper that caches tokens can keep using its last one until it expires, at most 30 minutes. In the session's last half hour, though, a token is used until about a minute before the session ends. A copied token keeps working until it expires (at most 30 minutes).
Coding agents¶
Run hawk proxy setup-client claude-code with HAWK_PROFILE set to configure
Claude Code under the profile: it gathers models with the profile's token, writes
hawk auth access-token --profile <name> --api-url <url> as the key helper, and
pins HAWK_PROFILE in Claude Code's settings so the hawk commands it runs use
the profile too, even when Claude Code is launched from a GUI. Calls go
through Middleman under the profile's grants. The helper refuses a profile that
has since been recreated against another deployment, so that deployment's token
never reaches this proxy; re-run setup instead. Running setup again without
HAWK_PROFILE removes the pin. An agent started any other way without
HAWK_PROFILE uses your full login.
A profile limits what is configured to use it, not what an agent can do: an
agent running commands as you on the same machine can still read your full
login's files and run hawk without the profile. It is a guardrail against
accidental cross-lab contamination, not a sandbox.
Logging in a devbox¶
A devbox is a remote machine, such as a cloud instance you reach over SSH, that
is logged in with only a profile's scope. Everything on it, you and your agents
alike, can then read and call only what that scope allows. The box holds a
session key, never your full login. It keeps the key in the OS keyring (on a
headless box, keyrings-alt's file backend, which hawk installs); the
short-lived token cache stays in a private file.
On the box, with HAWK_PROFILE unset, run one of:
hawk login --provider anthropic # call Anthropic's models, read what they may read
hawk login --public # read public transcripts, call public models
The command prints a link and a code, then waits. Open the link in the browser
on your own computer and log in to the viewer if asked. With --no-browser the
command only prints the link.
The approval page shows the code, the machine's name and address, the groups it will read, the models it will call, the groups left out and why, and when the login ends. Check that the code matches the one in your terminal. Approve only a request you just started yourself: code running on the box can start one too.
Once you approve, the box is logged in for 12 hours and renews its tokens by
itself. Plain hawk commands, hawk auth access-token and
hawk proxy setup-client claude-code on the box use this login without
HAWK_PROFILE. hawk auth status shows its scope and when it ends. A box holds
one devbox login per deployment; logging in again replaces it.
Before bed, run hawk login --extend on the box and approve it in the browser
for another 12 hours. The extension checks your access again. Only a login that
hasn't ended can be extended; after that, log in again.
To end the login, run hawk logout on the box: the session ends at once and the
key is deleted. From your own computer, hawk auth sessions list shows the box's
session as devbox with its hostname, and hawk auth sessions delete ID ends
it; the box then stops within 30 minutes.
A machine that holds your full login refuses hawk login --provider without
HAWK_PROFILE, so it isn't made restricted by accident. Run hawk logout first
if that's what you want. A devbox refuses a plain hawk login, so it can't pick
up your full login that way.
Common problems¶
| Message | Do this |
|---|---|
<host> could not be reached |
The proxy may be on a private network. Connect to it and retry. |
ANTHROPIC_AUTH_TOKEN is exported … (or ANTHROPIC_API_KEY) |
Unset it. It takes precedence over the apiKeyHelper, so Claude Code sends it instead of your Hawk token and requests 401. Setup removes one it finds in the settings file, but cannot touch an exported value. |
A .env changes the deployment or proxy URL |
Each deployment uses its own saved login, and tokens can only go to approved recipients. Remove an unintended override, or run hawk login to approve the new recipient. --yes cannot bypass this check; unrelated service settings do not invalidate the login. |
The apiKeyHelper … does not run (hawk wrote, hawk would write, or in <file>) |
Usually --hawk-command named a path that is not there, or hawk has moved since setup ran. Re-run setup, passing --hawk-command with the full path to hawk. |
Setup is incomplete: Claude Code has no model it can call |
The config was written, but this account has no model for this tool on this deployment. Access granted moments ago may still be propagating — otherwise ask for a model group. |
Only Claude Code is supported so far — PRs adding other tools are welcome.