This file provides guidance to Claude Code (claude.ai/code) when working with code in this repository.
# Build the binary
go build -o proxyai .
# Run the proxy
./proxyai
./proxyai --listen=:9000 --debug=true
# Lint (includes formatting)
make lint
# Format only
make fmt
# Initialize development environment (install linting tools)
make init
# Manage dependencies
make modThis is a transparent HTTP proxy for AI API providers (OpenAI, Anthropic, Gemini). Requests to /openai/* are forwarded to api.openai.com, /anthropic/* to api.anthropic.com, etc.
main.go- Server startup, graceful shutdown, HTTP handler registrationconfig.go- Flag parsing, environment variable loading (PROXY_TARGET_*), configuration types initializationinternal/proxy.go- Core proxy logic: request construction, header copying, response streaming (including SSE)internal/utils.go- Header utilities (hop-by-hop filtering), client IP extractioninternal/types/types.go-ConfigandProxyTargetstruct definitions
- Incoming request hits registered path prefix handler (e.g.,
/openai/) ProxyHandlerstrips the prefix, constructs target URL withhttps://scheme- Headers are copied (excluding hop-by-hop headers like
Connection,Transfer-Encoding) - X-Forwarded-For/Proto headers added unless
--no-forwardedflag is set - Response streamed back; SSE responses (
text/event-stream) get special handling with flush-after-write
Proxy targets can be added via:
--targetsflag:/path/:host,/path2/:host2- Environment variables:
PROXY_TARGET_NAME=/path/:host
Both override default targets if path prefix matches.