Skip to content

Commit 767c18b

Browse files
authored
docs: flow devops toolkit SDK manage multiple environments (#12479)
* flow-devops-sdk-basic-usage * multiple-environments
1 parent 954bc80 commit 767c18b

2 files changed

Lines changed: 82 additions & 29 deletions

File tree

docs/docs/API-Reference/flow-devops-sdk.mdx

Lines changed: 62 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -55,8 +55,7 @@ Instead of manually exporting, sharing, and importing flow JSON files from the L
5555
│ └── langflow-validate.yml # CI workflow
5656
├── .gitignore # ignores legacy credentials file
5757
├── .lfx/
58-
│ └── environments.yaml # edit with your instance URLs
59-
| # + API keys (safe to commit)
58+
│ └── environments.yaml # edit with your instance URLs + API key env var names (safe to commit)
6059
├── ci/
6160
│ ├── ci-push.sh # generic CI script
6261
│ ├── ci-test.sh # generic CI script
@@ -82,16 +81,16 @@ Instead of manually exporting, sharing, and importing flow JSON files from the L
8281
* `tests/test_flows.py`: Example tests that you can modify to test flows.
8382

8483
4. Add your Langflow API key to your `.env` file, or export it within the terminal session.
85-
8684
The Flow DevOps SDK includes `url` and `api_key_env` environment variables for `local`, `staging`, and `production` environments.
8785
The variable name for the API key differs between environments, so ensure you're adding the correct variable.
8886
For example, to add a Langflow API key to a local Langflow server, set:
89-
```bash
90-
export LANGFLOW_API_KEY=YOUR_LANGFLOW_API_KEY
87+
88+
```text
89+
export LANGFLOW_LOCAL_API_KEY=LANGFLOW_API_KEY
9190
```
92-
Replace `YOUR_LANGFLOW_API_KEY` with your server's API key.
9391

9492
5. To test server authentication with your API key, run:
93+
9594
```bash
9695
lfx login
9796
```
@@ -133,10 +132,10 @@ Instead of manually exporting, sharing, and importing flow JSON files from the L
133132

134133
## Validate flows
135134

136-
The Flow DevOps SDK can validate that local flows are correctly formed with `lfx validate` before pushing to the Langflow server.
135+
The Flow DevOps SDK can validate that local flows are correctly formed before pushing to the Langflow with `lfx validate`.
137136

138137
1. To test the Simple Agent starter flow, pass the flow JSON path to the `lfx validate` command:
139-
```bash
138+
```
140139
lfx validate flows/Simple_Agent.json
141140
```
142141
2. Once validated, push flow changes to the server with `lfx push`.
@@ -151,44 +150,78 @@ Generate a `requirements.txt` file to capture the minimal Python dependencies, s
151150
1. From your project directory, point `lfx requirements` at a flow JSON file.
152151
To print the requirements to the terminal:
153152

154-
```bash
153+
```
155154
lfx requirements flows/Simple_Agent.json
156155
```
157156

158-
To write a `requirements.txt` file instead of printing, use the `-o` or `--output` flag:
157+
To write a `requirements.txt` file instead of printing, use `-o` or `--output`:
159158

160-
```bash
159+
```
161160
lfx requirements flows/Simple_Agent.json -o requirements.txt
162161
```
163162

164163
2. Optionally, you can now share and serve the flow by keeping the flow JSON and `requirements.txt` in the same environment.
165164
To serve the flow without the Langflow UI, do the following:
166165

167166
1. Create a virtual environment:
168-
```bash
169-
uv venv VENV_NAME
170-
```
167+
```
168+
uv venv VENV_NAME
169+
```
171170

172171
2. Activate the virtual environment.
173-
```bash
174-
source VENV_NAME/bin/activate
175-
```
172+
```
173+
source VENV_NAME/bin/activate
174+
```
176175

177176
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+
```
181180

182181
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+
```
187185

188186
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+
```
192226

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`.

docs/sidebars.js

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -469,6 +469,26 @@ module.exports = {
469469
label: "API reference",
470470
className: "sidebar-category-with-icon sidebar-icon-fileCode",
471471
items: [
472+
{
473+
type: "doc",
474+
id: "API-Reference/api-reference-api-examples",
475+
label: "Get started with the Langflow API",
476+
},
477+
{
478+
type: "doc",
479+
id: "API-Reference/typescript-client",
480+
label: "Use the TypeScript client"
481+
},
482+
{
483+
type: "doc",
484+
id: "API-Reference/flow-devops-sdk",
485+
label: "Flow DevOps Toolkit SDK",
486+
},
487+
{
488+
type: "doc",
489+
id: "API-Reference/api-flows-run",
490+
label: "Flow trigger endpoints",
491+
},
472492
"API-Reference/api-reference-api-examples",
473493
"API-Reference/typescript-client",
474494
"API-Reference/flow-devops-sdk",

0 commit comments

Comments
 (0)