> ## Documentation Index
> Fetch the complete documentation index at: https://docs.superserve.ai/llms.txt
> Use this file to discover all available pages before exploring further.

# Environment variables

> Inject environment variables at sandbox creation - applied to every process spawned inside the VM.

Env vars set at creation time are applied to **every** process the sandbox runs: `commands.run()`, shells, and anything those spawn. They persist across `pause()` / `resume()` cycles.

<Warning>
  Env var values are delivered **in plain text** — any process in the sandbox can read them. For API keys and other credentials, use [secrets](/secrets/overview) instead: the sandbox only ever holds a stand-in token, and the real value is attached to outbound requests.
</Warning>

<CodeGroup>
  ```typescript TypeScript theme={"theme":{"light":"github-light","dark":"vitesse-dark"}}
  const sandbox = await Sandbox.create({
    name: "data-analyzer",
    envVars: {
      OPENAI_API_KEY: "sk-...",
      DATABASE_URL: "postgres://...",
      NODE_ENV: "production",
    },
  })

  const result = await sandbox.commands.run("echo $NODE_ENV")
  console.log(result.stdout)  // "production\n"
  ```

  ```python Python theme={"theme":{"light":"github-light","dark":"vitesse-dark"}}
  sandbox = Sandbox.create(
      name="data-analyzer",
      env_vars={
          "OPENAI_API_KEY": "sk-...",
          "DATABASE_URL": "postgres://...",
          "NODE_ENV": "production",
      },
  )

  result = sandbox.commands.run("echo $NODE_ENV")
  print(result.stdout)  # "production\n"
  ```
</CodeGroup>

## Per-command overrides

The `env` option on `commands.run()` adds to or overrides the sandbox-wide env for a single command.

<CodeGroup>
  ```typescript TypeScript theme={"theme":{"light":"github-light","dark":"vitesse-dark"}}
  const result = await sandbox.commands.run("echo $NODE_ENV", {
    env: { NODE_ENV: "staging" },
  })
  console.log(result.stdout)  // "staging\n"
  ```

  ```python Python theme={"theme":{"light":"github-light","dark":"vitesse-dark"}}
  result = sandbox.commands.run(
      "echo $NODE_ENV",
      env={"NODE_ENV": "staging"},
  )
  print(result.stdout)  # "staging\n"
  ```
</CodeGroup>

<Note>
  Values pass through unmodified - no shell expansion or interpolation. Escape `$` and special characters yourself if needed.
</Note>
