# Brick + Claude Code CLI: A Practical Guide to Smarter AI Routing and Cost Optimization

If you're running Claude Code CLI in production—or even just heavily in your daily workflow—you've probably noticed your API bills creeping up. The default model is Claude Opus, which is the most capable but also the most expensive model in the Anthropic lineup.

For trivial tasks—a quick git log explainer, a one-line refactor, a "what does this function do"—you're burning roughly $15 per million input tokens when Haiku would've done the job for $0.25. That's a 60x price difference for the same quality on simple work.

[Brick](https://github.com/regolo-ai/brick-SR1) is an open-source Mixture-of-Models routing gateway from the team at regolo that sits between you and your LLM provider and, in real time, decides which model should handle each request.

---

## What Brick actually does

Brick isn't a proxy or a simple round-robin load balancer, **It's a routing layer** that evaluates every incoming prompt along two axes simultaneously. It embeds every prompt into a 6-dimensional capability space using ModernBERT-base, the six dimensions map to:

- **Context**: how much background does the task need
- **Direction-following**: how precisely must the model adhere to instructions
- **Reasoning**: how many inference steps are required
- **Code**: how code-heavy the output needs to be
- **Tools/function-calling**: whether structured outputs are involved
- **Multilingual**: whether non-English content matters

Each prompt gets a vector score, and Brick figures out which model's capability profile is the best fit. It's single-pass—the embedding + classification takes roughly 40ms on a modern GPU, and even on CPU it stays under 200ms.

## How does it work

https://youtu.be/nMlzwZIj2ms 

---

## The complexity score

On top of the capability vector, Brick runs a lightweight complexity classifier based on Qwen3.5-0.8B with a LoRA adapter fine-tuned on roughly 50,000 labeled prompts.

**It outputs one of three ratings:** easy, medium, or hard.

![](https://regolo.ai/wp-content/uploads/2026/07/image-2-1024x247.png)This isn't just a proxy for token count—a 200-word legal contract review scores hard despite being short, while a 2,000-word explanation of how to use a JavaScript library might score medium.

The combination of these two scores determines which tier of model handles the request. The routing itself takes roughly 60ms end-to-end, which means your first token latency on routed requests is maybe 100ms slower than calling a model directly. In practice, I haven't noticed it.

---

# From zero to routing

## Step 1: quickstart 

```
# Clone and install
git clone https://github.com/regolo-ai/brick-SR1.git
cd brick-SR1

# Create local env and install all modules
pip3 -m venv .venv && source .venv/bin/activate && pip install -r requirements.txt

# Set your Anthropic API key
export ANTHROPIC_API_KEY=sk-ant-...Code language: PHP (php)
```

## Step 2: wrap claude in brick

```
brick claude on     # wires ANTHROPIC_BASE_URL in ~/.claude/settings.json, auto-starts the routerCode language: PHP (php)
```

Then:

1. Open a **new** Claude Code session (your current session is unaffected).
2. In the `/model` picker, select **brick-claude** (it sits alongside the built-in opus/sonnet/haiku aliases, which it does not replace).

To turn Brick off, just typing:

```
brick claude off    # restores ANTHROPIC_BASE_URL, optionally stops the routerCode language: PHP (php)
```

The `brick claude on` command automatically wires Claude Code to route through the Brick gateway. It modifies your Claude Code configuration to point at the local Brick server, starts the gateway if it isn't already running, and sets the default mode to mid. The corresponding `brick claude off` reverts the configuration and stops the gateway.

`brick claude status` shows you your current routing mode, the health of the Brick server, and rolling stats from the last few minutes: how many requests went to each model, average routing latency, and estimated cost versus running everything uncached on Opus.

## Step 3: 

```
brick chat
```

![](https://regolo.ai/wp-content/uploads/2026/07/Screenshot-2026-07-20-alle-18.15.33-1024x393.png)## Observability 

```
brick claude status         # live dashboard (default in an interactive terminal)
brick claude status --once  # static one-shot viewCode language: PHP (php)
```

![](https://regolo.ai/wp-content/uploads/2026/07/brick-claude-status-1024x421.png)## Under the hood: the routing decisions

Brick exposes OpenTelemetry-compatible traces for every routing decision. Each span includes the capability vector scores, the complexity classification, the confidence, and the selected target model. If you're running a Grafana stack or just want to pipe traces to Jaeger, you can see exactly why any given request ended up at Haiku versus Opus.

Here's a rough outline of what a trace looks like:

```
brick.route: 42ms
  ├── brick.embed: 18ms
  │   └── scores: [0.82, 0.34, 0.91, 0.45, 0.12, 0.03]
  ├── brick.classify: 24ms
  │   └── complexity: medium (confidence: 0.88)
  └── brick.select: 0.2ms
      └── selected: claude-sonnet-4-20250514 (mode: mid)Code language: CSS (css)
```

Related: the lack of a local dashboard is annoying. You'll want to pipe this data somewhere you can query it because the CLI status command only shows aggregates. The OpenTelemetry export endpoint is configurable in the YAML under `observability.otlp_endpoint`.

---

## Frequently Asked Questions

### Is Brick compatible with any OpenAI-compatible API, or only Anthropic?

As of the v1-beta release, Brick primarily targets Anthropic's Claude models. The team has announced OpenAI and open-model support for future releases, but the routing profiles and complexity benchmarks are currently tuned for the Claude family.

### Does Brick cache responses?

Not yet. Caching is listed as a planned feature. The team recommends using a separate caching layer (like GPTCache or Redis-based response caching) in front of Brick if response deduplication is a concern for your workload. They've said a native caching module is expected in a future release.

### Can I run Brick without a GPU?

Yes. The ModernBERT embedding layer runs on CPU without issues for low-concurrency setups. For production deployments with 20+ concurrent requests, the team recommends GPU acceleration. On CPU, expect routing latency to climb from roughly 60ms to 200ms+ under load.

### How does Brick compare to other routing approaches like OpenRouter's model selection or Portkey's gateway?

OpenRouter selects models based on availability and price across providers—it's fundamentally a marketplace router. Portkey offers observability, fallbacks, and configurable routing rules. Brick is the only option I've found that does content-based dynamic routing: it actually *understands what the prompt needs* and routes accordingly. All three can be complementary. I use Portkey for production observability and Brick for intelligent model selection.

### What happens if the Brick server goes down?

Claude Code falls back to your default configured model. Brick is designed to be a sidecar—it's not inline in the critical path in a way that blocks your workflow. If the gateway is unreachable, Claude Code uses whatever model you have set as the default (typically the one configured before `brick claude on`).

---

St**art your free 30-day trial at [regolo.ai](https://regolo.ai/) and deploy LLMs with complete privacy by design.**

👉 [Talk with our Engineers](https://regolo.ai/contacts/) or [Start your 30 days free →](https://regolo.ai/pricing)

---

- [Discord](https://discord.gg/ZzZvuR2y) - Share your thoughts
- [GitHub Repo](https://github.com/regolo-ai/) - Code of blog articles ready to start
- Follow Us on X [@regolo\_ai](https://x.com/regolo_ai)
- Open discussion on our [Subreddit Community](https://www.reddit.com/r/regolo_ai/)

---

*Built with ❤️ by the Regolo team. Questions? [regolo.ai/contact](https://regolo.ai/contact)* or chat with us on [Discord](https://discord.gg/ZzZvuR2y)