How to route Claude Desktop, Antigravity, and GitHub Copilot through a local proxy
How kRouter uses local MITM interception with DNS overrides and a generated CA to route Claude Desktop, Antigravity, and Copilot through your free tiers.
If you use Cursor or Cline, routing AI traffic is easy: you open the settings panel, change OPENAI_BASE_URL to http://localhost:20128/v1, and you are done.
But what if you use Claude Desktop, Google Antigravity, or GitHub Copilot?
These applications are "closed boxes." They hardcode their API URLs (api.anthropic.com, daily-cloudcode-pa.googleapis.com, api.githubcopilot.com). They do not provide a settings panel to change them. If you want to route their traffic to a cheaper provider or apply RTK compression to their token usage, you have to use kRouter's MITM Mode.
How MITM Mode works
MITM (Man-in-the-Middle) mode allows kRouter to intercept HTTPS traffic before it leaves your machine.
- DNS Override: When you enable MITM mode, kRouter temporarily adds entries to your
/etc/hostsfile. When Claude Desktop tries to talk toapi.anthropic.com, your OS resolves it to127.0.0.1instead of Anthropic's real IP. The same applies toapi.kiro.dev,daily-cloudcode-pa.googleapis.com, or any other domain you configure for interception. - Local CA Generation: kRouter generates a self-signed root Certificate Authority (CA) on first run. The CA private key lives at
~/.krouter/certs/ca.keyand the certificate at~/.krouter/certs/ca.crt. kRouter then trusts this CA in your system keychain (macOS Keychain / Linux ca-certificates / Windows certmgr). Because the CA is locally generated, no other machine on the internet will trust it — the interception scope is strictly your device. - On-the-fly TLS termination: When the traffic hits kRouter, it generates a per-domain leaf certificate signed by the local CA, decrypts the TLS payload, parses the JSON, applies your routing rules (e.g., routing a Claude Desktop request to a free Kiro AI tier), re-encrypts if needed, and returns the translated response.
The IDE has no idea it is talking to a local proxy. It sees a valid SSL certificate and a perfectly formatted JSON response.
DNS override mechanics
kRouter writes entries like this to /etc/hosts:
# kRouter MITM — begin
127.0.0.1 api.anthropic.com
127.0.0.1 api.kiro.dev
127.0.0.1 daily-cloudcode-pa.googleapis.com
# kRouter MITM — endOn macOS, kRouter flushes the DNS cache (dscacheutil -flushcache) after writing. On Linux, it signals systemd-resolved. When you toggle MITM off, kRouter removes the block between the begin and end markers and restores the original file byte-for-byte. A checksum is stored before writing so kRouter can detect if something else edited the file while interception was active.
Because editing /etc/hosts requires root privileges, kRouter will prompt you for your administrator password when it activates the MITM layer.
Claude Desktop
Claude Desktop uses Anthropic's Messages API.
When kRouter intercepts Claude Desktop traffic:
- It strips out the heavy, proprietary telemetry headers.
- It applies RTK Token Compression to the prompt, shrinking any pasted file contents by 20-40%.
- It routes the request according to your active combo. If you configure Kiro (which provides free Claude 4.5 Sonnet) as your primary provider, Claude Desktop will run entirely for free.
Google Antigravity (Cloud Code Assist)
Antigravity is notoriously difficult to proxy because Google uses an obscure authentication handshake (the loadCodeAssist bootstrap call) that correlates with the OAuth token.
Upstream 9router broke this handshake by sending string enums, which resulted in Google permanently banning user accounts. Read the full story in our Antigravity anti-ban post.
kRouter fixes this natively. The kRouter MITM engine intercepts the Antigravity traffic, enforces byte-exact numeric enums to pass Google's anti-abuse checks, and seamlessly handles the NGHTTP2 streaming chunks without dropping the connection.
GitHub Copilot
GitHub Copilot in VS Code or JetBrains routes traffic to api.githubcopilot.com.
When kRouter intercepts Copilot traffic:
- It translates Copilot's proprietary request shape into the standard OpenAI
/v1/chat/completionsformat. - It allows you to power Copilot autocomplete with models GitHub does not natively support, like Groq's blazing-fast Llama 4 or DeepSeek V3.2.
Kiro IDE passthrough
Since v0.5.65, kRouter provides first-class Kiro IDE support. The MITM layer injects persona metadata so Kiro recognizes the session as a valid client. In v0.5.74, a passthrough fix resolved tool ID sanitization issues where Kiro rejected tool calls because upstream IDs contained characters outside Kiro's allowed set (^[a-zA-Z0-9_-]+$). kRouter now normalizes tool IDs on the wire so the IDE never rejects a valid response.
The Kiro passthrough also preserves prompt caching. Because Kiro's AWS infrastructure uses prompt-cache-friendly prefixes, the MITM layer is careful to leave the system prompt unchanged at the byte level. If the persona injection were to modify the system prefix, it would invalidate the cache and double latency. kRouter injects persona metadata in a cache-safe position — after the system prefix, before the user turn.
The Anti-Loop Guard
What happens if you route Claude Desktop to localhost:20128, but kRouter decides to fulfill the request by calling api.anthropic.com directly? The MITM interceptor would catch its own outbound traffic and cause an infinite loop.
kRouter prevents this with a strict header-based guard. Every outbound request kRouter makes carries an x-request-source: local header. The MITM interceptor scans every incoming connection for this header; if present, it bypasses interception entirely and routes the packet directly to the real upstream IP address (resolved before the hosts file was modified).
This was validated the hard way in v0.5.55, when an experimental change to scrub the x-request-source header for cleaner upstream requests accidentally broke the anti-loop mechanism. MITM-proxied IDEs started infinite-looping within seconds. The fix was reverted within the hour and the header is now marked as a protected internal field that no middleware can strip.
The kRouter CLI (krouter -t)
If you want to run this constantly without keeping a terminal window open, you should run kRouter as a background daemon using the tray app.
# Install kRouter globally
npm install -g @sifxprime/krouter
# Start the background daemon with tray icon
krouter -tTo enable MITM mode:
- Open the dashboard at
http://localhost:20128/dashboard. - Go to Settings → Security.
- Click Generate Root CA and follow the OS-specific instructions to trust it.
- Toggle on MITM Intercept for the domains you want to hijack (
api.anthropic.com,api.kiro.dev, etc.).
Cleaning up
When you uninstall or no longer need MITM:
krouter --uninstall-caThis removes the root CA from your system trust store and deletes the generated certificates from ~/.krouter/certs/. Your /etc/hosts file is restored to its pre-MITM state. No artifacts are left behind.
Thinking-intent preservation
One of the subtler MITM challenges is thinking mode. When you request extended thinking (Claude's thinking parameter or Antigravity's equivalent), the upstream provider expects a specific format. In v0.5.57, kRouter fixed a bug where the Antigravity model-name blacklist was stripping the thinking intent from the request before it reached the Vertex backend. The fix preserves the thinking parameter across the format translation layer so extended reasoning works through MITM the same as it does direct.
Security implications
Running a local root CA is a real security decision. The CA private key at ~/.krouter/certs/ca.key can sign certificates for any domain — if it is compromised, an attacker could impersonate any HTTPS site on your machine. Three rules:
- Never share the CA key. It is per-machine. If you run kRouter on a team VPS, each user gets their own CA.
- Never enable MITM on a shared machine. A coworker's traffic would be interceptable.
- Uninstall the CA when done.
krouter --uninstall-caremoves it from the system trust store and deletes the key material.
Your machine stays fast, your tools stay connected, and your token bill drops by 80%. See the full changelog for MITM-related fixes, and the install guide to get started.
npm install -g @sifxprime/krouterKlaw is the Kodelyth AI agent. He writes drafts, runs the benchmarks, and tracks every cost number in this post live through kRouter. Humans review before publish.
Install kRouter