Claude Code · Relay

Claude Code API Relay (Available in China, Pay-as-You-Go)

A Claude Code API relay is an endpoint compatible with the Anthropic API: point Claude Code's ANTHROPIC_BASE_URL at it, enter the Key issued by the relay, and you can use Claude Code directly from a network in China. AICodeWith does not require an overseas credit card; it uses prepaid balance billed per token.

Last checked

What Is a Claude Code Relay

Claude Code itself is a command-line client; it sends requests to the endpoint specified by ANTHROPIC_BASE_URL. By default this is Anthropic's endpoint, which networks in China usually cannot reach, and payment also requires an overseas credit card. A relay provides an Anthropic API-compatible address; you do not need to change the client, just switch the endpoint address and the Key.

A relay uses API Key calls; you do not need to log in to a Claude account and it does not use a Claude subscription.

Relays vs. Claude Subscription vs. Mirror Sites

Claude subscription (Pro / Max)API relay (AICodeWith)Mirror site
How to useUse /login to log in to a Claude accountConfigure ANTHROPIC_BASE_URL and KeyUsually a web version; accounts are shared or sold
PaymentOverseas credit card, fixed monthly pricePayments in China; prepaid balance billed by usageVaries by provider
Networks in ChinaMust be arranged on your ownDirectly reachableDirectly reachable
Works with Claude Code CLIYesYesUsually not
Quota5-hour and weekly limitsBilled against balance; rate and concurrency limits applyVaries by provider

A "mirror site" generally refers to shared or sold access to the web version of Claude; it is not the same as the API relay used with the Claude Code CLI.

Setup in 3 Steps

  1. 1. Get a Key

    Register and log in to AICodeWith, then create a Key on the API Keys page in the console. Detailed screenshots are on the Get API Key page.

  2. 2. Set ANTHROPIC_BASE_URL and ANTHROPIC_AUTH_TOKEN

    It is recommended to write them into ~/.claude/settings.json; the CLI, VS Code, and JetBrains plugins will all read this file. Leave ANTHROPIC_API_KEY empty to avoid conflicts.

    ~/.claude/settings.json
    {
      "env": {
        "ANTHROPIC_AUTH_TOKEN": "你的_API_KEY",
        "ANTHROPIC_API_KEY": "",
        "ANTHROPIC_BASE_URL": "https://api.aicodewith.ai"
      }
    }
  3. 3. Verify

    Reopen your terminal, run claude, and enter /status to confirm the API endpoint is api.aicodewith.ai. You can also verify temporarily with environment variables:

    macOS / Linux
    export ANTHROPIC_BASE_URL="https://api.aicodewith.ai"
    export ANTHROPIC_AUTH_TOKEN="你的_API_KEY"
    export ANTHROPIC_API_KEY=""

Get API Key tutorial with screenshotsClaude Code integration guideClaude Code third-party API setup guide

Supported Models and Prices

Claude family models are supported; use /model in Claude Code to switch between them. Real-time unit prices, available channels, and channel health for each model are on the Models page. Billing is based on actual token usage.

Models and real-time pricesTop-up and plans

How to Choose a Relay

  • Stability: check whether multiple channels are available, whether the Models page publicly shows channel status, and whether you can switch channels when overloaded occurs during peak hours.
  • Billing: whether token usage is transparently billed, whether you can see usage records for each request, and whether you can set spending limits on a Key.
  • Privacy: review how data is handled as described in the privacy policy, and avoid giving your Key to "shared accounts" of unknown origin.
  • Refunds: whether clear refund rules exist. AICodeWith: unused balance can be refunded within 90 days with a 10% processing fee deducted; see the refund policy for details.

Common Errors

The most common are 401 (wrong Key or variable), 429 (concurrency too high), overloaded (model busy), and configuration changes not taking effect. See the error reference for the cause and fix for each.

Claude Code common errors and fixes

FAQ

Will using a relay get my account banned?

A relay uses API Key calls; you do not need to log in to a Claude account, and it does not use a Claude subscription. Please comply with the terms of service and do not use it for prohibited purposes.

Is a relay safe? Will it store my code?

Request and response content is forwarded to the upstream model provider. The platform records and retains API call logs for 90 days for service quality analysis and troubleshooting; see the privacy policy for details. We recommend not putting sensitive information such as passwords or private keys in prompts, and setting a spending limit on each Key.

Do you support monthly plans?

We do not offer monthly-plan billing that resets each month. We use prepaid balance billed by usage: pay for what you use; the balance is valid for 12 months and is not reset monthly. Light usage will not waste a monthly fee; you can also purchase prepaid packages.

What is the difference between a mirror and a relay?

Mirror sites are generally shared or sold access to the web version of Claude and cannot be used directly with the Claude Code CLI. A relay provides an Anthropic API-compatible endpoint; Claude Code works once you change the endpoint address and the Key.

How long is the balance valid?

The balance is valid for 12 months and is not reset monthly.

Ready to try it?

Billing is per token from a prepaid balance. Rate and concurrency limits apply, and you can set daily, monthly or total spend caps on each API key.

Related

AICodeWith is an independent third-party API service and is not affiliated with Anthropic or OpenAI. Claude, Claude Code, Codex, and other names belong to their respective owners. Prices are subject to real-time data on the Models page; rate and concurrency limits apply; a 10% processing fee is deducted for refunds; see the refund policy for details.