# Layered Configuration for Third-Party LLM API Access: Sharing One Set of Credentials Between Coding Assistant Plugins and CLI
How to connect a coding assistant plugin and its CLI tool to a third-party model gateway: understand the two independent checks (plugin login and process requests), where each reads its configuration from, and how to layer credentials and shared settings so both entry points work reliably.
I. The Problem: Why the Same Tutorial Works for Some and Fails for Others
When using AI coding assistant tools, many developers want requests to go to a model gateway of their own choosing instead of the tool’s default service endpoint. The common approach is to search for tutorials — and you’ll quickly find that available tutorials fall into two camps:
- One says: put the gateway URL and access token into the global configuration file in your home directory (e.g.,
~/.claude/settings.jsonfor assistant config files), and both the CLI tool and the editor plugin will share it. - The other says: you must add the credentials to the environment variables list in your editor’s extension settings, or the plugin will stay stuck on the login page.
Both camps have people claiming success — and people failing repeatedly. The reason is simple: each camp describes only one of two independent checks, and neither explains the full chain.
This article first clarifies which configuration each check reads, then presents a recommended layered configuration approach, provides a three-step verification procedure, and finally covers recent version changes relevant to gateway users. Note: this article is based on official documentation, so please verify commands and field names against your own environment before applying them.
II. The Core Principle: Every Request Passes Two Checks
Something many tutorials fail to explain: between the moment you start a conversation in your editor and the moment the request actually reaches the gateway, there are two independent validation stages — and they read configuration from completely different sources.
2.1 First check: plugin login validation (before process start)
Before launching the underlying assistant process, the editor extension performs a login-state check. This check reads the editor’s own extension configuration — the environmentVariables setting — and, if you launch the editor from a terminal, the extension can also inherit environment variables from your current shell.
If this check finds no valid credentials, the typical symptom is the plugin panel stuck on the login page no matter how you refresh or restart — because the process that issues requests hasn’t even started yet.
2.2 Second check: the assistant process actually sending requests
The process that actually sends HTTP requests to the gateway is the assistant process launched by the extension. This process can read two kinds of configuration:
- Values injected via environment variables by the extension;
- Key-value pairs in the
envblock of the global configuration file.
If the URL or token at this stage is missing or wrong, the request goes to the default endpoint, or returns 401 Unauthorized.
2.3 The two checks at a glance
| Stage | Configuration source | If unreadable |
|---|---|---|
| Plugin login check (pre-launch) | Extension settings’ environment variables; shell variables inherited when launched from a terminal | Panel stuck on login page |
| Assistant process (actual requests) | The above environment variables + the env block in the global config file |
Request sent to default endpoint, or 401 |
2.4 Explaining why “both camps” sometimes succeed
With this table, the conflict between the two tutorial camps becomes clear:
- People who only wrote the global config file succeeded if they happened to launch the editor from a terminal with the relevant variables already exported — the first check passed, so they concluded “the global config file is enough.”
- People who launched the editor graphically (from the Dock or Start menu) couldn’t read shell variables, failed the first check, got stuck on the login page, and concluded “you must write it into extension settings.”
The official documentation also explicitly warns: variables exported in a shell only apply to that terminal and the programs it launches; an editor opened graphically won’t inherit them. This exactly explains why the same tutorial produces different results for different people.
Another common pitfall: many editor plugins bundle their own assistant binary, and the extension’s version number reflects its bundled version. Upgrading the CLI tool to the latest version in your terminal does not change the plugin’s version — the two must be upgraded separately.
III. Recommended Layered Configuration
Once you understand the principle, the configuration strategy follows one rule: put credentials where the first check can read them, and shared settings where both ends can read them.
3.1 Layer one: editor user settings (credentials and gateway URL)
Open the command palette in your editor and run “Open User Settings (JSON)”, then add a structure like the following (field names should match your extension’s documentation):
{"extension-name.environmentVariables": [{ "name": "GATEWAY_URL_VAR", "value": "https://your-gateway-url" },{ "name": "AUTH_TOKEN_VAR", "value": "replace-with-your-token" }],"extension-name.disableLoginPrompt": true}
A detail about authentication headers: some gateways require a standard Bearer token header, in which case use an AUTH_TOKEN-style variable; if the gateway requires the key in an x-api-key header, use an API_KEY-style variable instead. Choosing the wrong variable type is a common cause of “I configured everything but keep getting 401.”
3.2 Layer two: the env block in the global config file (shared behavior settings)
For behavior switches needed by both the CLI tool and the plugin (e.g., model name mapping, timeouts, log-level settings), write them into the env block of the global configuration file. Both ends will read them, avoiding duplicated maintenance.
If you also use the CLI tool, you can export the same credential variables in your shell profile (e.g., ~/.bashrc or ~/.zshrc), providing a fallback for terminal scenarios.
3.3 Security recommendations
- Never commit tokens to any repository. Even though editor user settings live on your local machine, avoid letting sync plugins carry them to shared devices.
- If a team shares a gateway, issue individual tokens per person on the gateway side for easier auditing and revocation.
IV. Three-Step Verification
After configuring, don’t rely on the plugin UI alone. Verify in this order:
Step 1: Verify the credentials themselves. Use plain curl to request the gateway’s model list or a minimal completion request, confirming both the URL and token work. This rules out problems on the gateway side.
Step 2: Verify the CLI tool. Run the assistant command in your terminal, ask a simple question, and confirm the request actually reached your gateway (checking the gateway’s access logs is the most reliable method).
Step 3: Verify the editor plugin. Launch the editor both ways, testing each: first from a terminal, then from the Dock/Start menu. If the first works but the second gets stuck on the login page, your extension settings layer isn’t right yet. Only when both succeed is your layered configuration in place.
V. Version-Upgrade Changes Relevant to Gateway Users
These tools iterate quickly, and recent minor releases include two categories of changes affecting gateway users:
First, configuration-reading logic occasionally changes. If you suddenly get stuck on the login page or see 401 errors after an upgrade, compare the extension’s changelog to check whether the environmentVariables reading behavior has changed.
Second, the bundled assistant version updates along with the extension. This means even if you haven’t touched the CLI tool, upgrading the extension may change the underlying assistant’s behavior, including details of env block handling and authentication headers. Teams are advised to run the three-step verification in a single-person environment before rolling out upgrades organization-wide.
VI. Summary
The root cause of failed third-party gateway integration is usually not incorrect configuration, but a failure to understand that the “plugin login check” and the “request-sending process” read configurations from different sources. Remember three rules to configure reliably:
- Write credentials and URLs into the editor extension’s environment variables setting so graphical launches pass the login check;
- Write shared behavior settings into the
envblock of the global config file, shared by the CLI and the plugin; - After upgrades, verify layer by layer with the three-step process (curl, CLI, and dual-method plugin launch) to isolate issues to a specific stage.
Following this layered approach eliminates the “the tutorial says it works but mine doesn’t” trial-and-error loop, and lets you quickly pinpoint which layer broke when versions change.
