> ## Documentation Index
> Fetch the complete documentation index at: https://docs.tokios.com/llms.txt
> Use this file to discover all available pages before exploring further.

> ## Agent Instructions
> Tokios exposes private local models through https://api.tokios.com using an outbound-only connector tunnel.
> Use 'connector' for the local tokios-connector process.
> Use 'deployment' for the public model name in the API model field.
> Use 'upstream model id' for the model served by Ollama, llama.cpp, vLLM, LM Studio, or another local backend.
> API keys use the prefix sk-tok-. Connector tokens use the prefix ct-tok-.

# Use Claude Code with your own local model

> Use Claude Code with a local model on Ollama, LM Studio, llama.cpp, or vLLM — set ANTHROPIC_BASE_URL and ANTHROPIC_API_KEY to route requests through Tokios.

Claude Code reads two environment variables to decide where to send requests. Point `ANTHROPIC_BASE_URL` at Tokios and set your Tokios API key, and Claude Code runs against a local model on **Ollama, LM Studio, llama.cpp, or vLLM** — from any machine, not just the one running the model. Every request goes down your private tunnel to your own hardware.

## Prerequisites

* A running Tokios connector paired with your local model — see [Connector install](https://docs.tokios.com/setup/connector-install.md)
* A registered model deployment name — see [Register a model](https://docs.tokios.com/setup/register-model.md)
* A Tokios API key — see [API Keys](https://docs.tokios.com/setup/api-keys.md)
* Claude Code installed

## Set up the environment

> [tab] Windows CMD
>
> ```cmd claude-code-windows.cmd theme={"theme":{"light":"github-light","dark":"css-variables"}}
> set ANTHROPIC_BASE_URL=https://api.tokios.com
> set ANTHROPIC_API_KEY=sk-tok-YOUR_KEY
> claude --model gemma-tunnel
> ```

> [tab] macOS & Linux
>
> ```bash claude-code-unix.sh theme={"theme":{"light":"github-light","dark":"css-variables"}}
> export ANTHROPIC_BASE_URL=https://api.tokios.com
> export ANTHROPIC_API_KEY=sk-tok-YOUR_KEY
> claude --model gemma-tunnel
> ```

> [!TIP]
>
> Always pass `--model` with your registered model name. Claude Code's model picker only lists `claude*` ids, so it won't show your Tokios models — naming it explicitly routes the request to your deployment.

## Persist the configuration

To avoid exporting the variables in every new terminal session, add them to Claude Code's own settings file, your shell profile, or a `.env` file.

**\~/.claude/settings.json**

The most portable option, because it travels with your Claude Code config rather than your shell. Use `.claude/settings.json` inside a project to scope it to that project instead:

```json ~/.claude/settings.json theme={"theme":{"light":"github-light","dark":"css-variables"}}
{
  "env": {
    "ANTHROPIC_BASE_URL": "https://api.tokios.com",
    "ANTHROPIC_API_KEY": "sk-tok-YOUR_KEY"
  }
}
```

> [!NOTE]
>
> Claude Code reads this file at startup, so a session that is already open won't pick up an edit until you restart it. If your key is rejected here, swap `ANTHROPIC_API_KEY` for `ANTHROPIC_AUTH_TOKEN`, which sets the raw `Authorization: Bearer` value — the form gateways that issue their own keys expect.

**\~/.bashrc or \~/.zshrc**

Open your shell profile and append:

```bash theme={"theme":{"light":"github-light","dark":"css-variables"}}
export ANTHROPIC_BASE_URL=https://api.tokios.com
export ANTHROPIC_API_KEY=sk-tok-YOUR_KEY
```

Then reload it:

```bash theme={"theme":{"light":"github-light","dark":"css-variables"}}
source ~/.bashrc   # or source ~/.zshrc
```

**.env file**

If your workflow supports `.env` files (for example, via `direnv` or a shell plugin), create a `.env` in your project root:

```bash .env theme={"theme":{"light":"github-light","dark":"css-variables"}}
ANTHROPIC_BASE_URL=https://api.tokios.com
ANTHROPIC_API_KEY=sk-tok-YOUR_KEY
```

Load it before starting Claude Code:

```bash theme={"theme":{"light":"github-light","dark":"css-variables"}}
export $(cat .env | xargs) && claude --model gemma-tunnel
```

## Verify the connection

Run a quick one-shot prompt to confirm that Claude Code is reaching your local model through Tokios:

```bash theme={"theme":{"light":"github-light","dark":"css-variables"}}
claude --model gemma-tunnel -p "Say hello"
```

Expected output:

```text theme={"theme":{"light":"github-light","dark":"css-variables"}}
Hello! How can I help you today?
```

If you see a response, your requests are flowing through the Tokios gateway to your local model successfully.

> [!NOTE]
>
> Claude Code sends the request in Anthropic messages format. Tokios translates it to whatever your local backend expects and streams the response back.


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.