Skip to main content
Version: 1.10.x (Next)

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

  • Install and start Langflow

  • Create a Langflow API key

  • Install the Langflow lfx package

    To install the lfx package from PyPI, do the following:

    1. Create a virtual environment:


      _10
      uv venv VENV_NAME

    2. Activate the virtual environment.


      _10
      source VENV_NAME/bin/activate

    3. Install the Langflow LFX package in the virtual environment:


      _10
      uv pip install lfx

    4. Run Flow DevOps Toolkit commands in the virtual environment that has LFX installed.

      Alternatively, you can run uvx lfx commands, or run LFX from the src/lfx directory in a cloned Langflow repo. For more information, see the Langflow LFX README.

Create a project and version a flow

  1. Create a flow in the Langflow UI, such as the Simple Agent starter flow in the Quickstart.

  2. Open a terminal session within the virtual environment that has lfx installed.

  3. To initialize a project, run:


    _10
    lfx init PROJECT_NAME

    Replace PROJECT_NAME with a name for your project folder. lfx init creates a scaffold for your project. The output is similar to the following:


    _23
    demo-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:
    _23
    1. Edit `.lfx/environments.yaml` with your instance URL
    _23
    2. export LANGFLOW_LOCAL_API_KEY=<key> (Settings -> API Keys)
    _23
    3. 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 .gitkeep file for flow versioning.
    • tests/test_flows.py: Example tests that you can modify to test flows.
  4. Add your Langflow API key to your .env file, or export it within the terminal session. The Flow DevOps SDK includes url and api_key_env environment variables for local, staging, and production environments. 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:


    _10
    export LANGFLOW_LOCAL_API_KEY=LANGFLOW_API_KEY

  5. To test server authentication with your API key, run:


    _10
    lfx login

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

  6. To check the connected server for existing flows, run:


    _10
    lfx pull

    The Flow DevOps SDK lists your server's flows. Output is similar to the following (from a project directory such as demo-project/):


    _10
    Pulling all flows from http://localhost:7860
    _10
    Pulled '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
    _10
    1 updated.

    lfx pull pulls flow changes on the server to JSON files under flows/ in your project (for example demo-project/flows). If you run lfx pull again, the Flow DevOps SDK reports a Status of Unchanged. You will pull changes in the next steps.

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

  8. Return to your terminal, and run lfx status. The Flow DevOps SDK reports the flow's Status as UPDATED, because the hash of the flow JSON has changed with your update.

  9. To pull the reported changes from the Langflow server to your local project folder, run lfx pull.

  10. To push flow changes from flows stored locally in demo-project/flows to the Langflow server, run lfx push.

Validate flows

The Flow DevOps SDK can validate that local flows are correctly formed before pushing to the Langflow with lfx validate.

  1. To test the Simple Agent starter flow, pass the flow JSON path to the lfx validate command:

    _10
    lfx validate flows/Simple_Agent.json

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

  1. From your project directory, point lfx requirements at a flow JSON file. To print the requirements to the terminal:


    _10
    lfx requirements flows/Simple_Agent.json

    To write a requirements.txt file instead of printing, use -o or --output:


    _10
    lfx requirements flows/Simple_Agent.json -o requirements.txt

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

    1. Create a virtual environment:

    _10
    uv venv VENV_NAME

    1. Activate the virtual environment.

    _10
    source VENV_NAME/bin/activate

    1. Install the dependencies from requirements.txt in the virtual environment:

    _10
    uv pip install -r requirements.txt

    1. To set a Langflow API key, run:

    _10
    export LANGFLOW_API_KEY=LANGFLOW_API_KEY

    1. To serve the flow without the Langflow UI, pass the flow JSON path to the lfx serve command:

    _10
    lfx serve flows/Simple_Agent.json

    lfx serve starts 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:


_10
local:
_10
url: http://127.0.0.1:7860
_10
api_key_env: LANGFLOW_LOCAL_API_KEY
_10
staging:
_10
url: https://staging.example.com
_10
api_key_env: LANGFLOW_STAGING_API_KEY
_10
production:
_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:


_10
lfx 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.

Search