Adding Your Own Environment Variables
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 and we'll update your instance.
Step 1 — Add the variable in Settings
- Open your app in LlamaPress so you can see the Leo chat panel.
- Click the Settings icon ( the cog at the top, next to Leo's name).
- Click Environment & Models.
- Find the Your Variables section.
- Click Add Variable.
- Type the key name. Use all capital letters, no spaces, with an
underscore (
_) between words — for exampleGEMINI_API_KEYorSTRIPE_SECRET_KEY. - Paste the value.
- 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:
- Click into the Leo chat box.
- Type
/— a command menu appears. - Type
restartand 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 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 for more.
Want to see everything else Leo can do? Read Leo Tools and Features. Curious what happens to your app's code and data over time? See You Own Your App.
Stuck connecting an API, or not sure which variables your integration needs? Email support@llamapress.ai and we'll walk through it with you.