Claude

Use Case:

Suitable for users who want to use Claude models in the terminal for code analysis, code modification, and Agent tasks.
Claude Code uses the Anthropic Messages protocol. Please select a Claude model from your model restriction list; using non-Claude models such as GPT or Gemini in Claude Code is not recommended.
ANTHROPIC_BASE_URL should be set to https://api.maitoken.net without /v1. Claude Code automatically calls https://api.maitoken.net/v1/messages .

1. macOS / Linux Configuration

  1. Check Claude Code: Open a terminal and run claude --version. If the command is not found, install Claude Code according to its installation instructions first.

  2. Select a Model: Copy an available Claude Model ID from the model restriction list in the MaiToken Console.

  3. Set Gateway URL: Set ANTHROPIC_BASE_URL to https://api.maitoken.net .

  4. Set Authentication: Store your MaiToken Key in ANTHROPIC_AUTH_TOKEN. Claude Code automatically sends authentication using the Authorization: Bearer header.

  5. Set Model: Store the exact Claude Model ID in ANTHROPIC_MODEL, then run claude in the same terminal window.

export ANTHROPIC_BASE_URL="https://api.maitoken.net"export ANTHROPIC_AUTH_TOKEN="<Your MaiToken Key>"export ANTHROPIC_MODEL="<Claude Model ID>" claude

2. Windows PowerShell Configuration

Open PowerShell and run the following commands:

$env:ANTHROPIC_BASE_URL="https://api.maitoken.net"$env:ANTHROPIC_AUTH_TOKEN="<Your MaiToken Key>"$env:ANTHROPIC_MODEL="<Claude Model ID>" claude

Login Note: When authenticating through the MaiToken gateway with ANTHROPIC_AUTH_TOKEN, you do not need to log in to Claude.ai; the directory trust prompt shown when entering a project for the first time is not an account login either.

To avoid background model errors, we recommend assigning an available model to the model aliases used by Claude Code. Claude Code may use sonnet, opus, and haiku aliases for different tasks. If you encounter permission errors for other models during testing, set all of the variables below to the same available Claude Model ID.
macOS / Linux
export ANTHROPIC_DEFAULT_SONNET_MODEL="<Claude Model ID>"export ANTHROPIC_DEFAULT_OPUS_MODEL="<Claude Model ID>"export ANTHROPIC_DEFAULT_HAIKU_MODEL="<Claude Model ID>"export CLAUDE_CODE_SUBAGENT_MODEL="<Claude Model ID>"
Windows PowerShell
$env:ANTHROPIC_DEFAULT_SONNET_MODEL="<Claude Model ID>"$env:ANTHROPIC_DEFAULT_OPUS_MODEL="<Claude Model ID>"$env:ANTHROPIC_DEFAULT_HAIKU_MODEL="<Claude Model ID>"$env:CLAUDE_CODE_SUBAGENT_MODEL="<Claude Model ID>"
Variable Value
ANTHROPIC_BASE_URL https://api.maitoken.net
ANTHROPIC_AUTH_TOKEN <Your MaiToken Key>
ANTHROPIC_MODEL <Claude Model ID>
Actual Request URL https://api.maitoken.net/v1/messages , automatically appended by Claude Code

How to Test After Setup

  1. Test Basic Chat: Enter "Reply OK only". Receiving a normal reply confirms that your API Key, gateway URL, and Model ID are basically correct.

  2. Test Project Reading: Open a test project and enter "Please read the current project and list only the top-level file names without modifying any files."

  3. Test Agent: After receiving the directory listing, ask the Agent to create a new file named test-maitoken.txt containing hello. Do not run initial tests on a real production project.

Troubleshooting

Issue Suggested Fix
401 / Unauthorized Confirm you are using ANTHROPIC_AUTH_TOKEN and that the variable is set in the same terminal window where you launch claude.
404 /v1/messages ANTHROPIC_BASE_URL must be set only to https://api.maitoken.net —do not include /v1 or /v1/messages.
Model unavailable Select the exact Claude Model ID from the model restriction list rather than a localized display name.
Calls a different model after startup Set ANTHROPIC_DEFAULT_SONNET_MODEL, ANTHROPIC_DEFAULT_OPUS_MODEL, ANTHROPIC_DEFAULT_HAIKU_MODEL, and CLAUDE_CODE_SUBAGENT_MODEL.
Chat works but cannot edit files Ensure the current directory has write permissions and that both the model and gateway fully support Anthropic tool calling and streaming output.