For the complete documentation index, see llms.txt. This page is also available as Markdown.

Claude Code CLI

Claude Code is Anthropic's official AI coding assistant that runs in your terminal. TensorX 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 TensorX

  • 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 TensorX API key (get one here)

  • Terminal access (macOS, Linux, or Windows with WSL)

Installation

Install Claude Code globally:

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

Verify installation:


Quick Start - No Account Required

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

Example with MiniMax-M2

Print mode (-p) outputs the response and exits. For interactive development sessions with file editing and bash commands, see Interactive Mode Setup below.


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:

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 TensorX.

Step 2: Configure TensorX

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

Step 3: Start Using Claude Code

Navigate to your project and run:

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


Available 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:

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 TensorX 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 TensorX. 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 TensorX.

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:


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 TensorX. 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 TensorX 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.

Q: Does TensorX support the Anthropic Messages API (/v1/messages)?

Yes. TensorX exposes an Anthropic-compatible /v1/messages endpoint at https://api.tensorx.ai, which is what Claude Code targets when you set ANTHROPIC_BASE_URL. Standard per-key rate limits apply (see Rate Limits); there is no separate endpoint to enable.

Last updated

Was this helpful?