Flow DevOps Toolkit SDK
Use the Flow DevOps Toolkit SDK to version, test, and deploy your flows.
Instead of manually exporting, sharing, and importing flow JSON files from the Langflow UI, the Flow DevOps toolkit offers terminal-based workflows for versioning, environment variables, testing, and deployment.
Prerequisites
-
Create a Langflow API key
-
Install the Langflow
lfxpackageTo install the
lfxpackage from PyPI, do the following:-
Create a virtual environment:
_10uv venv VENV_NAME -
Activate the virtual environment.
_10source VENV_NAME/bin/activate -
Install the Langflow LFX package in the virtual environment:
_10uv pip install lfx -
Run Flow DevOps Toolkit commands in the virtual environment that has LFX installed.
Alternatively, you can run
uvx lfxcommands, or run LFX from thesrc/lfxdirectory in a cloned Langflow repo. For more information, see the Langflow LFX README.
-
Create a project and version a flow
-
Create a flow in the Langflow UI, such as the Simple Agent starter flow in the Quickstart.
-
Open a terminal session within the virtual environment that has
lfxinstalled. -
To initialize a project, run:
_10lfx init PROJECT_NAMEReplace
PROJECT_NAMEwith a name for your project folder.lfx initcreates a scaffold for your project. The output is similar to the following:_23demo-project/_23├── .github/_23│ └── workflows/_23│ ├── langflow-push.yml # CI workflow_23│ ├── langflow-test.yml # CI workflow_23│ └── langflow-validate.yml # CI workflow_23├── .gitignore # ignores legacy credentials file_23├── .lfx/_23│ └── environments.yaml # edit with your instance URLs + API key env var names (safe to commit)_23├── ci/_23│ ├── ci-push.sh # generic CI script_23│ ├── ci-test.sh # generic CI script_23│ └── ci-validate.sh # generic CI script_23├── flows/_23│ └── .gitkeep # versioned empty directory_23└── tests/_23├── __init__.py_23└── test_flows.py # flow_runner example tests_23_23✔ Project scaffolded. Next steps:_231. Edit `.lfx/environments.yaml` with your instance URL_232. export LANGFLOW_LOCAL_API_KEY=<key> (Settings -> API Keys)_233. lfx pull --env local --output-dir flows/The project scaffold includes the following tools for building flows:
.github/workflows: GitHub CI tooling..lfx/environments.yaml: Control your project's URL and API keys as environment variables for local, staging, and production environments.ci/Shell scripts for pushing, testing, and validating flows.flows/: An empty directory to store flows that includes a.gitkeepfile for flow versioning.tests/test_flows.py: Example tests that you can modify to test flows.
-
Add your Langflow API key to your
.envfile, or export it within the terminal session. The Flow DevOps SDK includesurlandapi_key_envenvironment variables forlocal,staging, andproductionenvironments. The variable name for the API key differs between environments, so ensure you're adding the correct variable. For example, to add a Langflow API key to a local Langflow server, set:_10export LANGFLOW_LOCAL_API_KEY=LANGFLOW_API_KEY -
To test server authentication with your API key, run:
_10lfx loginThe Flow DevOps SDK tests your key against the URL and confirms the connection is working. If the test reports
Authentication failed, create and export a new key and try again. -
To check the connected server for existing flows, run:
_10lfx pullThe Flow DevOps SDK lists your server's flows. Output is similar to the following (from a project directory such as
demo-project/):_10Pulling all flows from http://localhost:7860_10Pulled 'Simple Agent' -> flows/Simple_Agent.json_10_10┌────────────────┬──────────────────────────────────────┬───────────────────────────┬──────────┐_10│ Name │ ID │ File │ Status │_10├───── ───────────┼──────────────────────────────────────┼───────────────────────────┼──────────┤_10│ Simple Agent │ c2f91b01-9a73-4c62-b7f0-e15bc3bd6802 │ flows/Simple_Agent.json │ CREATED │_10└────────────────┴──────────────────────────────────────┴───────────────────────────┴──────────┘_10_101 updated.lfx pullpulls flow changes on the server to JSON files underflows/in your project (for exampledemo-project/flows). If you runlfx pullagain, the Flow DevOps SDK reports a Status ofUnchanged. You will pull changes in the next steps. -
In the Langflow UI, open the Simple Agent flow and change the flow. For example, change the Chat Input to a different input string. Save the flow.
-
Return to your terminal, and run
lfx status. The Flow DevOps SDK reports the flow's Status asUPDATED, because the hash of the flow JSON has changed with your update. -
To pull the reported changes from the Langflow server to your local project folder, run
lfx pull. -
To push flow changes from flows stored locally in
demo-project/flowsto the Langflow server, runlfx push.
Validate flows
The Flow DevOps SDK can validate that local flows are correctly formed before pushing to the Langflow with lfx validate.
- To test the Simple Agent starter flow, pass the flow JSON path to the
lfx validatecommand:_10lfx validate flows/Simple_Agent.json - Once validated, push flow changes to the server with
lfx push.
Generate requirements.txt for flows
The Flow DevOps SDK can generate a requirements.txt file for a flow.
A flow JSON describes nodes and wiring, and does not list the PyPI packages components import at runtime.
Generate a requirements.txt file to capture the minimal Python dependencies, so you can install a matching environment for the flow.
-
From your project directory, point
lfx requirementsat a flow JSON file. To print the requirements to the terminal:_10lfx requirements flows/Simple_Agent.jsonTo write a
requirements.txtfile instead of printing, use-oor--output:_10lfx requirements flows/Simple_Agent.json -o requirements.txt -
Optionally, you can now share and serve the flow by keeping the flow JSON and
requirements.txtin the same environment. To serve the flow without the Langflow UI, do the following:- Create a virtual environment:
_10uv venv VENV_NAME- Activate the virtual environment.
_10source VENV_NAME/bin/activate- Install the dependencies from
requirements.txtin the virtual environment:
_10uv pip install -r requirements.txt- To set a Langflow API key, run:
_10export LANGFLOW_API_KEY=LANGFLOW_API_KEY- To serve the flow without the Langflow UI, pass the flow JSON path to the
lfx servecommand:
_10lfx serve flows/Simple_Agent.jsonlfx servestarts a FastAPI app that exposes your flow as an HTTP API endpoint. For more information, see the Langflow LFX README.
Manage multiple environments with environments.yaml
The environments.yaml file created at initialization contains three example entries for deployment environments:
_10local:_10 url: http://127.0.0.1:7860_10 api_key_env: LANGFLOW_LOCAL_API_KEY_10staging:_10 url: https://staging.example.com_10 api_key_env: LANGFLOW_STAGING_API_KEY_10production:_10 url: https://langflow.example.com_10 api_key_env: LANGFLOW_PRODUCTION_API_KEY
Each entry contains a url for the Langflow base URL, and an api_key_env field.
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.
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.
environments.yaml is distinct from the Langflow or LFX .env file.
environments.yaml controls which remote Langflow instance you're deploying flows to, flow versioning, and environment variable names for API keys.
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.
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.
For example, to send a push request to a server named local in environments.yaml, run:
_10lfx push --env local
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.