Skip to main content

Langflow Executor - A lightweight CLI tool for executing and serving Langflow AI flows

Project description

lfx - Langflow Executor

lfx is a command-line tool for running Langflow workflows. It provides two main commands: serve and run.

Installation

From PyPI (recommended)

# Install globally
uv pip install lfx

# Or run without installing using uvx
uvx lfx serve my_flow.json
uvx lfx run my_flow.json "input"

From source (development)

# Clone and run in workspace
git clone https://github.com/langflow-ai/langflow
cd langflow/src/lfx
uv run lfx serve my_flow.json

Commands

lfx serve - Run flows as an API

Serve a Langflow workflow as a REST API.

Important: You must set the LANGFLOW_API_KEY environment variable before running the serve command.

export LANGFLOW_API_KEY=your-secret-key
uv run lfx serve my_flow.json --port 8000

This creates a FastAPI server with your flow available at /flows/{flow_id}/run. The actual flow ID will be displayed when the server starts.

Options:

  • --host, -h: Host to bind server (default: 127.0.0.1)
  • --port, -p: Port to bind server (default: 8000)
  • --verbose, -v: Show diagnostic output
  • --env-file: Path to .env file
  • --log-level: Set logging level (debug, info, warning, error, critical)
  • --check-variables/--no-check-variables: Check global variables for environment compatibility (default: check)

Example:

# Set API key (required)
export LANGFLOW_API_KEY=your-secret-key

# Start server
uv run lfx serve simple_chat.json --host 0.0.0.0 --port 8000

# The server will display the flow ID, e.g.:
# Flow ID: af9edd65-6393-58e2-9ae5-d5f012e714f4

# Call API using the displayed flow ID
curl -X POST http://localhost:8000/flows/af9edd65-6393-58e2-9ae5-d5f012e714f4/run \
  -H "Content-Type: application/json" \
  -H "x-api-key: your-secret-key" \
  -d '{"input_value": "Hello, world!"}'

lfx run - Run flows directly

Execute a Langflow workflow and get results immediately.

uv run lfx run my_flow.json "What is AI?"

Options:

  • --format, -f: Output format (json, text, message, result) (default: json)
  • --verbose: Show diagnostic output
  • --input-value: Input value to pass to the graph (alternative to positional argument)
  • --flow-json: Inline JSON flow content as a string
  • --stdin: Read JSON flow from stdin
  • --check-variables/--no-check-variables: Check global variables for environment compatibility (default: check)

Examples:

# Basic execution
uv run lfx run simple_chat.json "Tell me a joke"

# JSON output (default)
uv run lfx run simple_chat.json "input text" --format json

# Text output only
uv run lfx run simple_chat.json "Hello" --format text

# Using --input-value flag
uv run lfx run simple_chat.json --input-value "Hello world"

# From stdin (requires --input-value for input)
echo '{"data": {"nodes": [...], "edges": [...]}}' | uv run lfx run --stdin --input-value "Your message"

# Inline JSON
uv run lfx run --flow-json '{"data": {"nodes": [...], "edges": [...]}}' --input-value "Test"

Input Sources

Both commands support multiple input sources:

  • File path: uv run lfx serve my_flow.json
  • Inline JSON: uv run lfx serve --flow-json '{"data": {"nodes": [...], "edges": [...]}}'
  • Stdin: uv run lfx serve --stdin

Development

# Install development dependencies
make dev

# Run tests
make test

# Format code
make format

License

MIT License. See LICENSE for details.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

lfx-0.1.1.tar.gz (4.0 MB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

lfx-0.1.1-py3-none-any.whl (912.2 kB view details)

Uploaded Python 3

File details

Details for the file lfx-0.1.1.tar.gz.

File metadata

  • Download URL: lfx-0.1.1.tar.gz
  • Upload date:
  • Size: 4.0 MB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.8.10

File hashes

Hashes for lfx-0.1.1.tar.gz
Algorithm Hash digest
SHA256 5b11fe4cd9610751f34731548dce2a341b2e2ef1cdcc1b404d3468d135edcea7
MD5 aca70ccc04c0e2e730c80092b8e5ae79
BLAKE2b-256 b0820086b7b4281652d9ff5904aa1196044dcdc0284ea2cb1bf68041368d84d0

See more details on using hashes here.

File details

Details for the file lfx-0.1.1-py3-none-any.whl.

File metadata

  • Download URL: lfx-0.1.1-py3-none-any.whl
  • Upload date:
  • Size: 912.2 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.8.10

File hashes

Hashes for lfx-0.1.1-py3-none-any.whl
Algorithm Hash digest
SHA256 9ed8d840e4adebfc2afa19c8727a86c53d8cfeb3945feaa1d1dd8de62448fb47
MD5 5c67065b7eb3250dee48c20bb0b4edd1
BLAKE2b-256 6cdba7460eb4b6f06089a63dcc850a5700680f18d711be38d19e8df1d4768df9

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page