Skip to content

Installing the CLI

Prerequisites

  • Python 3.13+. hawk code download needs a final release of 3.13.15+, 3.14.7+ or 3.15.0+ to download a whole repository; --path, which reads one file, doesn't.
  • uv for Python package management
  • Access to a Hawk deployment (API server URL + OAuth2 credentials)

(Node.js 22, pnpm, and Graphviz are only needed for developing Hawk itself, not for using the CLI — see Contributing.)

Install the CLI

Install from PyPI with uv (or pip):

uv tool install "hawk[cli]"
# or: pip install "hawk[cli]"

To match a specific Hawk deployment, pin the release: uv tool install "hawk[cli]==2.0.0" (run hawk version, or check <API_URL>/version, to see which version the server runs).

Python client

Automation scripts can talk to the same API without Click:

pip install "hawk[client]"
# or: uv add "hawk[client]"
import asyncio
from hawk.client import HawkClient

async def main() -> None:
    async with HawkClient() as client:
        jobs = await client.get_jobs(mine=True, limit=5)
        print(jobs)

asyncio.run(main())

HawkClient() reads HAWK_API_URL. It authenticates with an explicit token=, or with the same store the CLI uses (HAWK_ACCESS_TOKEN or a previous hawk login). It does not prompt for login, and it does not refresh a stored login token. You can also pass api_url= explicitly. create_eval_set / create_scan accept a YAML dict; the server validates it. This extra does not install Inspect AI. See the Python client page for submitting a run and the generated API reference.

PyPI installs pull upstream Inspect AI

The published package depends on the upstream inspect-ai and inspect-scout PyPI releases. METR-operated deployments pin lightly-patched forks via [tool.uv.sources], which don't ship in package metadata — so a hawk local run from a PyPI install builds its runner venv with upstream Inspect, not the fork. This is expected and fine for normal use; cluster runs (which use the deployment's runner image) are unaffected. To match a deployment's exact Inspect build, install from source instead (below).

Install from source (dev)

To hack on the CLI or run the latest unreleased main:

# latest main
uv tool install "hawk[cli] @ git+https://github.com/METR/hawk#subdirectory=hawk"

# editable clone
git clone https://github.com/METR/hawk.git
cd hawk/hawk
uv pip install -e ".[cli]"

Configuration

Set these environment variables before using the CLI, or put them in a .env file:

export HAWK_API_URL=https://api.hawk.example.com
Variable Required Description
HAWK_API_URL Yes, unless you only use Middleman URL of your Hawk API server
HAWK_LOG_VIEWER_URL No URL for the web log viewer (overrides what the API advertises)
HAWK_MIDDLEMAN_URL Only for Middleman-only access URL of the Middleman LLM proxy, used by hawk models and the hawk proxy admin commands (overrides what the API advertises). With no HAWK_API_URL, also where hawk login discovers its OIDC settings
HAWK_RELAY_URL No URL of the relay used by hawk acp / hawk attach (overrides what the API advertises)
HAWK_AI_GATEWAY_URL No LLM gateway URL for hawk local runs (local-only; not advertised by the API). Usually your deployment's Middleman URL, which your login already approves; any other gateway is approved by running hawk login after setting it
HAWK_ACCESS_TOKEN No Bearer token to use instead of hawk login — for CI and other non-interactive use
HAWK_DATADOG_EVAL_SET_DASHBOARD_URL No Datadog dashboard URL for eval sets
HAWK_DATADOG_SCAN_DASHBOARD_URL No Datadog dashboard URL for scans
HAWK_RUNNER_LOG_FORMAT No Set to json for structured runner logs (useful with hawk local)
HAWK_VERSION_CHECK No What to do when the CLI and server versions differ: prompt (default — warn, and ask to continue only when the major versions differ), warn (warn only), block (abort), or off

OIDC configuration is discovered automatically from /auth/config on the API server, or on Middleman for Middleman-only access — no OIDC env vars are needed for the CLI.

Middleman-only access

If you can reach Middleman but not the Hawk API (a tailnet grant for Middleman alone, say), set only HAWK_MIDDLEMAN_URL. hawk login then reads its login settings from /auth/config on Middleman's hostname, which Middleman's tailnet ingress load balancer answers itself when the deployment sets hawk:middlemanTailnetConnector (requests reaching Middleman another way get a 404). The login is saved under Middleman's URL, separately from any API login, and token refresh, hawk auth access-token and hawk local use it without fetching /auth/config again. hawk models and hawk proxy models/labs/secrets talk to Middleman directly. Commands that call the API, such as hawk eval-set and hawk proxy setup-client, still need HAWK_API_URL.

export HAWK_MIDDLEMAN_URL=https://middleman.hawk.example.com
hawk login

When both variables are set, the CLI always discovers from HAWK_API_URL and does not fall back to Middleman if the API is unreachable. If the API is out of reach for you, leave HAWK_API_URL unset, including in ./.env and ~/.config/hawk-cli/env; otherwise hawk login fails with "Could not fetch config".

Dotenv values are literal: ${VAR} interpolation is disabled. Credential URLs containing interpolation placeholders are rejected before discovery.

Each variable resolves independently — pin all URLs to one deployment

The CLI reads each variable separately from the environment, the current directory's .env, and the global ~/.config/hawk-cli/env; an explicit URL in the global file overrides auto-discovery.

A stale global override can select a different service than the API advertises. Review credential destinations when logging in. Sending credentials to a new recipient requires another login to approve it.

Fix: always set HAWK_API_URL, HAWK_MIDDLEMAN_URL, and HAWK_LOG_VIEWER_URL together for the same deployment — scripts/dev/generate-env.py emits all three. With Middleman-only access, set HAWK_MIDDLEMAN_URL alone instead.

INSPECT_LOG_DIR

Inspect's log directory variable is INSPECT_LOG_DIR. The name INSPECT_LOG_ROOT_DIR was removed. Hawk passes an explicit log directory (logs/<job-id>/ for hawk local) and does not read INSPECT_LOG_DIR, so setting it does not move a Hawk run's .eval files.

Version compatibility

Hawk uses SemVer (e.g. 2.0.0). Before each command the CLI probes the API's GET /version and warns when the two have drifted out of sync — the common cause of a command that works for one person but not another. A differing major version means a backwards-incompatible change and is flagged as likely incompatible; same-major drift is compatible per SemVer. The API and middleman each expose GET /version and an X-Hawk-Server-Version response header; the drift check uses the API's (the deployment's version).

hawk version    # prints the local CLI version and the deployed server version

A deployment between releases (e.g. one deployed from main), and a CLI installed from git or an editable checkout, also report the commit they were built from, which hawk version shows: 2.0.0.post12+g1a2b3c4d5 is built from commit 1a2b3c4d5, 12 commits after the 2.0.0 release (.dirty marks uncommitted changes). This is informational only: the drift check below compares releases, so differing commits of the same release don't trigger it. The API and middleman send it in an X-Hawk-Server-Build header and as build in GET /version.

To pin the CLI to a deployment, install the matching release (e.g. uv tool install "hawk[cli]==2.0.0"; see Install the CLI). HAWK_VERSION_CHECK controls the reaction to drift:

  • prompt (default) — warn and proceed; when the major versions differ, first ask to continue, on stderr. When stdin or stderr isn't a terminal (CI, scripts, 2> redirects) it never asks — same as warn.
  • warn — warn and proceed, whatever the drift.
  • block — abort on any drift (including SemVer-compatible patch/minor). Recommended for CI when you need an exact match.
  • off — skip the check.

Authentication

hawk login

This authenticates via the browser-based PKCE flow (a localhost callback on port 18922). OIDC configuration is fetched from the API server and cached locally. Running hawk login also refreshes the cached OIDC configuration.

Each deployment keeps its own login, so log in once per deployment (and once more after upgrading Hawk), then switch between deployments freely.

If a project .env (a cloned repository's, say) points Hawk at a URL your login hasn't approved, login shows the URL and asks first. Say yes only if you trust that repository. Without a terminal, as in a coding agent's shell, login refuses and prints a hawk login --approve <URL> command to run once you've checked the URL.

On headless machines (SSH boxes, containers), use hawk login --no-browser. You don't need to know which OIDC provider your deployment uses — the CLI picks the best flow it supports:

  • Provider implements the device grant (Okta, Auth0, most enterprise IdPs) → the OAuth2 Device Authorization flow. Prints a short user code and a URL; approve it in a browser on any device and the CLI picks up the result on its own. Nothing to copy back.
  • Provider doesn't (the default Cognito auth — user pools have no device-authorization endpoint) → paste-back PKCE. Prints a login URL to open on any device, then you paste the resulting http://localhost:18922/callback?... redirect URL (which fails to load in your browser — that's expected) back into the CLI.

In the paste-back case, if you SSH with -L 18922:localhost:18922 the login completes automatically without pasting. You can also supply just the callback URL from a file: hawk login --no-browser < url.txt.

hawk login --device forces the device flow rather than letting the CLI choose, and fails with "device flow not supported by the current OIDC provider" if the provider lacks it — useful when you want a script to assert the flow instead of silently falling back.

For fully non-interactive CLI use (CI, service accounts), set HAWK_ACCESS_TOKEN and set HAWK_API_URL yourself: exported, or in ~/.config/hawk-cli/env. A project .env cannot choose where a supplied token goes. Middleman and the relay are then used at the URLs that API reports; set HAWK_MIDDLEMAN_URL or HAWK_RELAY_URL the same way only to use a different one. hawk local accepts that Middleman as its AI gateway; set HAWK_AI_GATEWAY_URL for any other. The Python SDK accepts dotenv API URLs with supplied tokens. Supplied tokens never use a stored refresh token.

Hawk doesn't follow redirects on requests that carry credentials, so set HAWK_API_URL to the final URL; login names it if the one you set redirects.

Run your first eval

The example configs live in the repo. Paths below are relative to the repo root. A PyPI install does not include them:

git clone https://github.com/METR/hawk.git
cd hawk
hawk eval-set hawk/examples/simple.eval-set.yaml
hawk logs -f    # watch it run
hawk web        # open results in browser

If you installed from a checkout and your shell is still in hawk/hawk/, run cd .. before hawk eval-set instead of cloning again.