Relay365Multi-model API relay desk
← All desk bulletins
Agent shift notesEN659 desk reads

VS Code Assistants: A Guide to Environment Variables

A coding assistant running beside VS Code does not automatically share configuration with every other assistant. Each extension, command-line tool, and SDK decides which environment variables to read. This walkthrough helps you identify the right settings, pass them to the right process, and keep credentials out of your repository.

#1 · Identify what actually runs your assistant

Start by distinguishing a VS Code extension from a command-line tool running in the integrated terminal. Claude Code, Codex, and Gemini CLI may run in that terminal, while an extension can run in a separate extension-host process.

Check the tool’s documentation for its authentication method, endpoint settings, and configuration precedence. An extension might use VS Code settings or a sign-in flow instead of environment variables. Installing two assistants does not make them read the same variables.

#2 · Understand where variables come from

Programs normally inherit environment variables from the process that launches them. If you start VS Code from a configured shell, it can inherit that shell’s environment. Starting it from a desktop launcher may produce a different environment.

Setting a variable inside an integrated terminal affects programs launched afterward from that terminal, not an already-running extension host. Likewise, terminal-specific VS Code settings do not automatically configure extensions. After changing launch-time variables, fully quit and reopen VS Code when necessary.

#3 · Separate credentials, endpoints, and models

These settings solve different problems:

  • Credentials authorize requests, usually through an API key or token.
  • Base URLs choose the service receiving requests.
  • Model identifiers select a model supported by that service.

Changing an endpoint does not automatically replace credentials or select a compatible model. Use the provider’s exact API model identifier rather than assuming a display name is accepted. A key issued by one service generally cannot authenticate directly with another.

#4 · Check Claude Code’s Anthropic variables

For API-key authentication, Claude Code supports ANTHROPIC_API_KEY. ANTHROPIC_BASE_URL can point supported configurations at an alternative Anthropic-compatible endpoint. ANTHROPIC_AUTH_TOKEN is a separate bearer-token mechanism; do not treat it as an interchangeable spelling of the API-key variable.

Existing sign-in state, managed settings, and other authentication options can affect behavior. Follow the endpoint provider’s Claude Code instructions, and avoid leaving competing credentials configured while troubleshooting. Protocol compatibility matters: an OpenAI-compatible endpoint alone is not sufficient for an Anthropic-native client.

#5 · Treat Codex and OpenAI SDKs separately

OpenAI SDKs commonly read OPENAI_API_KEY. Base-URL configuration depends on the SDK and version: some support OPENAI_BASE_URL, while others require an explicit client option. Check the SDK you actually use.

Codex has its own configuration and authentication choices. Custom providers can be configured with a base_url and an env_key naming the environment variable that holds their credential. Do not assume that exporting OPENAI_BASE_URL will configure every Codex installation. Its selected provider, authentication mode, and required API capabilities must agree with the destination service.

#6 · Check Gemini CLI’s authentication path

Gemini CLI supports GEMINI_API_KEY for Gemini API-key authentication. Vertex AI configurations use a different path, involving settings such as GOOGLE_GENAI_USE_VERTEXAI, GOOGLE_CLOUD_PROJECT, and GOOGLE_CLOUD_LOCATION, alongside appropriate Google credentials.

Other Google libraries may recognize GOOGLE_API_KEY, but that does not make it a universal substitute across tools. For a relay setup, use the relay’s current Gemini CLI instructions rather than guessing an endpoint variable or applying OpenAI settings to a Gemini-native client.

#7 · Verify without exposing secrets

Check whether the expected variable is present without printing its value. Then make a small request and inspect the reported provider, model, and error category. Authentication failures suggest credential problems; unsupported-model or protocol errors suggest configuration mismatches.

A .env file is not automatically loaded by every assistant. Keep credential files out of version control, avoid secrets in shared workspace settings, and redact terminal output before sharing logs.

#8 · Consider a relay when it simplifies your setup

Relay365 is a pay-as-you-go relay desk for multiple model families, with support for Claude Code, Codex, Gemini CLI, and OpenAI SDKs. Its API base is https://api.api365relay.com; OpenAI clients add /v1. Follow its tool-specific setup instructions rather than applying that suffix universally.

If consolidating provider access fits your workflow, create a Relay365 account and test one assistant first. Confirm model availability, pricing, protocol support, and data-handling requirements before expanding the setup.

Further desk bulletins

Curious how it runs on your own code? Sign up →