How to Connect a Third-Party LLM API Gateway in a Code Editor Plugin
This article explains why some editor plugin configurations work while others remain stuck on the login page when connecting to a third-party LLM API gateway. It covers the two configuration checks—the plugin login check and the underlying CLI process—and recommends a layered setup with credentials in editor user settings and shared runtime options in the global configuration file. It also provides a three-step verification flow and version-related precautions.
1. Background: Why Some Configurations Work and Others Stay Stuck on the Login Page
When using an AI coding assistant in an editor and pointing it to a self-hosted or purchased API gateway—for example, a third-party service compatible with mainstream LLM protocols—community tutorials often give two conflicting recommendations:
- One says: write the service URL and token into the CLI tool’s global configuration file, a settings-style JSON file in the user home directory, and both the command line and the editor plugin will use them.
- Another says: you must write them into the environment-variable injection section of the editor’s user settings, otherwise the plugin will remain on the login screen.
Interestingly, both approaches have succeeded for some users and failed completely for others. This is not mysterious; each side describes only one of two checks. Once you understand where each check reads its configuration, failures become easy to explain.
2. Core Mechanism: A Request Must Pass Two Checks
According to the official integration documentation, before starting the underlying CLI process, this type of coding assistant plugin reads environment-variable injection settings from the editor’s user settings, such as claudeCode.environmentVariables, to check whether credentials are valid. The env block in the global configuration file can be passed to the launched CLI process, but it does not reach the plugin’s own pre-login check.
In other words, a complete request goes through two stages that read configuration from different sources:
- Plugin login check (before startup): reads only the environment-variable injection entries in the editor’s user settings. If the editor is launched from a terminal, it may also inherit variables exported in the shell. If nothing is found, the panel stays on the login page.
- CLI process (actual request sender): reads both the injected variables above and the
envblock in the global configuration file. If nothing is found, the request may go to the default official endpoint or return a 401 authentication failure.
This explains the disagreement between the two tutorial camps. Users who only write the global configuration file may pass the login check by chance if they launch the editor from a terminal and the relevant variables are also exported in the shell. They conclude that the config file is enough. Users who launch the editor from a desktop icon or Start menu cannot read shell variables and therefore stay on the login page. The official documentation also notes that variables exported in a shell apply only to that terminal session and its child processes; applications opened from a graphical interface entry point cannot read them.
Another often-overlooked detail: these plugins usually bundle their own embedded CLI tool, and the plugin version number corresponds to the bundled CLI version. If you manually upgrade the CLI in a terminal, the version used by the plugin does not update with it. When troubleshooting version-related behavior differences, always confirm the version the plugin actually uses.
3. Recommended Layered Configuration
The configuration principle can be summarized in one sentence: put credentials and service addresses where the login check can read them, and put shared non-credential settings where both sides can read them.
1. Editor User Settings (for Credentials and Service Address)
Open the editor’s user settings JSON file and add the environment-variable injection configuration, as shown below:
{"claudeCode.environmentVariables": [{ "name": "ANTHROPIC_BASE_URL", "value": "https://your-gateway-address" },{ "name": "ANTHROPIC_AUTH_TOKEN", "value": "your-access-token" }],"claudeCode.disableLoginPrompt": true}
Two notes:
ANTHROPIC_AUTH_TOKENcorresponds to theAuthorization: Bearerrequest header. If your gateway requires anx-api-keyheader, use theANTHROPIC_API_KEYvariable instead.disableLoginPromptdisables the login-page prompt, preventing the plugin from repeatedly showing the login screen when it cannot detect an official account.
2. Global Configuration File (for Shared Runtime Settings)
Runtime settings unrelated to credentials—such as output style, timeout values, and tool allowlists—can be written into the env block of the global configuration file, and the CLI process will read them. This way, shared settings remain effective even if editor settings are overridden.
3. Standardize the Launch Method
For team collaboration, it is recommended to standardize launching the editor from a terminal, for example by running code ., and exporting the relevant variables in the shell configuration file as a fallback. This reduces environment differences that cause some users to succeed while others fail.
4. Three-Step Verification Flow
After configuration, verify layer by layer in the following order to avoid one failure masking another:
- Verify the login check: Restart the editor, open the AI assistant panel, and confirm that it no longer stays on the login page and that the panel initializes normally.
- Verify request routing: Send a chat request, and use the gateway-side access log or local packet capture to confirm that the request actually reaches your gateway address rather than being sent to the default official endpoint.
- Verify shared configuration: Trigger a behavior in the session that depends on the
envblock configuration, such as calling a tool restricted by an allowlist, and confirm that the CLI process reads the shared configuration correctly.
If any step fails, use the rule of thumb “login check looks at editor settings; request routing looks at global configuration” to locate the issue quickly.
5. Version Evolution Precautions
In several recent minor versions, specifically the 2.1.323 to 2.1.327 range, there have been adjustments to behavior relevant to gateway users. For example, credential check timing and configuration priority may change slightly. Therefore, it is strongly recommended to:
- Check the release notes for the corresponding version before upgrading the plugin to confirm that the configuration method has no breaking changes.
- Pin the plugin version within a team to avoid the troubleshooting cost of “same configuration, different results” caused by version differences among members.
6. Conclusion
The essence of configuration problems is understanding “who reads what.” The plugin login check and the CLI process are two independent configuration consumers. A layered configuration puts credentials where they must be read and shared settings where they are generally readable. Combined with the three-step verification flow, this turns occasional “it happens to work” setups into reproducible, stable integrations. Finally, note that this article is based on official documentation. Different gateways may require different authentication headers, so verify against your own environment before going live.
