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

# Claude Code on Tensormesh

> Drive open-weight models with stock Anthropic Claude Code CLI against Tensormesh — sign up, set three env vars, and run.

Get stock [Claude Code CLI](https://www.npmjs.com/package/@anthropic-ai/claude-code) driving open-weight models against Tensormesh in 5 minutes. No config file, no proxy — just three environment variables. Every model listed below supports the full Claude Code flow today (chat + tool use); `MiniMaxAI/MiniMax-M2.5` is the recommended default.

## Quick Links

<CardGroup cols={3}>
  <Card title="Sign up / Log in" icon="user-plus" href="https://app.tensormesh.ai/login">
    Create your Tensormesh account with Google or GitHub.
  </Card>

  <Card title="Get an API key" icon="key" href="https://app.tensormesh.ai/profile?tab=api">
    Generate an `ak-...` key under **Profile → API keys**.
  </Card>

  <Card title="Install Claude Code" icon="download" href="https://www.npmjs.com/package/@anthropic-ai/claude-code">
    `npm install -g @anthropic-ai/claude-code` — verified against 2.1.145+.
  </Card>

  <Card title="Supported models" icon="list" href="#supported-models">
    Matrix of Claude-Code-ready models on Tensormesh serverless.
  </Card>

  <Card title="Get support" icon="envelope" href="mailto:saas-support@tensormesh.ai">
    Email [saas-support@tensormesh.ai](mailto:saas-support@tensormesh.ai) for help.
  </Card>
</CardGroup>

## TL;DR

Three environment variables, no config file:

```bash theme={null}
# Step 1 — install Claude Code CLI (skip if already installed)
npm install -g @anthropic-ai/claude-code

# Step 2 — point Claude Code at Tensormesh (add to ~/.zshrc or ~/.bashrc to persist)
export ANTHROPIC_BASE_URL=https://serverless.tensormesh.ai
export ANTHROPIC_API_KEY=ak-...

# Run it — --bare tells Claude Code to authenticate strictly via
# ANTHROPIC_API_KEY (no OAuth/keychain fallback). Required for the
# interactive TUI when using a custom base URL.
claude --bare
```

That's the full setup — no `config.toml`, no PATH change, no proxy.

<Tip>
  Running `claude --bare` every time gets old. Persist it as an alias so plain `claude` Just Works:

  ```bash theme={null}
  echo "alias claude='claude --bare'" >> ~/.zshrc
  source ~/.zshrc
  ```

  For one-shot prompts (`claude -p "..."`), the `--bare` flag isn't strictly required — the Anthropic SDK uses `ANTHROPIC_API_KEY` in non-interactive mode. But keeping it consistent is cleaner.
</Tip>

## Prerequisites

* **Claude Code CLI** installed via `npm install -g @anthropic-ai/claude-code`. Verified against `2.1.145` (chat + tool use end-to-end); forward-compatible with later versions barring upstream Claude Code breaking changes.
* **A Tensormesh account** with an API key (`ak-...`). [Sign up](https://app.tensormesh.ai/login), then visit [Profile → API keys](https://app.tensormesh.ai/profile?tab=api).
* **macOS or Linux**, bash or zsh. Windows binaries ship in recent Claude Code releases but aren't currently tested by Tensormesh.

<Note>
  Tensormesh accepts Claude Code's native `x-api-key` header. You do **not** need to use `claude login` or the Anthropic OAuth flow — those are for Anthropic-hosted models. Setting `ANTHROPIC_API_KEY` is sufficient.
</Note>

<Note>
  You do **not** need to run any local infrastructure. Tensormesh handles the full Anthropic Messages API server-side, so stock `claude` pointed at `serverless.tensormesh.ai` is the complete setup.
</Note>

## Supported models

| Model                                     | Claude Code status | Notes                               |
| ----------------------------------------- | ------------------ | ----------------------------------- |
| `MiniMaxAI/MiniMax-M2.5`                  | ✓ chat + tool use  | Recommended default; 192K context   |
| `MiniMaxAI/MiniMax-M2.7`                  | ✓ chat + tool use  | Newer MiniMax release; 200K context |
| `openai/gpt-oss-120b`                     | ✓ chat + tool use  | Reasoning + tools, 128K context     |
| `openai/gpt-oss-20b`                      | ✓ chat + tool use  | Reasoning + tools, 128K context     |
| `Qwen/Qwen3-30B-A3B`                      | ✓ chat + tool use  | Reasoning + tools, 40K context      |
| `Qwen/Qwen3-Coder-30B-A3B-Instruct`       | ✓ chat + tool use  | Coding-tuned, 256K context          |
| `Qwen/Qwen3-Coder-480B-A35B-Instruct-FP8` | ✓ chat + tool use  | Coding-tuned, 256K context          |
| `moonshotai/Kimi-K2.6`                    | ✓ chat + tool use  | Reasoning + tools, 32K context      |
| `lukealonso/GLM-5.1-NVFP4-MTP`            | ✓ chat + tool use  | Reasoning + tools, 198K context     |
| `deepseek-ai/DeepSeek-V4-Flash`           | ✓ chat + tool use  | Long-context, **1M tokens**         |

<Tip>
  `GET /v1/models` reflects what's currently available — Tensormesh hides any model that's temporarily cold. If you see fewer models than the table lists, retry after 30–60 seconds; the first request to a cold model warms it up.
</Tip>

For non-Claude-Code clients (Python SDK, curl, custom apps), every model in the table works fine via `/v1/messages` and `/v1/chat/completions` as well. The matrix above is calibrated specifically for stock Claude Code CLI.

## Switching models

Claude Code defaults to a Claude-family model if `--model` is omitted. To use a Tensormesh model, pass `--model` on the command line. Per-invocation overrides don't change any defaults — they only affect the current run.

### Per-invocation (no env edit)

```bash theme={null}
claude --model MiniMaxAI/MiniMax-M2.5                            # MiniMax (recommended default)
claude --model MiniMaxAI/MiniMax-M2.7                            # newer MiniMax, 200K
claude --model openai/gpt-oss-120b                               # reasoning, large
claude --model openai/gpt-oss-20b                                # reasoning, small
claude --model Qwen/Qwen3-30B-A3B                                # reasoning, 40K
claude --model Qwen/Qwen3-Coder-30B-A3B-Instruct                 # coder, 256K
claude --model Qwen/Qwen3-Coder-480B-A35B-Instruct-FP8           # coder, 256K
claude --model moonshotai/Kimi-K2.6                              # Kimi reasoning, 32K
claude --model lukealonso/GLM-5.1-NVFP4-MTP                      # GLM 5.1, 198K
claude --model deepseek-ai/DeepSeek-V4-Flash                     # DeepSeek, 1M context
```

### Set a default for every session

The cleanest way to pin a Tensormesh model as your everyday default is `ANTHROPIC_MODEL`, persisted alongside the other two env vars:

```bash theme={null}
# Add to ~/.zshrc or ~/.bashrc
export ANTHROPIC_BASE_URL=https://serverless.tensormesh.ai
export ANTHROPIC_API_KEY=ak-...
export ANTHROPIC_MODEL=MiniMaxAI/MiniMax-M2.5
```

After reloading your shell, `claude` (no `--model`) uses the model above. Per-invocation `--model` still overrides.

### Optional: shell aliases for frequent switching

If you switch models often, add aliases to your `~/.zshrc` (zsh) or `~/.bashrc` (bash):

```bash theme={null}
alias cc-mini='claude --model MiniMaxAI/MiniMax-M2.5'
alias cc-gpt='claude --model openai/gpt-oss-120b'
alias cc-qwen='claude --model Qwen/Qwen3-30B-A3B'
alias cc-coder='claude --model Qwen/Qwen3-Coder-480B-A35B-Instruct-FP8'
alias cc-coder-small='claude --model Qwen/Qwen3-Coder-30B-A3B-Instruct'
alias cc-kimi='claude --model moonshotai/Kimi-K2.6'
alias cc-deepseek='claude --model deepseek-ai/DeepSeek-V4-Flash'
```

Reload your shell, then run `cc-coder` from any directory to start a Claude Code session against that model.

## Setup

The three steps from the TL;DR, with explanation.

<Steps>
  <Step title="Install Claude Code CLI">
    ```bash theme={null}
    npm install -g @anthropic-ai/claude-code
    ```

    This installs the `claude` command to your global `node_modules/bin`. Verify with `claude --version`.
  </Step>

  <Step title="Point Claude Code at Tensormesh">
    Set two environment variables in your shell (add them to `~/.zshrc` or `~/.bashrc` to persist):

    ```bash theme={null}
    export ANTHROPIC_BASE_URL=https://serverless.tensormesh.ai
    export ANTHROPIC_API_KEY=ak-...
    ```

    `ANTHROPIC_BASE_URL` redirects the Anthropic SDK away from `api.anthropic.com` to Tensormesh. `ANTHROPIC_API_KEY` is sent as the `x-api-key` header on every request (Anthropic-SDK convention).

    <Tabs>
      <Tab title="Fresh setup">
        Add both lines to `~/.zshrc` or `~/.bashrc`, then `source` the file or open a new terminal.
      </Tab>

      <Tab title="Already using Claude Code with Anthropic">
        If you currently use Claude Code against Anthropic's hosted models, just override the two variables in the shell where you want Tensormesh:

        ```bash theme={null}
        ANTHROPIC_BASE_URL=https://serverless.tensormesh.ai \
        ANTHROPIC_API_KEY=ak-... \
          claude
        ```

        Or set them per-shell when working on a Tensormesh-targeted project, and unset for Claude work. The two providers are mutually exclusive within a single `claude` invocation.
      </Tab>
    </Tabs>

    Don't have a key yet? [Generate one in your profile](https://app.tensormesh.ai/profile?tab=api).
  </Step>

  <Step title="(Optional) pin a default model">
    Without `ANTHROPIC_MODEL`, Claude Code defaults to a Claude-family model, which won't resolve on Tensormesh. Either pass `--model` on every invocation, or set the default once:

    ```bash theme={null}
    export ANTHROPIC_MODEL=MiniMaxAI/MiniMax-M2.5
    ```

    Persist alongside the other two env vars.
  </Step>
</Steps>

## Usage

```bash theme={null}
# Interactive TUI (works in any directory)
# --bare is required: it tells Claude Code to authenticate strictly
# via ANTHROPIC_API_KEY. Without it, the TUI tries OAuth/keychain
# first and shows "Not logged in" even when your env vars are set.
claude --bare

# One-shot prompt — --bare optional here; Anthropic SDK uses
# ANTHROPIC_API_KEY by default in non-interactive mode.
claude -p "Explain what foo.py does"

# Interactive TUI + bypass all permission prompts (sandbox use only —
# see Permission modes below)
claude --bare --dangerously-skip-permissions
```

<Note>
  The `--bare` requirement for the TUI is a property of Claude Code's auth precedence — when a custom `ANTHROPIC_BASE_URL` is set, Claude Code's interactive mode still tries OAuth/keychain first by default. `--bare` switches it to strict env-var auth. The alias in the [TL;DR](#tldr) tip is the simplest way to make this transparent for daily use.
</Note>

### Slash commands in TUI

Inside an interactive `claude` session, type `/` to bring up the command picker (autocomplete). The set of commands varies slightly between Claude Code versions, so the picker is the source of truth. To exit a session cleanly, type `/exit` or press `Ctrl-D` twice.

### Permission and sandbox modes

By default, Claude Code asks for confirmation before each file write, shell command, and tool call. Three modes:

| Mode                             | When to use                                                                                                                                                                                                                                                     |
| -------------------------------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| *(no flag)*                      | Default — prompts before each potentially-impactful action. Safest for unfamiliar prompts.                                                                                                                                                                      |
| `--dangerously-skip-permissions` | Bypasses all permission checks (writes, shell, tool calls). Per Anthropic's guidance, **recommended only for sandboxes with no internet access** — i.e. an isolated container or VM where a misbehaving agent can't reach outside resources.                    |
| `--bare`                         | Strips hooks, plugins, auto-memory, keychain reads, and `CLAUDE.md` auto-discovery. Auth is restricted to `ANTHROPIC_API_KEY` (no OAuth or keychain fallback), which is the path Tensormesh uses — so `--bare` is the most predictable mode for scripts and CI. |

<Note>
  `--bare` is the recommended mode when calling Claude Code from automated pipelines — fewer side effects, more deterministic behavior, no surprise interactive prompts, and a single explicit auth path. Combine with `-p` for one-shot prompts.
</Note>

### Recommended settings

* **`MiniMaxAI/MiniMax-M2.5` is the most reliable all-purpose default** for Claude Code on Tensormesh. It handles the full agentic loop (read → edit → run shell → iterate) and stays consistent across long multi-turn sessions (verified through 10+ turns of stateful workflow without drift).
* **For pure code generation or editing** (e.g. write a function, refactor a file, translate snippets), `Qwen/Qwen3-Coder-30B-A3B-Instruct` (256K) or `Qwen/Qwen3-Coder-480B-A35B-Instruct-FP8` are coding-tuned alternatives. They're strong at code-generation work but can be more brittle than MiniMax on composite tool-orchestration prompts (e.g. "create file X, then run Y, then summarize") — if you hit unexpected output, retry with a simpler one-step prompt or fall back to MiniMax.
* **For very long contexts**, `deepseek-ai/DeepSeek-V4-Flash` (1M tokens) handles inputs that won't fit elsewhere.
* **Stay in the default (prompted) permission mode for code you don't fully trust.** Reach for `--dangerously-skip-permissions` only inside a sandboxed environment with no internet access, per Anthropic's own guidance.

## Troubleshooting

<Note>
  When a request fails, the meaningful error message is the most recent line printed by Claude Code. Match that line against the Symptom column below.
</Note>

| Symptom (the actual error line)                                                                                                  | Likely cause                                                                                                                                                                                                                                                                                     | Fix                                                                                                                                                                                                                                                                                                                                                                                                                    |
| -------------------------------------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `command not found: claude`                                                                                                      | Claude Code CLI not installed                                                                                                                                                                                                                                                                    | `npm install -g @anthropic-ai/claude-code`                                                                                                                                                                                                                                                                                                                                                                             |
| `Not logged in · Please run /login` *(in the interactive TUI, despite `ANTHROPIC_API_KEY` being set)*                            | Claude Code's interactive TUI tries OAuth/keychain before env-var auth. Without `--bare`, your env-var key is ignored.                                                                                                                                                                           | Run `claude --bare` instead of plain `claude`. To make this the default, alias it: `echo "alias claude='claude --bare'" >> ~/.zshrc && source ~/.zshrc`.                                                                                                                                                                                                                                                               |
| `API Error: 500 Internal Server Error` *(after Claude Code's "try again" suggestion)*                                            | Most often an **invalid or wrong-environment API key**. Authentication failures are surfaced as 5xx, which Claude Code wraps with its retry-suggestion text.                                                                                                                                     | Verify your key matches your target environment (`ak-dev-...`, `ak-staging-...`, `ak-live-...`). Quickest probe: a real POST that exercises auth, e.g. `curl -sS -X POST -H "x-api-key: $ANTHROPIC_API_KEY" -H "Content-Type: application/json" -d '{"model":"MiniMaxAI/MiniMax-M2.5","max_tokens":5,"messages":[{"role":"user","content":"hi"}]}' https://serverless.tensormesh.ai/v1/messages` — HTTP 500 = bad key. |
| `There's an issue with the selected model (<slug>). It may not exist or you may not have access to it.`                          | Three things can produce this message: (1) typo in the model slug; (2) the model is currently cold and Tensormesh is hiding it from `/v1/models`; (3) `ANTHROPIC_BASE_URL` has a `/v1` suffix (the Anthropic SDK then double-appends `/v1`, hits an unknown path, surfaces it as a model error). | Check the [supported models](#supported-models) matrix against your spelling. Confirm `echo $ANTHROPIC_BASE_URL` returns `https://serverless.tensormesh.ai` **without** a `/v1` suffix (a trailing slash is fine). If the model is in the table and the URL is clean, wait 30–60 seconds and retry to warm the model.                                                                                                  |
| `Maximum context length is N tokens`                                                                                             | Conversation grew past the model's context window                                                                                                                                                                                                                                                | Start a fresh session (type `/` in the TUI to see the available clear/exit commands in your version), or switch to a larger-context model (e.g., `deepseek-ai/DeepSeek-V4-Flash` for 1M tokens).                                                                                                                                                                                                                       |
| Same "It may not exist or you may not have access to it" message but the slug looks like `claude-opus-4-7…` or `claude-sonnet-…` | `ANTHROPIC_MODEL` not set and `--model` not passed — Claude Code defaulted to its own Claude-family model, which Tensormesh doesn't serve.                                                                                                                                                       | Either set `ANTHROPIC_MODEL` (see [Setup](#setup)) or pass `--model <slug>` on every invocation.                                                                                                                                                                                                                                                                                                                       |
| `claude` sits silent for many seconds after a prompt, no error                                                                   | `ANTHROPIC_BASE_URL` points to an unreachable host                                                                                                                                                                                                                                               | Confirm `echo $ANTHROPIC_BASE_URL` returns `https://serverless.tensormesh.ai`. If you set it to a private URL or typo'd, requests will block until the SDK's network timeout.                                                                                                                                                                                                                                          |

Still stuck? Email [saas-support@tensormesh.ai](mailto:saas-support@tensormesh.ai) with the meaningful error line and the output of `claude --version`.

## Rollback / uninstall

To remove Tensormesh from your Claude Code setup:

1. Unset the three environment variables from your shell, and remove them from `~/.zshrc` / `~/.bashrc`:

   ```bash theme={null}
   unset ANTHROPIC_BASE_URL ANTHROPIC_API_KEY ANTHROPIC_MODEL
   ```

2. Claude Code will resume targeting Anthropic's hosted API on its next invocation.

All actions reverse the setup steps above. No config files to clean up.
