Skip to main content
Claude Code Main Interface

Prerequisites

Claude Code is a command-line AI programming assistant by Anthropic that supports direct AI conversation, code generation, and debugging in the terminal. By connecting to APIMart, you can use multiple models including GPT, Claude, and Gemini within Claude Code. Before you begin, make sure you have:
  1. Obtained an APIMart API Key Log in to the APIMart Console to get your API key (starts with sk-)
Tip: If you don’t have an APIMart account yet, please register at APIMart first and obtain your API key.

Step 1: Install Claude Code

Choose any of the following methods to install:

Verify Installation

After installation, run the following command to confirm:
claude --version
If a version number is displayed (e.g., 1.x.x), the installation was successful.

Step 2: Configure APIMart API

Three configuration methods are available. Choose the one that suits your workflow. The most stable approach — configure once and it persists. 1. Locate the configuration directory:
  • Windows: Press Win + R, enter %userprofile%\.claude
  • macOS: Press Command + Shift + G, enter ~/.claude
  • Linux: Navigate to ~/.claude
If the directory doesn’t exist, run claude once in the terminal and press Ctrl + C to exit — the directory will be created automatically.
2. Create or edit the settings.json file:
{
  "env": {
    "ANTHROPIC_BASE_URL": "https://api.apimart.ai",
    "ANTHROPIC_AUTH_TOKEN": "sk-xxxxxxxxxxxx",
    "ANTHROPIC_MODEL": "claude-sonnet-4-6-apimart",
    "CLAUDE_CODE_DISABLE_NONESSENTIAL_TRAFFIC": "1"
  }
}
ParameterDescription
ANTHROPIC_BASE_URLAPIMart API address, fixed as https://api.apimart.ai
ANTHROPIC_AUTH_TOKENYour APIMart API key (starts with sk-)
ANTHROPIC_MODELDefault model to use, choose from the model list below
CLAUDE_CODE_DISABLE_NONESSENTIAL_TRAFFICSet to 1 to reduce non-essential network requests
Save the file and restart Claude Code to apply.

Method 2: Permanent Environment Variables

Write configuration to system environment so all terminal windows load it automatically.
echo 'export ANTHROPIC_BASE_URL="https://api.apimart.ai"' >> ~/.zshrc
echo 'export ANTHROPIC_API_KEY="sk-xxxxxxxxxxxx"' >> ~/.zshrc
echo 'export ANTHROPIC_MODEL="claude-sonnet-4-6-apimart"' >> ~/.zshrc
source ~/.zshrc

Method 3: Temporary Environment Variables

Suitable for quick testing — configuration is lost when the terminal is closed.
export ANTHROPIC_API_KEY="sk-xxxxxxxxxxxx"
export ANTHROPIC_MODEL="claude-sonnet-4-6-apimart"
export ANTHROPIC_BASE_URL="https://api.apimart.ai"
claude
Temporary environment variables only work in the current terminal window. You’ll need to set them again after switching windows or closing the terminal.

Step 3: Start Using

Verify Configuration

Launch Claude Code and send a simple message to confirm:
claude "Hello"
If you receive an AI response, the configuration is successful. If you see 401, 403, or other errors, refer to the FAQ below.

Usage Modes

Claude Code offers two interaction modes:
  • Interactive mode: Run claude for continuous conversation, ideal for complex tasks
  • Single command: Run claude "your question" for a one-off response, ideal for quick queries

Supported Models

APIMart supports the full Claude model series. You can flexibly switch based on your needs:
Model NameFeaturesRecommended Use
claude-opus-4-6Strongest overall capabilityComplex architecture, difficult debugging
claude-sonnet-4-6Balanced performance and speedDaily programming, code generation
claude-opus-4-5-20251101Advanced reasoningComplex code, deep analysis
claude-sonnet-4-5-20250929Excellent code capabilityAlgorithm design, code optimization
claude-haiku-4-5-20251001Ultra-fast responseQuick Q&A, code snippets
All models above support a Thinking (extended reasoning) version — append -thinking to the model ID, e.g., claude-opus-4-6-thinking. Thinking mode is ideal for complex tasks requiring deep reasoning.

APIMart Discounted Models

APIMart offers exclusive discounted models at only 20% of the official price, with the same capabilities. Simply append -apimart to the model ID:
Discounted Model NameFeatures
claude-opus-4-6-apimartStrongest overall capability
claude-sonnet-4-6-apimartBalanced performance and speed
claude-opus-4-5-20251101-apimartAdvanced reasoning
claude-sonnet-4-5-20250929-apimartExcellent code capability
claude-haiku-4-5-20251001-apimartUltra-fast response
Thinking versions are also available, e.g., claude-opus-4-6-thinking-apimart, claude-sonnet-4-6-thinking-apimart, etc.
Model Recommendations:
  • 💰 Best Value: claude-sonnet-4-6-apimart — Best choice for daily programming, only 20% of official price
  • 🚀 High Performance: claude-opus-4-6-apimart — For the most complex code and architecture challenges
  • Fast Response: claude-haiku-4-5-20251001-apimart — When you need instant feedback
  • 🧠 Deep Thinking: claude-opus-4-6-thinking-apimart — When deep reasoning is needed
To switch models, use the /model command in interactive mode, or modify the ANTHROPIC_MODEL field in your configuration and restart.

Common Commands

Here are frequently used commands and shortcuts in Claude Code:
CommandDescription
claudeEnter interactive mode
claude "question"Single query
claude --versionCheck version
/modelSwitch model in interactive mode
/helpView help information
Ctrl + CExit interactive mode

FAQ

Q1: Still seeing the login selection page after configuration?

If “Select login method” still appears after startup, the configuration hasn’t taken effect. Troubleshooting steps:
  1. Using settings.json: Check if the file path is correct
    • Windows: C:\Users\<username>\.claude\settings.json
    • macOS / Linux: ~/.claude/settings.json
  2. Using environment variables: Make sure you launched Claude Code from the same terminal window where you set the variables
  3. Check JSON format: Ensure brackets, commas, and quotes are all correct

Q2: Getting 401 / 403 errors?

Error CodeMeaningSolution
401 UnauthorizedAPI key missing or invalidCheck if the key is correct and starts with sk-
403 ForbiddenInsufficient permissions or expired keyGo to Console to verify key status
Also ensure ANTHROPIC_BASE_URL is set to https://api.apimart.ai, not the official Anthropic address.

Q3: “Unable to connect” error?

This means Claude Code failed to connect to the API service.
  1. Check your network connection
  2. Verify ANTHROPIC_BASE_URL is configured correctly
  3. If using a proxy, ensure it allows access to api.apimart.ai

Q4: “Auth conflict” error?

If you see a message like:
Auth conflict: Both a token (claude.ai) and an API key (ANTHROPIC_API_KEY) are set.
This means you’re logged into claude.ai and have an API Key set at the same time, causing a conflict. Solution: Run /logout in Claude Code interactive mode to sign out of claude.ai, keeping only the API Key configuration.

Q5: max_tokens error when using non-Claude models?

If you see an error like:
max_tokens is too large: 32000. This model supports at most 16384 completion tokens.
This is because Claude Code sends requests with Claude model parameters by default (32000 tokens), while some non-Claude models (e.g., gpt-4o) have lower token limits. Solution: Switch to a Claude model (e.g., claude-sonnet-4-6-apimart), which is natively compatible with Claude Code and won’t cause this issue.

Q6: Slow response?

  1. Switch to a faster model (e.g., claude-haiku-4-5-20251001-apimart or claude-sonnet-4-6-apimart)
  2. Shorten your prompts to reduce context length
  3. Check your network conditions

Q7: How to switch models?

Two ways:
  1. In interactive mode: Enter the /model command
  2. Edit configuration: Change the ANTHROPIC_MODEL field in settings.json or environment variables, then restart Claude Code

Q8: Does Claude Code automatically read local files?

No. Claude Code requires you to explicitly reference files, and it will ask for confirmation before performing sensitive operations. It’s recommended to use it in dedicated project directories.

Q9: How to analyze local files with Claude Code?

In interactive mode, you can reference files by:
  • Entering the file path directly
  • Dragging files into the terminal window
  • Copy-pasting file content

Q10: How to check usage and costs?

Log in to the APIMart Console to view:
  • API call statistics
  • Token consumption details
  • Cost statistics and trends

Support

If you encounter any issues:

Get Started with APIMart

Sign up for APIMart now, get your API key, and experience multi-model programming assistant in Claude Code!