Skip to content
All posts
·5 min readtutorialclaude-codeclaude code setup api key

How to Set Up Claude Code with a Cheap API Key (Save Up to 70%)

Step-by-step guide to configuring Claude Code with claudeapi.cheap. Set up your API key, environment variables, and start coding at a fraction of the cost.

What Is Claude Code?

Claude Code is Anthropic's AI coding assistant that runs directly in your terminal. It can write code, debug issues, refactor files, manage git operations, run shell commands, and even architect entire projects. Think of it as a senior developer sitting inside your command line.

Under the hood, Claude Code sends requests to the Anthropic API with every interaction. That means every question you ask, every file you edit, and every command you run costs money at official API rates.

The Cost Problem

Heavy Claude Code users can easily spend $50 to $200 / month on API calls. A single complex coding session with Claude Opus can burn through $5 to $10 in tokens. If you use Claude Code daily for professional work, those costs compound quickly.

Here is a rough breakdown of what a typical day might look like at official pricing:

| Activity | Model | Estimated cost |

|----------|-------|----------------|

| Morning code review | Sonnet 4.6 | $2–4 |

| Feature implementation | Opus 4.7 / 4.6 | $5–10 |

| Debugging session | Sonnet 4.6 | $1–3 |

| Test writing | Haiku 4.5 | $0.50–1 |

| Daily total | | $8.50–18 |

Over a month, that is $170 to $360 at official rates. With claudeapi.cheap Pro (80% off), you cut that down to about $35–$72.

The Solution: Route Through claudeapi.cheap

By pointing Claude Code at our proxy endpoint, every API call goes through claudeapi.cheap instead of directly to Anthropic. You get the exact same models, the exact same quality, and the exact same features — just at a much lower price.

Setup Guide (Under 2 Minutes)

Step 1: Create Your Account

Sign up at claudeapi.cheap. It is free and takes about 30 seconds. No credit card required — we accept crypto payments.

Step 2: Top Up Your Balance

Deposit funds using USDT, BTC, ETH, or 100+ cryptocurrencies from your dashboard. Your balance is shared across all API calls.

Step 3: Generate an API Key

Go to your dashboard and create a new API key. It will look like sk-cc-xxxxxxxxxxxx.

Step 4: Set Environment Variables

Open your terminal and add these two lines to your shell configuration file:

For bash (~/.bashrc):

export ANTHROPIC_API_KEY="sk-cc-your-api-key-here"
export ANTHROPIC_BASE_URL="https://claudeapi.cheap/api/proxy"

For zsh (~/.zshrc):

export ANTHROPIC_API_KEY="sk-cc-your-api-key-here"
export ANTHROPIC_BASE_URL="https://claudeapi.cheap/api/proxy"

For fish (~/.config/fish/config.fish):

set -gx ANTHROPIC_API_KEY "sk-cc-your-api-key-here"
set -gx ANTHROPIC_BASE_URL "https://claudeapi.cheap/api/proxy"

After saving, reload your shell:

source ~/.bashrc   # or ~/.zshrc

Step 5: Launch Claude Code

claude

That is it. Claude Code will automatically pick up the environment variables and route all requests through claudeapi.cheap at discounted rates.

Verifying Your Setup

To confirm everything is working, run a quick test after launching Claude Code:

# Inside Claude Code, ask it something simple
> What model are you using?

You can also check your usage dashboard to verify that requests are showing up and being billed at the discounted rate.

Choosing the Right Model

Claude Code supports all available Claude models. Here is how to think about which one to use:

  • claude-sonnet-4-6 — Best for everyday coding. Fast responses, strong code quality, and the best price-to-performance ratio. Use this as your default.
  • claude-opus-4-7 / claude-opus-4-6 — Most powerful options. Use for complex refactoring, architecture decisions, large codebase analysis, and tricky debugging sessions. 4.7 is the newest flagship.
  • claude-haiku-4-5 — Fastest and cheapest. Good for quick questions, simple edits, and test generation.
  • You can switch models within Claude Code using the /model command.

    Troubleshooting

    "Authentication failed" error

    Double-check that your API key is correct and starts with sk-cc-. Make sure there are no extra spaces or quotes in your environment variable.

    "Connection refused" error

    Verify the base URL is exactly https://claudeapi.cheap/api/proxy with no trailing slash. Also check your internet connection.

    Environment variables not loading

    Make sure you added the export lines to the correct shell config file and ran source on it. You can verify with:

    echo $ANTHROPIC_BASE_URL

    If it prints the URL, your setup is correct.

    Rate limit errors

    Basic accounts get 200 requests per minute. If you need more, upgrade to Pro for 500 RPM + 2M TPM and priority support.

    Tips for Saving Even More

    1. Use Sonnet for most tasks — it handles 90% of coding work at a fraction of Opus pricing

    2. Switch to Haiku for simple tasks — test generation, formatting, and quick lookups

    3. Reserve Opus for complex work — architecture reviews, multi-file refactors, and deep debugging

    4. Monitor your usage — check the dashboard regularly to track spending

    5. Upgrade to Pro if you are a heavy user — $19 one-time for 80% off pays for itself within a week of active coding.

    For more cost-saving strategies, read our guide on how to save money on AI API costs.

    Start Coding for Less

    Claude Code is one of the best AI coding tools available. With claudeapi.cheap, you can use it without worrying about runaway API bills. Set up takes 2 minutes, and every session after that saves you money.

    Get started at claudeapi.cheap