Skip to main content

ai-agent-gateway-cli

Python client for the ai-agent-gateway HTTP/SSE protocol, shipped as the hank entrypoint.

Usage

python -m agent_gateway_cli login
python -m agent_gateway_cli chat "hello"
python -m agent_gateway_cli --config-namespace cashnerd login
python -m agent_gateway_cli --config-namespace cashnerd chat --session default "hello"
hank login
hank chat
hank chat "hello"
hank chat --model-key anthropic.claude-sonnet-5 --effort high \
  --model-key-for plan.author=anthropic.claude-opus-5 \
  --effort-for plan.author=high "research this company"
hank chat --model-key anthropic.claude-opus-5 --save-preference "remember this choice"
hank control health

The default config namespace is agent-gateway for python -m agent_gateway_cli and hank for the hank entrypoint, which writes:

  • ~/.cache/hank/cli_config.json
  • ~/.cache/hank/sessions/<name>.json

--config-namespace cashnerd writes under ~/.cache/cashnerd/ instead. The namespace directory and its sessions/ directory are created mode 0700; the files inside are 0600.

hank chat with no message on an interactive terminal replaces the process with the agent-gateway-tui binary (the Node >= 24 package @henrychien/agent-gateway-tui), passing the resolved namespace and session as arguments and the resolved connection as GATEWAY_BASE_URL, GATEWAY_API_KEY, GATEWAY_USER_ID, and AGENT_GATEWAY_ROUTE_PREFIX. hank chat "<message>" and any non-interactive stdout run the Python client in this package instead.

Contract

The CLI sends context.channel = "cli" on every chat request. When user_id is configured, it is sent as a top-level field on both /api/chat/init and /api/chat. Tool approvals post tool_call_id, nonce, approved, and allow_tool_type.

The CLI consumes authenticated capability_choices from /api/chat/init. --model-key accepts only an exact session-eligible stable key, and --effort requires it. When both are omitted, the chat request omits all selection fields and the server resolves the capability default. Repeatable --model-key-for CAPABILITY=MODEL_KEY and optional --effort-for CAPABILITY=LEVEL flags populate strict init-time run overrides. Provider-qualified selectors, upstream model names, display-label aliases, and local fallback catalogs are not accepted.

--save-preference and --clear-preference use the authenticated server preference contract for account-wide session.driver state. Session-history files do not store or resolve model preferences.

Every gateway request is composed as base_url + route_prefix + path, so the hosted deployment is reached as https://hank.investments/gateway/api/chat/init. The default BaseUrlPolicy accepts any hostname over https, allows http only for a loopback host, and rejects a query or fragment. A base URL may carry the deployment path: it is hoisted out of the base URL into the route prefix, so --base-url https://hank.investments/gateway resolves to base URL https://hank.investments with route prefix /gateway/api, identical to --base-url https://hank.investments --route-prefix /gateway/api. An explicit --route-prefix (or AGENT_GATEWAY_ROUTE_PREFIX) that neither equals nor extends the base URL path is refused, naming both values. TLS verification is on by default; --insecure and HANK_INSECURE=1 are honored only for a loopback gateway, and HANK_CA_BUNDLE selects a custom CA bundle. Products that need a narrower policy can inject BaseUrlPolicy(allowed_schemes=..., allowed_hostnames=...).

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

ai_agent_gateway_cli-0.4.1.tar.gz (116.7 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

ai_agent_gateway_cli-0.4.1-py3-none-any.whl (69.8 kB view details)

Uploaded Python 3

File details

Details for the file ai_agent_gateway_cli-0.4.1.tar.gz.

File metadata

  • Download URL: ai_agent_gateway_cli-0.4.1.tar.gz
  • Upload date:
  • Size: 116.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.13.2

File hashes

Hashes for ai_agent_gateway_cli-0.4.1.tar.gz
Algorithm Hash digest
SHA256 5a88662aa3d31880f4bcafe7d29645122041ad4dec15d3a4835c9374d03d35d3
MD5 c335d65e34b0e3e1ed4f691c22b5fa5d
BLAKE2b-256 4d0f929d1c61f854ae249f47af2cfd3b1fc23dfce5ae0f1c2db02a7b3b4f761f

See more details on using hashes here.

File details

Details for the file ai_agent_gateway_cli-0.4.1-py3-none-any.whl.

File metadata

File hashes

Hashes for ai_agent_gateway_cli-0.4.1-py3-none-any.whl
Algorithm Hash digest
SHA256 ace70e6ab9fa5cd39f9c1eabe9049cbc1861e6b5a13c1f37d2599c5c4bf7f993
MD5 c07b3fdd403f3b67c9c48df84f968d99
BLAKE2b-256 f8d5914e2ecb97a34993d878e44d22264f6d748fa5bd8ee8b53bde21c8c7ae26

See more details on using hashes here.

Release history Release notifications | RSS feed

0.4.4

2 files

0.4.3

2 files

0.4.2

2 files

This release

0.4.1 This release

2 files

0.1.0

2 files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page