← All articles

How to Use Claude API in Claude Code (CLI) with Your Own Key

·2 min read·Claude API Tech

Claude Code is Anthropic's official command-line coding agent. It normally bills through an Anthropic account, but it also respects standard environment variables — so you can point it at your own key from Claude API Tech and pay only for real usage. No VPN, pay with crypto, all Claude models under one balance.

See the complete walkthrough in the Claude Code integration guide.

What you'll need

  • Claude Code installed
  • An API key in the sk-cs2-* format from Claude API Tech
  • A terminal

Step 1. Get an API key

Sign up and create a key in your dashboard. The format is sk-cs2-.... New accounts get $1.50 in test credit, so you can try everything at zero cost.

Step 2. Install Claude Code

Use the official installer for macOS, Linux, or WSL:

curl -fsSL https://claude.ai/install.sh | bash

Other installation options are available on the official Claude Code website.

Step 3. Add settings

Create or open .claude/settings.json in your project root and add:

{
  "env": {
    "ANTHROPIC_BASE_URL": "https://api.llm-gate.tech",
    "ANTHROPIC_API_KEY": "sk-cs2-your-key"
  },
  "model": "sonnet"
}

For a personal setting shared by all projects, use ~/.claude/settings.json. Do not commit a real key to a public repository; you can also keep a personal key in the Git-ignored .claude/settings.local.json file.

Step 4. Run it

cd your-project
claude

Claude Code now routes every request through your Claude API Tech balance. Ask it to explain code, fix a bug, or build a feature — the same experience as the official CLI.

Troubleshooting

  • invalid x-api-key / 401 — check that the key is copied in full and starts with sk-cs2-.
  • Connection errors — make sure ANTHROPIC_BASE_URL has no trailing slash and no /v1.
  • Settings are not applied — make sure .claude/settings.json is in the current project root and contains valid JSON.

Done

One key, one balance, every Claude model — right inside Claude Code. Top up with crypto whenever you need more.

For more on settings scope and safe key storage, read the Claude Code integration documentation.

Read next