You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
2. Optionally, you can now share and serve the flow by keeping the flow JSON and `requirements.txt` in the same environment.
165
164
To serve the flow without the Langflow UI, do the following:
166
165
167
166
1. Create a virtual environment:
168
-
```bash
169
-
uv venv VENV_NAME
170
-
```
167
+
```
168
+
uv venv VENV_NAME
169
+
```
171
170
172
171
2. Activate the virtual environment.
173
-
```bash
174
-
source VENV_NAME/bin/activate
175
-
```
172
+
```
173
+
source VENV_NAME/bin/activate
174
+
```
176
175
177
176
3. Install the dependencies from `requirements.txt` in the virtual environment:
178
-
```bash
179
-
uv pip install -r requirements.txt
180
-
```
177
+
```bash
178
+
uv pip install -r requirements.txt
179
+
```
181
180
182
181
4. To set a Langflow API key, run:
183
-
```bash
184
-
export LANGFLOW_API_KEY=YOUR_LANGFLOW_API_KEY
185
-
```
186
-
Replace `YOUR_LANGFLOW_API_KEY` with your server's API key.
182
+
```
183
+
export LANGFLOW_API_KEY=LANGFLOW_API_KEY
184
+
```
187
185
188
186
5. To serve the flow without the Langflow UI, pass the flow JSON path to the `lfx serve` command:
189
-
```bash
190
-
lfx serve flows/Simple_Agent.json
191
-
```
187
+
```
188
+
lfx serve flows/Simple_Agent.json
189
+
```
190
+
191
+
`lfx serve` starts a FastAPI app that exposes your flow as an HTTP API endpoint.
192
+
For more information, see the [Langflow LFX README](https://github.com/langflow-ai/langflow/blob/main/src/lfx/README.md).
193
+
194
+
## Manage multiple environments with `environments.yaml`
195
+
196
+
The `environments.yaml` file created at initialization contains three example entries for deployment environments:
197
+
198
+
```yaml
199
+
local:
200
+
url: http://127.0.0.1:7860
201
+
api_key_env: LANGFLOW_LOCAL_API_KEY
202
+
staging:
203
+
url: https://staging.example.com
204
+
api_key_env: LANGFLOW_STAGING_API_KEY
205
+
production:
206
+
url: https://langflow.example.com
207
+
api_key_env: LANGFLOW_PRODUCTION_API_KEY
208
+
```
209
+
210
+
Each entry contains a `url` for the Langflow base URL, and an `api_key_env` field.
211
+
The `api_key_env` field names an environment variable that you either `export` or store in a `.env` file, and does not store the secret string itself, which makes `environments.yaml` safe to commit to version control.
212
+
213
+
The names `local`, `staging`, and `production` in `environments.yaml` are conventions, and can be named whatever your project requires. You can add more than three entries.
214
+
215
+
`environments.yaml`is distinct from the Langflow or LFX `.env` file.
216
+
`environments.yaml`controls which remote Langflow instance you're deploying flows to, flow versioning, and environment variable _names_ for API keys.
217
+
The `.env` contains runtime values for the Langflow server, and might also contain _actual secret values_, so the `.env` should not be committed to version control.
218
+
219
+
Commands that call a Langflow server over HTTP, such as `lfx pull` or `lfx push`, use `--env ENVIRONMENT_NAME` to determine which Langflow instance to send the request to.
220
+
221
+
For example, to send a `push` request to a server named `local` in `environments.yaml`, run:
222
+
223
+
```bash
224
+
lfx push --env local
225
+
```
192
226
193
-
`lfx serve` starts a FastAPI app that exposes your flow as an HTTP API endpoint.
194
-
For more information, see the [Langflow LFX README](https://github.com/langflow-ai/langflow/blob/main/src/lfx/README.md).
227
+
This command will send the request to the Langflow base URL at `http://127.0.0.1:7860` using a Langflow API key named `LANGFLOW_LOCAL_API_KEY`.
0 commit comments