CLI vs. Editor Extension: How API Gateway Configuration Differs

    Connecting an AI coding assistant to a private or self-hosted API gateway can require different settings for the CLI and its editor extension. This article explains the extension’s two configuration checks, outlines a layered setup for credentials and shared settings, and provides a three-step verification process, with guidance on environment inheritance and version differences.

    When connecting an AI coding assistant to a private or self-hosted API gateway, developers often encounter a confusing mismatch: the standalone command-line interface (CLI) and the editor extension appear to offer the same functionality, yet their configuration requirements differ.

    Online guides tend to recommend one of two approaches. Some say that placing the gateway URL and token in the global user configuration file is enough for both the CLI and the extension. Others insist that credentials must be added to the extension’s environment-variable settings; otherwise, the extension remains stuck on its login screen.

    Both approaches have worked for some users and failed for others. The underlying reason is that the extension performs two separate checks, and those checks do not necessarily read the same configuration sources.

    This article explains those checks, presents a layered configuration approach, and walks through a three-step verification process before covering important version-related details.

    1. Two Checks, Different Configuration Sources

    The editor extension’s gateway connection workflow can be divided into two stages.

    First Check: The Extension’s Login Check

    Before starting the underlying coding assistant process, the extension checks the user’s authentication configuration.

    At this stage, it reads the extension’s environment-variable settings from the editor’s user settings. If the editor was launched from a terminal, it can also inherit environment variables exported in that shell.

    Second Check: Requests from the Underlying Process

    Once the login check passes, the extension starts the assistant process that sends API requests.

    That process can read both the environment variables described above and the environment-variable block in the global user configuration file.

    If the first check cannot find credentials, the extension panel remains on the login screen. If the underlying process cannot find the correct configuration, requests may go to the default official endpoint or fail with a 401 Unauthorized response.

    This distinction explains why apparently conflicting guides can both produce successful results. A developer who only edits the global configuration file may also happen to launch the editor from a terminal where the required variables are already exported. Those inherited variables allow the first check to pass, leading the developer to conclude that the configuration file alone is sufficient.

    By contrast, an editor launched from a desktop shortcut, Dock, or Start menu does not inherit variables exported in that terminal session. Without credentials available to the first check, the extension stays on the login screen.

    The official documentation also notes this environment-variable scope: variables exported in a shell apply to that terminal session and programs launched directly from it. Applications opened through the graphical interface do not receive those shell exports.

    Another important detail is runtime versioning. Editor extensions typically include a bundled CLI runtime, and the extension version corresponds to its bundled assistant version. Updating the standalone CLI in your terminal does not update the runtime used by the extension.

    When troubleshooting, check which version is actually running. A working terminal CLI and a failing extension do not necessarily indicate a configuration problem.

    The guiding principle is simple: put credentials where the login check can read them, and put shared configuration where both runtimes can read it.

    Editor User Settings: Credentials and Gateway URL

    Open the editor’s command palette, select the command to open user settings as JSON, and add the following configuration:

    1. {
    2. "claudeCode.environmentVariables": [
    3. {
    4. "name": "ANTHROPIC_BASE_URL",
    5. "value": "https://your-gateway-address"
    6. },
    7. {
    8. "name": "ANTHROPIC_AUTH_TOKEN",
    9. "value": "replace-with-your-token"
    10. }
    11. ],
    12. "claudeCode.disableLoginPrompt": true
    13. }

    The authentication token variable uses the Authorization: Bearer request header. If your gateway instead requires an x-api-key header, use the corresponding API key environment variable.

    Global User Configuration: Shared Settings

    Use the tool’s configuration file in your home directory for non-credential settings shared by the CLI and the extension, such as model preferences, proxy settings, and timeout parameters.

    This avoids duplicating common settings for the CLI while allowing the process launched by the extension to read them as well.

    Temporary Overrides: For Debugging Only

    For troubleshooting, you can inject an environment variable directly before a launch command:

    1. ANTHROPIC_BASE_URL=https://your-gateway-address anthropic-cli

    This is a temporary, terminal-scoped override for the invoked command. It is useful for quick verification, but it should not be treated as a persistent configuration method.

    3. A Three-Step Verification Process

    After configuring the gateway, test each layer in the following order. The point at which a test fails helps identify the source of the problem.

    1. Verify CLI connectivity.
      Run the CLI directly in the terminal and send a simple request. Confirm that the gateway URL and token work.

    2. Launch the editor from the terminal and test the extension.
      Open the editor using its launch command in the same terminal, with the relevant environment variables exported. The editor can then inherit those variables. If the extension works in this context, the configuration values are valid, and environment-variable propagation is the likely issue.

    3. Launch the editor from the graphical interface for a final check.
      Open it from a desktop shortcut, Dock, or Start menu. This verifies that the extension’s environment-variable configuration in user settings is taking effect without relying on terminal exports. If the first two tests pass but this one fails, check the user settings JSON syntax and whether the settings were placed at the user or workspace level.

    4. Version Differences and Other Considerations

    Recent extension versions have changed some behavior for gateway users. Details such as environment-variable precedence and login-screen handling can differ between minor releases.

    If a previously working configuration fails after an extension update, do not immediately assume the gateway is at fault. First compare the extension versions and review the relevant release notes.

    Keep credentials out of project repositories and workspace settings. Store them in user-level settings to reduce the risk of accidental exposure and avoid configuration drift between projects.

    The configuration approach described here is based on the official documentation, but behavior may vary slightly by version. Check the versions in your environment before applying the settings, and use the official documentation as the primary reference when troubleshooting unexpected behavior.