Claude Code is Anthropic’s terminal-based coding agent. Because it reads its API endpoint and key from environment variables, you can redirect it to 元任务 AI 网关 without modifying any source files. This lets you use gateway billing, model selection, and usage tracking while keeping the full Claude Code workflow.Documentation Index
Fetch the complete documentation index at: https://docs.metask.ai/llms.txt
Use this file to discover all available pages before exploring further.
Prerequisites
- Node.js 18 or later installed
- A 元任务 AI 网关 API key from your dashboard
Steps
Install Claude Code
Install the Claude Code CLI globally using npm:Verify the installation:
terminal
terminal
Set environment variables
Set To make these variables permanent, add the
ANTHROPIC_BASE_URL and ANTHROPIC_API_KEY before running Claude Code. Claude Code reads these variables at startup and uses them for every API call.export lines to your shell profile (e.g., ~/.zshrc, ~/.bashrc, or ~/.profile) and reload it with source ~/.zshrc.Run Claude Code
Start Claude Code in your project directory:Claude Code will connect to the gateway using the variables you set. At the model selection prompt, enter a model identifier from the gateway’s Available Models list.
terminal
One-line invocation
You can also set the variables inline for a single session without permanently changing your environment:terminal
Persist configuration in your shell profile
Add the following lines to~/.zshrc or ~/.bashrc so the variables are set automatically in every new terminal session:
~/.zshrc or ~/.bashrc
terminal
If Claude Code reports an authentication error, verify that
ANTHROPIC_API_KEY is set to a valid gateway key (not an Anthropic key) and that ANTHROPIC_BASE_URL ends with /v1.