Skip to content

Claude Code on Free Docker Hub Models: Setup, Limits, Cost

A walkthrough for wiring Claude Code to free Docker Hub models, the errors that block it, and the cost maths that sends most people back.

· · 21 min read

Updated: November 28, 2026

Bar chart of local model sizes from gpt-oss at 12.1 GB to qwen3-coder-next at 48.4 GB

Quick Take

Docker Model Runner speaks the Anthropic messages protocol, so Claude Code can talk to a model on your own SSD. In theory that is two environment variables and one pull. This guide walks the whole path from the vendor docs and the published llama.cpp source, flags the places where it breaks, and works through the arithmetic that sends most people back to the hosted model.

TL;DR: It can be made to work, and the numbers say most people shouldn't. Model Runner compiles every tool's JSON Schema into a GBNF grammar, llama.cpp can reject it, and the session 400s on the first request; a short proxy or a disallowed tool fixes that. What neither fixes is the arithmetic. The opening request from an empty project is tens of thousands of tokens, which eats roughly half a 64k window before you type, local prompt processing makes even a one-file question slow, and a machine that does this properly costs about the same per month as the hosted subscription you were trying to cancel. Splitting the work between local and hosted is the setup worth having, and that is the third article.

No translation layer needed

Every "run Claude Code on a local model" guide from a year ago had a translation layer in the middle, and it had to. Claude Code speaks the Anthropic messages protocol, almost every local inference server speaks the OpenAI chat-completions protocol, and something has to reshape the JSON between them.

Docker Model Runner removed the need. Its API surface carries three dialects at once:

RouteDialect
/engines/v1/chat/completionsOpenAI
/anthropic/v1/messagesAnthropic
/api/chatOllama

That middle row means no protocol translation. Claude Code sets its base URL, posts the request it was always going to post, and the runner answers in the shape it expects.

Something still has to sit in between, for a completely different reason, and that is most of this article.

Version numbers matter here more than usual, because docker model grew several of these subcommands recently and the older ones are missing on Docker Desktop builds from early 2026.

Step 1: Check the runner

docker model status

On a working install you get the backend as well as the state:

Docker Model Runner is running
BACKEND    STATUS         DETAILS
llama.cpp  Running        llama.cpp <build>-metal
diffusers  Not Installed

Read the backend line. On Apple silicon the Metal build is what puts the model on the GPU; if you see a plain CPU build, everything below still works and will be roughly an order of magnitude slower.

If the command reports the runner is not running, install or start it:

docker model install-runner

Step 2: Open the TCP port

By default the runner answers containers at model-runner.docker.internal and nothing else. Claude Code is a process on your host, not a container, so it needs a real port.

docker desktop enable model-runner --tcp 12434

The Docker Desktop UI has the same switch under Settings, AI. Confirm it took:

curl -s http://localhost:12434/
Docker Model Runner

The service is running.

If you get a connection refused here, stop and fix it. Everything after this point produces confusing errors when the port is closed, because Claude Code reports a failed API call rather than a failed connection.

Step 3: Pick and pull a model

Docker Hub's ai/ namespace is a normal registry namespace holding models as OCI artifacts, so docker model pull works exactly like docker pull. Search from the CLI rather than the website, because the CLI prints the download size:

docker model search coder

The coding-relevant part of the catalogue on 28 August 2026:

ModelSizeNotes
ai/gpt-oss12.1 GB20B, MXFP4, small default context
ai/devstral-small-215.2 GB24B dense, tuned for agentic edits
ai/glm-4.7-flash18.3 GB30B MoE, ~3B active
ai/qwen3-coder18.6 GB30B MoE, long native context
ai/deepcoder-preview9.0 GB14B, reasoning-flavoured
ai/qwen3-coder-next48.4 GB80B MoE, needs a workstation

That size column is close to the resident memory the weights will occupy. On a 16 GB machine, ai/gpt-oss is the realistic ceiling. On 24 GB the 18 GB models load but leave very little for the KV cache once you widen the context, which is the next section's problem.

docker model pull ai/devstral-small-2

Pulls are plain registry traffic, so they inherit whatever your network gives you. On a slow or proxied connection an 18 GB model is an overnight job. Worth knowing before you start it during a standup.

Step 4: Test the endpoint without Claude Code

Debugging two unfamiliar things at once is how people conclude "it doesn't work". Test the bridge on its own:

curl -s http://localhost:12434/anthropic/v1/messages \
  -H "Content-Type: application/json" \
  -d '{
    "model": "ai/devstral-small-2",
    "max_tokens": 64,
    "messages": [{"role": "user", "content": "Reply with the word ready."}]
  }'

A healthy response is Anthropic-shaped. Trimmed, it looks like this:

{
  "type": "message",
  "role": "assistant",
  "content": [{ "type": "thinking", "thinking": "..." }],
  "model": "ai/devstral-small-2",
  "stop_reason": "max_tokens",
  "usage": { "input_tokens": 14, "output_tokens": 64 }
}

Two details. The model field tells you which model actually answered, so check it against what you asked for. And the route is documented two ways: the API reference lists /anthropic/v1/messages in its endpoint table and uses the short /v1/messages form in its curl examples, so if one 404s, try the other.

If you get a 404 here, check the model name against docker model ls before blaming the URL. The runner log shows what it received:

docker model logs | grep -i "anthropic api request" -A1

Step 5: The context trap

This is the step the official guide mentions in passing and the step that decides whether your session is usable.

Claude Code sends much more than your prompt: its system prompt, the JSON schema for every tool it can call, your project's CLAUDE.md, and then your prompt. On an empty directory that handshake is already tens of thousands of tokens, and it grows with every MCP server you have connected.

There is a second half to this that the guide does not mention at all. Claude Code has to guess your model's window, and for a model name it does not recognise it guesses 200k:

Claude Code prints a notice when the model name is unknown to it, and the text tells you to set CLAUDE_CODE_MAX_CONTEXT_TOKENS to the model's real window. Every Docker Hub model is unrecognised, so expect it every time. If the model actually has 40k, Claude Code will happily fill far more than that before it thinks about compacting, and the runner truncates underneath. Tell it the truth:

export CLAUDE_CODE_MAX_CONTEXT_TOKENS=40960

Then make sure the model can hold that. Do not assume the default; set the window explicitly. The runner can change it at runtime without re-downloading the weights:

docker model configure --context-size 32768 ai/gpt-oss

Widening context is not free: the KV cache scales with it, so a 32k window on a 12 GB model can add several gigabytes of resident memory. On a 24 GB laptop that is the difference between a session that runs and a session that swaps.

Models with a long native window, such as ai/qwen3-coder (its model card lists 262,144 tokens), leave far more room to work with. That alone is a reason to prefer them, though the window the runner actually loads is still the one you configure.

Step 6: Launch Claude Code

From your project directory:

ANTHROPIC_BASE_URL=http://localhost:12434 claude --model ai/devstral-small-2

On Windows PowerShell:

$env:ANTHROPIC_BASE_URL = "http://localhost:12434"
claude --model ai/devstral-small-2

Inside the session, run /status. It prints the API base URL in use, which is the only trustworthy confirmation that you are talking to your own machine and not quietly burning hosted tokens because a typo in the variable name made the export a no-op.

There is also a shortcut that does the configuration for you:

docker model launch claude

That launcher sets the base URL for you, and the URL it picks can be a version-stamped Docker Desktop path that changes between releases. For anything you write down and reuse, the explicit port is the stable choice.

What Claude Code sends

The runner keeps a request log, which helps in understanding why a small model behaves badly:

docker model requests --follow --model ai/devstral-small-2

Leave that running in a second terminal while you use Claude Code in the first. Do this once and the context problem stops being abstract. You can see the size of the system prompt, and you can see the tool-call JSON the model is being asked to produce.

What Does the "failed to parse grammar" Failure Mean?

The first failure many people hit comes before the context window, on the first request:

API Error: 400 Failed to initialize samplers: failed to parse grammar

That error is worth explaining, because nothing about it points at the cause and searching it gets you nowhere useful.

To make a local model emit valid tool calls, Model Runner converts the JSON Schema of every tool in your session into a GBNF grammar and constrains llama.cpp's sampler to it, instead of trusting the prompt alone. You can watch it happen:

docker model logs | grep '::='

You will see one grammar rule per field of every tool you have. And llama.cpp refuses to compile the grammar if any of them is too big. A JSON Schema string with a large maxLength becomes a repetition like char{0,N}, and past a point the parser gives up on the whole thing.

The limit is in llama.cpp's own source. llama-grammar.cpp defines MAX_REPETITION_THRESHOLD as 2000 and throws "number of repetitions exceeds sane defaults" when a repeat count goes above it. A second check throws when the number of rules being repeated, multiplied by the repeat count, passes the same figure. So the cliff sits near 2,000, exactly where depends on the rest of the rule, and a maxLength of 4,096 or 524,288 is far over it. Anything over takes down the entire session, not just that one tool, because the grammar is compiled as a single unit.

Find your own offenders:

docker model logs | grep -oE 'tool-[A-Za-z-]+-schema-[A-Za-z-]+ ::= .*char\{0,[0-9]{4,}\}'

Two things matter when you hunt for the offender. First, one tool is enough to fail the whole session. Second, --disallowedTools is worth trying: on Claude Code 2.1.329, a request captured through a stub endpoint with --disallowedTools "Artifact,Workflow" no longer carried those two tools at all, and the body dropped from about 88 KB to 48 KB. Older versions may behave differently, so capture your own request before relying on it. The proxy below does that capture.

A stub server is enough to capture it, and it needs no model at all. It logs every request body and answers 400:

import http from 'node:http';
import fs from 'node:fs';

const log = [];
http.createServer((req, res) => {
  const chunks = [];
  req.on('data', (c) => chunks.push(c));
  req.on('end', () => {
    const raw = Buffer.concat(chunks).toString('utf8');
    log.push({ url: req.url, bytes: Buffer.byteLength(raw), body: JSON.parse(raw || 'null') });
    fs.writeFileSync('capture.json', JSON.stringify(log));
    res.writeHead(400, { 'content-type': 'application/json' });
    res.end('{"type":"error","error":{"type":"invalid_request_error","message":"stub"}}');
  });
}).listen(12999, '127.0.0.1');

Point Claude Code at it with ANTHROPIC_BASE_URL=http://127.0.0.1:12999, a throwaway ANTHROPIC_API_KEY, --strict-mcp-config and an empty mcpServers object, then read the tools array and the byte count out of capture.json.

Two independent causes, and one limit:

1. pattern is the main one. Model Runner hands each schema's regex to llama.cpp's converter, which cannot express several ordinary constructs. Look for pattern keywords in the tools array of a captured request; each one is a candidate for the 400.

2. Size bounds are the second. maxLength and maxItems both turn into repetition rules, and the limit in the source applies to both. The proxy below strips them from 1,500 up, comfortably under the 2,000 limit.

3. Total grammar complexity has a ceiling. The second check in the source multiplies the rules being repeated by the repeat count, so it is the combined complexity that matters, not the number of tools as such. A session with many MCP servers connected can fail no matter what you strip, so disconnect what you don't need.

Causes one and two can be fixed on the wire. A small proxy that walks the request and deletes those keywords is about eighty lines:

function stripBounds(node: unknown): void {
  if (Array.isArray(node)) {
    node.forEach(stripBounds);
    return;
  }
  if (node === null || typeof node !== 'object') {
    return;
  }
  const obj = node as Record<string, unknown>;
  if (typeof obj.pattern === 'string') {
    delete obj.pattern;
  }
  for (const key of ['maxLength', 'maxItems'] as const) {
    if (typeof obj[key] === 'number' && (obj[key] as number) >= 1500) {
      delete obj[key];
    }
  }
  Object.values(obj).forEach(stripBounds);
}

Sit that in front of port 12434, rewrite tools on the way through, pipe the response back untouched so SSE streaming still works, and point ANTHROPIC_BASE_URL at the proxy instead. Nothing is lost: those keywords are input validation, and Claude Code validates tool inputs on its own side anyway.

With the proxy in place and MCP servers off, a one-shot run looks like this:

ANTHROPIC_BASE_URL=http://localhost:12435 claude --model ai/gpt-oss \
  --strict-mcp-config --mcp-config '{"mcpServers":{}}' \
  -p "Read sample.ts and tell me the exported value, nothing else."

If that returns the value, the whole loop works: system prompt, tool schemas, a Read call and an answer, entirely on your own machine.

Context and memory: the limits after the grammar

The grammar was the interesting failure. The ones below cost more time.

The handshake is tens of thousands of tokens. Not "several thousand", which is the natural guess. A request captured on 26 November 2026 from Claude Code 2.1.329, in an empty directory with a clean config and no MCP servers, with a stub server standing in for the runner, was 88 KB with 13 tools attached and 148 KB after the retry added more. At roughly four bytes a token that is about 22,000 to 37,000 tokens. It is an estimate: the runner counts with the model's own tokenizer, your Claude Code version attaches different tools, and CLAUDE.md and MCP servers add more. The runner tells you the real figure when it refuses:

API Error: 400 request (N tokens) exceeds the available context size (4096 tokens)

The runtime config is the lever that works:

docker model configure --context-size 65536 --keep-alive 15m ai/gpt-oss

And remember to raise CLAUDE_CODE_MAX_CONTEXT_TOKENS to match, or Claude Code refuses the prompt from its own side before the runner ever sees it.

Two resident models will not fit. ai/qwen3-coder is the better coding model, and the arithmetic rules it out on a 24 GB machine: 18.6 GB of weights plus a KV cache wide enough for that handshake is more memory than the GPU can address, and on Apple Silicon that shows up as a Metal out-of-memory error rather than a slow session.

Worse, --keep-alive means an earlier model is still resident when you start the next one, so a configuration that worked ten minutes ago fails now for no visible reason. docker model ps shows the truth, and docker model unload --all before each session removes the whole class of problem.

Context width has a cost curve too, not just a cliff. Push the window toward 98k and the runner allocates KV across four slots; once that no longer fits in GPU memory the model spills and generation slows to a crawl. Pick the narrowest window that holds the handshake plus your task.

Half the window can be gone before you type. This is the part that is easy to underestimate. A 64k context minus a handshake in the 22,000 to 37,000 range leaves roughly 27k to 42k for everything else, and /clear does not give any of it back. Clearing wipes the transcript, not the system prompt and the tool schemas, so a cleared session restarts at the same floor.

That sounds like room until a tool is involved. Reasoning tokens count against the window like any other, so one tool call that returns a batch of records can eat what is left in a single turn. So does a git log, a directory listing, a file over a few hundred lines.

A practical rule: local sessions are for one file and one edit. Anything that fans out, reads widely, or pipes a command's output back into the model belongs on the hosted side. Widening the window doesn't rescue it either, because the wider window is exactly where the model spills and generation crawls.

Speed once it works

Speed depends on your hardware more than on anything in this article, so time it yourself before you trust a number from someone else's machine. The shape doesn't change, though: every request starts by pushing a handshake of tens of thousands of tokens through prompt processing on local silicon, so even a one-file question can be measured in minutes, not seconds. A thinking model such as ai/qwen3 is slower still, because it spends most of its budget reasoning about a trivial question before it answers.

Correct answers are possible; how fast they arrive depends on your hardware.

The cost of a dedicated box

The laptop is the wrong test. Nobody sensible runs a shared coding model on the machine they are typing on, so price the thing people actually propose: a dedicated Linux box in the corner.

Two builds, both real configurations rather than aspirational ones. The prices are rough August 2026 estimates in euros for used and retail parts, not quotes, so check current listings before you trust them; they will drift.

ItemSingle-GPUDual-GPU
GPU1x RTX 3090 24 GB, used2x RTX 3090 24 GB, used
7001,400
Board, CPU, 64 GB DDR5550650
PSU850 W, 1201,200 W, 190
Case, NVMe, fans180230
Build total1,5502,470

Now run it. A 3090 pulls around 350 W flat out, and --keep-alive means the model sits resident between your questions rather than reloading, so there is an idle floor too. Four hours a day of real generation on the dual build, an 80 W idle draw the rest of the time, at 0.35 EUR/kWh:

LineSingle-GPUDual-GPU
Hardware, spread over 24 months65103
Electricity per month2845
Monthly, EUR93148

Set that against the thing it replaces. A Claude Max subscription at the 5x tier is 100 USD a month, roughly 92 EUR at the rate that week. The 20x tier is double that.

So the dual-GPU box, the one that comfortably holds a 30B model with a window wide enough for the handshake, costs more per month than the subscription, for two years, before anyone has fixed a driver. The single-GPU build lands at a dead heat with the 5x tier while running a weaker model in a narrower window.

And that comparison flatters the local side, because it prices only the electricity and the parts. It does not price an evening spent bisecting a GBNF grammar, the docker model configure versus docker model package detour, or the fact that every Docker update can move one of those subcommands under you. Nor does it price the wait: minutes for a question about one file, against a few seconds hosted, ten times a day. With a "free local model", the tokens are the only free part.

What not to expect

Be honest about the ceiling. A 15 GB model on a laptop is not a substitute for a hosted frontier model, and pretending otherwise wastes an afternoon.

Long agentic runs are where the gap shows. A hosted model will chain twenty tool calls across a refactor without losing the thread; a small local model drifts, forgets a file it already read, or re-runs the same search. Note that malformed tool JSON, the classic complaint about local models, is not the failure mode here. Grammar-constrained sampling makes it structurally impossible for the model to emit invalid JSON. It can still pick the wrong tool or the wrong argument, and now it does so in perfectly well-formed syntax.

Local does win in a few narrower cases: code that cannot leave the building, working on a train, and grinding through a repetitive mechanical edit across forty files, where you do not care whether the model is clever and you do care that it is free. Our practical rundown of AI coding tools covers where each tier of model earns its place, and the Claude Code workflow for React assumes the hosted model for a reason.

Which Local Model Is Best for TypeScript and React?

None of them has a benchmark that answers it. The score quoted for every local coding model is SWE-bench Verified, and that's 500 human-screened GitHub issues from Python repositories. It rewards finding your way around a repo and producing an edit that applies, and those skills transfer. JSX, the TypeScript type system and CSS layout don't appear in it at all. Multi-SWE-bench does include TypeScript and JavaScript, so check there first for the model you're eyeing. Mostly, though, you're choosing on proxies, and I didn't run these models against each other either. What follows is a reading of the published specs, not a measurement.

One naming trap first. Scores get attached to "Qwen3-Coder" that belong to Qwen3-30B-A3B, the general-purpose model. docker model pull ai/qwen3-coder gives you Qwen3-Coder-30B-A3B-Instruct, and its model card lists 30.5B parameters in total, 3.3B activated, a native context of 262,144 tokens, and no SWE-bench Verified number. Any score you see next to it is somebody else's run on somebody else's harness. Mistral, by contrast, publishes 68.0% for the 24B Devstral Small 2 with a 256K window. That's a vendor figure. Treat it as a ranking hint.

Which proxies, then? Context first, because a React change is rarely one file: the component, its props type, the hook it calls and the stylesheet all have to fit next to that handshake. Tool-call judgement second, since the grammar already guarantees the syntax. Parameter count last. By memory:

  • 16 GB: ai/gpt-oss, for single components and boilerplate. Not for agentic refactors.
  • 24 GB: ai/devstral-small-2. It fits with room left for the KV cache.
  • 32 GB or more: ai/qwen3-coder, for the long native window.

Whatever you pull, keep TypeScript strict mode and a fast typecheck in the loop, so the compiler catches an invented member before you read it. And why trust anyone's ranking when a check of your own takes a quarter of an hour? Give each candidate the same five prompts and grade on whether the output compiles and behaves:

  1. A typed useFetch<T> hook with loading, error and abort handling.
  2. A discriminated union for a form state machine, plus an exhaustive switch.
  3. A responsive card grid in CSS grid with minmax and auto-fit, no media queries.
  4. A component with a wrong useEffect dependency array, to fix and explain.
  5. A three-file change: rename a prop, update the type, update the consumer.

The first four test knowledge. The fifth tests whether the model can be trusted inside an agent, and it's the tiebreaker.

Verdict

On any reading of the numbers, a local model does not replace the hosted one.

Nothing here is impossible. The grammar problem has a fix, the context problem has a fix, and a local model can answer real questions about real files. The setup works, and it still loses on all three counts I care about: it is slower on wall-clock, weaker on multi-file reasoning, and once you buy hardware that holds a decent model it is not even cheaper. With nothing on the other side of the scale, I can't call that a trade-off.

What survives is the private-code and offline cases above, plus a more interesting one: not every request Claude Code sends is hard. Reading a file, summarising a tool result, checking a status: a 12 GB model handles those, and they are a real share of a session.

So the useful move is to stop sending the easy half somewhere expensive, and that needs a router rather than an environment variable. Everything you installed here is the prerequisite for it, so the hybrid setup, step by step picks up exactly where this article stops.

Rolling it back

Nothing here is sticky unless you made it sticky.

unset ANTHROPIC_BASE_URL     # back to the hosted model
docker model unload --all    # free the RAM, keep the weights
docker model rm ai/devstral-small-2   # free the disk

If you exported the variable in ~/.zshrc, remove it there too. An orphaned ANTHROPIC_BASE_URL pointing at a runner you have since stopped produces a connection error on every claude invocation, and it is not obvious where it came from three weeks later.

Correction, November 26, 2026: An earlier version of this guide presented several measurements as first-person results: a 35,482-token handshake, a maxLength cliff between 1,900 and 2,000, and 50 of 81 tools compiling against 60 failing. None of them could be reproduced from a saved script or log, so they are replaced above with the limit from llama.cpp's source and a request capture dated November 26, 2026. The claim that --disallowedTools does not remove a tool's schema was also wrong for Claude Code 2.1.329.

Frequently Asked Questions

Does this need a proxy like LiteLLM or claude-code-router?
Not for protocol translation. Docker Model Runner exposes /anthropic/v1/messages alongside its OpenAI-compatible routes, so it already answers in the shape Claude Code expects, which is why the usual translation proxies are unnecessary here. You do still need a thin proxy, but for a different job: deleting the pattern and maxLength keywords from tool schemas so llama.cpp can compile the grammar. That is eighty lines, not a framework.
Is my Anthropic subscription still being used?
Not while ANTHROPIC_BASE_URL points at localhost. Every request goes to the model on your disk, which is also why the local session cannot fall back to a hosted Claude model when the small one struggles. Unset the variable to go back.
Why does Claude Code fail immediately with a context or token error?
Because the model's default context is too small. Claude Code sends its system prompt plus the JSON schema for every tool before your first word. A request captured from Claude Code 2.1.329 on 26 November 2026, in an empty directory with no MCP servers, was 88 to 148 KB of JSON depending on which tools were attached. At roughly four bytes a token that is about 22,000 to 37,000 tokens, an estimate rather than the runner's own count. Against a 4,096-token default it fails at once. Fix it with docker model configure --context-size 65536.
Which models on Docker Hub are worth pulling for coding?
The ai namespace ships ai/devstral-small-2 at 15.2 GB, ai/qwen3-coder at 18.6 GB, ai/glm-4.7-flash at 18.3 GB and ai/gpt-oss at 12.1 GB. Size on Docker Hub is close to the RAM the weights need, so match it against your machine before pulling 18 GB over a slow link.
What does Failed to initialize samplers: failed to parse grammar mean?
Model Runner compiles the JSON Schema of every tool in your session into a GBNF grammar so llama.cpp can only emit valid tool calls. Two things break that conversion: a pattern regex llama.cpp cannot express, and a maxLength or maxItems bound above llama.cpp's repetition limit of 2,000 (MAX_REPETITION_THRESHOLD in llama-grammar.cpp). Either one fails the whole grammar, so the entire session 400s rather than the one tool. Two fixes work: stop Claude Code sending the offending tool, because on Claude Code 2.1.329 --disallowedTools removes a tool's schema from the request, or run a small proxy that deletes those keywords from the tools array before forwarding it. Separately, keep the tool count down. The same source rejects a grammar when the rules being repeated multiplied by the repeat count pass that limit, so a session with many tools or MCP servers can fail even after you strip every bound.
Does /clear free up the context on a local model?
No. Clearing drops the conversation, but the system prompt and every tool schema are resent on the next request, so a cleared session starts again at the same floor. On a 64k window that can leave only about half the window as room, which one command with a long output plus the model's own reasoning tokens can exhaust in a single turn. Treat a local session as one file and one edit, and keep wide-reading or output-heavy commands on the hosted model.
Is running Claude Code on a local model actually cheaper?
Not once the hardware is priced in. A dual RTX 3090 build capable of holding a 30B model with a window wide enough for a handshake of tens of thousands of tokens came to about 2,470 EUR on estimated August 2026 prices, which is 103 EUR a month spread over two years, plus roughly 45 EUR of electricity. That is more than a Claude Max 5x subscription at 100 USD a month, for a weaker model that has to process that whole handshake locally before it answers even a single-file question. The tokens are free. Nothing else about it is.
Can I keep the setting permanently?
You can export ANTHROPIC_BASE_URL in your shell profile, but that hijacks every claude invocation on the machine. A shell alias or a per-project .envrc is safer, because you almost certainly want the hosted model for real work and the local one for the offline or private cases.