Setup guide · as of 2026-10-07

Claude Code VS Code Extension: API Key and Custom Gateway Setup

As of 2026-10-07, the official Claude Code docs give one reliable way to point the VS Code extension at a custom gateway: put ANTHROPIC_BASE_URL and ANTHROPIC_AUTH_TOKEN in claudeCode.environmentVariables in your VS Code user settings, because the extension checks credentials from that setting before launching. Add the same two values to the env block of ~/.claude/settings.json so the terminal CLI shares them. For QCode the values are https://api.qcode.cc/api and a key that starts with cr_. This page covers the steps, how the extension relates to the CLI, and three common problems: a key that isn't found, a login prompt that keeps appearing, and model selection.

Updated 2026-10-08

#environmentVariables#Shared settings.json#Skip the login prompt#Model selection

Four things to know first

2 values

All QCode needs

ANTHROPIC_BASE_URL set to https://api.qcode.cc/api (up to /api, no trailing slash) and ANTHROPIC_AUTH_TOKEN set to the cr_ key you create in the dashboard.

User settings

The reliable place for the gateway credential

Per the official docs, the extension checks credentials in claudeCode.environmentVariables before launching; values in ~/.claude/settings.json reach the spawned process but not the extension's own login check.

settings.json

Config shared with the terminal CLI

~/.claude/settings.json is shared between the extension and the CLI. Put the same two values in its env block and claude in the terminal uses the same gateway. Keep them out of a project's .claude/settings.json, which gets committed.

1M

Context window behind a custom base URL

Since 2.1.285, sessions behind a custom ANTHROPIC_BASE_URL run Opus 4.7+, Sonnet 5+ and Fable at 1M directly; if your gateway stops at 200K, the official changelog says to run /autocompact 200k.

How the VS Code extension reads its configuration

As of 2026-10-07, the short answer is that the extension has two kinds of settings. Per the official docs, extension settings in VS Code control how the extension behaves, while ~/.claude/settings.json is shared between the extension and the CLI and holds environment variables, allowed commands, hooks and MCP servers. For a custom gateway, the official gateway docs put the credential in claudeCode.environmentVariables in your VS Code user settings, because the extension checks credentials there before launching. The extension bundles its own copy of the CLI for the chat panel but does not add claude to your PATH; to run claude in the integrated terminal you need the standalone CLI install. It requires VS Code 1.94.0 or later. Signing in with a paid Claude subscription or a Console account needs no API key; with a gateway, a credential variable takes the place of your claude.ai login.

Recent VS Code-related changes (as of 2026-10-07)

As of 2026-10-07, the newest release on GitHub Releases is 2.1.292, published 2026-10-06 (UTC). The gateway-related items: since 2.1.285, sessions behind a custom ANTHROPIC_BASE_URL use the 1M context window of models that have one (Opus 4.7+, Sonnet 5+, Fable), and the official changelog says to run /autocompact 200k if your gateway stops at 200K; 2.1.280 added a Status dialog to VS Code, opened by typing /status, showing the session's version, account, model and server details; from 2.1.277, where plan limits do not apply (the changelog lists Vertex, Bedrock, Foundry and API key), the Account & usage dialog shows the session's cost and token usage; 2.1.290 fixed sign-in and new sessions giving no clear reason when Claude Code cannot find or start its program.

Release timeline

2026-09-04

2.1.261 released (UTC): fixed the VS Code sign-in screen appearing despite the Disable Login Prompt setting when Claude Code reports no login or a request fails for lack of one.

2026-09-22

2.1.280 released (UTC): VS Code gained a Status dialog. Type /status in the panel to see the session's version, account, model and server details, which makes it easier to check that your configuration took effect.

2026-09-29

2.1.285 released (UTC): sessions behind a custom ANTHROPIC_BASE_URL now run models that have a 1M window (Opus 4.7+, Sonnet 5+, Fable) at 1M directly.

Confirmed vs not documented

Confirmed (verbatim in the docs)

Each of these can be checked word for word in the official Claude Code docs, the changelog or the QCode docs: VS Code 1.94.0 or later; the extension bundles the CLI but does not add it to PATH; ~/.claude/settings.json is shared between the extension and the CLI; gateway variables go in claudeCode.environmentVariables, whose credentials the extension checks before launching; Disable Login Prompt skips authentication prompts; ANTHROPIC_AUTH_TOKEN is sent as Authorization: Bearer and ANTHROPIC_API_KEY as x-api-key; a credential variable takes precedence over a saved claude.ai login; setting only ANTHROPIC_BASE_URL without a credential does not replace the subscription login; the extension and the CLI share conversation history; the switch to a 1M default window in 2.1.285; and the QCode values https://api.qcode.cc/api and a cr_ key.

Not documented or not verified

This page draws no conclusion on three points. First, as of 2026-10-07 the official extension settings table does not list a separate API key or base URL setting; this page covers only the configuration locations the official docs list, and other config-file approaches are out of scope. Second, the official docs say Claude Code cannot detect a lower limit that a gateway enforces, so whether your gateway accepts 1M is for its own docs or your own testing to show. Third, setting names and buttons in the extension change between versions; this page follows the official docs fetched on 2026-10-07 without testing each version, so go by the version you have.

Where it goes and how it relates to the CLI

environmentVariables vs settings.json

Writing both is simplest. claudeCode.environmentVariables is a VS Code user setting that sets environment variables for the Claude process; the extension checks its credentials before launching, which is why the official gateway docs put the credential there. The env block in ~/.claude/settings.json is shared by the extension and the terminal CLI, and the official VS Code docs recommend it for shared config. Write only the latter and the values reach the process but not the extension's own login check; write only the former and the config is not shared with the terminal CLI.

VS Code extension vs terminal CLI

Both read the same settings files and share conversation history: run claude --resume in the terminal to continue an extension conversation. The difference is features. The official comparison table says the CLI has all commands and skills while the extension has a subset (type / to see them); the ! Bash shortcut and tab completion are CLI-only. The extension does not add claude to your PATH, so the CLI needs its own install; when the extension doesn't show why something fails, the official advice is to run claude in the terminal for more detailed error messages.

Five steps to a custom gateway

① Install the extension: open the Extensions view (Cmd+Shift+X / Ctrl+Shift+X), search for Claude Code and click Install, or run code --install-extension anthropic.claude-code in a terminal; VS Code 1.94.0 or later is required. ② Run Preferences: Open User Settings (JSON) from the Command Palette and add claudeCode.environmentVariables with two entries: name ANTHROPIC_BASE_URL with value https://api.qcode.cc/api, and name ANTHROPIC_AUTH_TOKEN with your cr_ key as the value. ③ If a login screen still appears, open settings, search for Claude Code login and check Disable Login Prompt (the official docs describe it as skipping authentication prompts for third-party setups). ④ To share the config with the terminal CLI, add the same two values to the env block of ~/.claude/settings.json (on Windows %USERPROFILE%\.claude\settings.json); do not put them in a project's .claude/settings.json. ⑤ Run Developer: Reload Window, type /status in the panel to check the version, account, model and server details, then send a test message.

On QCode

On QCode, the two values come from the QCode docs: ANTHROPIC_BASE_URL=https://api.qcode.cc/api (up to /api, no trailing slash) and ANTHROPIC_AUTH_TOKEN set to a key that starts with cr_ (created in the dashboard), which Claude Code sends as a Bearer token. Claude models work only through the Anthropic-protocol endpoint, and that is the protocol the VS Code extension uses. Claude models you can call on QCode include claude-sonnet-5-5, claude-opus-5-5 and claude-sonnet-5; billing is per token, each model's price is on /models, and the Claude family has no separate long-context tier. In North America and Europe you can use us.qcode.cc (Los Angeles); for networks in mainland China the docs suggest asia.qcode.cc, with the same path and the same key. Every request can be looked up at probe.qcode.cc by entering your key.

Frequently asked questions

Where do I enter the API key and custom base URL for Claude Code in VS Code?

In claudeCode.environmentVariables in your VS Code user settings. Run Preferences: Open User Settings (JSON) from the Command Palette and add two entries, ANTHROPIC_BASE_URL and ANTHROPIC_AUTH_TOKEN; for QCode, use https://api.qcode.cc/api and your cr_ key. As of 2026-10-07, the official extension settings table does not list a separate API key or base URL setting, and the official gateway docs say the extension checks credentials from this setting before launching, so it's the reliable place for a gateway credential.

I exported the variables in my terminal, but the extension still can't find the key. Why?

Most likely the variables never reached VS Code. The official docs say shell exports apply only to that terminal session and programs started from it, and an editor launched from the dock or Start menu won't see them. Putting them only in the env block of ~/.claude/settings.json is not enough either: those values reach the spawned process but not the extension's own login check. Add both to claudeCode.environmentVariables, run Developer: Reload Window, and type /status in the panel to check.

Why does it still ask me to log in after I configured everything?

Usually the extension's login check doesn't see a credential. First make sure the credential is in claudeCode.environmentVariables and that you didn't set only ANTHROPIC_BASE_URL: the official docs say setting the base URL without a credential variable doesn't replace the subscription, and a saved claude.ai login stays the active credential. If the login screen still appears, search settings for Claude Code login and check Disable Login Prompt; 2.1.261 fixed the screen appearing despite that setting, so update older versions first. If startup shows a warning that names two credential sources and ends in auth may not work as expected, the official fix is to run /logout so only the gateway credential remains.

Can the VS Code extension and the terminal CLI share one configuration?

Yes, through ~/.claude/settings.json. The official docs say the terminal, the VS Code and JetBrains extensions and the desktop app all read the same settings files; put ANTHROPIC_BASE_URL and ANTHROPIC_AUTH_TOKEN in its env block and claude in the terminal uses the same gateway. When a shell export and a settings-file env block set the same variable, the settings-file value applies. The two also share conversation history, so claude --resume in the terminal continues an extension conversation. Note that the extension does not add claude to your PATH; the CLI needs its own install.

How do I choose a model, and what if the one I want isn't in the picker?

Click the model pill below the prompt box or type /model; you can also set the ANTHROPIC_MODEL environment variable or the model field in a settings file. The official docs say /model saves your choice as the default for new sessions in the model field of your user settings, so the extension and the CLI read the same default. If your gateway's model names aren't in Claude Code's built-in list, the official fix is CLAUDE_CODE_ENABLE_GATEWAY_MODEL_DISCOVERY=1, which fills the picker from the gateway's model list. On QCode, the model can be claude-sonnet-5-5, claude-opus-5-5 or claude-sonnet-5; the current list is on /models.

Should I use ANTHROPIC_AUTH_TOKEN or ANTHROPIC_API_KEY?

For QCode, use ANTHROPIC_AUTH_TOKEN. The official docs say it is sent in the Authorization: Bearer header, while ANTHROPIC_API_KEY goes in x-api-key; a credential in the wrong variable reaches the gateway in a header it doesn't read and fails with 401, so switch to the other variable and try again. The QCode docs put the key in ANTHROPIC_AUTH_TOKEN by convention, and a tool that only reads ANTHROPIC_API_KEY also works with the same cr_ key. One more difference: ANTHROPIC_API_KEY needs a one-time approval in interactive mode before it takes over, while ANTHROPIC_AUTH_TOKEN takes precedence over a saved login immediately.

Sources

Configuration locations and extension behavior: the official Claude Code docs page for VS Code (code.claude.com: prerequisites, the extension settings table, third-party setup steps, the CLI comparison and common fixes), plus the pages on connecting to an LLM gateway, the LLM gateway overview, authentication, settings, environment variables and model configuration, all fetched on 2026-10-07. Version changes: the CHANGELOG and GitHub Releases publish times (UTC) of the anthropics/claude-code repository, fetched the same day. QCode values: the QCode docs pages on environment variables (updated 2026-09-25), endpoints and API formats, and VS Code integration (updated 2026-09-18), plus the /models page, fetched the same day.

Connect VS Code to QCode

Two variables and one cr_ key, shared by the extension and the terminal CLI. Billed per token; see /models for each model's price.

Related reading

The steps and quotes on this page were checked on 2026-10-07 against the official Claude Code docs, the changelog and the QCode docs; upstream changes may happen without notice. Extension screens and setting names change between versions, so go by the version you have; model availability is whatever /models shows.

Try first, then decide

Not sure which tier? Start with Starter ($8.57/mo) and upgrade when you're happy — the unused value of the old plan goes back to your balance.