Skip to content
BerriAIPublic

About

Lens tracing and investigation platform, standalone and embedded in LiteLLM

Resources

Contributing

Stars

87 stars

Watchers

0 watching

Forks

Repository files navigation

LiteLLM Lens

Self-improving agents, on your infrastructure.

Start locally with Git and Docker, or Set it up for me with your coding agent

Copy a setup prompt
Set up Lens for this project using https://github.com/BerriAI/lens/blob/main/docs/setup-with-agent.md. Inspect the existing project and deployment first. Reuse a working Lens installation if one exists; otherwise start standalone Lens with ClickHouse using the documented quickstart. Ask only for consequential missing choices. Preserve configuration, data, secrets, and my agent's model connection. Connect this project's instrumentation and verify a real run by its trace ID, including its input, output, and tool calls. Report the Lens URL, changes made, and verification results without exposing credentials.

Agent swarms flow through the LiteLLM gateway into one trace per run, and Lens loops what it learns back into your agents



Your agents run. Lens watches every run, finds what went wrong, and feeds it back.
The next run is better.


Early access   ·   Docs   ·   Contributing   ·   Launch post   ·   4K film



Lens CLI

Evaluate models, harnesses, and custom agents on your own tasks

Lens CLI ranks twelve model and harness configurations by pass rate and estimated cost

Saved sample run: 24 synthetic tasks across 12 configurations, with token-based cost estimates


Lens CLI cost-versus-quality chart compares pass rates and estimated total costs for the same twelve configurations

Compare pass rate and estimated cost before choosing a model and harness

Try the CLI preview



Lens traces



Lens finding



Lens dataset




Run Lens on its own or open it inside LiteLLM. Your traces stay in your own ClickHouse.
Point Claude Code, Codex or OpenCode at them and let your agents improve your agents.


Using Claude Code? Its telemetry is off by default and Lens needs it to record your turns.
Turn on the required Claude Code settings before your first session. There is one setup for Lens with a LiteLLM gateway and one for standalone Lens.


Get started

Run locally

Install Docker with Docker Compose 2.24 or newer and make sure Docker is running. Then run this from a checkout of this repository:

docker compose up --wait
docker compose logs -n1 credentials

The first command starts Lens and ClickHouse. The second prints the address to open and the setup token to paste there:

credentials-1  | Open http://localhost:4318/ui/ and paste this setup token: <your token>

The token is also saved as LENS_ADMIN_TOKEN in deploy/lens/.env. docker compose down stops Lens and keeps its data, and adding --volumes deletes the stored traces

See Run Lens for recording your first trace and configuring a deployment

Connect a local LiteLLM gateway

Lens and the gateway share two secrets. Generate them once in deploy/lens/.env and restart Lens to load them:

printf 'LITELLM_LENS_SERVICE_TOKEN=%s\nLENS_GATEWAY_SECRET=%s\n' \
  "$(openssl rand -hex 32)" "$(openssl rand -hex 32)" >> deploy/lens/.env
docker compose up -d --wait

Then give the gateway the same two values and the Lens address, and restart it:

LITELLM_LENS_URL=http://localhost:4318
LITELLM_LENS_PUBLIC_URL=http://localhost:4318
LITELLM_LENS_SERVICE_TOKEN=<same value as Lens>
LENS_GATEWAY_SECRET=<same value as Lens>

LITELLM_LENS_URL is the address the gateway calls and LITELLM_LENS_PUBLIC_URL is the one your browser and agents use. A gateway running in a container cannot reach Lens at localhost. With Docker Desktop, set LITELLM_LENS_URL=http://host.docker.internal:4318. On Linux, attach the gateway to the lens_default network and use http://lens:4318

Setting LITELLM_LENS_URL turns the connection on, so the gateway needs no config.yaml change. Lens then opens from the LiteLLM sidebar with your LiteLLM login. To also offer Log in with LiteLLM on the Lens sign-in page, set LENS_GATEWAY_PUBLIC_URL in deploy/lens/.env to the address your browser uses for the gateway, such as http://localhost:4000

Add Lens to LiteLLM covers Helm, split deployments and the connection check

About

Lens tracing and investigation platform, standalone and embedded in LiteLLM

Resources

Contributing

Stars

87 stars

Watchers

0 watching

Forks

Releases

Packages

Used by

Contributors

Languages