# How to integrate Claude Code with Lens Loop for local API tracing

**URL:** <https://forums.k8slens.dev/t/how-to-integrate-claude-code-with-lens-loop-for-local-api-tracing/6695>\
**Category:** Lens Loop\
**Created:** [December 6, 2025, 7:36pm UTC](https://forums.k8slens.dev/t/how-to-integrate-claude-code-with-lens-loop-for-local-api-tracing/6695 "2025-12-06T19:36:50Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![sramadugu1](https://forums.k8slens.dev/letter_avatar_proxy/v4/letter/s/4491bb/32.png) [@sramadugu1](https://forums.k8slens.dev/u/sramadugu1)\
**Post date:** [December 6, 2025, 7:36pm UTC](https://forums.k8slens.dev/t/how-to-integrate-claude-code-with-lens-loop-for-local-api-tracing/6695/1 "2025-12-06T19:36:50Z")

</div>

Hi,

I’m trying to route Claude Code API requests through Lens Loop for local development and request tracing.  
I’d like to understand the proper way to set this up.

What I’ve tried:

1. Lens Loop is running locally on port 31300 with the Anthropic endpoint available at  
[http://localhost:31300/anthropic/v1](http://localhost:31300/anthropic/v1)
2. I set the environment variable: export ANTHROPIC\_BASE\_URL=[http://localhost:31300/anthropic/v1](http://localhost:31300/anthropic/v1)
3. I started Claude Code and ran some commands

Questions:

1. Is ANTHROPIC\_BASE\_URL the correct/supported environment variable for Claude Code to route requests  
through a custom endpoint, or should I be using a different approach (like HTTP\_PROXY/HTTPS\_PROXY)?
2. What’s the recommended way to persist this configuration so I don’t have to manually export the  
variable every time I start a new terminal session?
3. Once configured, how can I verify that Claude Code requests are actually flowing through Lens Loop?  
What should I look for in the Loop dashboard?
4. Are there any known issues or gotchas with this integration I should be aware of?
5. Is this a supported/documented workflow, or is this an edge case use case?

---

<div class="post-metadata">

**Author:** ![hlaitala](https://forums.k8slens.dev/user_avatar/forums.k8slens.dev/hlaitala/32/2032_2.png) [@hlaitala](https://forums.k8slens.dev/u/hlaitala)\
**Post date:** [December 6, 2025, 7:41pm UTC](https://forums.k8slens.dev/t/how-to-integrate-claude-code-with-lens-loop-for-local-api-tracing/6695/2 "2025-12-06T19:41:30Z")

</div>

Hello @sramadugu1 — thanks for contacting us!

* * *

### 1) Is `ANTHROPIC_BASE_URL` the right variable?

Yes. Claude Code supports routing through a custom Anthropic-compatible gateway via `ANTHROPIC_BASE_URL`. This is the intended way to point Claude Code at a local proxy/gateway, so Lens Loop should work here.  
Reference: [https://code.claude.com/docs/en/third-party-integrations#configuration-overview](https://code.claude.com/docs/en/third-party-integrations#configuration-overview)

* * *

### 2) How to persist it

This depends on your environment and shell.

**Example on macOS (zsh):**

**Set for the current terminal session:**

```bash
export ANTHROPIC_BASE_URL="http://localhost:31300/anthropic"

```

**Persist it for future sessions:**  
Add this line to your `~/.zshrc` (or `~/.bashrc` if you use bash):

```bash
export ANTHROPIC_BASE_URL="http://localhost:31300/anthropic"

```

Then reload your shell:

```bash
source ~/.zshrc

```

* * *

### 3) How to verify traffic / where traces show up

Once configured, run a few Claude Code commands and check Lens Loop.

- Because `x-loop-project` isn’t set in Claude Code request headers, traces will show up automatically under the **Default project** in Lens Loop.
- Please refer to the screenshot I attached — that’s the expected location.

 ![Screenshot 2025-12-06 at 20.47.21](https://forums.k8slens.dev/original/2X/4/4c15dd49eab27f7dd6ea0849d1f3348fa0fdb447.jpeg)

**Important note:**  
We’ve identified a bug in our Anthropic proxying code, so the **current released beta doesn’t capture Anthropic traces correctly**. The fix is already done and will be delivered via **automatic update** in the **next beta release**.

* * *

### 4) Recommended Lens Loop docs

For a full walkthrough of traffic capture and supported formats, please review:  
[https://docs.k8slens.dev/lens-loop/getting-started/capture-traffic/#capture-traffic](https://docs.k8slens.dev/lens-loop/getting-started/capture-traffic/#capture-traffic)

* * *

### 5) Supported workflow / expectations

- **Claude Code side:** this is a supported workflow. They explicitly document gateway/proxy usage through `ANTHROPIC_BASE_URL`:  
[https://code.claude.com/docs/en/llm-gateway](https://code.claude.com/docs/en/llm-gateway)

- **Lens Loop side:** we don’t specifically document “Claude Code proxying” as a first-class workflow, but it works because Claude Code allows proxying through a custom Anthropic base URL.

* * *

---

<div class="post-metadata">

**Author:** ![sramadugu1](https://forums.k8slens.dev/letter_avatar_proxy/v4/letter/s/4491bb/32.png) [@sramadugu1](https://forums.k8slens.dev/u/sramadugu1)\
**Post date:** [December 8, 2025, 7:08am UTC](https://forums.k8slens.dev/t/how-to-integrate-claude-code-with-lens-loop-for-local-api-tracing/6695/3 "2025-12-08T07:08:20Z")

</div>

followed the same steps but dont see anything showing up, will wait for the update and try again.

---

<div class="post-metadata">

**Author:** ![hlaitala](https://forums.k8slens.dev/user_avatar/forums.k8slens.dev/hlaitala/32/2032_2.png) [@hlaitala](https://forums.k8slens.dev/u/hlaitala)\
**Post date:** [December 8, 2025, 1:41pm UTC](https://forums.k8slens.dev/t/how-to-integrate-claude-code-with-lens-loop-for-local-api-tracing/6695/4 "2025-12-08T13:41:50Z")

</div>

Hello @sramadugu1 — quick update for you!

We’ve released a new beta that fixes this issue. Please see the release notes here:  
[https://forums.k8slens.dev/t/loop-v2025-12-08-beta-release/6702](https://forums.k8slens.dev/t/loop-v2025-12-08-beta-release/6702)

To make sure you’re on the latest version, you can manually trigger the update check on

**Lens Loop → Check for Updates…**

On macOS, this option is located in the app menu, as shown in your screenshot:

 ![Screenshot 2025-12-08 at 15.30.40](https://forums.k8slens.dev/original/2X/8/8046caa0703eb7214b654d15532b83337b68a624.png)

Once updated, Anthropic proxying and tracing should work as expected.
