跳转到主要内容

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.

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.

Prerequisites

  • Node.js 18 or later installed
  • A 元任务 AI 网关 API key from your dashboard

Steps

1

Install Claude Code

Install the Claude Code CLI globally using npm:
terminal
npm install -g @anthropic-ai/claude-code
Verify the installation:
terminal
claude --version
2

Set environment variables

Set 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 ANTHROPIC_BASE_URL="https://napi.origintask.cn/v1"
export ANTHROPIC_API_KEY="YOUR_API_KEY"
To make these variables permanent, add the export lines to your shell profile (e.g., ~/.zshrc, ~/.bashrc, or ~/.profile) and reload it with source ~/.zshrc.
3

Run Claude Code

Start Claude Code in your project directory:
terminal
claude
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.

One-line invocation

You can also set the variables inline for a single session without permanently changing your environment:
terminal
ANTHROPIC_BASE_URL="https://napi.origintask.cn/v1" \
ANTHROPIC_API_KEY="YOUR_API_KEY" \
claude

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
export ANTHROPIC_BASE_URL="https://napi.origintask.cn/v1"
export ANTHROPIC_API_KEY="YOUR_API_KEY"
Then reload your profile:
terminal
source ~/.zshrc
Some Claude Code features — such as tool use, vision inputs, or extended context windows — depend on the specific capabilities of the model you select. Check the Available Models page to confirm that your chosen model supports the features you need.
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.