Send every Claude Code request through aiproxy so you can observe, audit, and rewrite Anthropic traffic.
aiproxyrunning locally (examples below usehttp://localhost:8080)- Install the
aiproxycertificate authority (see Quick Start → TLS certificate)
The Claude CLI accepts a custom base URL. Point it at the /anthropic reverse-proxy endpoint that aiproxy exposes to run in router mode: aiproxy forwards the request upstream, adds observability, and skips full TLS interception.
export ANTHROPIC_BASE_URL=http://localhost:8080/anthropic
claudeProxy mode routes every HTTP(S) call the CLI makes through aiproxy. The NO_PROXY list keeps loopback addresses local so the CLI can still talk to services running on the same machine.
export HTTP_PROXY=http://localhost:8080
export HTTPS_PROXY=$HTTP_PROXY
export NO_PROXY=localhost,127.0.0.1
claudeSome Node.js distributions ship a standalone certificate bundle and ignore the operating system trust store. If Claude fails TLS handshakes, point the runtime at the aiproxy CA explicitly:
export NODE_EXTRA_CA_CERTS=~/.aiproxy/aiproxy-ca-cert.pem
claudeRemove the proxy settings when you finish testing:
unset HTTP_PROXY HTTPS_PROXY NO_PROXY NODE_EXTRA_CA_CERTSRun a quick prompt with the CLI, for example:
claude "Explain how aiproxy monitors Anthropic traffic."Watch the aiproxy logs or terminal UI. You should see requests to /v1/messages. If no requests appear, confirm the environment variables remain set in the current shell and that the certificate authority is trusted.