Relay365Multi-model API relay desk
← All desk bulletins
Field notes from the deskEN1 desk reads

Shift Note: Environment Variables Across Three OSes

The setting lives in the process, not the command

An environment variable is a named text value that a program can read when it starts. Applications use these values for settings such as an API address, a working directory, or an API key. This keeps configuration separate from application code.

A variable has a name and a value. For example, OPENAI_BASE_URL could hold https://api.api365relay.com/v1. Names are usually uppercase by convention. On macOS and Linux, capitalization matters: API_KEY and api_key are different names.

The important operational detail is inheritance. A program normally receives environment variables from the process that launches it. A variable set in one terminal is available to programs started there, but it does not automatically reach another terminal or an already-running application.

macOS terminals usually start with zsh

Modern macOS accounts normally use zsh. To set a variable for the current terminal session, enter export OPENAI_BASE_URL="https://api.api365relay.com/v1". To supply a key, use export OPENAI_API_KEY="your-api-key", replacing the placeholder with your actual key.

The export command makes the variable available to child processes. Without export, a shell variable may exist only inside the shell rather than being passed to applications.

For a setting that should return in new interactive zsh sessions, add the export line to ~/.zshrc using a text editor. The tilde means your home directory. Open a new terminal afterward, or run source ~/.zshrc to reload that file in the current shell.

You may also encounter ~/.zprofile, which zsh reads for login shells. These files serve different startup stages; avoid copying the same setting into several files without checking which one your shell actually reads. If you use Bash instead, follow its startup-file rules.

Linux uses the same export syntax, with shell-specific files

In Bash or zsh on Linux, the same session command works: export OPENAI_BASE_URL="https://api.api365relay.com/v1". It lasts until that shell closes, unless you remove or replace it first.

For interactive Bash terminals, ~/.bashrc is a common place for persistent export lines. After editing it, open another terminal or run source ~/.bashrc. Bash login shells read different startup files, and whether they load ~/.bashrc depends on your configuration.

These instructions do not configure every application on the machine. Desktop applications, scheduled jobs, containers, and system services can have separate environments. For a service, use its service manager's configuration rather than assuming your personal shell settings will apply.

Windows commands depend on the terminal shell

Windows Terminal can host PowerShell, Command Prompt, and other shells. Check which one you are using before copying commands.

  • In PowerShell, set a session value with $env:OPENAI_BASE_URL = "https://api.api365relay.com/v1".
  • In Command Prompt, use set "OPENAI_BASE_URL=https://api.api365relay.com/v1" for the current session.
  • To save a user-level value from PowerShell, run [Environment]::SetEnvironmentVariable("OPENAI_BASE_URL", "https://api.api365relay.com/v1", "User").

A saved user-level value does not update existing processes. Restart the terminal application before testing it, and restart any editor or application that needs the new value. You can also edit user variables through Windows' environment-variable settings. Prefer user scope unless a setting genuinely belongs to every account.

Check a harmless value before handling a secret

On macOS or Linux, check the address with printenv OPENAI_BASE_URL. In PowerShell, enter $env:OPENAI_BASE_URL. In Command Prompt, enter echo %OPENAI_BASE_URL%.

Avoid printing API keys into screenshots, shared logs, or support conversations. Commands containing keys may remain in shell history, and startup files store them as readable text. Never commit keys to source control. A .env file is not automatically loaded by the operating system; your application or a supporting tool must read it.

To remove a session variable, use unset OPENAI_API_KEY in Bash or zsh, Remove-Item Env:OPENAI_API_KEY in PowerShell, or set "OPENAI_API_KEY=" in Command Prompt. Remove any saved definition separately.

Connect the client after checking its variable names

Relay365 is a useful option when you want a pay-as-you-go relay desk for multiple model families. Its API base is https://api.api365relay.com; OpenAI clients use https://api.api365relay.com/v1. Check your client's documentation: not every tool reads OPENAI_BASE_URL or OPENAI_API_KEY automatically.

If that setup fits your workflow, create a Relay365 account, configure the address and key your client expects, and launch it from the configured environment. When a setting appears missing, check the shell, startup file, and launching process before changing the application code.

Further desk bulletins

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