"The mitmproxy tool also supports addons where you can transform HTTP requests between Claude Code and third-party web servers. For example, you could write an add-on that intercepts https://api.anthropic.com and updates the X-API-Key header with an actual Anthropic API Key."
"You can then pass this add-on via mitmproxy -s reroute_hosts.py."
If using HAproxy, then is no need to write "add-ons", just edit the configuration file and reload
For example, something like
http-request set-header x-api-key API_KEY if { hdr(host) api.anthropic.com }
echo reload|socat stdio unix:/path-to-socket/socket-name
For me, HAproxy is smaller and faster than mitmproxy