Configure Claude Code in 5 Minutes

(Unofficial)

This guide is independently community-maintained. It is not affiliated with, endorsed by, or sponsored by the vendor of the third-party tool it covers. All third-party trademarks are the property of their respective owners.

One command to set up Claude Code with CodeGateway — works on macOS, Linux, and Windows. Updated 2026-05-15: aligned with AI Gateway repositioning.

TL;DR: Run Anthropic Claude Code in under 5 minutes — one curl line points it at CodeGateway, new accounts get a starting credit after binding a card (current amount shown on the signup/pricing page), billed per token, no extra network setup.

One of the fastest ways for you and your team to use Claude Code without manual network setup is the CodeGateway one-liner script — a single shell command, no extra network setup, no manual SDK config. Below are the commands for macOS / Linux / Windows. Run, then claude to start.

This is a quick command reference. For the full story with real-world latency tests and advanced workflows, see the blog deep dive: Claude Code Quickstart Guide.

1. Get an API Key (30 seconds)

You need a CodeGateway API key first:

  1. Sign in to CodeGateway Dashboard
  2. Go to API Keys
  3. Click Create Key and copy the string starting with sk-cg-
No account yet? Sign up and bind a card — a free starting credit; the current amount and model-based conversion are shown on the signup/pricing page. Enough to verify your setup and try a few real tasks.

2. One-Liner Script (macOS / Linux)

Open terminal, replace YOUR_KEY with your key, and run:

bash
curl -s https://www.codegateway.dev/setup.sh | bash -s -- --key sk-cg-YOUR_KEY

The script does three things:

  • Installs Claude Code if missing (via pip install or brew install)
  • Writes ~/.claude/settings.json with ANTHROPIC_BASE_URL and ANTHROPIC_AUTH_TOKEN
  • Backs up your existing shell config (prevents conflicts)

After it finishes, run claude to start. Welcome screen = you're good.


3. One-Liner Script (Windows / PowerShell)

Open PowerShell as Administrator:

powershell
& { $key='sk-cg-YOUR_KEY'; iwr -useb https://codegateway.dev/setup.ps1 | iex }

If you hit "execution policy" errors, run this first:

powershell
Set-ExecutionPolicy -ExecutionPolicy RemoteSigned -Scope CurrentUser -Force

4. Manual Config (If You Prefer Not to Run a Script)

Put this in ~/.claude/settings.json:

json
{
  "env": {
    "ANTHROPIC_BASE_URL": "https://api.codegateway.dev",
    "ANTHROPIC_AUTH_TOKEN": "sk-cg-YOUR_KEY"
  }
}

Or set environment variables (good for quick testing):

bash
export ANTHROPIC_BASE_URL="https://api.codegateway.dev"
export ANTHROPIC_AUTH_TOKEN="sk-cg-YOUR_KEY" 

5. Verify

bash
claude --version    # Check that Claude Code is installed
claude              # Start the REPL inside any project directory

Ask something like "Hi, briefly introduce yourself". If Claude responds, the CodeGateway access chain is working.

Under the hood: your request is proxied through Cloudflare's global edge network to Anthropic's official API, end-to-end TLS encrypted. Actual latency depends on your network — see real-time response times for each call in Dashboard → Usage.

6. 1M Context and Model Selection

These CodeGateway Claude models already run at a 1M-token context window — no beta request, and nothing to append on the gateway side:

Model (the exact id from /v1/models)

Context window

claude-sonnet-5-5

1M

claude-opus-5-5

1M

claude-sonnet-5

1M

claude-opus-5

1M

claude-fable-5-1 / claude-fable-5

1M

The client does not know that. Claude Code cannot read the gateway's context window, so it assumes 200K — unless the model id carries [1m]. Getting the full window therefore takes three client-side steps:

1. Turn on gateway model discovery (one time):

bash
export CLAUDE_CODE_ENABLE_GATEWAY_MODEL_DISCOVERY=1

2. Restart Claude Code. Discovery runs once at startup and is cached in ~/.claude/cache/gateway-models.json.

3. Pick the row labelled `(1M context)` in `/model`. CodeGateway advertises an extra [1m] spelling for these models in /v1/models, which the picker shows as "Sonnet 5.5 (1M context)" and friends. Selecting it sizes that session at 1M instead of auto-compacting around 200K.

To make it the default for new sessions, pin the default model to the suffixed spelling:

bash
export ANTHROPIC_DEFAULT_SONNET_MODEL='claude-sonnet-5-5[1m]'
# likewise ANTHROPIC_DEFAULT_OPUS_MODEL / ANTHROPIC_DEFAULT_FABLE_MODEL

Or put "model": "claude-sonnet-5-5[1m]" in ~/.claude/settings.json.

`[1m]` is the client's "size me at 1M" marker, not a gateway switch. These models are natively 1M: skipping that row does not get you truncated upstream — Claude Code simply compacts earlier, around 200K. The client strips the suffix before sending, so the gateway receives claude-sonnet-5-5.

Hard rule: the suffix is honoured only for models that really are 1M — a mistake fails loudly instead of degrading silently:

Requested model

Result

claude-sonnet-5-5[1m]

✅ 200, served as claude-sonnet-5-5

claude-sonnet-4-6[1m]

❌ 400 (Sonnet 4.6 is a 200K model — marking it 1M is a config error)

To pin a few rows under labels you choose, use modelPicker in ~/.claude/settings.json:

json
{
"modelPicker": {
"options": [
{ "model": "claude-sonnet-5-5[1m]", "label": "Sonnet 5.5 (1M)", "description": "Everyday coding, 1M context" },
{ "model": "claude-opus-5-5[1m]", "label": "Opus 5.5 (1M)", "description": "Complex refactors and long-horizon work" }
]
}
}
model is taken verbatim; use the full id (/v1/models returns e.g. claude-sonnet-5-5[1m]) to pin a version and get the 1M variant. Bare family aliases (sonnet / opus / haiku / fable, with or without [1m]) are also accepted, but they follow the newest catalog version. For the Desktop setup, see "Claude Desktop with CodeGateway".

7. FAQ

Q: Which Claude model should I use?

A: Sonnet 4.6 for daily coding (strong price/performance), Opus 4.7 for complex architecture and refactors. See Claude Code vs Cursor vs Copilot.

Q: How does CodeGateway pricing work?

A: Anthropic's published rate plus a flat 1.07× markup — the same for every account, regardless of usage. See Flat Markup Explained and Billing Guide.

Q: What's the API key format?

A: Must start with sk-cg-. Create one in Dashboard → API Keys. You can have multiple keys per account (one per project).

Q: Is the install script safe?

A: Not open source, but you can download, inspect, then run — split the one-liner into two steps:

bash
# 1. Download the script first, review the contents locally
curl -s https://www.codegateway.dev/setup.sh -o setup.sh
less setup.sh   # or cat setup.sh — read every action before trusting it

# 2. Run only after you're comfortable
bash setup.sh --key sk-cg-YOUR_KEY

The script collects no personal info — it only modifies ~/.claude/settings.json and your shell config (with backups of the originals).

Q: What files does the script modify?

A: Only two: ~/.claude/settings.json and your shell config (~/.zshrc or ~/.bashrc). Both are backed up first.

Q: Windows says "execution policy" error?

A: Run as Administrator, or execute Set-ExecutionPolicy -ExecutionPolicy RemoteSigned -Scope CurrentUser -Force first.

Q: What about a "401 Unauthorized" error?

A: Check whether your API key is expired or copied incompletely. Full troubleshooting: Error Troubleshooting Guide.


8. Next Steps

  • ✅ Got it working? → Read the Blog Deep Dive for advanced workflows (slash commands, Plan mode, Hooks automation)
  • 💰 Want to see actual costs? → Billing Guide
  • ⚖️ Picking a model? → Claude Code vs Cursor vs Copilot
  • 📚 Official Claude Code docs → Anthropic Documentation

References

Turn this doc into a real API call

Lacking an official key or facing overseas card payment issues? Create an sk-cg- key after signing up, point your base URL at CodeGateway, and keep your existing SDK or CLI unchanged. Pay per token; binding a card adds free credit.

Sign up free
Author:CodeGateway teamReviewed on:2026-09-05
Claude Code One-Liner Setup | macOS / Linux / Windows