# Adding Your Own Environment Variables

> Add API keys and other environment variables from Settings, then restart Leo so your app can use them.

Source: https://llamapress.ai/wiki/adding-environment-variables | Updated: 2026-08-17

---

[Back to Wiki](https://llamapress.ai/wiki)

Give your app API keys and other secret settings — right from the Settings panel.

An **environment variable** is a named value your app can read while it runs. It is the standard, safe place to keep **secrets** — things like an API key for Stripe, Google Gemini, OpenAI, or an email service. The secret stays out of your code and out of your pages, but your app can still use it.

**The short version:** Settings  Environment & Models  Your Variables  Add Variable. Then type `/restart` in the Leo chat. Done.

## Before you start

- You need the value you want to store — for example, the API key from your provider's dashboard.
- This feature ships with LlamaPress version **0.7.1** and newer. If you don't see "Your Variables" in Settings, email [support@llamapress.ai](mailto:support@llamapress.ai) and we'll update your instance.

## Step 1 — Add the variable in Settings

1. Open your app in LlamaPress so you can see the Leo chat panel.
2. Click the **Settings** icon ( the cog at the top, next to Leo's name).
3. Click **Environment & Models**.
4. Find the **Your Variables** section.
5. Click **Add Variable**.
6. Type the **key name**. Use all capital letters, no spaces, with an underscore (`_`) between words — for example `GEMINI_API_KEY` or `STRIPE_SECRET_KEY`.
7. Paste the **value**.
8. Click **Save**.

**Naming rules:** ALL\_CAPS, no spaces, underscores between words. `GEMINI_API_KEY` works. `gemini api key` does not.

## Step 2 — Restart your app

Your app only reads environment variables when it starts. So after you save a new variable, restart the app:

1. Click into the Leo chat box.
2. Type `/` — a command menu appears.
3. Type `restart` and press **Enter**.

Leo restarts your application. This takes a moment — your app may be briefly unavailable while it comes back up. When it's back, the new variable is live.

## Step 3 — Use it in your app

Now you (or Leo) can read the value anywhere in your Rails app with `ENV["YOUR_KEY_NAME"]`. The easiest way: just tell Leo the variable exists. For example:

> "I added a variable called `GEMINI_API_KEY` in Settings. Please use it to connect the app to the Gemini API."

Leo will wire it up with `ENV["GEMINI_API_KEY"]` in the right place — without ever writing the secret itself into your code.

**Keep secrets secret.** Never paste an API key into the chat, into your code, or onto a page of your app. Put it in Your Variables instead, and refer to it by its key name. If you think a key has leaked, generate a new one in your provider's dashboard and update the value in Settings.

## Updating or removing a variable

Go back to **Settings → Environment & Models → Your Variables**. You can change a value or remove a variable there. After any change, run `/restart` again so the app picks it up.

## Troubleshooting

- **The app can't see my variable.** Did you restart? New and changed variables only take effect after `/restart`.
- **My key name won't save.** Check the naming rules: all capital letters, no spaces, underscores between words.
- **I don't see "Your Variables" in Settings.** Your instance may be on an older version. Email [support@llamapress.ai](mailto:support@llamapress.ai) and we'll update it.
- **The integration still fails after the restart.** Double-check the value for extra spaces at the start or end, and confirm the key is active in your provider's dashboard. See [Common Errors and Fixes](https://llamapress.ai/wiki/common-errors-and-fixes) for more.

Want to see everything else Leo can do? Read [Leo Tools and Features](https://llamapress.ai/wiki/leo-tools-and-features). Curious what happens to your app's code and data over time? See [You Own Your App](https://llamapress.ai/wiki/you-own-your-app).

Stuck connecting an API, or not sure which variables your integration needs? Email [support@llamapress.ai](mailto:support@llamapress.ai) and we'll walk through it with you.
