Environment Variable

Last Updated: July 29, 2026 | By Mihail Sebastian | AI Dictionary

A named value the operating system passes to a program when it starts. Applications read API keys, paths, and settings from it instead of hardcoding them.

What is an Environment Variable?

An environment variable is a named value that the operating system passes to a program when it starts. Programs read configuration from it (API keys, file paths, feature flags) instead of hardcoding those values into source code.

The separation matters for two reasons. Secrets stay out of the codebase, and the same code runs unchanged in development, testing, and production because each environment supplies its own values.

How Environment Variables Work

Every process inherits a set of key-value pairs from whatever launched it. You set one in a shell (export HF_TOKEN=...), in a .env file, in a CI system’s settings, or in a container, and the program reads it by name at runtime.

ML tooling leans on this mechanism. CUDA_VISIBLE_DEVICES controls which GPUs a training job sees, and credentials for services like Hugging Face or OpenAI travel as variables such as HF_TOKEN and OPENAI_API_KEY.

Containers follow the same pattern. A Dockerfile sets defaults with its ENV instruction, and values passed when the container starts override them.

Example of an Environment Variable

A team trains a model on a shared GPU server and deploys it to the cloud. The training script needs a dataset path and two specific GPUs; the deployed service needs a database URL and an API key.

None of those values appear in the code. On the server, CUDA_VISIBLE_DEVICES=0,1 and DATA_DIR=/mnt/datasets are set before the job starts; in the cloud, the platform injects DATABASE_URL and the key from its secret store. One codebase, two environments, zero credentials in version control.

Related AI terms: Dockerfile · Deploy · CUDA · Version Control

Did you like the Environment Variable gist?

Learn about 250+ need-to-know artificial intelligence terms in the AI Dictionary.

Mihail Sebastian — Writes about AI governance, regulation, and the technology behind them. Placeholder bio — replace with a real credential line. About

Read the Governor's Letter

Stay ahead with Governor's Letter, the newsletter delivering expert insights, AI updates, and curated knowledge directly to your inbox.

By subscribing to the Governor's Letter, you consent to receive emails from AI Guv.
We respect your privacy - read our Privacy Policy to learn how we protect your information.

Browse All AI Terms A–Z

Every term in the dictionary, in alphabetical order. Jump to a letter or scroll the full list.

A

B

C

D

E

F

G

H

I

J

K

L

M

N

O

P

Q

R

S

T

U

V

W

X

Y

Z