Skip to content

Commit 82d7383

Browse files
authored
docs: Clarify .env file scope in Flash documentation (#562)
2 parents d2c43be + 1e5c79a commit 82d7383

4 files changed

Lines changed: 50 additions & 8 deletions

File tree

flash/apps/local-testing.mdx

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -155,12 +155,22 @@ flash run --auto-provision
155155

156156
**Authentication errors**
157157

158-
Ensure `RUNPOD_API_KEY` is set in your `.env` file or environment:
158+
Run `flash login` to authenticate:
159+
160+
```bash
161+
flash login
162+
```
163+
164+
Alternatively, set `RUNPOD_API_KEY` as an environment variable or in your `.env` file:
159165

160166
```bash
161167
export RUNPOD_API_KEY="your_api_key_here"
162168
```
163169

170+
<Note>
171+
Values in your `.env` file are only available locally for CLI commands. They are not passed to deployed endpoints.
172+
</Note>
173+
164174
## Next steps
165175

166176
- [Deploy to production](/flash/apps/deploy-apps) when your app is ready.

flash/cli/login.mdx

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -57,16 +57,20 @@ Instead of using `flash login`, you can set your API key directly as an environm
5757
export RUNPOD_API_KEY=your_api_key_here
5858
```
5959

60-
Or add it to your project's `.env` file:
60+
Or add it to your project's `.env` file for local CLI use:
6161

6262
```bash
6363
RUNPOD_API_KEY=your_api_key_here
6464
```
6565

66-
You can generate an API key with the correct permissions from [Settings > API Keys](https://www.runpod.io/console/user/settings) in the Runpod console.
66+
Generate an API key from [Settings > API Keys](https://www.runpod.io/console/user/settings) in the Runpod console.
6767

6868
<Warning>
69-
Your Runpod API key needs **All** access permissions to your Runpod account.
69+
Values in your `.env` file are only used for local CLI commands and development. They are **not** passed to deployed endpoints. To set environment variables on deployed endpoints, use the `env` parameter in your endpoint configuration. See [Endpoint parameters](/flash/configuration/parameters#env) for details.
70+
</Warning>
71+
72+
<Warning>
73+
Your Runpod API key needs **All** access permissions.
7074
</Warning>
7175

7276

flash/configuration/parameters.mdx

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -282,6 +282,24 @@ async def load_model():
282282
...
283283
```
284284

285+
<Warning>
286+
Values in your project's `.env` file are only available locally for CLI commands and development. They are **not** passed to deployed endpoints. You must declare environment variables explicitly using the `env` parameter.
287+
</Warning>
288+
289+
To pass a local environment variable to your deployed endpoint, read it from `os.environ`:
290+
291+
```python
292+
import os
293+
294+
@Endpoint(
295+
name="ml-worker",
296+
gpu=GpuGroup.ANY,
297+
env={"HF_TOKEN": os.environ["HF_TOKEN"]} # Read from local env, pass to workers
298+
)
299+
async def load_model():
300+
...
301+
```
302+
285303
<Note>
286304
Environment variables are excluded from configuration hashing. Changing environment values won't trigger endpoint recreation, making it easy to rotate API keys.
287305
</Note>

flash/troubleshooting.mdx

Lines changed: 14 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -82,19 +82,29 @@ RUNPOD_API_KEY environment variable is required but not set
8282

8383
1. Generate an API key from [Settings > API Keys](https://www.runpod.io/console/user/settings) in the Runpod console. The key needs **All** access permissions.
8484

85-
2. Set the key using one of these methods:
85+
2. Authenticate using one of these methods:
8686

87-
**Option 1: Environment variable**
87+
**Option 1: Use `flash login` (recommended)**
88+
```bash
89+
flash login
90+
```
91+
Opens your browser for authentication and saves your credentials.
92+
93+
**Option 2: Environment variable**
8894
```bash
8995
export RUNPOD_API_KEY="your_api_key"
9096
```
9197

92-
**Option 2: .env file in your project root**
98+
**Option 3: .env file for local CLI use**
9399
```bash
94100
echo "RUNPOD_API_KEY=your_api_key" > .env
95101
```
96102

97-
**Option 3: Add to your shell profile (`~/.bashrc` or `~/.zshrc`) for global authorization**
103+
<Note>
104+
Values in your `.env` file are only available locally for CLI commands. They are not passed to deployed endpoints.
105+
</Note>
106+
107+
**Option 4: Shell profile for persistent local access**
98108
```bash
99109
echo 'export RUNPOD_API_KEY="your_api_key"' >> ~/.bashrc
100110
source ~/.bashrc

0 commit comments

Comments
 (0)