Anthropic adapter setup (UH-136)
The anthropic adapter is a first-class HTTP client for the official
pay-per-token Anthropic Messages API
(POST https://api.anthropic.com/v1/messages). It talks directly to
Anthropic’s metered API with your own key.
Status: experimental.
ToS / posture: this is the official, sanctioned, pay-per-token API. It is distinct from:
hermes-proxy— OAuth-backed subscription routing via a local Hermes proxy, andoh-my-pi(anddocs/runbooks/anthropic-via-omp.md) — routing through the OMP credential store.Use
anthropicwhen you want to pay Anthropic per token with your own API key, with no proxy in the path.
1. Get an API key
Section titled “1. Get an API key”Create a key at https://console.anthropic.com/settings/keys. Export it (the adapter reads it from the environment and never persists it to the manifest):
export ANTHROPIC_API_KEY="sk-ant-..."2. Add the adapter manifest
Section titled “2. Add the adapter manifest”uh adapter add anthropicThis writes .harness/adapters/anthropic.yaml:
schema_version: uh.adapter.v0id: anthropicname: Anthropicruntime: anthropiccapabilities: - messages-api - http-transport - sentinel-protocol - pay-per-tokenstatus: experimentalconfig: runtime_config: base_url: "https://api.anthropic.com/v1" model: "claude-sonnet-4-6" max_tokens: 8192 request_timeout_ms: 120000 extra_headers: {}3. Verify connectivity
Section titled “3. Verify connectivity”uh adapter check anthropicA healthy check prints the reachable endpoint and the number of models the key
can see. A missing key degrades gracefully (found:false) so CI can skip the
live smoke job.
4. Run a mission
Section titled “4. Run a mission”uh run <mission-id> --runtime anthropic- The API key is read from
ANTHROPIC_API_KEYand never written to the manifest. - The Messages API requires
max_tokens; the manifest default is8192. - The pinned API version header is
anthropic-version: 2023-06-01. request_timeout_msbounds each HTTP call (default 120 000 ms).base_urlcan be overridden (e.g. for a gateway); the adapter appends/messagesand/models.extra_headerslets you pass any forward-compat header (e.g.anthropic-beta).- Token usage is captured from the response
usageobject ({ input_tokens, output_tokens }) and emitted as aruntime.usageevent. - See
docs/runbooks/openrouter-setup.mdfor the cheapest OpenAI-compat pay-per-token alternative, anddocs/runbooks/anthropic-via-omp.mdfor the subscription-routing path and its ToS posture.