
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:- 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:- macOS / Linux (Recommended)
- Windows
- NPM Install
Install with the official script:Or install via Homebrew:
If you encounter permission issues, add
sudo before the command.Verify Installation
After installation, run the following command to confirm:1.x.x), the installation was successful.
Step 2: Configure APIMart API
Three configuration methods are available. Choose the one that suits your workflow.Method 1: Edit settings.json (Recommended)
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.settings.json file:
| Parameter | Description |
|---|---|
ANTHROPIC_BASE_URL | APIMart API address, fixed as https://api.apimart.ai |
ANTHROPIC_AUTH_TOKEN | Your APIMart API key (starts with sk-) |
ANTHROPIC_MODEL | Default model to use, choose from the model list below |
CLAUDE_CODE_DISABLE_NONESSENTIAL_TRAFFIC | Set to 1 to reduce non-essential network requests |
Method 2: Permanent Environment Variables
Write configuration to system environment so all terminal windows load it automatically.- macOS (zsh)
- macOS / Linux (bash)
- Windows
Method 3: Temporary Environment Variables
Suitable for quick testing — configuration is lost when the terminal is closed.- macOS / Linux
- Windows (PowerShell)
- Windows (CMD)
Step 3: Start Using
Verify Configuration
Launch Claude Code and send a simple message to confirm:401, 403, or other errors, refer to the FAQ below.
Usage Modes
Claude Code offers two interaction modes:- Interactive mode: Run
claudefor 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 Name | Features | Recommended Use |
|---|---|---|
claude-opus-4-6 | Strongest overall capability | Complex architecture, difficult debugging |
claude-sonnet-4-6 | Balanced performance and speed | Daily programming, code generation |
claude-opus-4-5-20251101 | Advanced reasoning | Complex code, deep analysis |
claude-sonnet-4-5-20250929 | Excellent code capability | Algorithm design, code optimization |
claude-haiku-4-5-20251001 | Ultra-fast response | Quick Q&A, code snippets |
-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 Name | Features |
|---|---|
claude-opus-4-6-apimart | Strongest overall capability |
claude-sonnet-4-6-apimart | Balanced performance and speed |
claude-opus-4-5-20251101-apimart | Advanced reasoning |
claude-sonnet-4-5-20250929-apimart | Excellent code capability |
claude-haiku-4-5-20251001-apimart | Ultra-fast response |
claude-opus-4-6-thinking-apimart, claude-sonnet-4-6-thinking-apimart, etc.
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:| Command | Description |
|---|---|
claude | Enter interactive mode |
claude "question" | Single query |
claude --version | Check version |
/model | Switch model in interactive mode |
/help | View help information |
Ctrl + C | Exit 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:- Using settings.json: Check if the file path is correct
- Windows:
C:\Users\<username>\.claude\settings.json - macOS / Linux:
~/.claude/settings.json
- Windows:
- Using environment variables: Make sure you launched Claude Code from the same terminal window where you set the variables
- Check JSON format: Ensure brackets, commas, and quotes are all correct
Q2: Getting 401 / 403 errors?
| Error Code | Meaning | Solution |
|---|---|---|
401 Unauthorized | API key missing or invalid | Check if the key is correct and starts with sk- |
403 Forbidden | Insufficient permissions or expired key | Go to Console to verify key status |
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.- Check your network connection
- Verify
ANTHROPIC_BASE_URLis configured correctly - If using a proxy, ensure it allows access to
api.apimart.ai
Q4: “Auth conflict” error?
If you see a message like:/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: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?
- Switch to a faster model (e.g.,
claude-haiku-4-5-20251001-apimartorclaude-sonnet-4-6-apimart) - Shorten your prompts to reduce context length
- Check your network conditions
Q7: How to switch models?
Two ways:- In interactive mode: Enter the
/modelcommand - Edit configuration: Change the
ANTHROPIC_MODELfield insettings.jsonor 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:- 📚 APIMart Documentation
- 💬 Discord Community
- 🐦 Twitter @APIMart_
- 📧 Technical Support: zhihong@apimart.ai
Get Started with APIMart
Sign up for APIMart now, get your API key, and experience multi-model programming assistant in Claude Code!