# Claude Code CLI

Claude Code is Anthropic's official AI coding assistant that runs in your terminal. Tensorix provides an API-compatible endpoint allowing you to use Claude Code with open-source models like **GLM-5.1** and **MiniMax-M2** at a fraction of the cost.

## Key Benefits

* 🚀 **Powerful open-source models** - GLM-5.1, MiniMax-M2.5, MiniMax-M2, and more
* 💰 **Pay-as-you-go pricing** through Tensorix
* ✨ **Full Claude Code features** - file editing, bash commands, multi-turn conversations
* 🇪🇺 **EU-hosted infrastructure** with zero data retention

## Prerequisites

* Node.js 18 or newer
* A Tensorix API key ([get one here](https://app.tensorix.ai))
* Terminal access (macOS, Linux, or Windows with WSL)

## Installation

Install Claude Code globally:

```bash
npm install -g @anthropic-ai/claude-code
```

Verify installation:

```bash
claude --version
```

***

## Quick Start - No Account Required

For quick queries and scripting, use **print mode** which doesn't require any Anthropic account.

### Example with GLM-5.1 (Recommended)

```bash
export ANTHROPIC_API_KEY="<YOUR_TENSORIX_API_KEY>"
export ANTHROPIC_BASE_URL="https://api.tensorix.ai"
export ANTHROPIC_MODEL="z-ai/glm-5.1"

claude -p "Explain what a REST API is"
```

### Example with MiniMax-M2

```bash
export ANTHROPIC_API_KEY="<YOUR_TENSORIX_API_KEY>"
export ANTHROPIC_BASE_URL="https://api.tensorix.ai"
export ANTHROPIC_MODEL="minimax/minimax-m2"

claude -p "Write a Python function to reverse a string"
```

{% hint style="info" %}
Print mode (`-p`) outputs the response and exits. For interactive development sessions with file editing and bash commands, see **Interactive Mode Setup** below.
{% endhint %}

***

## Interactive Mode Setup

Interactive mode provides the full Claude Code experience with file editing, bash commands, and multi-turn conversations. Requires **one-time** free Anthropic account setup.

### Step 1: Initial Setup (One-Time Only)

Run `claude` and complete the OAuth login:

```bash
claude
```

Select **"Anthropic Console account"** when prompted and follow the browser login. A free Anthropic account works - you won't be charged by Anthropic as all requests route through Tensorix.

### Step 2: Configure Tensorix

Create or edit `~/.claude/settings.json`:

{% tabs %}
{% tab title="GLM-5.1 (Recommended)" %}

```json
{
  "env": {
    "ANTHROPIC_BASE_URL": "https://api.tensorix.ai",
    "ANTHROPIC_AUTH_TOKEN": "<YOUR_TENSORIX_API_KEY>",
    "ANTHROPIC_MODEL": "z-ai/glm-5.1",
    "ANTHROPIC_SMALL_FAST_MODEL": "z-ai/glm-5.1",
    "ANTHROPIC_DEFAULT_HAIKU_MODEL": "z-ai/glm-5.1",
    "ANTHROPIC_DEFAULT_SONNET_MODEL": "z-ai/glm-5.1",
    "ANTHROPIC_DEFAULT_OPUS_MODEL": "z-ai/glm-5.1",
    "API_TIMEOUT_MS": "3000000",
    "CLAUDE_CODE_DISABLE_NONESSENTIAL_TRAFFIC": "1"
  }
}
```

{% endtab %}

{% tab title="MiniMax-M2.5" %}

```json
{
  "env": {
    "ANTHROPIC_BASE_URL": "https://api.tensorix.ai",
    "ANTHROPIC_AUTH_TOKEN": "<YOUR_TENSORIX_API_KEY>",
    "ANTHROPIC_MODEL": "minimax/minimax-m2.5",
    "ANTHROPIC_SMALL_FAST_MODEL": "minimax/minimax-m2.5",
    "ANTHROPIC_DEFAULT_HAIKU_MODEL": "minimax/minimax-m2.5",
    "ANTHROPIC_DEFAULT_SONNET_MODEL": "minimax/minimax-m2.5",
    "ANTHROPIC_DEFAULT_OPUS_MODEL": "minimax/minimax-m2.5",
    "API_TIMEOUT_MS": "3000000",
    "CLAUDE_CODE_DISABLE_NONESSENTIAL_TRAFFIC": "1"
  }
}
```

{% endtab %}

{% tab title="MiniMax-M2" %}

```json
{
  "env": {
    "ANTHROPIC_BASE_URL": "https://api.tensorix.ai",
    "ANTHROPIC_AUTH_TOKEN": "<YOUR_TENSORIX_API_KEY>",
    "ANTHROPIC_MODEL": "minimax/minimax-m2",
    "ANTHROPIC_SMALL_FAST_MODEL": "minimax/minimax-m2",
    "ANTHROPIC_DEFAULT_HAIKU_MODEL": "minimax/minimax-m2",
    "ANTHROPIC_DEFAULT_SONNET_MODEL": "minimax/minimax-m2",
    "ANTHROPIC_DEFAULT_OPUS_MODEL": "minimax/minimax-m2",
    "API_TIMEOUT_MS": "3000000",
    "CLAUDE_CODE_DISABLE_NONESSENTIAL_TRAFFIC": "1"
  }
}
```

{% endtab %}
{% endtabs %}

### Step 3: Start Using Claude Code

Navigate to your project and run:

```bash
cd /path/to/your/project
claude
```

{% hint style="warning" %}
You'll see a warning about auth conflict - **this is normal and can be ignored.** All requests now route through Tensorix!
{% endhint %}

### Why All Model Variables Are Required

Claude Code uses different models for different internal tasks:

| Variable                         | Purpose                             |
| -------------------------------- | ----------------------------------- |
| `ANTHROPIC_MODEL`                | Main model for conversations        |
| `ANTHROPIC_SMALL_FAST_MODEL`     | Quick background tasks              |
| `ANTHROPIC_DEFAULT_HAIKU_MODEL`  | Token counting and small operations |
| `ANTHROPIC_DEFAULT_SONNET_MODEL` | Standard coding tasks               |
| `ANTHROPIC_DEFAULT_OPUS_MODEL`   | Complex reasoning tasks             |

{% hint style="danger" %}
**Important:** If you don't set all of these, Claude Code will try to call `claude-haiku-4-5` or other Anthropic models which don't exist on Tensorix, causing errors.
{% endhint %}

***

## Available Models

### Recommended Models

| Model            | ID                     | Best For                        |
| ---------------- | ---------------------- | ------------------------------- |
| **GLM-5.1** ⭐    | `z-ai/glm-5.1`         | Coding, reasoning, general use  |
| **MiniMax-M2.5** | `minimax/minimax-m2.5` | Reasoning, functions            |
| **Kimi-K2.5**    | `moonshotai/kimi-k2.5` | Vision, functions, long context |
| **MiniMax-M2**   | `minimax/minimax-m2`   | Coding, fast responses          |

### Other Supported Models

| Model         | ID                            |
| ------------- | ----------------------------- |
| DeepSeek V3.1 | `deepseek/deepseek-chat-v3.1` |
| DeepSeek R1   | `deepseek/deepseek-r1-0528`   |
| MiniMax M2.5  | `minimax/minimax-m2.5`        |

***

## Switching Models

To switch models, update **all** model variables in `~/.claude/settings.json`:

```json
{
  "env": {
    "ANTHROPIC_BASE_URL": "https://api.tensorix.ai",
    "ANTHROPIC_AUTH_TOKEN": "<YOUR_TENSORIX_API_KEY>",
    "ANTHROPIC_MODEL": "<MODEL_ID>",
    "ANTHROPIC_SMALL_FAST_MODEL": "<MODEL_ID>",
    "ANTHROPIC_DEFAULT_HAIKU_MODEL": "<MODEL_ID>",
    "ANTHROPIC_DEFAULT_SONNET_MODEL": "<MODEL_ID>",
    "ANTHROPIC_DEFAULT_OPUS_MODEL": "<MODEL_ID>",
    "API_TIMEOUT_MS": "3000000",
    "CLAUDE_CODE_DISABLE_NONESSENTIAL_TRAFFIC": "1"
  }
}
```

Replace `<MODEL_ID>` with your chosen model (e.g., `z-ai/glm-5.1`).

After editing, **start a new Claude Code session** for changes to take effect.

***

## Troubleshooting

### "claude-haiku-4-5 not found" or similar model errors

**Solution:** You haven't set all model aliases. Ensure your `settings.json` includes:

* `ANTHROPIC_DEFAULT_HAIKU_MODEL`
* `ANTHROPIC_DEFAULT_SONNET_MODEL`
* `ANTHROPIC_DEFAULT_OPUS_MODEL`
* `ANTHROPIC_SMALL_FAST_MODEL`

All should be set to your chosen Tensorix model.

### Auth conflict warning

**Message:** `⚠Auth conflict: Both a token (ANTHROPIC_AUTH_TOKEN) and an API key...`

**Solution:** This warning is normal and can be ignored. Claude Code is using your `ANTHROPIC_AUTH_TOKEN` from `settings.json` which points to Tensorix. Your requests are routing correctly.

### OAuth login still required after configuration

**Solution:** Interactive mode requires a one-time Anthropic OAuth. This is a Claude Code requirement. After completing it once, your `settings.json` config will route all actual API requests through Tensorix.

For scripting without OAuth, use print mode: `claude -p "your prompt"`

### Configuration not taking effect

**Solution:**

1. Close all Claude Code sessions
2. Verify `~/.claude/settings.json` has correct JSON syntax
3. Open a new terminal window
4. Run `claude` again

### Timeout errors

**Solution:** Increase `API_TIMEOUT_MS` in your `settings.json`:

```json
"API_TIMEOUT_MS": "6000000"
```

***

## FAQ

**Q: Do I need an Anthropic account?**

For interactive mode, yes - a free account for one-time OAuth. For print mode (`-p` flag), no account is needed.

**Q: Will I be charged by Anthropic?**

No. All API requests route through Tensorix. The Anthropic OAuth is only for authentication, not billing.

**Q: Why do I need to set all the model variables?**

Claude Code uses different models for different internal tasks (token counting, background operations, etc.). Setting all aliases ensures everything routes to your chosen Tensorix model.

**Q: Can I use different models for different tasks?**

Yes! You can set `ANTHROPIC_DEFAULT_HAIKU_MODEL` to a faster/cheaper model and `ANTHROPIC_DEFAULT_OPUS_MODEL` to a more capable one.

**Q: What's the difference between ANTHROPIC\_API\_KEY and ANTHROPIC\_AUTH\_TOKEN?**

Both work, but `ANTHROPIC_AUTH_TOKEN` is preferred for custom endpoints. Use `ANTHROPIC_AUTH_TOKEN` in `settings.json`.


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.tensorix.ai/ai-coding-assistants/claude-code-cli.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
