---
title: "Ollama in Claude Code — local or cloud, for a team · Selan"
description: "Ollama runs Claude Code on a local or cloud model through its Anthropic-compatible API. Run Ollama's cloud for a team through Selan, no key on a laptop."
url: https://selan.ai/guides/ollama-in-claude-code
updated: 2026-10-20T06:55:15+00:00
---

Guide · Other models in Claude Code

# How do you use Ollama with Claude Code?

Run `ollama launch claude`, or point `ANTHROPIC_BASE_URL` at Ollama, which answers in Anthropic's API format. That runs Claude Code on a model on your own machine or on Ollama's cloud. Selan connects Ollama's cloud only, not a local server. An owner adds the company's Ollama key once, and each developer runs `selan claude --model ollama:gemma4:31b`.

## Why does Ollama work in Claude Code at all?

Claude Code sends every request in Anthropic's Messages format. It reaches another server when `ANTHROPIC_BASE_URL` is set to that server's address.

Ollama answers in that format from version 0.14.0. Its local server does, and so does its cloud at `https://ollama.com`.

Ollama supports a subset of the format. Messages, streaming and tool calls work on compatible models. Tool-choice controls, deferred tools and hosted web search are not fully supported.

## How do you run Claude Code on a local Ollama model?

Install Ollama and Claude Code, then start Claude Code through Ollama:

```bash
ollama launch claude
```

To set it up yourself, Ollama's docs give two variables. `ANTHROPIC_BASE_URL` is `http://localhost:11434`. `ANTHROPIC_AUTH_TOKEN` is `ollama`, which is required but ignored.

Pick a model trained for tool calls, because Claude Code edits files and runs commands through tools. For a larger repository, Ollama says to set the context length to 64k or higher.

The model then runs on your own hardware, and Ollama's plans put no limit on local use. How fast it answers depends on that hardware.

## How do you use Ollama's cloud models in Claude Code?

Ollama's cloud needs no Ollama install. Create an API key on ollama.com, then start Claude Code against it:

```bash
ANTHROPIC_BASE_URL=https://ollama.com \
ANTHROPIC_AUTH_TOKEN="$OLLAMA_API_KEY" \
ANTHROPIC_API_KEY="" \
claude --model glm-5.3-flash
```

The cloud takes the key only as a bearer token, so it goes in `ANTHROPIC_AUTH_TOKEN`. Claude Code's settings files override these shell variables, so change them there too, and `/status` checks the connection.

Name a cloud model as `https://ollama.com/api/tags` lists it, such as `gemma4:31b`. The Ollama app and CLI spell the same model `gemma4:cloud`.

Ollama's paid plans include a monthly amount of usage. It is measured in tokens at each model's rate, and use past it draws on credits you buy. Ollama is one account per person, and its Team plan is the one sold for shared use.

That works for one person. On a team, it is one Ollama key and one set of variables per laptop, and no shared view of who used what. Why a key on every laptop is the expensive part is in [keeping API keys off laptops](https://selan.ai/guides/claude-code-without-api-keys).

## How does a team run Ollama in Claude Code through Selan?

An owner pastes the company's Ollama API key in Selan, then switches on the Ollama models the team may use under [Settings → Models](https://control.selan.ai/settings/models). Selan lists Gemma 4, DeepSeek V4.1 Flash and DeepSeek V4 Pro on Ollama by name.

Developers install the `selan` CLI, sign in as themselves and name the model:

```bash
selan claude --model ollama:gemma4:31b
```

The part before the first colon is the provider. Everything after it is Ollama's own model id, passed through as it is.

With `--model`, Selan tells Claude Code the model's real context window. Selan lists Gemma 4 at 262,144 tokens, DeepSeek V4.1 Flash at 1,048,576 and V4 Pro at 1,000,000. If an owner set a lower context limit for your company, a session compacts there instead.

To skip the flag, an owner adds the model to Claude Code's picker under [Settings → Model pickers](https://control.selan.ai/settings/pickers). It then appears in `/model`. The details are in [Run any model](https://selan.ai/docs#any-model).

## What does Selan not do with Ollama?

Selan reaches Ollama's cloud at ollama.com, never an Ollama server on your laptop.

-   **No local models.** To run a model on your own machine, use Ollama's own setup above. Selan's usage record and spend limits do not see those turns.
-   **No silent swaps.** Ollama answers only when you name one of its models. A request that names no model never lands on it.
-   **No fallback.** An Ollama turn runs on Ollama and on no other provider. If the key is out of usage, the request fails rather than moving elsewhere.
-   **No spend-limit cap.** Selan has no per-token price for Ollama, so an Ollama turn does not count against a member's [spend limit](https://selan.ai/solutions/spend). Ollama's own usage page and credit settings cap that use.

Every provider Selan connects is on [Providers and models](https://selan.ai/docs/providers).

## What does a team get beyond the model?

-   **One usage record.** Ollama turns land beside Claude turns, per person and per repository. [Usage per developer](https://selan.ai/guides/claude-code-usage-per-developer) shows what an owner sees.
-   **No Ollama key on a laptop.** The key stays on the gateway. A developer holds a Selan session you can revoke.
-   **Codex on the same key.** `selan codex --model ollama:gemma4:31b` uses Ollama's own Responses API. Codex edits files through the shell there. See [Codex](https://selan.ai/docs/codex#model).
-   **Other models beside it.** The same session can name Claude, GPT or Kimi on your other accounts. See [any model in Claude Code](https://selan.ai/solutions/models).

**Good to know:** Anthropic doesn't support routing Claude Code to non-Claude models through any gateway, Selan included. An Ollama session is the gateway's to answer for, not Anthropic's.

[Start for free](https://selan.ai/pricing)

Free for up to three seats, and the Free plan needs no card.

### The short version

-   Ollama answers in Anthropic's API format, so Claude Code reaches it by its base URL.
-   On your own machine, `ollama launch claude` runs it on a local model, with a 64k+ context for larger repositories.
-   Ollama's cloud takes a key as a bearer token at `https://ollama.com`, one key per laptop by hand.
-   Through Selan, a developer runs `selan claude --model ollama:gemma4:31b` on the company's Ollama key, with no key on a laptop.
-   Selan connects Ollama's cloud only, never a local server.

The manual setup is Ollama's Claude Code, Anthropic compatibility and cloud docs, and its plans are its pricing page, all as read on 20 October 2026. Anthropic's position is its LLM gateway docs. What Selan does is its model list, its CLI and its providers, Codex and getting-started docs as they stood on the same day.
