docs: refresh cli page (#9274)

* cli-values

* split-out-introductory-commands

* remove-feature-flag-envs

* cleanup-cli-links

* fix type

* clarification-on-cli-superuser

* remove-internal-env-vars

* alignment and editorial

* audit booleans

---------

Co-authored-by: April M <april.murphy@datastax.com>
Co-authored-by: April I. Murphy <36110273+aimurphy@users.noreply.github.com>
This commit is contained in:
Mendon Kissling 2025-08-02 11:24:31 -04:00 • committed by GitHub
commit f3701989b8
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
34 changed files with 456 additions and 266 deletions

View file

@ -3,9 +3,32 @@ title: Langflow CLI
slug: /configuration-cli
---
import Link from '@docusaurus/Link';
import Tabs from '@theme/Tabs';
import TabItem from '@theme/TabItem';
import Icon from "@site/src/components/icon";
The Langflow command line interface (Langflow CLI) is the main interface for managing and running the Langflow server.
The Langflow command line interface is the main interface for managing and running the Langflow server.
The Langflow CLI is automatically installed when you [install the Langflow package](/get-started-installation).
It isn't available for Langflow Desktop.
## How to use the CLI
The Langflow CLI can be invoked in several ways, depending on your installation method and environment.
The recommended approach is to run the CLI with `uv run` from within a virtual environment where Langflow is installed.
For example, to start Langflow on the default port, run the following command:
```bash
uv run langflow run
```
If Langflow is installed globally or added to your PATH, you can execute the CLI directly with `langflow`.
```bash
langflow run
```
## Precedence
@ -14,14 +37,12 @@ Langflow CLI options override the values of [environment variables](/environment
For example, if you have `LANGFLOW_PORT=7860` defined as an environment variable, and you run the CLI with `--port 7880`, then Langflow sets the port to `7880` because the CLI option overrides the environment variable.
This also applies to Boolean environment variables.
For example, if your set `LANGFLOW_REMOVE_API_KEYS=True` in your `.env` file, then you can change this to `False` by running the CLI with `--no-remove-api-keys`.
For example, if you set `LANGFLOW_REMOVE_API_KEYS=True` in your `.env` file, then you can change it to `False` by running the CLI with `--no-remove-api-keys`.
## Options
## Langflow CLI options
All Langflow CLI commands support options that modify the command's behavior or set environment variables.
### Option syntax
To set values for options, you can use either of the following syntax styles:
* `--option value`
@ -32,152 +53,318 @@ Values with spaces must be surrounded by quotation marks:
* `--option 'Value with Spaces'`
* `--option="Value with Spaces"`
### Boolean forms
### Boolean options
Boolean options enable and disable settings.
They accept no value.
Instead, each Boolean option has a true (enabled) and false (disabled) form:
They have a true (enabled) and false (disabled) form:
* Enabled (true): `--option`
* Disabled (false): `--no-option`
For example, `--remove-api-keys` is equivalent to `LANGFLOW_REMOVE_API_KEYS=True`:
The following examples compare Boolean option forms for `REMOVE_API_KEYS`.
<Tabs>
<TabItem value="true" label="True" default>
`--remove-api-keys` is equivalent to setting `LANGFLOW_REMOVE_API_KEYS=True` in `.env`:
```bash
langflow run --remove-api-keys
uv run langflow run --remove-api-keys
```
In contrast, `--no-remove-api-keys` is equivalent to `LANGFLOW_REMOVE_API_KEYS=False`:
</TabItem>
<TabItem value="false" label="False">
`--no-remove-api-keys` is equivalent to `LANGFLOW_REMOVE_API_KEYS=False` in `.env`:
```bash
langflow run --no-remove-api-keys
uv run langflow run --no-remove-api-keys
```
### Default options
</TabItem>
</Tabs>
In the following command references, default values for Booleans include both the CLI flag and the equivalent Boolean evaluation, such as "`--option` (true)" and "`--no-option` (false)".
### Universal options
The following options are available for all Langflow CLI commands:
* `--version`, `-v`: Show the version and exit.
* `--install-completion`: Install auto-completion for the current shell.
* `--show-completion`: Show the location of the auto-completion config file, if installed.
* `--help`: Print information about command usage, options, and arguments.
These are modifiers that change the output or execution of a command.
They aren't Booleans, and they accept no values.
## CLI commands
The following sections describe the available CLI commands and any non-default options available for each command.
The following sections describe the available CLI commands and any additional options (beyond the [universal options](#universal-options)) available for each command.
### langflow
Running the CLI without any arguments prints a list of available options and commands:
Running the CLI without any arguments prints a list of available options and commands.
<Tabs groupId="Invocation">
<TabItem value="uv (recommended)" label="uv (recommended)" default>
```bash
uv run langflow
```
</TabItem>
<TabItem value="Direct" label="Direct">
```bash
langflow
# or
python -m langflow
```
</TabItem>
</Tabs>
### langflow api-key {#langflow-api-key}
Create a Langflow API key with superuser privileges.
Creates a Langflow API key.
You must be a superuser to create API keys with the CLI.
For more information, see [Langflow API keys](/api-keys-and-authentication#langflow-api-keys).
<Tabs groupId="Invocation">
<TabItem value="uv (recommended)" label="uv (recommended)" default>
```bash
langflow api-key
# or
uv run langflow api-key
```
</TabItem>
<TabItem value="Direct" label="Direct">
```bash
langflow api-key
```
</TabItem>
</Tabs>
#### Options
| Option | Default | Type | Description |
|--------|---------|--------|-------------|
| `--log-level` | `error` | String | The logging level. One of `debug`, `info`, `warning`, `error`, or `critical`. |
### langflow copy-db
Copy the Langflow database files from the cache directory to the current directory containing `__main__.py`.
You can find this directory by running `which langflow`.
Copies the Langflow database files from the cache directory to the current Langflow installation directory, which is the directory containing `__main__.py`.
You can find the copy target directory by running `which langflow`.
The following files are copied if they exist in the cache directory:
* `langflow.db`: The main Langflow database, stored in the user cache directory
* `langflow-pre.db`: The pre-release database, if it exists
<Tabs groupId="Invocation">
<TabItem value="uv (recommended)" label="uv (recommended)" default>
```bash
uv run langflow copy-db
```
</TabItem>
<TabItem value="Direct" label="Direct">
```bash
langflow copy-db
# or
python -m langflow copy-db
```
The database files are `langflow.db` and `langflow-pre.db`.
If these files don't exist in the cache directory, then nothing is copied.
</TabItem>
</Tabs>
### langflow migration
Run or test database migrations:
Manages Langflow database schema changes using [Alembic](https://alembic.sqlalchemy.org/en/latest/), a database migration tool for SQLAlchemy.
```bash
langflow migration [OPTIONS]
# or
python -m langflow migration [OPTIONS]
```
The `migration` command has two modes:
#### Options
* **Test mode (default)**: Checks if migrations can be applied safely without actually running the migrations.
Use this mode to previews the changes that would be made to the database schema before proceeding with the migrations.
| Option | Default | Type | Description |
|--------|---------|--------|-------------|
| `--test` | `true` | Boolean | Run migrations in test mode. Use `--no-test` to disable test mode. |
| `--fix` | `false` (`--no-fix`) | Boolean | Fix migrations. This is a destructive operation, and all affected data will be deleted. Only use this option if you know what you are doing. |
* **Fix mode**: Applies the migrations to update the database schema.
:::warning
`langflow migration --fix` is a destructive operation that can delete data.
Always run `langflow migration` first to preview the changes.
:::
<Tabs groupId="Invocation">
<TabItem value="uv (recommended)" label="uv (recommended)" default>
1. Run test mode:
```bash
uv run langflow migration
```
2. Preview the changes returned by the test to determine if it's safe to proceed with the migration.
3. Run fix mode to apply the changes:
```bash
uv run langflow migration --fix
```
</TabItem>
<TabItem value="Global" label="Global">
1. Run test mode:
```bash
langflow migration
```
2. Preview the changes returned by the test to determine if it's safe to proceed with the migration.
3. Run fix mode to apply the changes:
```bash
langflow migration --fix
```
</TabItem>
</Tabs>
### langflow run
Start the Langflow server.
Starts the Langflow server.
<Tabs groupId="Invocation">
<TabItem value="uv (recommended)" label="uv (recommended)" default>
```bash
uv run langflow run [OPTIONS]
```
</TabItem>
<TabItem value="Direct" label="Direct">
```bash
langflow run [OPTIONS]
# or
python -m langflow run [OPTIONS]
```
</TabItem>
</Tabs>
#### Options
This command supports some common and non-sensitive configuration options for your Langflow server.
Other options must be set in the `.env` or your terminal.
For more information Langflow configuration options, see [Langflow environment variables](/environment-variables).
| Option | Default | Type | Description |
|--------|---------|--------|-------------|
| <Link id="run-host"/>`--host` | `localhost` | String | The host on which the Langflow server will run. |
| <Link id="run-workers"/>`--workers` | `1` | Integer | Number of worker processes. |
| <Link id="run-worker-timeout"/>`--worker-timeout` | `300` | Integer | Worker timeout in seconds. |
| <Link id="run-port"/>`--port` | `7860` | Integer | The port on which the Langflow server will run. The server automatically selects a free port if the specified port is in use. |
| <Link id="run-components-path"/>`--components-path` | `/components` | String | Path to the directory containing custom components. |
| `--env-file` | Not set | String | Path to the `.env` file containing environment variables. |
| `--log-level` | `critical` | Enum | Set the logging level as one of `debug`, `info`, `warning`, `error`, or `critical`. |
| `--log-file` | `logs/langflow.log` | String | Set the path to the log file for Langflow. |
| <Link id="run-cache"/>`--cache` | `async` | Enum | Type of cache to use as one of `async`, `redis`, `memory`, or `disk`. |
| <Link id="run-frontend-path"/>`--frontend-path` | `./frontend` | String | Path to the frontend directory containing build files. This is for development purposes only. |
| <Link id="run-open-browser"/>`--open-browser` | `true` | Boolean | Open the system web browser on startup. Use `--no-open-browser` to disable opening the system web browser on startup. |
| <Link id="run-remove-api-keys"/>`--remove-api-keys` | `false` (`--no-remove-api-keys`) | Boolean | Remove API keys from the projects saved in the database. |
| <Link id="run-backend-only"/>`--backend-only` | `false` (`--no-backend-only`) | Boolean | Only run Langflow's backend server (no frontend). |
| <Link id="run-store"/>`--store` | `true` | Boolean | Enable the Langflow Store features. Use `--no-store` to disable the Langflow Store features. |
| <Link id="run-auto-saving"/>`--auto-saving` | `true` | Boolean | Enable flow auto-saving. Use `--no-auto-saving` to disable flow auto-saving. |
| <Link id="run-auto-saving-interval"/>`--auto-saving-interval` | `1000` | Integer | Set the interval for flow auto-saving in milliseconds. |
| <Link id="run-health-check-max-retries"/>`--health-check-max-retries` | `5` | Integer | Set the maximum number of retries for the health check. Use `--no-health-check-max-retries` to disable the maximum number of retries for the health check. |
| <Link id="run-max-file-size-upload"/>`--max-file-size-upload` | `100` | Integer | Set the maximum file size for the upload in megabytes. |
| `--ssl-cert-file-path` | Not set | String | Path to the SSL certificate file on the local system. |
| `--ssl-key-file-path` | Not set | String | Path to the SSL key file on the local system. |
| `--auto-saving` | `--auto-saving` (true) | Boolean | Whether to enable flow auto-saving. Use `--no-auto-saving` to disable flow auto-saving. |
| `--auto-saving-interval` | `1000` | Integer | The interval for flow auto-saving in milliseconds. |
| `--backend-only` | `--no-backend-only` (false) | Boolean | Whether to run Langflow's backend service only (no frontend). Omit or use `--no-backend-only` to start both the frontend and backend. See [Start Langflow in headless mode](#start-langflow-in-headless-mode). |
| `--cache` | `async` | String | The type of cache to use. One of `async`, `redis`, `memory`, or `disk`. |
| `--components-path` | Not set | String | The path to the directory containing custom components. |
| `--dev` | `--no-dev` (false) | Boolean | Whether to run in development mode (may contain bugs). |
| `--env-file` | Not set | String | The path to the `.env` file containing Langflow environment variables. See [Start Langflow with a specific .env file](#start-langflow-with-a-specific-env-file). |
| `--frontend-path` | Not set | String | The path to the frontend directory containing build files. This is only used when [contributing to the Langflow codebase](/contributing-how-to-contribute) or developing a custom Langflow image that includes customized frontend code. |
| `--health-check-max-retries` | `5` | Integer | The maximum number of retries for the health check. |
| `--host` | `localhost` | String | The host on which the Langflow server will run. |
| `--log-file` | `logs/langflow.log` | String | The path to the log file for Langflow. |
| `--log-level` | `critical` | String | The logging level as one of `debug`, `info`, `warning`, `error`, or `critical`. |
| `--log-rotation` | Not set | String | The log rotation (Time/Size). |
| `--max-file-size-upload` | `100` | Integer | The maximum size in megabytes for file uploads. |
| `--open-browser` | `--no-open-browser` (false) | Boolean | Whether to open the system web browser on startup. Use `--open-browser` to open the system's default web browser when Langflow starts. |
| `--port` | `7860` | Integer | The port on which the Langflow server will run. The server automatically selects a free port if the specified port is in use. |
| `--remove-api-keys` | `--no-remove-api-keys` (false) | Boolean | Whether to remove API keys from projects saved in the Langflow database. |
| `--ssl-cert-file-path` | Not set | String | The path to the SSL certificate file on the local system. |
| `--ssl-key-file-path` | Not set | String | The path to the SSL key file on the local system. |
| `--store` | `--store` (true) | Boolean | Whether to enable the Langflow Store features. Use `--no-store` to disable the Langflow Store features. |
| `--worker-timeout` | `300` | Integer | The worker timeout in seconds. |
| `--workers` | `1` | Integer | The number of worker processes. |
For information about the environment variables that correspond to these options, see [Supported environment variables](/environment-variables#supported-variables).
#### Start Langflow with a specific .env file {#start-langflow-with-a-specific-env-file}
The `--env-file` option starts Langflow using the configuration defined in the given `.env` file.
Additional options appended to this command override the values in the `.env` file if there are duplicates.
If `--env-file` is omitted or doesn't include all required variables, Langflow uses the default values for those variables.
<Tabs groupId="Invocation">
<TabItem value="uv (recommended)" label="uv (recommended)" default>
```bash
uv run langflow run --env-file PATH/TO/LANGFLOW/.env
```
</TabItem>
<TabItem value="Direct" label="Direct">
```bash
langflow run --env-file PATH/TO/LANGFLOW/.env
```
</TabItem>
</Tabs>
#### Start Langflow in headless mode {#start-langflow-in-headless-mode}
The `--backend-only` option starts Langflow's backend service only.
This headless mode has no frontend (visual editor), and you can only access the server programmatically with the Langflow API and CLI.
<Tabs groupId="Invocation">
<TabItem value="uv (recommended)" label="uv (recommended)" default>
```bash
uv run langflow run --backend-only
```
</TabItem>
<TabItem value="Direct" label="Direct">
```bash
langflow run --backend-only
```
</TabItem>
</Tabs>
### langflow superuser {#langflow-superuser}
Create a superuser account.
Creates a superuser account with the given username and password.
Controlled by the [`LANGFLOW_ENABLE_SUPERUSER_CLI`](/api-keys-and-authentication#langflow-enable-superuser-cli) environment variable:
* **`LANGFLOW_ENABLE_SUPERUSER_CLI=True` (Default)**: The `langflow superuser` command is available, and superuser creation is unrestricted.
* **`LANGFLOW_ENABLE_SUPERUSER_CLI=False` (Recommended)**: Disables the `langflow superuser` command.
For security reasons, this is recommended to prevent unauthorized superuser creation, especially in production environments.
<Tabs groupId="Invocation">
<TabItem value="uv (recommended)" label="uv (recommended)" default>
```bash
langflow superuser [OPTIONS]
# or
python -m langflow superuser [OPTIONS]
uv run langflow superuser --username [NAME] --password [PASSWORD] [OPTIONS]
```
</TabItem>
<TabItem value="Direct" label="Direct">
```bash
langflow superuser --username [NAME] --password [PASSWORD] [OPTIONS]
```
</TabItem>
</Tabs>
#### Options
| Option | Default | Type | Description |
|--------|---------|--------|-------------|
| `--username` | `langflow` | String | Specify the name for the superuser. |
| `--password` | `langflow` | String | Specify the password for the superuser. |
| `--log-level` | `error` | String | The logging level. One of `debug`, `info`, `warning`, `error`, or `critical`. |
For more information, see [`LANGFLOW_SUPERUSER` and `LANGFLOW_SUPERUSER_PASSWORD`](/api-keys-and-authentication#langflow-superuser).
For this command, `--username` and `--password` aren't optional, and they have no default value.
The command fails if you don't provide these arguments.
For more information, see [`LANGFLOW_SUPERUSER` and `LANGFLOW_SUPERUSER_PASSWORD`](/api-keys-and-authentication#langflow-superuser).
#### Disable CLI superuser creation
The `langflow superuser` command is controlled by the [`LANGFLOW_ENABLE_SUPERUSER_CLI`](/api-keys-and-authentication#langflow-enable-superuser-cli) environment variable:
* **`LANGFLOW_ENABLE_SUPERUSER_CLI=True` (default)**: The `langflow superuser` command is available, and superuser creation is unrestricted.
* **`LANGFLOW_ENABLE_SUPERUSER_CLI=False` (recommended)**: Disables the `langflow superuser` command.
For security reasons, this is recommended to prevent unauthorized superuser creation, especially in production environments.
To disable the `langflow superuser` command, you must set `LANGFLOW_ENABLE_SUPERUSER_CLI=False` in your Langflow `.env` file, and then [start Langflow with your `.env` file](#start-langflow-with-a-specific-env-file).