Skip to content

Using New API with Claude Code

Install Claude Code

bash
pnpm install -g @anthropic-ai/claude-code
bash
npm install -g @anthropic-ai/claude-code
bash
yarn global add @anthropic-ai/claude-code

Configure Environment Variables

Enter the following commands in the terminal to set environment variables to use New API's Anthropic API:

::: tabs

::: tab Linux/macOS (bash/zsh)

bash
# Set New API's API base URL
export ANTHROPIC_BASE_URL=https://model.imkk.us/

# Set your New API API key, which can be obtained from https://model.imkk.us/console/token
export ANTHROPIC_AUTH_TOKEN=sk-xxx
export ANTHROPIC_API_KEY=sk-xxx

:::

::: tab Windows PowerShell

powershell
# Set New API's API base URL
$env:ANTHROPIC_BASE_URL="https://model.imkk.us/"

# Set your New API API key, which can be obtained from https://model.imkk.us/console/token
$env:ANTHROPIC_AUTH_TOKEN="sk-xxx"
$env:ANTHROPIC_API_KEY="sk-xxx"

:::

::: tab Windows CMD

cmd
# Set New API's API base URL
set ANTHROPIC_BASE_URL=https://model.imkk.us/

# Set your New API API key, which can be obtained from https://model.imkk.us/console/token
set ANTHROPIC_AUTH_TOKEN=sk-xxx
set ANTHROPIC_API_KEY=sk-xxx

:::

::: tab Fish Shell

fish
# Set New API's API base URL
set -gx ANTHROPIC_BASE_URL "https://model.imkk.us/"

# Set your New API API key, which can be obtained from https://model.imkk.us/console/token
set -gx ANTHROPIC_AUTH_TOKEN "sk-xxx"
set -gx ANTHROPIC_API_KEY "sk-xxx"

:::

:::

IMPORTANT

Please make sure to replace sk-xxx with the Token provided by New API. You can get the API Key from the New API Console.

Direct Launch and Use

After configuring the environment variables, use the terminal to open the project directory you want to work with, then run the following command to start Claude Code:

bash
# Enter the project directory
cd my-project

# Directly start Claude Code
claude

TIP

You can add environment variable configuration to your shell configuration file to avoid manually setting it each time:

::: tabs

::: tab Linux/macOS (bash/zsh)

bash
# Add to ~/.bashrc or ~/.zshrc file
export ANTHROPIC_BASE_URL=https://model.imkk.us/
export ANTHROPIC_AUTH_TOKEN=sk-xxx
export ANTHROPIC_API_KEY=sk-xxx

::: tab Windows PowerShell

powershell
# Add to PowerShell profile ($PROFILE)
$env:ANTHROPIC_BASE_URL="https://model.imkk.us/"
$env:ANTHROPIC_AUTH_TOKEN="sk-xxx"
$env:ANTHROPIC_API_KEY="sk-xxx"

:::

::: tab Windows CMD

cmd
# Add to batch file or system environment variables
set ANTHROPIC_BASE_URL=https://model.imkk.us/
set ANTHROPIC_AUTH_TOKEN=sk-xxx
set ANTHROPIC_API_KEY=sk-xxx

:::

::: tab Fish Shell

fish
# Add to ~/.config/fish/config.fish file
set -gx ANTHROPIC_BASE_URL "https://model.imkk.us/"
set -gx ANTHROPIC_AUTH_TOKEN "sk-xxx"
set -gx ANTHROPIC_API_KEY "sk-xxx"

:::

:::

:::