mirror of
https://github.com/langflow-ai/langflow.git
synced 2026-07-25 13:56:04 +08:00
Merge remote-tracking branch 'origin/frontend-memory' into api-memory
This commit is contained in:
35
.github/workflows/py_autofix.yml
vendored
35
.github/workflows/py_autofix.yml
vendored
@ -5,6 +5,7 @@ on:
|
||||
- "**/*.py"
|
||||
- "src/lfx/src/lfx/components/**"
|
||||
- "scripts/build_component_index.py"
|
||||
types: [opened, synchronize, reopened, labeled]
|
||||
env:
|
||||
PYTHON_VERSION: "3.13"
|
||||
|
||||
@ -12,7 +13,7 @@ env:
|
||||
jobs:
|
||||
lint:
|
||||
name: Run Ruff Check and Format
|
||||
if: ${{ github.actor != 'github-actions[bot]' }}
|
||||
if: github.event.action != 'labeled' && github.actor != 'github-actions[bot]'
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- uses: actions/checkout@v6
|
||||
@ -30,7 +31,7 @@ jobs:
|
||||
|
||||
update-starter-projects:
|
||||
name: Update Starter Projects
|
||||
if: ${{ github.actor != 'github-actions[bot]' }}
|
||||
if: github.event.action != 'labeled' && github.actor != 'github-actions[bot]'
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- uses: actions/checkout@v6
|
||||
@ -55,10 +56,35 @@ jobs:
|
||||
|
||||
update-component-index:
|
||||
name: Update Component Index
|
||||
if: ${{ github.actor != 'github-actions[bot]' }}
|
||||
if: >-
|
||||
github.actor != 'github-actions[bot]'
|
||||
&& (github.event.action != 'labeled' || github.event.label.name == 'fix-index')
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- uses: actions/checkout@v6
|
||||
with:
|
||||
ref: ${{ github.head_ref }}
|
||||
fetch-depth: 0
|
||||
- name: Merge base branch
|
||||
run: |
|
||||
git config user.name "github-actions[bot]"
|
||||
git config user.email "github-actions[bot]@users.noreply.github.com"
|
||||
git merge origin/${{ github.base_ref }} --no-edit || {
|
||||
# Check which files have conflicts
|
||||
CONFLICTED=$(git diff --name-only --diff-filter=U)
|
||||
|
||||
# If any non-generated files conflict, bail out — needs manual resolution
|
||||
if echo "$CONFLICTED" | grep -v component_index.json | grep -q .; then
|
||||
echo "::error::Merge conflicts in non-generated files require manual resolution"
|
||||
git merge --abort
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# Only component_index.json conflicts — resolve and finish merge
|
||||
git checkout --theirs src/lfx/src/lfx/_assets/component_index.json
|
||||
git add src/lfx/src/lfx/_assets/component_index.json
|
||||
GIT_EDITOR=true git merge --continue
|
||||
}
|
||||
- name: "Setup Environment"
|
||||
uses: astral-sh/setup-uv@v6
|
||||
with:
|
||||
@ -76,6 +102,3 @@ jobs:
|
||||
run: make build_component_index
|
||||
|
||||
- uses: autofix-ci/action@635ffb0c9798bd160680f18fd73371e355b85f27
|
||||
|
||||
|
||||
|
||||
|
||||
4
.github/workflows/python_test.yml
vendored
4
.github/workflows/python_test.yml
vendored
@ -93,7 +93,7 @@ jobs:
|
||||
- name: Run unit tests
|
||||
uses: nick-fields/retry@v3
|
||||
with:
|
||||
timeout_minutes: 15
|
||||
timeout_minutes: 20
|
||||
max_attempts: 2
|
||||
command: make unit_tests args="-x -vv --splits ${{ matrix.splitCount }} --group ${{ matrix.group }} --reruns 5 --cov --cov-config=src/backend/.coveragerc --cov-report=xml --cov-report=html"
|
||||
|
||||
@ -161,7 +161,7 @@ jobs:
|
||||
python-version: ${{ matrix.python-version }}
|
||||
prune-cache: false
|
||||
- name: Run lfx tests
|
||||
run: uv run make lfx_tests
|
||||
run: make lfx_tests
|
||||
env:
|
||||
DO_NOT_TRACK: true # disable telemetry reporting
|
||||
|
||||
|
||||
298
.github/workflows/release.yml
vendored
298
.github/workflows/release.yml
vendored
@ -23,6 +23,11 @@ on:
|
||||
required: false
|
||||
type: boolean
|
||||
default: false
|
||||
release_sdk:
|
||||
description: "Release langflow-sdk package (required when releasing LFX)"
|
||||
required: false
|
||||
type: boolean
|
||||
default: false
|
||||
build_docker_base:
|
||||
description: "Build Docker Image for Langflow Base"
|
||||
required: true
|
||||
@ -60,6 +65,7 @@ jobs:
|
||||
echo "release_package_base: ${{ inputs.release_package_base }}"
|
||||
echo "release_package_main: ${{ inputs.release_package_main }}"
|
||||
echo "release_lfx: ${{ inputs.release_lfx }}"
|
||||
echo "release_sdk: ${{ inputs.release_sdk }}"
|
||||
echo "build_docker_base: ${{ inputs.build_docker_base }}"
|
||||
echo "build_docker_main: ${{ inputs.build_docker_main }}"
|
||||
echo "pre_release: ${{ inputs.pre_release }}"
|
||||
@ -95,7 +101,7 @@ jobs:
|
||||
validate-dependencies:
|
||||
name: Validate Release Dependencies
|
||||
runs-on: ubuntu-latest
|
||||
if: ${{ inputs.release_package_base || inputs.release_package_main || inputs.release_lfx || inputs.build_docker_base || inputs.build_docker_main }}
|
||||
if: ${{ inputs.release_package_base || inputs.release_package_main || inputs.release_lfx || inputs.release_sdk || inputs.build_docker_base || inputs.build_docker_main }}
|
||||
needs: [validate-tag]
|
||||
steps:
|
||||
- name: Validate that build-base is enabled if build-main is enabled
|
||||
@ -106,6 +112,12 @@ jobs:
|
||||
exit 1
|
||||
fi
|
||||
|
||||
if [ "${{ inputs.release_lfx }}" = "true" ] && [ "${{ inputs.release_sdk }}" = "false" ]; then
|
||||
echo "Error: Cannot release LFX without releasing langflow-sdk."
|
||||
echo "LFX depends on langflow-sdk. Please enable 'release_sdk' or disable 'release_lfx'."
|
||||
exit 1
|
||||
fi
|
||||
|
||||
echo "✅ Release dependencies validated successfully."
|
||||
|
||||
determine-base-version:
|
||||
@ -259,6 +271,67 @@ jobs:
|
||||
echo skipped=false >> $GITHUB_OUTPUT
|
||||
fi
|
||||
|
||||
determine-sdk-version:
|
||||
name: Determine SDK Version
|
||||
needs: [validate-tag, validate-dependencies]
|
||||
if: ${{ inputs.release_sdk || inputs.release_lfx }}
|
||||
runs-on: ubuntu-latest
|
||||
outputs:
|
||||
version: ${{ steps.version.outputs.version }}
|
||||
skipped: ${{ steps.version.outputs.skipped }}
|
||||
steps:
|
||||
- name: Checkout code
|
||||
uses: actions/checkout@v6
|
||||
with:
|
||||
ref: ${{ inputs.release_tag }}
|
||||
|
||||
- name: Setup Environment
|
||||
uses: astral-sh/setup-uv@v6
|
||||
with:
|
||||
enable-cache: true
|
||||
cache-dependency-glob: "uv.lock"
|
||||
python-version: "3.13"
|
||||
prune-cache: false
|
||||
|
||||
- name: Install SDK dependencies
|
||||
run: uv sync --dev --package langflow-sdk
|
||||
|
||||
- name: Determine version
|
||||
id: version
|
||||
run: |
|
||||
version=$(python3 -c "
|
||||
import tomllib, pathlib
|
||||
data = tomllib.loads(pathlib.Path('src/sdk/pyproject.toml').read_text())
|
||||
print(data['project']['version'])
|
||||
")
|
||||
echo "SDK version from pyproject.toml: $version"
|
||||
|
||||
# Check if langflow-sdk exists on PyPI (may be first release)
|
||||
pypi_response=$(curl -s -o /dev/null -w "%{http_code}" "https://pypi.org/pypi/langflow-sdk/json")
|
||||
if [ "$pypi_response" = "404" ]; then
|
||||
echo "langflow-sdk has never been published to PyPI. This will be the first release."
|
||||
last_released_version=""
|
||||
else
|
||||
if [ ${{inputs.pre_release}} == "true" ]; then
|
||||
last_released_version=$(curl -s "https://pypi.org/pypi/langflow-sdk/json" | jq -r '.releases | keys | .[]' | grep -E '(a|b|rc|dev|alpha|beta)' | sort -V | tail -n 1)
|
||||
version="$(uv run ./scripts/ci/langflow_pre_release_tag.py "$version" "$last_released_version")"
|
||||
echo "Latest SDK pre-release version: $last_released_version"
|
||||
echo "SDK pre-release version to be released: $version"
|
||||
else
|
||||
last_released_version=$(curl -s "https://pypi.org/pypi/langflow-sdk/json" | jq -r '.releases | keys | .[]' | grep -vE '(a|b|rc|dev|alpha|beta)' | sort -V | tail -n 1)
|
||||
echo "Latest SDK release version: $last_released_version"
|
||||
fi
|
||||
fi
|
||||
|
||||
if [ "$version" = "$last_released_version" ]; then
|
||||
echo "SDK pypi version $version is already released. Skipping release."
|
||||
echo skipped=true >> $GITHUB_OUTPUT
|
||||
exit 1
|
||||
else
|
||||
echo version=$version >> $GITHUB_OUTPUT
|
||||
echo skipped=false >> $GITHUB_OUTPUT
|
||||
fi
|
||||
|
||||
ci:
|
||||
name: CI
|
||||
needs: [validate-tag, validate-dependencies]
|
||||
@ -272,10 +345,10 @@ jobs:
|
||||
runs-on: ubuntu-latest
|
||||
secrets: inherit
|
||||
|
||||
build-lfx:
|
||||
name: Build LFX
|
||||
needs: [determine-lfx-version]
|
||||
if: ${{ needs.determine-lfx-version.outputs.skipped == 'false' }}
|
||||
build-sdk:
|
||||
name: Build langflow-sdk
|
||||
needs: [determine-sdk-version]
|
||||
if: ${{ needs.determine-sdk-version.outputs.skipped == 'false' }}
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- name: Checkout code
|
||||
@ -289,6 +362,78 @@ jobs:
|
||||
cache-dependency-glob: "uv.lock"
|
||||
python-version: "3.13"
|
||||
prune-cache: false
|
||||
- name: Set version for pre-release
|
||||
if: ${{ inputs.pre_release }}
|
||||
run: |
|
||||
VERSION="${{ needs.determine-sdk-version.outputs.version }}"
|
||||
echo "Setting SDK pre-release version to: $VERSION"
|
||||
cd src/sdk
|
||||
|
||||
# Update version in SDK pyproject.toml
|
||||
sed -i.bak "s/^version = .*/version = \"$VERSION\"/" pyproject.toml
|
||||
|
||||
# Verify the change
|
||||
echo "Updated pyproject.toml version:"
|
||||
grep "^version" pyproject.toml
|
||||
- name: Build project for distribution
|
||||
run: make sdk_build args="--wheel"
|
||||
- name: Verify built version
|
||||
run: |
|
||||
EXPECTED_VERSION="${{ needs.determine-sdk-version.outputs.version }}"
|
||||
WHEEL_FILE=$(ls src/sdk/dist/*.whl)
|
||||
echo "Built wheel: $WHEEL_FILE"
|
||||
|
||||
NORMALIZED_VERSION=$(echo "$EXPECTED_VERSION" | sed 's/\.rc/rc/g; s/\.a/a/g; s/\.b/b/g; s/\.dev/dev/g')
|
||||
echo "Expected version: $EXPECTED_VERSION"
|
||||
echo "Normalized for wheel: $NORMALIZED_VERSION"
|
||||
|
||||
if [[ ! "$WHEEL_FILE" =~ $NORMALIZED_VERSION ]]; then
|
||||
echo "❌ Error: Wheel version doesn't match expected version"
|
||||
echo "Expected: $EXPECTED_VERSION (normalized: $NORMALIZED_VERSION)"
|
||||
echo "Wheel file: $WHEEL_FILE"
|
||||
exit 1
|
||||
fi
|
||||
echo "✅ Version verified: $EXPECTED_VERSION"
|
||||
- name: Test SDK import
|
||||
run: |
|
||||
cd src/sdk
|
||||
uv venv test-env --seed
|
||||
uv pip install --python ./test-env/bin/python dist/*.whl
|
||||
EXPECTED_VERSION="${{ needs.determine-sdk-version.outputs.version }}"
|
||||
./test-env/bin/python -c "from importlib.metadata import version; import langflow_sdk; installed_version = version('langflow-sdk'); print(f'langflow-sdk {installed_version} imported successfully'); assert installed_version == '$EXPECTED_VERSION', f'Installed version {installed_version} does not match expected version $EXPECTED_VERSION'"
|
||||
- name: Upload Artifact
|
||||
uses: actions/upload-artifact@v6
|
||||
with:
|
||||
name: dist-sdk
|
||||
path: src/sdk/dist
|
||||
|
||||
build-lfx:
|
||||
name: Build LFX
|
||||
needs: [determine-lfx-version, determine-sdk-version, build-sdk]
|
||||
if: |
|
||||
always() &&
|
||||
!cancelled() &&
|
||||
needs.determine-lfx-version.result == 'success' &&
|
||||
needs.determine-lfx-version.outputs.skipped == 'false'
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- name: Checkout code
|
||||
uses: actions/checkout@v6
|
||||
with:
|
||||
ref: ${{ inputs.release_tag }}
|
||||
- name: Setup Environment
|
||||
uses: astral-sh/setup-uv@v6
|
||||
with:
|
||||
enable-cache: true
|
||||
cache-dependency-glob: "uv.lock"
|
||||
python-version: "3.13"
|
||||
prune-cache: false
|
||||
- name: Download SDK artifact
|
||||
if: needs.build-sdk.result == 'success'
|
||||
uses: actions/download-artifact@v7
|
||||
with:
|
||||
name: dist-sdk
|
||||
path: ./sdk-dist
|
||||
- name: Install LFX dependencies
|
||||
run: uv sync --dev --package lfx
|
||||
- name: Set version for pre-release
|
||||
@ -304,6 +449,31 @@ jobs:
|
||||
# Verify the change
|
||||
echo "Updated pyproject.toml version:"
|
||||
grep "^version" pyproject.toml
|
||||
- name: Update langflow-sdk dependency for pre-release
|
||||
if: ${{ inputs.pre_release && needs.build-sdk.result == 'success' }}
|
||||
run: |
|
||||
SDK_VERSION="${{ needs.determine-sdk-version.outputs.version }}"
|
||||
echo "Updating langflow-sdk dependency to allow pre-release version: $SDK_VERSION"
|
||||
cd src/lfx
|
||||
|
||||
# Extract current langflow-sdk constraint from pyproject.toml
|
||||
CURRENT_CONSTRAINT=$(grep -E '^\s*"langflow-sdk' pyproject.toml | head -1)
|
||||
echo "Current constraint: $CURRENT_CONSTRAINT"
|
||||
|
||||
# Create new constraint using the next major derived from SDK_VERSION
|
||||
SDK_BASE_VERSION=$(echo "$SDK_VERSION" | sed 's/[^0-9.].*$//')
|
||||
SDK_MAJOR=$(echo "$SDK_BASE_VERSION" | cut -d. -f1)
|
||||
NEXT_MAJOR=$((SDK_MAJOR + 1))
|
||||
NEW_CONSTRAINT="\"langflow-sdk>=$SDK_VERSION,<$NEXT_MAJOR.dev0\""
|
||||
|
||||
echo "New constraint: $NEW_CONSTRAINT"
|
||||
|
||||
# Replace the constraint
|
||||
sed -i.bak "s|\"langflow-sdk[^\"]*\"|$NEW_CONSTRAINT|" pyproject.toml
|
||||
|
||||
# Verify the change
|
||||
echo "Updated langflow-sdk dependency:"
|
||||
grep "langflow-sdk" pyproject.toml
|
||||
- name: Build project for distribution
|
||||
run: |
|
||||
cd src/lfx
|
||||
@ -329,8 +499,16 @@ jobs:
|
||||
- name: Test CLI
|
||||
run: |
|
||||
cd src/lfx
|
||||
uv pip install dist/*.whl --force-reinstall
|
||||
uv run lfx --help
|
||||
# Use a clean venv and install both SDK and LFX wheels together
|
||||
# so uv can resolve the local SDK dependency without falling back to PyPI.
|
||||
uv venv test-env --seed
|
||||
if [ -d "../../sdk-dist" ]; then
|
||||
SDK_WHEEL=$(find ../../sdk-dist -name "*.whl" -type f | head -1)
|
||||
uv pip install --python ./test-env/bin/python --force-reinstall "$SDK_WHEEL" dist/*.whl
|
||||
else
|
||||
uv pip install --python ./test-env/bin/python --force-reinstall dist/*.whl
|
||||
fi
|
||||
./test-env/bin/lfx --help
|
||||
- name: Upload Artifact
|
||||
uses: actions/upload-artifact@v6
|
||||
with:
|
||||
@ -339,8 +517,14 @@ jobs:
|
||||
|
||||
build-base:
|
||||
name: Build Langflow Base
|
||||
needs: [build-lfx, determine-base-version, determine-lfx-version]
|
||||
if: ${{ inputs.release_package_base && needs.determine-base-version.outputs.skipped == 'false' }}
|
||||
needs: [build-lfx, build-sdk, determine-base-version, determine-lfx-version]
|
||||
if: |
|
||||
always() &&
|
||||
!cancelled() &&
|
||||
inputs.release_package_base &&
|
||||
needs.determine-base-version.result == 'success' &&
|
||||
needs.determine-base-version.outputs.skipped == 'false' &&
|
||||
needs.build-lfx.result == 'success'
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- name: Checkout code
|
||||
@ -359,12 +543,22 @@ jobs:
|
||||
with:
|
||||
name: dist-lfx
|
||||
path: ./lfx-dist
|
||||
- name: Install dependencies with local LFX wheel
|
||||
- name: Download SDK artifact
|
||||
if: needs.build-sdk.result == 'success'
|
||||
uses: actions/download-artifact@v7
|
||||
with:
|
||||
name: dist-sdk
|
||||
path: ./sdk-dist
|
||||
- name: Install dependencies with local LFX and SDK wheels
|
||||
run: |
|
||||
# Create virtual environment
|
||||
uv venv
|
||||
# Install using pip with local wheel directory as find-links
|
||||
uv pip install --find-links ./lfx-dist --prerelease=allow -e src/backend/base
|
||||
# Install using pip with local wheel directories as find-links
|
||||
FIND_LINKS="--find-links ./lfx-dist"
|
||||
if [ -d "./sdk-dist" ]; then
|
||||
FIND_LINKS="$FIND_LINKS --find-links ./sdk-dist"
|
||||
fi
|
||||
uv pip install $FIND_LINKS --prerelease=allow -e src/backend/base
|
||||
- name: Check for dependency incompatibility
|
||||
run: uv pip check
|
||||
- name: Set version for pre-release
|
||||
@ -460,11 +654,19 @@ jobs:
|
||||
[
|
||||
build-base,
|
||||
build-lfx,
|
||||
build-sdk,
|
||||
determine-base-version,
|
||||
determine-main-version,
|
||||
determine-lfx-version,
|
||||
]
|
||||
if: ${{ inputs.release_package_main && needs.determine-main-version.outputs.skipped == 'false' }}
|
||||
if: |
|
||||
always() &&
|
||||
!cancelled() &&
|
||||
inputs.release_package_main &&
|
||||
needs.determine-main-version.result == 'success' &&
|
||||
needs.determine-main-version.outputs.skipped == 'false' &&
|
||||
needs.build-base.result == 'success' &&
|
||||
needs.build-lfx.result == 'success'
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- name: Checkout code
|
||||
@ -483,6 +685,12 @@ jobs:
|
||||
with:
|
||||
name: dist-lfx
|
||||
path: ./lfx-dist
|
||||
- name: Download SDK artifact
|
||||
if: needs.build-sdk.result == 'success'
|
||||
uses: actions/download-artifact@v7
|
||||
with:
|
||||
name: dist-sdk
|
||||
path: ./sdk-dist
|
||||
- name: Download base artifact
|
||||
uses: actions/download-artifact@v7
|
||||
with:
|
||||
@ -493,7 +701,11 @@ jobs:
|
||||
# Create virtual environment
|
||||
uv venv
|
||||
# Install using pip with local wheel directories as find-links
|
||||
uv pip install --find-links ./lfx-dist --find-links ./base-dist --prerelease=allow -e .
|
||||
FIND_LINKS="--find-links ./lfx-dist --find-links ./base-dist"
|
||||
if [ -d "./sdk-dist" ]; then
|
||||
FIND_LINKS="$FIND_LINKS --find-links ./sdk-dist"
|
||||
fi
|
||||
uv pip install $FIND_LINKS --prerelease=allow -e .
|
||||
- name: Check for dependency incompatibility
|
||||
run: uv pip check
|
||||
- name: Set version for pre-release
|
||||
@ -584,7 +796,7 @@ jobs:
|
||||
|
||||
test-cross-platform:
|
||||
name: Test Cross-Platform Installation
|
||||
needs: [build-base, build-main, build-lfx]
|
||||
needs: [build-base, build-main, build-lfx, build-sdk]
|
||||
if: |
|
||||
always() &&
|
||||
!cancelled() &&
|
||||
@ -594,12 +806,20 @@ jobs:
|
||||
base-artifact-name: "dist-base"
|
||||
main-artifact-name: "dist-main"
|
||||
lfx-artifact-name: "dist-lfx"
|
||||
sdk-artifact-name: ${{ needs.build-sdk.result == 'success' && 'dist-sdk' || '' }}
|
||||
pre_release: ${{ inputs.pre_release }}
|
||||
|
||||
publish-base:
|
||||
name: Publish Langflow Base to PyPI
|
||||
if: ${{ inputs.release_package_base }}
|
||||
needs: [build-base, test-cross-platform, ci]
|
||||
if: |
|
||||
always() &&
|
||||
!cancelled() &&
|
||||
inputs.release_package_base &&
|
||||
needs.build-base.result == 'success' &&
|
||||
needs.test-cross-platform.result == 'success' &&
|
||||
needs.ci.result == 'success' &&
|
||||
(needs.publish-lfx.result == 'success' || needs.publish-lfx.result == 'skipped')
|
||||
needs: [build-base, test-cross-platform, ci, publish-lfx]
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- name: Download base artifact
|
||||
@ -642,10 +862,50 @@ jobs:
|
||||
run: |
|
||||
uv publish dist/*.whl
|
||||
|
||||
publish-sdk:
|
||||
name: Publish langflow-sdk to PyPI
|
||||
needs: [build-sdk, test-cross-platform, ci]
|
||||
if: |
|
||||
always() &&
|
||||
!cancelled() &&
|
||||
inputs.release_sdk &&
|
||||
needs.build-sdk.result == 'success' &&
|
||||
needs.ci.result == 'success' &&
|
||||
(needs.test-cross-platform.result == 'success' || needs.test-cross-platform.result == 'skipped')
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- name: Checkout code
|
||||
uses: actions/checkout@v6
|
||||
with:
|
||||
ref: ${{ inputs.release_tag }}
|
||||
- name: Download SDK artifact
|
||||
uses: actions/download-artifact@v7
|
||||
with:
|
||||
name: dist-sdk
|
||||
path: src/sdk/dist
|
||||
- name: Setup Environment
|
||||
uses: astral-sh/setup-uv@v6
|
||||
with:
|
||||
enable-cache: false
|
||||
python-version: "3.13"
|
||||
- name: Publish SDK to PyPI
|
||||
if: ${{ !inputs.dry_run }}
|
||||
env:
|
||||
UV_PUBLISH_TOKEN: ${{ secrets.PYPI_API_TOKEN }}
|
||||
run: |
|
||||
make sdk_publish
|
||||
|
||||
publish-lfx:
|
||||
name: Publish LFX to PyPI
|
||||
if: ${{ inputs.release_lfx }}
|
||||
needs: [build-lfx, test-cross-platform, ci]
|
||||
needs: [build-lfx, test-cross-platform, ci, publish-sdk]
|
||||
if: |
|
||||
always() &&
|
||||
!cancelled() &&
|
||||
inputs.release_lfx &&
|
||||
needs.build-lfx.result == 'success' &&
|
||||
needs.test-cross-platform.result == 'success' &&
|
||||
needs.ci.result == 'success' &&
|
||||
(needs.publish-sdk.result == 'success' || needs.publish-sdk.result == 'skipped')
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- name: Download LFX artifact
|
||||
|
||||
1
.gitignore
vendored
1
.gitignore
vendored
@ -292,3 +292,4 @@ sso-config.yaml
|
||||
AGENTS.md
|
||||
CLAUDE.local.md
|
||||
langflow.log.*
|
||||
tmp_toolguard/
|
||||
@ -19,14 +19,14 @@ repos:
|
||||
language: system
|
||||
types_or: [python, pyi]
|
||||
args: [--fix]
|
||||
exclude: ^docs/docs/API-Reference/python-examples/
|
||||
exclude: ^docs/.*/API-Reference/python-examples/
|
||||
- id: ruff-format
|
||||
name: ruff format
|
||||
entry: uv run ruff format
|
||||
language: system
|
||||
types_or: [python, pyi]
|
||||
args: [--config, pyproject.toml]
|
||||
exclude: ^docs/docs/API-Reference/python-examples/
|
||||
exclude: ^docs/.*/API-Reference/python-examples/
|
||||
- id: validate-migrations
|
||||
name: Validate Alembic Migrations (Expand-Contract)
|
||||
entry: python src/backend/base/langflow/alembic/migration_validator.py
|
||||
|
||||
1980
.secrets.baseline
1980
.secrets.baseline
File diff suppressed because it is too large
Load Diff
4
.vscode/launch.json
vendored
4
.vscode/launch.json
vendored
@ -24,7 +24,9 @@
|
||||
"--reload-include",
|
||||
"./src/lfx/*",
|
||||
"--reload-exclude",
|
||||
"*.db*"
|
||||
"*.db*",
|
||||
"--reload-exclude",
|
||||
"./tmp_toolguard/*"
|
||||
],
|
||||
"jinja": true,
|
||||
"justMyCode": false,
|
||||
|
||||
2
Makefile
2
Makefile
@ -171,7 +171,7 @@ unit_tests_looponfail:
|
||||
lfx_tests: ## run lfx package unit tests
|
||||
@echo 'Running LFX Package Tests...'
|
||||
@cd src/lfx && \
|
||||
uv sync && \
|
||||
uv sync --dev && \
|
||||
uv run pytest tests/unit -v --cov=src/lfx --cov-report=xml --cov-report=html --cov-report=term-missing $(args)
|
||||
|
||||
integration_tests:
|
||||
|
||||
@ -55,8 +55,7 @@ Instead of manually exporting, sharing, and importing flow JSON files from the L
|
||||
│ └── langflow-validate.yml # CI workflow
|
||||
├── .gitignore # ignores legacy credentials file
|
||||
├── .lfx/
|
||||
│ └── environments.yaml # edit with your instance URLs
|
||||
| # + API keys (safe to commit)
|
||||
│ └── environments.yaml # edit with your instance URLs + API key env var names (safe to commit)
|
||||
├── ci/
|
||||
│ ├── ci-push.sh # generic CI script
|
||||
│ ├── ci-test.sh # generic CI script
|
||||
@ -82,16 +81,16 @@ Instead of manually exporting, sharing, and importing flow JSON files from the L
|
||||
* `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:
|
||||
```bash
|
||||
export LANGFLOW_API_KEY=YOUR_LANGFLOW_API_KEY
|
||||
|
||||
```text
|
||||
export LANGFLOW_LOCAL_API_KEY=LANGFLOW_API_KEY
|
||||
```
|
||||
Replace `YOUR_LANGFLOW_API_KEY` with your server's API key.
|
||||
|
||||
5. To test server authentication with your API key, run:
|
||||
|
||||
```bash
|
||||
lfx login
|
||||
```
|
||||
@ -133,10 +132,10 @@ Instead of manually exporting, sharing, and importing flow JSON files from the L
|
||||
|
||||
## Validate flows
|
||||
|
||||
The Flow DevOps SDK can validate that local flows are correctly formed with `lfx validate` before pushing to the Langflow server.
|
||||
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:
|
||||
```bash
|
||||
```
|
||||
lfx validate flows/Simple_Agent.json
|
||||
```
|
||||
2. Once validated, push flow changes to the server with `lfx push`.
|
||||
@ -151,13 +150,13 @@ Generate a `requirements.txt` file to capture the minimal Python dependencies, s
|
||||
1. From your project directory, point `lfx requirements` at a flow JSON file.
|
||||
To print the requirements to the terminal:
|
||||
|
||||
```bash
|
||||
```
|
||||
lfx requirements flows/Simple_Agent.json
|
||||
```
|
||||
|
||||
To write a `requirements.txt` file instead of printing, use the `-o` or `--output` flag:
|
||||
To write a `requirements.txt` file instead of printing, use `-o` or `--output`:
|
||||
|
||||
```bash
|
||||
```
|
||||
lfx requirements flows/Simple_Agent.json -o requirements.txt
|
||||
```
|
||||
|
||||
@ -165,30 +164,64 @@ Generate a `requirements.txt` file to capture the minimal Python dependencies, s
|
||||
To serve the flow without the Langflow UI, do the following:
|
||||
|
||||
1. Create a virtual environment:
|
||||
```bash
|
||||
uv venv VENV_NAME
|
||||
```
|
||||
```
|
||||
uv venv VENV_NAME
|
||||
```
|
||||
|
||||
2. Activate the virtual environment.
|
||||
```bash
|
||||
source VENV_NAME/bin/activate
|
||||
```
|
||||
```
|
||||
source VENV_NAME/bin/activate
|
||||
```
|
||||
|
||||
3. Install the dependencies from `requirements.txt` in the virtual environment:
|
||||
```bash
|
||||
uv pip install -r requirements.txt
|
||||
```
|
||||
```bash
|
||||
uv pip install -r requirements.txt
|
||||
```
|
||||
|
||||
4. To set a Langflow API key, run:
|
||||
```bash
|
||||
export LANGFLOW_API_KEY=YOUR_LANGFLOW_API_KEY
|
||||
```
|
||||
Replace `YOUR_LANGFLOW_API_KEY` with your server's API key.
|
||||
```
|
||||
export LANGFLOW_API_KEY=LANGFLOW_API_KEY
|
||||
```
|
||||
|
||||
5. To serve the flow without the Langflow UI, pass the flow JSON path to the `lfx serve` command:
|
||||
```bash
|
||||
lfx serve flows/Simple_Agent.json
|
||||
```
|
||||
```
|
||||
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](https://github.com/langflow-ai/langflow/blob/main/src/lfx/README.md).
|
||||
`lfx serve` starts a FastAPI app that exposes your flow as an HTTP API endpoint.
|
||||
For more information, see the [Langflow LFX README](https://github.com/langflow-ai/langflow/blob/main/src/lfx/README.md).
|
||||
|
||||
## Manage multiple environments with `environments.yaml`
|
||||
|
||||
The `environments.yaml` file created at initialization contains three example entries for deployment environments:
|
||||
|
||||
```yaml
|
||||
local:
|
||||
url: http://127.0.0.1:7860
|
||||
api_key_env: LANGFLOW_LOCAL_API_KEY
|
||||
staging:
|
||||
url: https://staging.example.com
|
||||
api_key_env: LANGFLOW_STAGING_API_KEY
|
||||
production:
|
||||
url: https://langflow.example.com
|
||||
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:
|
||||
|
||||
```bash
|
||||
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`.
|
||||
|
||||
33
docs/docs/Agents/langflow-mcp-client.mdx
Normal file
33
docs/docs/Agents/langflow-mcp-client.mdx
Normal file
@ -0,0 +1,33 @@
|
||||
---
|
||||
title: Langflow MCP Client for coding agents
|
||||
slug: /langflow-mcp-client
|
||||
---
|
||||
|
||||
import Icon from "@site/src/components/icon";
|
||||
|
||||
Connect coding agents such as **Bob (IBM)** and **Claude Code** to a Langflow instance so they can build and run flows over MCP.
|
||||
|
||||
This page describes the <Icon name="Terminal" aria-hidden="true"/> **Langflow MCP Client** entry in **Settings**. It is different from Langflow's other MCP options.
|
||||
|
||||
* [**Use Langflow as an MCP client**](/mcp-client): Use the **MCP Tools** component in flows so agent components _on the canvas_ can call external MCP servers or Langflow MCP URLs.
|
||||
* [**Use Langflow as an MCP server**](/mcp-server): Use the **MCP Servers** page in Langflow to expose your Langflow project as an MCP server to desktop clients such as Cursor or Windsurf.
|
||||
|
||||
## Connect Bob (IBM) or Claude Code
|
||||
|
||||
To connect Langflow to a coding agent, do the following:
|
||||
|
||||
1. Click your profile icon, select **Settings**, and then click <Icon name="Terminal" aria-hidden="true"/> **Langflow MCP Client**.
|
||||
2. Select the coding agent you want to connect to Langflow, and follow the steps shown in the UI.
|
||||
|
||||
All client configurations run `lfx-mcp` with `uvx`, and set `LANGFLOW_SERVER_URL` to your Langflow server URL and `LANGFLOW_API_KEY` to a Langflow API key of your choice.
|
||||
|
||||
* To connect to **Bob (IBM)**, paste the configuration JSON into `~/.bob/settings/mcp_settings.json`, or use **Edit Project MCP** for a project-only setup.
|
||||
* To connect to **Claude Code**, run the `claude mcp add` command shown on the page, or manually add the JSON configuration to `~/.claude.json`.
|
||||
|
||||
If you do not set `LANGFLOW_API_KEY`, the coding agent can log in with the Langflow username and password you use to sign in to the Langflow web UI for that server.
|
||||
|
||||
## See also
|
||||
|
||||
* [Use Langflow as an MCP client](/mcp-client)
|
||||
* [Use Langflow as an MCP server](/mcp-server)
|
||||
* [**MCP Tools** component](/mcp-tools)
|
||||
@ -6,6 +6,7 @@ slug: /mcp-client
|
||||
import Icon from "@site/src/components/icon";
|
||||
import McpIcon from '@site/static/logos/mcp-icon.svg';
|
||||
import PartialMcpNodeTip from '@site/docs/_partial-mcp-node-tip.mdx';
|
||||
import PartialMcpToolsAddSteps from '@site/docs/_partial-mcp-tools-add-steps.mdx';
|
||||
import Tabs from '@theme/Tabs';
|
||||
import TabItem from '@theme/TabItem';
|
||||
|
||||
@ -15,10 +16,12 @@ This page describes how to use Langflow as an MCP client with the [**MCP Tools**
|
||||
|
||||
For information about using Langflow as an MCP server, see [Use Langflow as an MCP server](/mcp-server).
|
||||
|
||||
## Use the MCP tools component
|
||||
## Use the MCP tools component {#use-the-mcp-tools-component}
|
||||
|
||||
The **MCP Tools** component connects to an MCP server so that a [Langflow agent](/agents) can use the server's tools when responding to user queries.
|
||||
|
||||
Register MCP servers, and then add **MCP Tools** from the <McpIcon /> **MCP** sidebar as described in [Connect to a non-Langflow MCP server](#mcp-stdio-mode).
|
||||
|
||||
This component has two modes, depending on the type of server you want to access:
|
||||
|
||||
* [Connect to a non-Langflow MCP server](#mcp-stdio-mode) with a JSON configuration file, server start command, or HTTP/SSE URL to access tools provided by external, non-Langflow MCP servers.
|
||||
@ -28,11 +31,11 @@ This component has two modes, depending on the type of server you want to access
|
||||
|
||||
<PartialMcpNodeTip />
|
||||
|
||||
1. Add an **MCP Tools** component to your flow.
|
||||
<PartialMcpToolsAddSteps />
|
||||
|
||||
2. In the **MCP Server** field, select a previously connected server or click <Icon name="Plus" aria-hidden="true"/> **Add MCP Server**.
|
||||
4. In the **MCP Server** field on the **MCP Tools** component, select the server you registered.
|
||||
|
||||
There are multiple ways to add a new server:
|
||||
New servers are registered in **Settings** > **MCP Servers**, or in the <McpIcon /> **MCP** sidebar > <Icon name="Plus" aria-hidden="true"/> **Add MCP Server**, using one of the following connection types:
|
||||
|
||||
* **JSON**: Paste the MCP server's JSON configuration object into the field, including required and optional parameters that you want to use, and then click **Add Server**.
|
||||
* **STDIO**: Enter the MCP server's **Name**, **Command**, and any **Arguments** and **Environment Variables** the server uses, and then click **Add Server**.
|
||||
@ -40,31 +43,31 @@ This component has two modes, depending on the type of server you want to access
|
||||
* **HTTP/SSE**: Enter your MCP server's **Name**, **URL**, and any **Headers** and **Environment Variables** the server uses, and then click **Add Server**.
|
||||
The default **URL** for Langflow MCP servers is `http://localhost:7860/api/v1/mcp/project/PROJECT_ID/streamable` or `http://localhost:7860/api/v1/mcp/streamable`. For more information, see [Connect to a Langflow MCP server](#mcp-http-mode).
|
||||
|
||||
3. To configure headers for your MCP server, enter each header in the **Headers** fields as key-value pairs.
|
||||
5. To configure headers for your MCP server, enter each header in the **Headers** fields as key-value pairs.
|
||||
You can use [global variables](/configuration-global-variables) in header values by entering the global variable name as the header value.
|
||||
For more information, see [Use global variables in MCP server headers](#use-global-variables-in-mcp-server-headers).
|
||||
|
||||
4. To use environment variables in your server command, enter each variable in the **Env** fields as key-value pairs.
|
||||
6. To use environment variables in your server command, enter each variable in the **Env** fields as key-value pairs.
|
||||
|
||||
5. In the **Tool** field, select a tool that you want this component to use, or leave the field blank to allow access to all tools provided by the MCP server.
|
||||
7. In the **Tool** field, select a tool that you want this component to use, or leave the field blank to allow access to all tools provided by the MCP server.
|
||||
|
||||
If you select a specific tool, you might need to configure additional tool-specific fields. For information about tool-specific fields, see your MCP server's documentation.
|
||||
|
||||
At this point, the **MCP Tools** component is serving a tool from the connected server, but nothing is using the tool. The next steps explain how to make the tool available to an [**Agent** component](/components-agents) so that the agent can use the tool in its responses.
|
||||
|
||||
6. In the [component's header menu](/concepts-components#component-menus), enable **Tool mode** so you can use the component with an agent.
|
||||
8. In the [component's header menu](/concepts-components#component-menus), enable **Tool mode** so you can use the component with an agent.
|
||||
|
||||
7. Connect the **MCP Tools** component's **Toolset** port to an **Agent** component's **Tools** port.
|
||||
9. Connect the **MCP Tools** component's **Toolset** port to an **Agent** component's **Tools** port.
|
||||
|
||||
If not already present in your flow, make sure you also attach **Chat Input** and **Chat Output** components to the **Agent** component.
|
||||
|
||||

|
||||
|
||||
8. Test your flow to make sure the MCP server is connected and the selected tool is used by the agent. Open the **Playground**, and then enter a prompt that uses the tool you connected through the **MCP Tools** component.
|
||||
10. Test your flow to make sure the MCP server is connected and the selected tool is used by the agent. Open the **Playground**, and then enter a prompt that uses the tool you connected through the **MCP Tools** component.
|
||||
|
||||
For example, if you use `mcp-server-fetch` with the `fetch` tool, you could ask the agent to summarize recent tech news. The agent calls the MCP server function `fetch`, and then returns the response.
|
||||
|
||||
9. If you want the agent to be able to use more tools, repeat these steps to add more tools components with different servers or tools.
|
||||
11. If you want the agent to be able to use more tools, repeat these steps to add more tools components with different servers or tools.
|
||||
|
||||
### Connect a Langflow MCP server {#mcp-http-mode}
|
||||
|
||||
@ -73,30 +76,39 @@ For more information about your projects' MCP servers, including exposing flows
|
||||
|
||||
Langflow MCP servers support both the **streamable HTTP** transport and **Server-Sent Events (SSE)** as a fallback.
|
||||
|
||||
To leverage flows-as-tools, use the **MCP Tools** component to connect to a project's MCP endpoint:
|
||||
To leverage flows-as-tools, register your Langflow MCP endpoint as a server first, and then add the **MCP Tools** component from the <McpIcon /> **MCP** sidebar.
|
||||
|
||||
1. Register the Langflow MCP server.
|
||||
Open **Settings** > **MCP Servers** or the <McpIcon /> **MCP** section in the flow sidebar, click <Icon name="Plus" aria-hidden="true"/> **Add MCP Server**, and select **HTTP/SSE** mode.
|
||||
|
||||
1. Add an **MCP Tools** component to your flow, click <Icon name="Plus" aria-hidden="true"/> **Add MCP Server**, and then select **HTTP/SSE** mode.
|
||||
2. In the **MCP URL** field, enter your Langflow server's MCP endpoint.
|
||||
- For project-specific servers: `http://localhost:7860/api/v1/mcp/project/PROJECT_ID/streamable`
|
||||
- For global MCP server: `http://localhost:7860/api/v1/mcp/streamable`
|
||||
- Default for Langflow Desktop: `http://localhost:7868/`
|
||||
|
||||
All flows available from the targeted server are treated as tools.
|
||||
3. In the [component's header menu](/concepts-components#component-menus), enable **Tool Mode** so you can use the component with an agent.
|
||||
4. Connect the **MCP Tools** component's **Toolset** port to an **Agent** component's **Tools** port.
|
||||
5. If not already present in your flow, make sure you also attach **Chat Input** and **Chat Output** components to the **Agent** component.
|
||||
All flows available from the targeted server are treated as tools. For authentication and project URLs, see [Use Langflow as an MCP server](/mcp-server).
|
||||
|
||||
3. Save the server. When the connection succeeds, the server is stored and appears as a tile in the **MCP** sidebar.
|
||||
|
||||
4. Add the **MCP Tools** component to the flow.
|
||||
|
||||
5. In the [component's header menu](/concepts-components#component-menus), enable **Tool Mode** so you can use the component with an agent.
|
||||
|
||||
6. Connect the **MCP Tools** component's **Toolset** port to an **Agent** component's **Tools** port.
|
||||
|
||||
7. If not already present in your flow, make sure you also attach **Chat Input** and **Chat Output** components to the **Agent** component.
|
||||
|
||||

|
||||
|
||||
6. Test your flow to make sure the agent uses your flows to respond to queries. Open the **Playground**, and then enter a prompt that uses a flow that you connected through the **MCP Tools** component.
|
||||
8. Test your flow to make sure the agent uses your flows to respond to queries. Open the **Playground**, and then enter a prompt that uses a flow that you connected through the **MCP Tools** component.
|
||||
|
||||
7. If you want the agent to be able to use more tools, repeat these steps to add more tools components with different servers or tools.
|
||||
9. If you want the agent to be able to use more tools, repeat these steps to add more tools components with different servers or tools.
|
||||
|
||||
## MCP Tools parameters
|
||||
|
||||
| Name | Type | Description |
|
||||
|------|------|-------------|
|
||||
| mcp_server | String | Input parameter. The MCP server to connect to. Select from previously configured servers or add a new one. |
|
||||
| mcp_server | String | Input parameter. The MCP server to connect to. |
|
||||
| tool | String | Input parameter. The specific tool to execute from the connected MCP server. Leave blank to allow access to all tools. |
|
||||
| use_cache | Boolean | Input parameter. Enable caching of MCP server and tools to improve performance. Default: `false`. |
|
||||
| verify_ssl | Boolean | Input parameter. Enable SSL certificate verification for HTTPS connections. Default: `true`. |
|
||||
@ -104,9 +116,9 @@ To leverage flows-as-tools, use the **MCP Tools** component to connect to a proj
|
||||
|
||||
## Manage connected MCP servers
|
||||
|
||||
To manage all MCP server connections for your Langflow client, click <McpIcon /> **MCP servers** in the visual editor, or click your profile icon, select **Settings**, and then click **MCP Servers**.
|
||||
To manage MCP server connections for use in flows, open the <McpIcon /> **MCP** section in the visual editor, and then click <Icon name="ArrowUpRight" aria-hidden="true"/> **Manage Servers**, or click your profile icon, select **Settings**, and then click **MCP Servers**.
|
||||
|
||||
To add a new MCP server, click **Add MCP Server**, and then follow the steps in [Use the MCP Tools component](#use-the-mcp-tools-component) to configure the connection and use the server in a flow.
|
||||
To add a new MCP server, click <Icon name="Plus" aria-hidden="true"/> **Add MCP Server**, register the server, and then select the server on the **MCP Tools** component as described in [Connect to a non-Langflow MCP server](#mcp-stdio-mode).
|
||||
|
||||
Click <Icon name="Ellipsis" aria-hidden="true"/> **More** to edit or delete an MCP server connection.
|
||||
|
||||
@ -249,7 +261,7 @@ For example, to create a global variable named `TEST_BEARER_TOKEN` for MCP serve
|
||||
2. Create a **Credential** global variable named `TEST_BEARER_TOKEN`.
|
||||
3. In the **Value** field, enter your MCP server's bearer token value. The value must include the `Bearer` prefix with a space, for example: `Bearer eyJhbG...`.
|
||||
4. Click **Save Variable**.
|
||||
5. To manage MCP server connections for your Langflow client, click <McpIcon /> **MCP servers** in the visual editor, or click your profile icon, select **Settings**, and then click **MCP Servers**.
|
||||
5. To manage MCP server connections for your Langflow client, click <McpIcon /> **MCP servers**, and then click <Icon name="ArrowUpRight" aria-hidden="true"/> **Manage Servers**, or click your profile icon, select **Settings**, and then click **MCP Servers**.
|
||||
6. Click <Icon name="Plus" aria-hidden="true"/> **Add MCP Server**.
|
||||
7. Select the following:
|
||||
* **Name**: test-mcp-server
|
||||
@ -262,7 +274,7 @@ For example, to create a global variable named `TEST_BEARER_TOKEN` for MCP serve
|
||||
After creating the server and global variable, you can connect to the server with the **MCP Tools** component, as explained in the next steps.
|
||||
|
||||
9. Add the **MCP Tools** component to a flow.
|
||||
10. In the **MCP Tools** component, select the **MCP Server** you created.
|
||||
10. In the **MCP Tools** component, confirm the **MCP Server** is set to the server you created.
|
||||
The MCP server configuration already includes the headers you configured earlier, so no further configuration is needed in the component. The global variable `TEST_BEARER_TOKEN` is automatically resolved when the component makes requests to the MCP server.
|
||||
|
||||
11. Optional: To override headers or add additional headers to the **MCP Tools** component, click the component to view the **Headers** parameter in the [component inspection panel](/concepts-components#component-menus), and then add header key values. Headers configured in the component take precedence over the headers configured in the MCP server settings.
|
||||
@ -273,5 +285,6 @@ The MCP server configuration already includes the headers you configured earlier
|
||||
|
||||
## See also
|
||||
|
||||
- [Langflow MCP Client](./langflow-mcp-client.mdx)
|
||||
- [Use Langflow as an MCP server](/mcp-server)
|
||||
- [Use a DataStax Astra DB MCP server with the MCP Tools component](/mcp-component-astra)
|
||||
@ -5,6 +5,7 @@ slug: /mcp-component-astra
|
||||
|
||||
import Icon from "@site/src/components/icon";
|
||||
import PartialMcpNodeTip from '@site/docs/_partial-mcp-node-tip.mdx';
|
||||
import McpIcon from '@site/static/logos/mcp-icon.svg';
|
||||
|
||||
This guide demonstrates how to [use Langflow as an MCP client](/mcp-client) by using the **MCP Tools** component to run a [DataStax Astra DB MCP server](https://github.com/datastax/astra-db-mcp) in an agent flow.
|
||||
|
||||
@ -22,20 +23,20 @@ This guide demonstrates how to [use Langflow as an MCP client](/mcp-client) by u
|
||||
|
||||
You can also use an existing flow or create a blank flow.
|
||||
|
||||
6. Remove the **URL** tool, and then replace it with an [**MCP Tools** component](/mcp-client).
|
||||
6. Remove the **URL** tool from the flow.
|
||||
|
||||
7. Configure the **MCP Tools** component as follows:
|
||||
7. Register the Astra DB MCP server from the <McpIcon /> **MCP** sidebar and add **MCP Tools** to the canvas.
|
||||
Use the following values:
|
||||
|
||||
1. In the **MCP Server** field, click <Icon name="Plus" aria-hidden="true"/> **Add MCP Server**.
|
||||
2. Select **Stdio** mode.
|
||||
3. In the **Name** field, enter a name for the MCP server.
|
||||
4. In the **Commmand** field, add the following code to connect to an Astra DB MCP server:
|
||||
1. In the **Name** field, enter a name for the MCP server.
|
||||
|
||||
2. In the **Command** field, add the following code to connect to an Astra DB MCP server:
|
||||
|
||||
```bash
|
||||
npx -y @datastax/astra-db-mcp
|
||||
```
|
||||
|
||||
5. In the **Environment Variables** fields, add variables for `ASTRA_DB_APPLICATION_TOKEN` and `ASTRA_DB_API_ENDPOINT` with the values from your Astra database.
|
||||
3. In the **Environment Variables** fields, add variables for `ASTRA_DB_APPLICATION_TOKEN` and `ASTRA_DB_API_ENDPOINT` with the values from your Astra database.
|
||||
|
||||
:::info
|
||||
Environment variables declared in your Langflow `.env` file can be referenced in your MCP server commands, but you cannot reference global variables declared in Langflow.
|
||||
|
||||
@ -3,14 +3,15 @@ title: MCP Tools
|
||||
slug: /mcp-tools
|
||||
---
|
||||
|
||||
import Icon from "@site/src/components/icon";
|
||||
import PartialParams from '@site/docs/_partial-hidden-params.mdx';
|
||||
import PartialMcpToolsAddSteps from '@site/docs/_partial-mcp-tools-add-steps.mdx';
|
||||
|
||||
The **MCP Tools** component connects to a Model Context Protocol (MCP) server and exposes the MCP server's functions as tools for Langflow agents to use to respond to input.
|
||||
|
||||
In addition to publicly available MCP servers and your own custom-built MCP servers, you can connect Langflow MCP servers, which allow your agent to use your Langflow flows as tools.
|
||||
To do this, use the **MCP Tools** component's [HTTP/SSE mode](/mcp-client#mcp-http-mode) to connect to your Langflow project's MCP server.
|
||||
|
||||
<PartialMcpToolsAddSteps />
|
||||
|
||||
For more information, see [Use Langflow as an MCP client](/mcp-client) and [Use Langflow as an MCP server](/mcp-server).
|
||||
|
||||
:::tip Tool mode is missing
|
||||
@ -33,4 +34,4 @@ If you're upgrading an existing flow and the **MCP Tools** component loses its *
|
||||
* In Langflow version 1.5, the **MCP Connection** component was renamed to the **MCP Tools** component.
|
||||
* In Langflow version 1.3, the **MCP Tools (stdio)** and **MCP Tools (SSE)** components were removed and replaced by the unified **MCP Connection** component, which was later renamed to **MCP Tools**.
|
||||
|
||||
</details>
|
||||
</details>
|
||||
|
||||
32
docs/docs/Components/policies.mdx
Normal file
32
docs/docs/Components/policies.mdx
Normal file
@ -0,0 +1,32 @@
|
||||
---
|
||||
title: Policies (Beta)
|
||||
slug: /policies
|
||||
---
|
||||
|
||||
The **Policies** component leverages [ToolGuard](https://github.com/AgentToolkit/toolguard) to automatically generate guard code that validates tool execution against defined business policies.
|
||||
|
||||
With this component, developers define business policies in natural language and integrate policy enforcement into agent workflows. It automatically generates validation code for tools from those policies, protects tool execution by enforcing policy compliance at runtime, and caches generated guard code for better performance.
|
||||
|
||||
The component supports **Generate** activity, which runs ToolGuard’s buildtime flow to produce new guard code from policies, and **Guard** activity, which reuses previously generated guard code for faster runs.
|
||||
|
||||
## Use the component in a flow
|
||||
|
||||
When `enabled` is `true`, you must supply at least one policy before generating guards.
|
||||
Generated guard code is written under `tmp_toolguard/{project_name}/`, with **Step 1** producing guard specifications from policies in `Step_1/`, and **Step 2** turning those specifications into executable guard code in `Step_2/`.
|
||||
If you switch to **Guard** (apply cached guards), the project directory must already contain valid generated guard code. The component handles module caching and cleanup automatically.
|
||||
|
||||
For more information, see the [ToolGuard GitHub repository](https://github.com/AgentToolkit/toolguard).
|
||||
|
||||
## Policies parameters
|
||||
|
||||
| Name | Type | Description |
|
||||
|------|------|-------------|
|
||||
| enabled | Boolean | Input parameter. If `true`, ToolGuard runs before tool execution; if `false`, policy validation is skipped. |
|
||||
| mode | String | Input parameter. **Activity**: **Generate** runs buildtime to create guard code, or **Guard** loads existing guards from the project folder. |
|
||||
| project | String | Input parameter. Folder name for generated code under `tmp_toolguard/` (default `my_project`). |
|
||||
| in_tools | List[Tool] | Input parameter. Tools the agent can use; they are wrapped with policy guards when enabled. |
|
||||
| policies | List[String] | Input parameter. One or more clear, self-contained business policy strings. Required when generating guards. |
|
||||
| model | Model | Input parameter. LLM used for Policies buildtime; Anthropic Claude Sonnet is recommended. Required when generating guards. |
|
||||
| api_key | String | Input parameter. Model provider API key (advanced). Required when generating guards. |
|
||||
| guarded_tools | List[Tool] | Output parameter. Tools with policy enforcement applied. Returns the original tools when the component is disabled. |
|
||||
|
||||
@ -21,4 +21,23 @@ This environment variable is a beta feature, and should not be your only safegua
|
||||
|
||||
In the event that Langflow could execute untrusted or LLM-generated code, run Langflow in an isolated and containerized execution environment.
|
||||
|
||||
For more information, see [Security](/security).
|
||||
### Configure a custom component allow-list
|
||||
|
||||
`LANGFLOW_ALLOW_CUSTOM_COMPONENTS` works together with optional paths that define which component templates the server loads, and which code hashes are trusted.
|
||||
|
||||
Directories listed in the `LANGFLOW_COMPONENTS_PATH` environment variable are loaded as custom components and merged into the server’s template set.
|
||||
When `LANGFLOW_ALLOW_CUSTOM_COMPONENTS` is set to `false`, the components in the `LANGFLOW_COMPONENTS_PATH` directory **remain allowed**.
|
||||
|
||||
To allow some components while blocking others, include the allowed custom components directory in `LANGFLOW_COMPONENTS_PATH` and set `LANGFLOW_ALLOW_CUSTOM_COMPONENTS` to `false`.
|
||||
|
||||
`LANGFLOW_COMPONENTS_INDEX_PATH` points to a prebuilt component index JSON file at a local path or `http://` / `https://` URL.
|
||||
This environment variable replaces the default index bundled with the `lfx` package.
|
||||
It does **not** import Python modules from a directory on disk.
|
||||
To allow-list custom components, use the `LANGFLOW_COMPONENTS_PATH` environment variable.
|
||||
|
||||
If both environment variables are set, Langflow builds one combined set of components from the custom index _and_ from `LANGFLOW_COMPONENTS_PATH`. If the same component category name exists in both, `LANGFLOW_COMPONENTS_PATH` replaces that whole category from the custom index.
|
||||
|
||||
For more information, see:
|
||||
|
||||
* [Environment variables](/environment-variables#visual-editor-and-playground-behavior)
|
||||
* [Security](/security)
|
||||
@ -92,6 +92,7 @@ If it detects a supported environment variable, then it automatically adopts the
|
||||
LANGFLOW_BUNDLE_URLS=["https://github.com/user/repo/commit/hash"]
|
||||
LANGFLOW_CACHE_TYPE=async
|
||||
LANGFLOW_COMPONENTS_PATH=/path/to/components/
|
||||
LANGFLOW_COMPONENTS_INDEX_PATH=/path/to/component_index.json
|
||||
LANGFLOW_CONFIG_DIR=/path/to/config/
|
||||
LANGFLOW_DATABASE_URL=postgresql://user:password@localhost:5432/langflow
|
||||
LANGFLOW_DEV=False
|
||||
@ -170,6 +171,7 @@ LANGFLOW_BACKEND_ONLY=False
|
||||
LANGFLOW_BUNDLE_URLS=["https://github.com/user/repo/commit/hash"]
|
||||
LANGFLOW_CACHE_TYPE=async
|
||||
LANGFLOW_COMPONENTS_PATH=/path/to/components/
|
||||
LANGFLOW_COMPONENTS_INDEX_PATH=/path/to/component_index.json
|
||||
LANGFLOW_CONFIG_DIR=/path/to/config/
|
||||
LANGFLOW_DATABASE_URL=postgresql://user:password@localhost:5432/langflow
|
||||
LANGFLOW_DEV=False
|
||||
@ -215,6 +217,7 @@ Environment="LANGFLOW_BACKEND_ONLY=false"
|
||||
Environment="LANGFLOW_BUNDLE_URLS=[\"https://github.com/user/repo/commit/hash\"]"
|
||||
Environment="LANGFLOW_CACHE_TYPE=async"
|
||||
Environment="LANGFLOW_COMPONENTS_PATH=/path/to/components/"
|
||||
Environment="LANGFLOW_COMPONENTS_INDEX_PATH=/path/to/component_index.json"
|
||||
Environment="LANGFLOW_CONFIG_DIR=/path/to/config"
|
||||
Environment="LANGFLOW_DATABASE_URL=postgresql://user:password@localhost:5432/langflow"
|
||||
Environment="LANGFLOW_DEV=false"
|
||||
@ -267,6 +270,7 @@ Create or edit the `.vscode/tasks.json` file in your project root.
|
||||
"LANGFLOW_BUNDLE_URLS": "[\"https://github.com/user/repo/commit/hash\"]",
|
||||
"LANGFLOW_CACHE_TYPE": "async",
|
||||
"LANGFLOW_COMPONENTS_PATH": "D:/path/to/components/",
|
||||
"LANGFLOW_COMPONENTS_INDEX_PATH": "D:/path/to/component_index.json",
|
||||
"LANGFLOW_CONFIG_DIR": "D:/path/to/config/",
|
||||
"LANGFLOW_DATABASE_URL": "postgresql://postgres:password@localhost:5432/langflow",
|
||||
"LANGFLOW_DEV": "false",
|
||||
@ -433,6 +437,7 @@ See [Telemetry](/contributing-telemetry).
|
||||
| `LANGFLOW_AUTO_SAVING_INTERVAL` | Integer | `1000` | Set the auto-save interval in milliseconds if `LANGFLOW_AUTO_SAVING=True`. |
|
||||
| `LANGFLOW_BUNDLE_URLS` | List[String] | `[]` | A list of URLs from which to load custom bundles. Supports GitHub URLs. If `LANGFLOW_AUTO_LOGIN=True`, flows from these bundles are loaded into the database. |
|
||||
| `LANGFLOW_COMPONENTS_PATH` | String | Not set | Path to a directory containing custom components. Typically used if you have local custom components or you are building a Docker image with custom components. |
|
||||
| `LANGFLOW_COMPONENTS_INDEX_PATH` | String | Not set | File path or URL (`http://` or `https://`) to a prebuilt component index JSON file used to populate built-in components in the visual editor. When not set, Langflow uses the included index. Useful for supplying a curated component index, for example in airgapped deployments. For more information, see [Block custom components](../Deployment/deployment-block-custom-components.mdx). |
|
||||
| `LANGFLOW_ALLOW_CUSTOM_COMPONENTS` | Boolean | `True` | If `false`, disables custom components and in-editor editing of component code. This feature is in beta. For more information, see [Block custom components](../Deployment/deployment-block-custom-components.mdx). |
|
||||
| `LANGFLOW_LOAD_FLOWS_PATH` | String | Not set | Path to a directory containing flow JSON files to be loaded on startup. Typically used when creating a Docker image with prepackaged flows. Requires `LANGFLOW_AUTO_LOGIN=True`. |
|
||||
| `LANGFLOW_CREATE_STARTER_PROJECTS` | Boolean | `True` | Whether to create templates during initialization. If `false`, Langflow doesn't create templates, and `LANGFLOW_UPDATE_STARTER_PROJECTS` is treated as `false`. |
|
||||
|
||||
@ -98,6 +98,22 @@ To get back to the **Projects** page after editing a flow, click the project nam
|
||||
2. Click <Icon name="Ellipsis" aria-hidden="true" /> **More**, and then select **Edit details**.
|
||||
3. Edit the **Name** and **Description**, and then click **Save**.
|
||||
|
||||
### Save and restore flow versions
|
||||
|
||||
You can save versions of a flow from the <Icon name="History" aria-hidden="true" /> **Version History** menu in the flow editor.
|
||||
|
||||
1. Open the flow that you want to version.
|
||||
2. In the flow editor sidebar, click <Icon name="History" aria-hidden="true" /> **Version History**.
|
||||
3. In **Current**, click **Save** to capture the current state of the flow as a saved version.
|
||||
4. Select a previously saved version to preview the flow in read-only mode.
|
||||
5. To replace the current draft with the selected version, click **Restore**.
|
||||
|
||||
When restoring a version, you can keep **Save current draft before restoring** enabled to create a backup of your current work before the selected version replaces it.
|
||||
|
||||
From a saved version's <Icon name="EllipsesVertical" aria-hidden="true" /> menu, you can also **Export** or **Delete** that version.
|
||||
|
||||
Saved flow versions are stored in the database configured for your Langflow deployment.
|
||||
|
||||
### Lock a flow
|
||||
|
||||
To prevent changes to a flow, you can lock it:
|
||||
|
||||
226
docs/docs/Flows/langflow-assistant.mdx
Normal file
226
docs/docs/Flows/langflow-assistant.mdx
Normal file
@ -0,0 +1,226 @@
|
||||
---
|
||||
title: Build components with Langflow Assistant
|
||||
slug: /langflow-assistant
|
||||
---
|
||||
|
||||
import Icon from "@site/src/components/icon";
|
||||
|
||||
**Langflow Assistant** is an in-app virtual assistant pane within the **Playground**.
|
||||
|
||||
It can answer questions about the application and help you get more out of Langflow.
|
||||
|
||||
**Langflow Assistant** understands the structure of the Langflow graph, so it can create components from natural language prompts.
|
||||
|
||||
Behind the scenes, **Langflow Assistant** runs a built-in Langflow flow on your Langflow server each time you send a message.
|
||||
This flow is distinct from the flow that is open in the canvas, and has its own language model.
|
||||
The language model in **Langflow Assistant** only has the currently opened flow in your workspace for context.
|
||||
To give **Langflow Assistant** context for a different flow, switch to that flow in your workspace, and open **Langflow Assistant**.
|
||||
|
||||
## Prerequisites
|
||||
|
||||
* Connect an LLM provider in the [Global model providers page](/components-models) for **Langflow Assistant** to use
|
||||
|
||||
## Create a custom component with Langflow Assistant
|
||||
|
||||
In this example, you'll prompt **Langflow Assistant** to create a custom component that validates and normalizes a list of URLs.
|
||||
|
||||
You'll then iterate on the code based on the results in the **Playground**.
|
||||
|
||||
1. In the **Playground**, click the <Icon name="Langflow" aria-hidden="true"/> **Langflow** icon.
|
||||
The **Langflow Assistant** pane opens.
|
||||
2. Optionally, ask `What can you help me with?` for a list of **Langflow Assistant's** capabilities.
|
||||
3. Prompt **Langflow Assistant** to generate a custom component. For example:
|
||||
```
|
||||
Create a custom component URLTitleExtractor with:
|
||||
input: text
|
||||
output: list of {url, title, status}
|
||||
timeout handling + per-URL error handling
|
||||
clean docstring and typed methods.”
|
||||
```
|
||||
|
||||
4. **Langflow Assistant** generates component code from your prompt. Because generation is model-driven, your code may differ from the example below.
|
||||
<details closed>
|
||||
<summary>Python component code</summary>
|
||||
|
||||
```
|
||||
import html
|
||||
import re
|
||||
from typing import Any
|
||||
from urllib.error import HTTPError, URLError
|
||||
from urllib.request import Request, urlopen
|
||||
|
||||
from lfx.custom import Component
|
||||
from lfx.io import FloatInput, MessageTextInput, Output
|
||||
from lfx.schema import DataFrame
|
||||
|
||||
|
||||
class URLTitleExtractor(Component):
|
||||
"""Extract URLs from text, fetch each page, and return URL/title/status rows."""
|
||||
|
||||
display_name = "URLTitleExtractor"
|
||||
description = "Extracts URLs from input text and fetches page titles with per-URL status handling."
|
||||
icon = "Link"
|
||||
|
||||
inputs = [
|
||||
MessageTextInput(
|
||||
name="text",
|
||||
display_name="Text",
|
||||
info="Text that may contain one or more URLs.",
|
||||
required=True,
|
||||
),
|
||||
FloatInput(
|
||||
name="timeout",
|
||||
display_name="Timeout",
|
||||
value=5.0,
|
||||
info="HTTP request timeout in seconds for each URL.",
|
||||
range_spec={"min": 0.1, "max": 60.0, "step": 0.1, "step_type": "float"},
|
||||
),
|
||||
]
|
||||
|
||||
outputs = [
|
||||
Output(
|
||||
name="dataframe",
|
||||
display_name="DataFrame",
|
||||
method="build_dataframe",
|
||||
),
|
||||
]
|
||||
|
||||
URL_PATTERN = re.compile(r"https?://[^\s<>\]\"'`{}|\\^]+", re.IGNORECASE)
|
||||
TITLE_PATTERN = re.compile(r"<title\b[^>]*>(.*?)</title>", re.IGNORECASE | re.DOTALL)
|
||||
|
||||
def build_dataframe(self) -> DataFrame:
|
||||
"""Build a DataFrame containing URL, extracted title, and request status."""
|
||||
urls = self._extract_urls(self.text)
|
||||
rows = [self._process_url(url, self.timeout) for url in urls]
|
||||
return DataFrame(rows)
|
||||
|
||||
def _extract_urls(self, text: str) -> list[str]:
|
||||
"""Extract unique URLs from text using a conservative regex."""
|
||||
if not text:
|
||||
return []
|
||||
|
||||
matches = self.URL_PATTERN.findall(text)
|
||||
cleaned_urls: list[str] = []
|
||||
seen: set[str] = set()
|
||||
|
||||
for url in matches:
|
||||
cleaned = url.rstrip(".,);:!?]}")
|
||||
if cleaned and cleaned not in seen:
|
||||
seen.add(cleaned)
|
||||
cleaned_urls.append(cleaned)
|
||||
|
||||
return cleaned_urls
|
||||
|
||||
def _process_url(self, url: str, timeout: float) -> dict[str, Any]:
|
||||
"""Fetch a URL and return a row with url, title, and status."""
|
||||
request = Request(
|
||||
url,
|
||||
headers={
|
||||
"User-Agent": "Mozilla/5.0 (compatible; Langflow URLTitleExtractor/1.0)"
|
||||
},
|
||||
)
|
||||
|
||||
try:
|
||||
with urlopen(request, timeout=float(timeout)) as response:
|
||||
status_code = getattr(response, "status", 200)
|
||||
content_bytes = response.read()
|
||||
content_type = response.headers.get_content_charset() or "utf-8"
|
||||
html_text = content_bytes.decode(content_type, errors="replace")
|
||||
title = self._extract_title(html_text)
|
||||
return {"url": url, "title": title, "status": str(status_code)}
|
||||
|
||||
except HTTPError as exc:
|
||||
title = ""
|
||||
try:
|
||||
body = exc.read()
|
||||
charset = exc.headers.get_content_charset() if exc.headers else None
|
||||
if body:
|
||||
html_text = body.decode(charset or "utf-8", errors="replace")
|
||||
title = self._extract_title(html_text)
|
||||
except Exception:
|
||||
title = ""
|
||||
return {"url": url, "title": title, "status": str(exc.code)}
|
||||
|
||||
except TimeoutError:
|
||||
return {"url": url, "title": "", "status": "timeout"}
|
||||
|
||||
except URLError as exc:
|
||||
reason = getattr(exc, "reason", None)
|
||||
if isinstance(reason, TimeoutError):
|
||||
status = "timeout"
|
||||
else:
|
||||
status = "request_error"
|
||||
return {"url": url, "title": "", "status": status}
|
||||
|
||||
except Exception:
|
||||
return {"url": url, "title": "", "status": "request_error"}
|
||||
|
||||
def _extract_title(self, html_text: str) -> str:
|
||||
"""Extract and normalize the HTML title from a document string."""
|
||||
if not html_text:
|
||||
return ""
|
||||
|
||||
match = self.TITLE_PATTERN.search(html_text)
|
||||
if not match:
|
||||
return ""
|
||||
|
||||
title = html.unescape(match.group(1))
|
||||
title = re.sub(r"\s+", " ", title).strip()
|
||||
return title
|
||||
```
|
||||
|
||||
</details>
|
||||
|
||||
To inspect the code, click **View Code**.
|
||||
To add the component to the canvas, click **Add to Canvas**.
|
||||
|
||||
5. Connect the component to **Chat Input** and **Chat Output** components.
|
||||
At this point your flow has three connected components:
|
||||
|
||||
* **Chat Input** sends the text that contains URLs into the **URLTitleExtractor** so the flow runs when you chat in the **Playground** or send a prompt from an app.
|
||||
* **URLTitleExtractor** reads that text, finds URLs, fetches each page, and outputs a [Table](/data-types#table) with `url`, `title`, and `status` columns.
|
||||
* **Chat Output** receives **URLTitleExtractor**'s result and displays the [Table](/data-types#table) back to the user or calling application.
|
||||
|
||||

|
||||
|
||||
6. Open the **Playground**, and tell Langflow to check a list of URLs.
|
||||
For example:
|
||||
```
|
||||
Check these links: https://langflow.org
|
||||
https://github.com/langflow-ai/langflow
|
||||
https://python.org
|
||||
https://this-domain-should-not-resolve-12345.invalid
|
||||
```
|
||||
7. Run the flow.
|
||||
The output will be similar to the following, with a [Table](/data-types#table) with one row per URL, including page titles and status codes.
|
||||
|
||||
| url | title | status |
|
||||
| --- | --- | --- |
|
||||
| https://langflow.org | Langflow \| Low-code AI builder for agentic and RAG applications | 200 |
|
||||
| https://github.com/langflow-ai/langflow | GitHub - langflow-ai/langflow: Langflow is a powerful tool for building and deploying AI-powered agents and workflows. - GitHub | 200 |
|
||||
| https://python.org | Welcome to Python.org | 200 |
|
||||
| https://this-domain-should-not-resolve-12345.invalid | | |
|
||||
|
||||
8. To iterate further, tell **Langflow Assistant** what you want.
|
||||
For example, prompt it to `Update URLTitleExtractor to add max_urls (default 5) and skip duplicates.`.
|
||||
|
||||
**Langflow Assistant** generates an updated **URLTitleExtractor** component (again, the exact code may differ from a previous run).
|
||||
9. Replace the old component with the new component.
|
||||
Set **max_urls** to `3`.
|
||||
In the **Playground**, enter a list that includes a duplicate URL and the invalid URL from before:
|
||||
```
|
||||
Check these links: https://langflow.org
|
||||
https://github.com/langflow-ai/langflow
|
||||
https://python.org
|
||||
https://langflow.org
|
||||
https://this-domain-should-not-resolve-12345.invalid
|
||||
```
|
||||
|
||||
10. Run the flow.
|
||||
The output will be similar to the following, with the duplicate `https://langflow.org` removed and only 3 valid URLs displayed.
|
||||
|
||||
| url | title | status |
|
||||
| --- | --- | --- |
|
||||
| https://langflow.org | Langflow \| Low-code AI builder for agentic and RAG applications | 200 |
|
||||
| https://github.com/langflow-ai/langflow | GitHub - langflow-ai/langflow: Langflow is a powerful tool for building and deploying AI-powered agents and workflows. - GitHub | 200 |
|
||||
| https://python.org | Welcome to Python.org | 200 |
|
||||
@ -52,10 +52,19 @@ To avoid the impact of potential breaking changes and test new versions, the Lan
|
||||
Highlights of this release include the following changes.
|
||||
For all changes, see the [Changelog](https://github.com/langflow-ai/langflow/releases).
|
||||
|
||||
### Breaking changes
|
||||
|
||||
### New features and enhancements
|
||||
|
||||
- Langflow MCP client for Bob (IBM) and Claude Code
|
||||
|
||||
The **Settings** page now includes <Icon name="Terminal" aria-hidden="true"/> **Langflow MCP Client**, with instructions to connect **Bob (IBM)** and **Claude Code** to your Langflow instance.
|
||||
For more information, see [Langflow MCP client for coding agents](../Agents/langflow-mcp-client.mdx).
|
||||
|
||||
- MCP Tools: register servers first, and then add from the MCP sidebar
|
||||
|
||||
**MCP Tools** is no longer added from the **Agents** component list. Register each MCP server under **Settings** > **MCP Servers**, or from the flow editor <McpIcon /> **MCP** sidebar.
|
||||
Each saved server appears as a unique **MCP Tools** component that can be dragged to the canvas.
|
||||
For more information, see [Use Langflow as an MCP client](/mcp-client#use-the-mcp-tools-component).
|
||||
|
||||
- Flow DevOps Toolkit SDK
|
||||
|
||||
Use the Flow DevOps Toolkit SDK to manage local and remote flows with Git-style terminal commands.
|
||||
@ -71,11 +80,21 @@ For all changes, see the [Changelog](https://github.com/langflow-ai/langflow/rel
|
||||
|
||||
The **Data Operations** component is now the [**JSON Operations** component](/data-operations), and the **DataFrame Operations** component is now the [**Table Operations** component](/dataframe-operations).
|
||||
|
||||
- Flow version history in the visual editor
|
||||
|
||||
You can now save point-in-time versions of a flow from **Version History**, preview saved versions in read-only mode, and restore an earlier version to your working draft.
|
||||
For more information, see [Build flows](../Flows/concepts-flows.mdx#save-and-restore-flow-versions).
|
||||
|
||||
- Enabled tool calling for Gemini 3 preview models
|
||||
|
||||
Tool calling is enabled for the following Google Gemini 3 preview models:
|
||||
`gemini-3.1-pro-preview`, `gemini-3-pro-preview`, `gemini-3-flash-preview`, and `gemini-3-pro-image-preview`.
|
||||
|
||||
- Build components with **Langflow Assistant**
|
||||
|
||||
**Langflow Assistant** is an in-app virtual assistant that can create components from natural language prompts directly within the Langflow workspace.
|
||||
For more information, see [Langflow Assistant](../Flows/langflow-assistant.mdx).
|
||||
|
||||
- Vulnerability reporting now uses HackerOne
|
||||
|
||||
Security reports should now be filed through [IBM's HackerOne program](https://hackerone.com/ibm).
|
||||
@ -87,6 +106,11 @@ For all changes, see the [Changelog](https://github.com/langflow-ai/langflow/rel
|
||||
Set `LANGFLOW_ALLOW_CUSTOM_COMPONENTS=false` to disable custom components and in-editor editing of component code.
|
||||
For more information, see [Block custom components](../Deployment/deployment-block-custom-components.mdx).
|
||||
|
||||
- **Policies** component (beta)
|
||||
|
||||
The **Policies** component uses [ToolGuard](https://github.com/AgentToolkit/toolguard) to generate guard code from natural-language business policies and apply it to agent tools.
|
||||
For more information, see [Policies (Beta)](../Components/policies.mdx).
|
||||
|
||||
## 1.8.x
|
||||
|
||||
Highlights of this release include the following changes.
|
||||
|
||||
@ -80,13 +80,9 @@ You need one **MCP Tools** component for each MCP server that you want your flow
|
||||
* Langflow Docker image: Install the server inside the Docker container.
|
||||
* Langflow Desktop or system-wide Langflow OSS: Install the server globally or in the same user environment where you run Langflow.
|
||||
|
||||
2. In your **Simple Agent** flow, remove the **URL** and **Calculator** tools, and then add an [**MCP Tools**](/mcp-client) component.
|
||||
2. In your **Simple Agent** flow, remove the **URL** and **Calculator** tools.
|
||||
|
||||
3. Click the **MCP Tools** component, and then click <Icon name="Plus" aria-hidden="true"/> **Add MCP Server**.
|
||||
|
||||
:::tip
|
||||
To manage all of your MCP server connections, click <McpIcon /> **MCP servers** in the visual editor, or click your profile icon, select **Settings**, and then click **MCP Servers**.
|
||||
:::
|
||||
3. Open the <McpIcon /> **MCP** section in the left sidebar, click <Icon name="Plus" aria-hidden="true"/> **Add MCP Server**, and register the weather MCP server.
|
||||
|
||||
4. In the **Add MCP Server** pane, provide the server startup command and arguments to connect the weather MCP server to your flow. For this tutorial, use either the **JSON** or **STDIO** option.
|
||||
|
||||
@ -132,11 +128,13 @@ You need one **MCP Tools** component for each MCP server that you want your flow
|
||||
|
||||
5. Click **Add Server**, and then wait for the **Actions** list to populate. This means that the MCP server successfully connected.
|
||||
|
||||
6. Drag the weather MCP server from the **MCP** sidebar onto the canvas to add the [**MCP Tools**](/mcp-client) component for that server.
|
||||
|
||||
With this weather server, the **MCP Tools** component also adds an optional **City** field.
|
||||
For this tutorial, don't enter anything in this field.
|
||||
Instead, you will add a geolocation MCP server in the next step, which the agent will use to detect your location.
|
||||
|
||||
6. Click the **MCP Tools** component, enable **Tool Mode** in the [component's header menu](/concepts-components#component-menus), and then connect the component's **Toolset** port to the **Agent** component's **Tools** port.
|
||||
7. Click the **MCP Tools** component, enable **Tool Mode** in the [component's header menu](/concepts-components#component-menus), and then connect the component's **Toolset** port to the **Agent** component's **Tools** port.
|
||||
|
||||
At this point your flow has four connected components:
|
||||
|
||||
@ -146,7 +144,7 @@ You need one **MCP Tools** component for each MCP server that you want your flow
|
||||
|
||||

|
||||
|
||||
7. To test the weather MCP server, click <Icon name="Play" aria-hidden="true" /> **Playground**, and then ask the LLM `Is it safe to go hiking in the Adirondacks today?`
|
||||
8. To test the weather MCP server, click <Icon name="Play" aria-hidden="true" /> **Playground**, and then ask the LLM `Is it safe to go hiking in the Adirondacks today?`
|
||||
|
||||
The **Playground** shows you the agent's logic as it analyzes the request and select tools to use.
|
||||
|
||||
@ -182,9 +180,9 @@ Note that this tool returns the IP geolocation of your Langflow server, so if yo
|
||||
|
||||
This MCP server can be started with one [npx](https://docs.npmjs.com/cli/v8/commands/npx) command, which downloads and runs the [Toolkit MCP server Node registry package](https://www.npmjs.com/package/@cyanheads/toolkit-mcp-server) without installing the package locally.
|
||||
|
||||
To add the Toolkip MCP server to your flow, do the following:
|
||||
To add the Toolkit MCP server to your flow, do the following:
|
||||
|
||||
1. Add another **MCP Tools** component to your flow, click the component, and then click <Icon name="Plus" aria-hidden="true"/> **Add MCP Server**.
|
||||
1. Open the <McpIcon /> **MCP** sidebar, click <Icon name="Plus" aria-hidden="true"/> **Add MCP Server**, and register a second server.
|
||||
|
||||
2. Select **STDIO**.
|
||||
|
||||
@ -199,7 +197,9 @@ To add the Toolkip MCP server to your flow, do the following:
|
||||
|
||||
5. Click **Add Server**, and then wait for the **Actions** list to populate. This means that the MCP server successfully connected.
|
||||
|
||||
6. Click the **MCP Tools** component, enable **Tool Mode** in the [component's header menu](/concepts-components#component-menus), and then connect the component's **Toolset** port to the **Agent** component's **Tools** port.
|
||||
6. Drag the **ip_geolocation** MCP server from the **MCP** sidebar to the canvas to add the second **MCP Tools** component.
|
||||
|
||||
7. Click the new **MCP Tools** component, enable **Tool Mode** in the [component's header menu](/concepts-components#component-menus), and then connect the component's **Toolset** port to the **Agent** component's **Tools** port.
|
||||
|
||||
Your flow now has an additional **MCP Tools** component for a total of five components.
|
||||
|
||||
|
||||
16
docs/docs/_partial-mcp-tools-add-steps.mdx
Normal file
16
docs/docs/_partial-mcp-tools-add-steps.mdx
Normal file
@ -0,0 +1,16 @@
|
||||
import Icon from "@site/src/components/icon";
|
||||
import McpIcon from '@site/static/logos/mcp-icon.svg';
|
||||
|
||||
As of Langflow 1.9.x, the **MCP Tools** component is not listed as a draggable component under the **Agents** category. To add an MCP tool to a flow, do the following:
|
||||
|
||||
1. Register the MCP server.
|
||||
Open **Settings** → **MCP Servers**, and then click **Add MCP Server**, or click <McpIcon /> **MCP** in the flow editor’s left sidebar, and then click <Icon name="Plus" aria-hidden="true"/> **Add MCP Server**.
|
||||
|
||||
2. Configure and save the server.
|
||||
Enter the connection details, and then click **Save**.
|
||||
For more information, see [Use Langflow as an MCP client](/mcp-client).
|
||||
|
||||
3. In the <McpIcon /> **MCP** sidebar, drag the new server to the canvas.
|
||||
The **MCP Tools** component for that server is added to the canvas.
|
||||
|
||||
For more information, see [Use Langflow as an MCP client](/mcp-client) and [Use Langflow as an MCP server](/mcp-server).
|
||||
@ -111,15 +111,19 @@ const config = {
|
||||
sidebarPath: require.resolve("./sidebars.js"), // Use sidebars.js file
|
||||
sidebarCollapsed: true,
|
||||
// Versioning configuration
|
||||
lastVersion: "1.8.0",
|
||||
lastVersion: "1.9.0",
|
||||
versions: {
|
||||
current: {
|
||||
label: "1.9.x (Next)",
|
||||
label: "1.10.x (Next)",
|
||||
path: "next",
|
||||
},
|
||||
"1.9.0": {
|
||||
label: "1.9.x",
|
||||
path: "",
|
||||
},
|
||||
"1.8.0": {
|
||||
label: "1.8.x",
|
||||
path: "",
|
||||
path: "1.8.0",
|
||||
},
|
||||
},
|
||||
beforeDefaultRemarkPlugins: [
|
||||
|
||||
@ -3,7 +3,7 @@
|
||||
"info": {
|
||||
"title": "Langflow V2 Workflow API",
|
||||
"description": "Filtered API for Langflow V2 workflow operations (3 endpoints)",
|
||||
"version": "1.8.0"
|
||||
"version": "1.9.0"
|
||||
},
|
||||
"paths": {
|
||||
"/api/v2/workflows": {
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@ -54,19 +54,19 @@
|
||||
"node": "22.22.0"
|
||||
},
|
||||
"overrides": {
|
||||
"lodash": "4.17.21",
|
||||
"lodash": "4.18.0",
|
||||
"fast-xml-parser": "4.5.4",
|
||||
"openapi-to-postmanv2": {
|
||||
"lodash": "4.17.21"
|
||||
"lodash": "4.18.0"
|
||||
},
|
||||
"postman-collection": {
|
||||
"lodash": "4.17.21"
|
||||
"lodash": "4.18.0"
|
||||
},
|
||||
"json-schema-resolve-allof": {
|
||||
"lodash": "4.17.21"
|
||||
"lodash": "4.18.0"
|
||||
},
|
||||
"json-refs": {
|
||||
"lodash": "4.17.21"
|
||||
"lodash": "4.18.0"
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -78,6 +78,11 @@ module.exports = {
|
||||
id: "Flows/concepts-flows-import",
|
||||
label: "Import and export flows"
|
||||
},
|
||||
{
|
||||
type: "doc",
|
||||
id: "Flows/langflow-assistant",
|
||||
label: "Build components with Langflow Assistant"
|
||||
},
|
||||
],
|
||||
},
|
||||
{
|
||||
@ -96,6 +101,7 @@ module.exports = {
|
||||
items: [
|
||||
"Agents/mcp-client",
|
||||
"Agents/mcp-server",
|
||||
"Agents/langflow-mcp-client",
|
||||
"Agents/mcp-component-astra",
|
||||
],
|
||||
},
|
||||
@ -354,6 +360,7 @@ module.exports = {
|
||||
items: [
|
||||
"Components/batch-run",
|
||||
"Components/guardrails",
|
||||
"Components/policies",
|
||||
"Components/llm-selector",
|
||||
"Components/smart-router",
|
||||
"Components/smart-transform",
|
||||
@ -464,10 +471,26 @@ module.exports = {
|
||||
label: "API reference",
|
||||
className: "sidebar-category-with-icon sidebar-icon-fileCode",
|
||||
items: [
|
||||
"API-Reference/api-reference-api-examples",
|
||||
"API-Reference/typescript-client",
|
||||
"API-Reference/flow-devops-sdk",
|
||||
"API-Reference/api-flows-run",
|
||||
{
|
||||
type: "doc",
|
||||
id: "API-Reference/api-reference-api-examples",
|
||||
label: "Get started with the Langflow API",
|
||||
},
|
||||
{
|
||||
type: "doc",
|
||||
id: "API-Reference/typescript-client",
|
||||
label: "Use the TypeScript client"
|
||||
},
|
||||
{
|
||||
type: "doc",
|
||||
id: "API-Reference/flow-devops-sdk",
|
||||
label: "Flow DevOps Toolkit SDK",
|
||||
},
|
||||
{
|
||||
type: "doc",
|
||||
id: "API-Reference/api-flows-run",
|
||||
label: "Flow trigger endpoints",
|
||||
},
|
||||
{
|
||||
type: "category",
|
||||
label: "Developer API (Beta)",
|
||||
|
||||
BIN
docs/static/img/lf-assistant-flow.png
vendored
Normal file
BIN
docs/static/img/lf-assistant-flow.png
vendored
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 218 KiB |
25
docs/versioned_docs/version-1.9.0/API-Reference/README.md
Normal file
25
docs/versioned_docs/version-1.9.0/API-Reference/README.md
Normal file
@ -0,0 +1,25 @@
|
||||
# API Examples (Local Test Harness)
|
||||
|
||||
Run all API example suites against a local Langflow server:
|
||||
|
||||
```bash
|
||||
make api_examples_local
|
||||
```
|
||||
|
||||
Run one test suite:
|
||||
|
||||
```bash
|
||||
make api_examples_local suites=python
|
||||
make api_examples_local suites=javascript
|
||||
make api_examples_local suites=curl
|
||||
```
|
||||
|
||||
The following examples are not executed in this harness:
|
||||
|
||||
- `api-build/build-flow-and-stream-events-2.py`
|
||||
- `api-build/build-flow-and-stream-events-3.py`
|
||||
- `api-flows-run/stream-llm-token-responses.py`
|
||||
- `api-openai-responses/example-streaming-request.py`
|
||||
- `api-logs/stream-logs.py`
|
||||
- `api-logs/retrieve-logs-with-optional-parameters.py`
|
||||
- `api-users/reset-password.py`
|
||||
198
docs/versioned_docs/version-1.9.0/API-Reference/api-build.mdx
Normal file
198
docs/versioned_docs/version-1.9.0/API-Reference/api-build.mdx
Normal file
@ -0,0 +1,198 @@
|
||||
---
|
||||
title: Build endpoints
|
||||
slug: /api-build
|
||||
---
|
||||
import CodeSnippet from '@site/src/components/CodeSnippet';
|
||||
import exampleApiBuildBuildFlowAndStreamEvents from '!!raw-loader!@site/docs/API-Reference/curl-examples/api-build/build-flow-and-stream-events.sh';
|
||||
import resultApiBuildResultBuildFlowAndStreamEvents from '!!raw-loader!@site/docs/API-Reference/curl-examples/api-build/result-build-flow-and-stream-events.json';
|
||||
import exampleApiBuildBuildFlowAndStreamEvents2 from '!!raw-loader!@site/docs/API-Reference/curl-examples/api-build/build-flow-and-stream-events-2.sh';
|
||||
import resultApiBuildResultBuildFlowAndStreamEvents2 from '!!raw-loader!@site/docs/API-Reference/curl-examples/api-build/result-build-flow-and-stream-events-2.json';
|
||||
import exampleApiBuildBuildFlowAndStreamEvents3 from '!!raw-loader!@site/docs/API-Reference/curl-examples/api-build/build-flow-and-stream-events-3.sh';
|
||||
import exampleApiBuildSetStartAndStopPoints from '!!raw-loader!@site/docs/API-Reference/curl-examples/api-build/set-start-and-stop-points.sh';
|
||||
import exampleApiBuildOverrideFlowParameters from '!!raw-loader!@site/docs/API-Reference/curl-examples/api-build/override-flow-parameters.sh';
|
||||
import resultApiBuildResultOverrideFlowParameters from '!!raw-loader!@site/docs/API-Reference/curl-examples/api-build/result-override-flow-parameters.json';
|
||||
import Tabs from '@theme/Tabs';
|
||||
import TabItem from '@theme/TabItem';
|
||||
import examplePythonApiBuildBuildFlowAndStreamEvents from '!!raw-loader!@site/docs/API-Reference/python-examples/api-build/build-flow-and-stream-events.py';
|
||||
import exampleJavascriptApiBuildBuildFlowAndStreamEvents from '!!raw-loader!@site/docs/API-Reference/javascript-examples/api-build/build-flow-and-stream-events.js';
|
||||
import examplePythonApiBuildBuildFlowAndStreamEvents2 from '!!raw-loader!@site/docs/API-Reference/python-examples/api-build/build-flow-and-stream-events-2.py';
|
||||
import exampleJavascriptApiBuildBuildFlowAndStreamEvents2 from '!!raw-loader!@site/docs/API-Reference/javascript-examples/api-build/build-flow-and-stream-events-2.js';
|
||||
import examplePythonApiBuildBuildFlowAndStreamEvents3 from '!!raw-loader!@site/docs/API-Reference/python-examples/api-build/build-flow-and-stream-events-3.py';
|
||||
import exampleJavascriptApiBuildBuildFlowAndStreamEvents3 from '!!raw-loader!@site/docs/API-Reference/javascript-examples/api-build/build-flow-and-stream-events-3.js';
|
||||
import examplePythonApiBuildSetStartAndStopPoints from '!!raw-loader!@site/docs/API-Reference/python-examples/api-build/set-start-and-stop-points.py';
|
||||
import exampleJavascriptApiBuildSetStartAndStopPoints from '!!raw-loader!@site/docs/API-Reference/javascript-examples/api-build/set-start-and-stop-points.js';
|
||||
import examplePythonApiBuildOverrideFlowParameters from '!!raw-loader!@site/docs/API-Reference/python-examples/api-build/override-flow-parameters.py';
|
||||
import exampleJavascriptApiBuildOverrideFlowParameters from '!!raw-loader!@site/docs/API-Reference/javascript-examples/api-build/override-flow-parameters.js';
|
||||
|
||||
|
||||
|
||||
:::info
|
||||
The `/build` endpoints are used by Langflow's frontend visual editor code.
|
||||
These endpoints are part of the internal Langflow codebase.
|
||||
|
||||
Don't use these endpoints to run flows in applications that use your Langflow flows.
|
||||
To run flows in your apps, see [Flow trigger endpoints](/api-flows-run).
|
||||
:::
|
||||
|
||||
The `/build` endpoints support Langflow's frontend code for building flows in the Langflow visual editor.
|
||||
You can use these endpoints to build vertices and flows, as well as execute flows with streaming event responses.
|
||||
You might need to use or understand these endpoints when contributing to the Langflow codebase.
|
||||
|
||||
## Build flow and stream events
|
||||
|
||||
This endpoint builds and executes a flow, returning a job ID that can be used to stream execution events.
|
||||
|
||||
1. Send a POST request to the `/build/$FLOW_ID/flow` endpoint:
|
||||
|
||||
<Tabs>
|
||||
<TabItem value="Python" label="Python" default>
|
||||
|
||||
<CodeSnippet source={examplePythonApiBuildBuildFlowAndStreamEvents} language="python" />
|
||||
|
||||
</TabItem>
|
||||
<TabItem value="JavaScript" label="JavaScript">
|
||||
|
||||
<CodeSnippet source={exampleJavascriptApiBuildBuildFlowAndStreamEvents} language="javascript" />
|
||||
|
||||
</TabItem>
|
||||
<TabItem value="curl" label="curl">
|
||||
|
||||
<CodeSnippet source={exampleApiBuildBuildFlowAndStreamEvents} language="bash" />
|
||||
|
||||
</TabItem>
|
||||
</Tabs>
|
||||
|
||||
<details>
|
||||
<summary>Result</summary>
|
||||
|
||||
<CodeSnippet source={resultApiBuildResultBuildFlowAndStreamEvents} language="json" />
|
||||
|
||||
</details>
|
||||
|
||||
2. After receiving a job ID from the build endpoint, use the `/build/$JOB_ID/events` endpoint to stream the execution results:
|
||||
|
||||
<Tabs>
|
||||
<TabItem value="Python" label="Python" default>
|
||||
|
||||
<CodeSnippet source={examplePythonApiBuildBuildFlowAndStreamEvents2} language="python" />
|
||||
|
||||
</TabItem>
|
||||
<TabItem value="JavaScript" label="JavaScript">
|
||||
|
||||
<CodeSnippet source={exampleJavascriptApiBuildBuildFlowAndStreamEvents2} language="javascript" />
|
||||
|
||||
</TabItem>
|
||||
<TabItem value="curl" label="curl">
|
||||
|
||||
<CodeSnippet source={exampleApiBuildBuildFlowAndStreamEvents2} language="bash" />
|
||||
|
||||
</TabItem>
|
||||
</Tabs>
|
||||
|
||||
<details>
|
||||
<summary>Result</summary>
|
||||
|
||||
<CodeSnippet source={resultApiBuildResultBuildFlowAndStreamEvents2} language="json" />
|
||||
|
||||
</details>
|
||||
|
||||
The `/build/$FLOW_ID/events` endpoint has a `stream` query parameter that defaults to `true`.
|
||||
To disable streaming and get all events at once, set `?stream=false`.
|
||||
|
||||
<Tabs>
|
||||
<TabItem value="Python" label="Python" default>
|
||||
|
||||
<CodeSnippet source={examplePythonApiBuildBuildFlowAndStreamEvents3} language="python" />
|
||||
|
||||
</TabItem>
|
||||
<TabItem value="JavaScript" label="JavaScript">
|
||||
|
||||
<CodeSnippet source={exampleJavascriptApiBuildBuildFlowAndStreamEvents3} language="javascript" />
|
||||
|
||||
</TabItem>
|
||||
<TabItem value="curl" label="curl">
|
||||
|
||||
<CodeSnippet source={exampleApiBuildBuildFlowAndStreamEvents3} language="bash" />
|
||||
|
||||
</TabItem>
|
||||
</Tabs>
|
||||
|
||||
## Build headers
|
||||
|
||||
| Header | Info | Example |
|
||||
|--------|------|---------|
|
||||
| Content-Type | Required. Specifies the JSON format. | "application/json" |
|
||||
| accept | Optional. Specifies the response format. | "application/json" |
|
||||
| x-api-key | Optional. Required only if authentication is enabled. | "sk-..." |
|
||||
|
||||
## Build parameters
|
||||
|
||||
| Parameter | Type | Description |
|
||||
|-----------|------|-------------|
|
||||
| inputs | object | Optional. Input values for flow components. |
|
||||
| data | object | Optional. Flow data to override stored configuration. |
|
||||
| files | array[string] | Optional. List of file paths to use. |
|
||||
| start_component_id | string | Optional. ID of the component where the execution should start. Component `id` values can be found in [Langflow JSON files](/concepts-flows-import#langflow-json-file-contents) |
|
||||
| stop_component_id | string | Optional. ID of the component where the execution should stop. Component `id` values can be found in [Langflow JSON files](/concepts-flows-import#langflow-json-file-contents).|
|
||||
| log_builds | Boolean | Whether to record build logs. Default: Enabled (`true`). |
|
||||
|
||||
### Set start and stop points
|
||||
|
||||
The `/build` endpoint accepts optional values for `start_component_id` and `stop_component_id` to control where the flow run starts and stops.
|
||||
Setting `stop_component_id` for a component triggers the same behavior as clicking **Run component** on that component in the visual editor: The specified component and all dependent components leading up to that component will run.
|
||||
|
||||
The following example stops flow execution at an **OpenAI** component:
|
||||
|
||||
<Tabs>
|
||||
<TabItem value="Python" label="Python" default>
|
||||
|
||||
<CodeSnippet source={examplePythonApiBuildSetStartAndStopPoints} language="python" />
|
||||
|
||||
</TabItem>
|
||||
<TabItem value="JavaScript" label="JavaScript">
|
||||
|
||||
<CodeSnippet source={exampleJavascriptApiBuildSetStartAndStopPoints} language="javascript" />
|
||||
|
||||
</TabItem>
|
||||
<TabItem value="curl" label="curl">
|
||||
|
||||
<CodeSnippet source={exampleApiBuildSetStartAndStopPoints} language="bash" />
|
||||
|
||||
</TabItem>
|
||||
</Tabs>
|
||||
|
||||
### Override flow parameters
|
||||
|
||||
The `/build` endpoint also accepts inputs for `data` directly, instead of using the values stored in the Langflow database.
|
||||
This is useful for running flows without having to pass custom values through the visual editor.
|
||||
|
||||
<Tabs>
|
||||
<TabItem value="Python" label="Python" default>
|
||||
|
||||
<CodeSnippet source={examplePythonApiBuildOverrideFlowParameters} language="python" />
|
||||
|
||||
</TabItem>
|
||||
<TabItem value="JavaScript" label="JavaScript">
|
||||
|
||||
<CodeSnippet source={exampleJavascriptApiBuildOverrideFlowParameters} language="javascript" />
|
||||
|
||||
</TabItem>
|
||||
<TabItem value="curl" label="curl">
|
||||
|
||||
<CodeSnippet source={exampleApiBuildOverrideFlowParameters} language="bash" />
|
||||
|
||||
</TabItem>
|
||||
</Tabs>
|
||||
|
||||
<details>
|
||||
<summary>Result</summary>
|
||||
|
||||
<CodeSnippet source={resultApiBuildResultOverrideFlowParameters} language="json" />
|
||||
|
||||
</details>
|
||||
|
||||
## See also
|
||||
|
||||
- [Get Vertex builds](/api-monitor#get-vertex-builds)
|
||||
- [Delete Vertex builds](/api-monitor#delete-vertex-builds)
|
||||
- [Session ID](/session-id)
|
||||
576
docs/versioned_docs/version-1.9.0/API-Reference/api-files.mdx
Normal file
576
docs/versioned_docs/version-1.9.0/API-Reference/api-files.mdx
Normal file
@ -0,0 +1,576 @@
|
||||
---
|
||||
title: Files endpoints
|
||||
slug: /api-files
|
||||
---
|
||||
import CodeSnippet from '@site/src/components/CodeSnippet';
|
||||
import exampleApiFilesUploadFileV1 from '!!raw-loader!@site/docs/API-Reference/curl-examples/api-files/upload-file-v1.sh';
|
||||
import resultApiFilesResultUploadFileV1 from '!!raw-loader!@site/docs/API-Reference/curl-examples/api-files/result-upload-file-v1.json';
|
||||
import exampleApiFilesUploadImageFilesV1 from '!!raw-loader!@site/docs/API-Reference/curl-examples/api-files/upload-image-files-v1.sh';
|
||||
import exampleApiFilesUploadImageFilesV12 from '!!raw-loader!@site/docs/API-Reference/curl-examples/api-files/upload-image-files-v1-2.sh';
|
||||
import exampleApiFilesListFilesV1 from '!!raw-loader!@site/docs/API-Reference/curl-examples/api-files/list-files-v1.sh';
|
||||
import resultApiFilesResultListFilesV1 from '!!raw-loader!@site/docs/API-Reference/curl-examples/api-files/result-list-files-v1.json';
|
||||
import exampleApiFilesDownloadFileV1 from '!!raw-loader!@site/docs/API-Reference/curl-examples/api-files/download-file-v1.sh';
|
||||
import resultApiFilesResultDownloadFileV1 from '!!raw-loader!@site/docs/API-Reference/curl-examples/api-files/result-download-file-v1.txt';
|
||||
import exampleApiFilesDeleteFileV1 from '!!raw-loader!@site/docs/API-Reference/curl-examples/api-files/delete-file-v1.sh';
|
||||
import resultApiFilesResultDeleteFileV1 from '!!raw-loader!@site/docs/API-Reference/curl-examples/api-files/result-delete-file-v1.json';
|
||||
import exampleApiFilesUploadFileV2 from '!!raw-loader!@site/docs/API-Reference/curl-examples/api-files/upload-file-v2.sh';
|
||||
import resultApiFilesResultUploadFileV2 from '!!raw-loader!@site/docs/API-Reference/curl-examples/api-files/result-upload-file-v2.txt';
|
||||
import exampleApiFilesUploadFileV22 from '!!raw-loader!@site/docs/API-Reference/curl-examples/api-files/upload-file-v2-2.sh';
|
||||
import exampleApiFilesSendFilesToYourFlowsV2 from '!!raw-loader!@site/docs/API-Reference/curl-examples/api-files/send-files-to-your-flows-v2.sh';
|
||||
import exampleApiFilesSendFilesToYourFlowsV22 from '!!raw-loader!@site/docs/API-Reference/curl-examples/api-files/send-files-to-your-flows-v2-2.sh';
|
||||
import exampleApiFilesListFilesV2 from '!!raw-loader!@site/docs/API-Reference/curl-examples/api-files/list-files-v2.sh';
|
||||
import resultApiFilesResultListFilesV2 from '!!raw-loader!@site/docs/API-Reference/curl-examples/api-files/result-list-files-v2.json';
|
||||
import exampleApiFilesDownloadFileV2 from '!!raw-loader!@site/docs/API-Reference/curl-examples/api-files/download-file-v2.sh';
|
||||
import resultApiFilesResultDownloadFileV2 from '!!raw-loader!@site/docs/API-Reference/curl-examples/api-files/result-download-file-v2.txt';
|
||||
import exampleApiFilesEditFileNameV2 from '!!raw-loader!@site/docs/API-Reference/curl-examples/api-files/edit-file-name-v2.sh';
|
||||
import resultApiFilesResultEditFileNameV2 from '!!raw-loader!@site/docs/API-Reference/curl-examples/api-files/result-edit-file-name-v2.json';
|
||||
import exampleApiFilesDeleteFileV2 from '!!raw-loader!@site/docs/API-Reference/curl-examples/api-files/delete-file-v2.sh';
|
||||
import resultApiFilesResultDeleteFileV2 from '!!raw-loader!@site/docs/API-Reference/curl-examples/api-files/result-delete-file-v2.json';
|
||||
import exampleApiFilesDeleteAllFilesV2 from '!!raw-loader!@site/docs/API-Reference/curl-examples/api-files/delete-all-files-v2.sh';
|
||||
import resultApiFilesResultDeleteAllFilesV2 from '!!raw-loader!@site/docs/API-Reference/curl-examples/api-files/result-delete-all-files-v2.json';
|
||||
import Tabs from '@theme/Tabs';
|
||||
import TabItem from '@theme/TabItem';
|
||||
import examplePythonApiFilesUploadFileV1 from '!!raw-loader!@site/docs/API-Reference/python-examples/api-files/upload-file-v1.py';
|
||||
import exampleJavascriptApiFilesUploadFileV1 from '!!raw-loader!@site/docs/API-Reference/javascript-examples/api-files/upload-file-v1.js';
|
||||
import examplePythonApiFilesUploadImageFilesV1 from '!!raw-loader!@site/docs/API-Reference/python-examples/api-files/upload-image-files-v1.py';
|
||||
import exampleJavascriptApiFilesUploadImageFilesV1 from '!!raw-loader!@site/docs/API-Reference/javascript-examples/api-files/upload-image-files-v1.js';
|
||||
import examplePythonApiFilesUploadImageFilesV12 from '!!raw-loader!@site/docs/API-Reference/python-examples/api-files/upload-image-files-v1-2.py';
|
||||
import exampleJavascriptApiFilesUploadImageFilesV12 from '!!raw-loader!@site/docs/API-Reference/javascript-examples/api-files/upload-image-files-v1-2.js';
|
||||
import examplePythonApiFilesListFilesV1 from '!!raw-loader!@site/docs/API-Reference/python-examples/api-files/list-files-v1.py';
|
||||
import exampleJavascriptApiFilesListFilesV1 from '!!raw-loader!@site/docs/API-Reference/javascript-examples/api-files/list-files-v1.js';
|
||||
import examplePythonApiFilesDownloadFileV1 from '!!raw-loader!@site/docs/API-Reference/python-examples/api-files/download-file-v1.py';
|
||||
import exampleJavascriptApiFilesDownloadFileV1 from '!!raw-loader!@site/docs/API-Reference/javascript-examples/api-files/download-file-v1.js';
|
||||
import examplePythonApiFilesDeleteFileV1 from '!!raw-loader!@site/docs/API-Reference/python-examples/api-files/delete-file-v1.py';
|
||||
import exampleJavascriptApiFilesDeleteFileV1 from '!!raw-loader!@site/docs/API-Reference/javascript-examples/api-files/delete-file-v1.js';
|
||||
import examplePythonApiFilesUploadFileV2 from '!!raw-loader!@site/docs/API-Reference/python-examples/api-files/upload-file-v2.py';
|
||||
import exampleJavascriptApiFilesUploadFileV2 from '!!raw-loader!@site/docs/API-Reference/javascript-examples/api-files/upload-file-v2.js';
|
||||
import examplePythonApiFilesUploadFileV22 from '!!raw-loader!@site/docs/API-Reference/python-examples/api-files/upload-file-v2-2.py';
|
||||
import exampleJavascriptApiFilesUploadFileV22 from '!!raw-loader!@site/docs/API-Reference/javascript-examples/api-files/upload-file-v2-2.js';
|
||||
import examplePythonApiFilesSendFilesToYourFlowsV2 from '!!raw-loader!@site/docs/API-Reference/python-examples/api-files/send-files-to-your-flows-v2.py';
|
||||
import exampleJavascriptApiFilesSendFilesToYourFlowsV2 from '!!raw-loader!@site/docs/API-Reference/javascript-examples/api-files/send-files-to-your-flows-v2.js';
|
||||
import examplePythonApiFilesSendFilesToYourFlowsV22 from '!!raw-loader!@site/docs/API-Reference/python-examples/api-files/send-files-to-your-flows-v2-2.py';
|
||||
import exampleJavascriptApiFilesSendFilesToYourFlowsV22 from '!!raw-loader!@site/docs/API-Reference/javascript-examples/api-files/send-files-to-your-flows-v2-2.js';
|
||||
import examplePythonApiFilesListFilesV2 from '!!raw-loader!@site/docs/API-Reference/python-examples/api-files/list-files-v2.py';
|
||||
import exampleJavascriptApiFilesListFilesV2 from '!!raw-loader!@site/docs/API-Reference/javascript-examples/api-files/list-files-v2.js';
|
||||
import examplePythonApiFilesDownloadFileV2 from '!!raw-loader!@site/docs/API-Reference/python-examples/api-files/download-file-v2.py';
|
||||
import exampleJavascriptApiFilesDownloadFileV2 from '!!raw-loader!@site/docs/API-Reference/javascript-examples/api-files/download-file-v2.js';
|
||||
import examplePythonApiFilesEditFileNameV2 from '!!raw-loader!@site/docs/API-Reference/python-examples/api-files/edit-file-name-v2.py';
|
||||
import exampleJavascriptApiFilesEditFileNameV2 from '!!raw-loader!@site/docs/API-Reference/javascript-examples/api-files/edit-file-name-v2.js';
|
||||
import examplePythonApiFilesDeleteFileV2 from '!!raw-loader!@site/docs/API-Reference/python-examples/api-files/delete-file-v2.py';
|
||||
import exampleJavascriptApiFilesDeleteFileV2 from '!!raw-loader!@site/docs/API-Reference/javascript-examples/api-files/delete-file-v2.js';
|
||||
import examplePythonApiFilesDeleteAllFilesV2 from '!!raw-loader!@site/docs/API-Reference/python-examples/api-files/delete-all-files-v2.py';
|
||||
import exampleJavascriptApiFilesDeleteAllFilesV2 from '!!raw-loader!@site/docs/API-Reference/javascript-examples/api-files/delete-all-files-v2.js';
|
||||
|
||||
|
||||
|
||||
Use the `/files` endpoints to move files between your local machine and Langflow.
|
||||
|
||||
All `/files` endpoints (both `/v1/files` and `/v2/files`) require authentication with a Langflow API key.
|
||||
You can only access files that belong to your own user account, even as a superuser.
|
||||
|
||||
## Differences between `/v1/files` and `/v2/files`
|
||||
|
||||
There are two versions of the `/files` endpoints.
|
||||
|
||||
`/v2/files` offers the following improvements over `/v1/files`:
|
||||
|
||||
- `/v2` files are organized by `user_id` instead of `flow_id`.
|
||||
This means files are owned by users, and they aren't attached to specific flows.
|
||||
You can upload a file to Langflow one time, and use it with multiple flows.
|
||||
- `/v2` files are tracked in the Langflow database.
|
||||
- `/v2` supports bulk upload and delete.
|
||||
- `/v2` responses contain more descriptive metadata.
|
||||
|
||||
However, `/v2/files` doesn't support image files.
|
||||
To send image files to your flows through the API, use [Upload image files (v1)](#upload-image-files-v1).
|
||||
|
||||
## Files/V1 endpoints
|
||||
|
||||
Use the `/files` endpoints to move files between your local machine and Langflow.
|
||||
|
||||
### Upload file (v1)
|
||||
|
||||
Upload a file to the `v1/files/upload/$FLOW_ID` endpoint:
|
||||
Replace **FILE_NAME** with the uploaded file name.
|
||||
|
||||
<Tabs>
|
||||
<TabItem value="Python" label="Python" default>
|
||||
|
||||
<CodeSnippet source={examplePythonApiFilesUploadFileV1} language="python" />
|
||||
|
||||
</TabItem>
|
||||
<TabItem value="JavaScript" label="JavaScript">
|
||||
|
||||
<CodeSnippet source={exampleJavascriptApiFilesUploadFileV1} language="javascript" />
|
||||
|
||||
</TabItem>
|
||||
<TabItem value="curl" label="curl">
|
||||
|
||||
<CodeSnippet source={exampleApiFilesUploadFileV1} language="bash" />
|
||||
|
||||
</TabItem>
|
||||
</Tabs>
|
||||
|
||||
Replace `FILE_NAME.txt` with the name and extension of the file you want to upload.
|
||||
Not all file types are supported.
|
||||
|
||||
<details>
|
||||
<summary>Result</summary>
|
||||
|
||||
<CodeSnippet source={resultApiFilesResultUploadFileV1} language="json" />
|
||||
|
||||
</details>
|
||||
|
||||
### Upload image files (v1)
|
||||
|
||||
Send image files to Langflow to use them in flows.
|
||||
|
||||
The default file limit is 1024 MB.
|
||||
To change this limit, set the `LANGFLOW_MAX_FILE_SIZE_UPLOAD` [environment variable](/environment-variables).
|
||||
|
||||
1. Attach the image to a `POST /v1/files/upload/$FLOW_ID` request with `--form` (`-F`) and the file path:
|
||||
|
||||
<Tabs>
|
||||
<TabItem value="Python" label="Python" default>
|
||||
|
||||
<CodeSnippet source={examplePythonApiFilesUploadImageFilesV1} language="python" />
|
||||
|
||||
</TabItem>
|
||||
<TabItem value="JavaScript" label="JavaScript">
|
||||
|
||||
<CodeSnippet source={exampleJavascriptApiFilesUploadImageFilesV1} language="javascript" />
|
||||
|
||||
</TabItem>
|
||||
<TabItem value="curl" label="curl">
|
||||
|
||||
<CodeSnippet source={exampleApiFilesUploadImageFilesV1} language="bash" />
|
||||
|
||||
</TabItem>
|
||||
</Tabs>
|
||||
|
||||
A successful request returns the `file_path` for the image in the Langflow file management system in the format `FLOW_ID/TIMESTAMP_FILENAME.TYPE`.
|
||||
For example:
|
||||
|
||||
```json
|
||||
{
|
||||
"flowId": "a430cc57-06bb-4c11-be39-d3d4de68d2c4",
|
||||
"file_path": "a430cc57-06bb-4c11-be39-d3d4de68d2c4/2024-11-27_14-47-50_image-file.png"
|
||||
}
|
||||
```
|
||||
|
||||
2. Use the returned `file_path` to send the image file to other components that can accept file input. Where you specify the file path depends on the component type.
|
||||
|
||||
The following example runs the **Basic Prompting** template flow, passing the image file and the query `describe this image` as input for the **Chat Input** component.
|
||||
In this case, the file path is specified in `tweaks`.
|
||||
|
||||
<Tabs>
|
||||
<TabItem value="Python" label="Python" default>
|
||||
|
||||
<CodeSnippet source={examplePythonApiFilesUploadImageFilesV12} language="python" />
|
||||
|
||||
</TabItem>
|
||||
<TabItem value="JavaScript" label="JavaScript">
|
||||
|
||||
<CodeSnippet source={exampleJavascriptApiFilesUploadImageFilesV12} language="javascript" />
|
||||
|
||||
</TabItem>
|
||||
<TabItem value="curl" label="curl">
|
||||
|
||||
<CodeSnippet source={exampleApiFilesUploadImageFilesV12} language="bash" />
|
||||
|
||||
</TabItem>
|
||||
</Tabs>
|
||||
|
||||
:::tip
|
||||
For help with tweaks, use the **Input Schema** in a flow's [**API access** pane](/concepts-publish#api-access).
|
||||
Setting tweaks with **Input Schema** also automatically populates the required component IDs.
|
||||
:::
|
||||
|
||||
### List files (v1)
|
||||
|
||||
List all files associated with a specific flow.
|
||||
|
||||
<Tabs>
|
||||
<TabItem value="Python" label="Python" default>
|
||||
|
||||
<CodeSnippet source={examplePythonApiFilesListFilesV1} language="python" />
|
||||
|
||||
</TabItem>
|
||||
<TabItem value="JavaScript" label="JavaScript">
|
||||
|
||||
<CodeSnippet source={exampleJavascriptApiFilesListFilesV1} language="javascript" />
|
||||
|
||||
</TabItem>
|
||||
<TabItem value="curl" label="curl">
|
||||
|
||||
<CodeSnippet source={exampleApiFilesListFilesV1} language="bash" />
|
||||
|
||||
</TabItem>
|
||||
</Tabs>
|
||||
|
||||
<details>
|
||||
<summary>Result</summary>
|
||||
|
||||
<CodeSnippet source={resultApiFilesResultListFilesV1} language="json" />
|
||||
|
||||
</details>
|
||||
|
||||
### Download file (v1)
|
||||
|
||||
Download a specific file from a flow.
|
||||
|
||||
<Tabs>
|
||||
<TabItem value="Python" label="Python" default>
|
||||
|
||||
<CodeSnippet source={examplePythonApiFilesDownloadFileV1} language="python" />
|
||||
|
||||
</TabItem>
|
||||
<TabItem value="JavaScript" label="JavaScript">
|
||||
|
||||
<CodeSnippet source={exampleJavascriptApiFilesDownloadFileV1} language="javascript" />
|
||||
|
||||
</TabItem>
|
||||
<TabItem value="curl" label="curl">
|
||||
|
||||
<CodeSnippet source={exampleApiFilesDownloadFileV1} language="bash" />
|
||||
|
||||
</TabItem>
|
||||
</Tabs>
|
||||
|
||||
<details>
|
||||
<summary>Result</summary>
|
||||
|
||||
<CodeSnippet source={resultApiFilesResultDownloadFileV1} language="text" />
|
||||
|
||||
</details>
|
||||
|
||||
### Delete file (v1)
|
||||
|
||||
Delete a specific file from a flow.
|
||||
|
||||
<Tabs>
|
||||
<TabItem value="Python" label="Python" default>
|
||||
|
||||
<CodeSnippet source={examplePythonApiFilesDeleteFileV1} language="python" />
|
||||
|
||||
</TabItem>
|
||||
<TabItem value="JavaScript" label="JavaScript">
|
||||
|
||||
<CodeSnippet source={exampleJavascriptApiFilesDeleteFileV1} language="javascript" />
|
||||
|
||||
</TabItem>
|
||||
<TabItem value="curl" label="curl">
|
||||
|
||||
<CodeSnippet source={exampleApiFilesDeleteFileV1} language="bash" />
|
||||
|
||||
</TabItem>
|
||||
</Tabs>
|
||||
|
||||
<details>
|
||||
<summary>Result</summary>
|
||||
|
||||
<CodeSnippet source={resultApiFilesResultDeleteFileV1} language="json" />
|
||||
|
||||
</details>
|
||||
|
||||
## Files/V2 endpoints
|
||||
|
||||
Use the `/files` endpoints to move files between your local machine and Langflow.
|
||||
|
||||
The `/v2/files` endpoints can be authenticated by an API key or JWT.
|
||||
To create a Langflow API key and export it as an environment variable, see [Get started with the Langflow API](/api-reference-api-examples).
|
||||
|
||||
### Upload file (v2)
|
||||
|
||||
Upload a file to your user account. The file can be used across multiple flows.
|
||||
|
||||
The file is uploaded in the format `USER_ID/FILE_ID.FILE_EXTENSION`, such as `07e5b864-e367-4f52-b647-a48035ae7e5e/d44dc2e1-9ae9-4cf6-9114-8d34a6126c94.pdf`.
|
||||
|
||||
1. To retrieve your current `user_id`, call the `/whoami` endpoint:
|
||||
|
||||
<Tabs>
|
||||
<TabItem value="Python" label="Python" default>
|
||||
|
||||
<CodeSnippet source={examplePythonApiFilesUploadFileV2} language="python" />
|
||||
|
||||
</TabItem>
|
||||
<TabItem value="JavaScript" label="JavaScript">
|
||||
|
||||
<CodeSnippet source={exampleJavascriptApiFilesUploadFileV2} language="javascript" />
|
||||
|
||||
</TabItem>
|
||||
<TabItem value="curl" label="curl">
|
||||
|
||||
<CodeSnippet source={exampleApiFilesUploadFileV2} language="bash" />
|
||||
|
||||
</TabItem>
|
||||
</Tabs>
|
||||
|
||||
<details>
|
||||
<summary>Result</summary>
|
||||
|
||||
<CodeSnippet source={resultApiFilesResultUploadFileV2} language="text" />
|
||||
|
||||
</details>
|
||||
|
||||
2. In the POST request to `v2/files`, replace **@FILE_NAME.EXTENSION** with the uploaded file name and its extension.
|
||||
You must include the ampersand (`@`) in the request to instruct curl to upload the contents of the file, not the string `FILE_NAME.EXTENSION`.
|
||||
|
||||
<Tabs>
|
||||
<TabItem value="Python" label="Python" default>
|
||||
|
||||
<CodeSnippet source={examplePythonApiFilesUploadFileV22} language="python" />
|
||||
|
||||
</TabItem>
|
||||
<TabItem value="JavaScript" label="JavaScript">
|
||||
|
||||
<CodeSnippet source={exampleJavascriptApiFilesUploadFileV22} language="javascript" />
|
||||
|
||||
</TabItem>
|
||||
<TabItem value="curl" label="curl">
|
||||
|
||||
<CodeSnippet source={exampleApiFilesUploadFileV22} language="bash" />
|
||||
|
||||
</TabItem>
|
||||
</Tabs>
|
||||
|
||||
The file is uploaded in the format `USER_ID/FILE_ID.FILE_EXTENSION`, and the API returns metadata about the uploaded file:
|
||||
|
||||
```json
|
||||
{
|
||||
"id":"d44dc2e1-9ae9-4cf6-9114-8d34a6126c94",
|
||||
"name":"engine_manual",
|
||||
"path":"07e5b864-e367-4f52-b647-a48035ae7e5e/d44dc2e1-9ae9-4cf6-9114-8d34a6126c94.pdf",
|
||||
"size":851160,
|
||||
"provider":null
|
||||
}
|
||||
```
|
||||
|
||||
### Send files to your flows (v2)
|
||||
|
||||
:::info
|
||||
The `/v2/files` endpoint can't send image files to flows.
|
||||
To send image files to your flows through the API, see [Upload image files (v1)](#upload-image-files-v1).
|
||||
:::
|
||||
|
||||
This endpoint uploads files to your Langflow server's file management system.
|
||||
To use an uploaded file in a flow, send the file path to a flow with a [**Read File** component](/read-file).
|
||||
|
||||
The default file limit is 1024 MB. To configure this value, change the `LANGFLOW_MAX_FILE_SIZE_UPLOAD` [environment variable](/environment-variables).
|
||||
|
||||
1. To send a file to your flow with the API, POST the file to the `/api/v2/files` endpoint.
|
||||
|
||||
Replace **FILE_NAME.EXTENSION** with the name and extension of the file you want to upload.
|
||||
This is the same step described in [Upload file (v2)](#upload-file-v2), but since you need the filename to upload to your flow, it is included here.
|
||||
|
||||
<Tabs>
|
||||
<TabItem value="Python" label="Python" default>
|
||||
|
||||
<CodeSnippet source={examplePythonApiFilesSendFilesToYourFlowsV2} language="python" />
|
||||
|
||||
</TabItem>
|
||||
<TabItem value="JavaScript" label="JavaScript">
|
||||
|
||||
<CodeSnippet source={exampleJavascriptApiFilesSendFilesToYourFlowsV2} language="javascript" />
|
||||
|
||||
</TabItem>
|
||||
<TabItem value="curl" label="curl">
|
||||
|
||||
<CodeSnippet source={exampleApiFilesSendFilesToYourFlowsV2} language="bash" />
|
||||
|
||||
</TabItem>
|
||||
</Tabs>
|
||||
|
||||
The file is uploaded in the format `USER_ID/FILE_ID.FILE_EXTENSION`, and the API returns metadata about the uploaded file:
|
||||
|
||||
```json
|
||||
{
|
||||
"id":"d44dc2e1-9ae9-4cf6-9114-8d34a6126c94",
|
||||
"name":"engine_manual",
|
||||
"path":"07e5b864-e367-4f52-b647-a48035ae7e5e/d44dc2e1-9ae9-4cf6-9114-8d34a6126c94.pdf",
|
||||
"size":851160,
|
||||
"provider": null
|
||||
}
|
||||
```
|
||||
|
||||
2. To use this file in your flow, add a **Read File** component to your flow.
|
||||
This component loads files into flows from your local machine or Langflow file management.
|
||||
|
||||
3. Run the flow, passing the `path` to the `Read-File` component in the `tweaks` object:
|
||||
|
||||
<Tabs>
|
||||
<TabItem value="Python" label="Python" default>
|
||||
|
||||
<CodeSnippet source={examplePythonApiFilesSendFilesToYourFlowsV22} language="python" />
|
||||
|
||||
</TabItem>
|
||||
<TabItem value="JavaScript" label="JavaScript">
|
||||
|
||||
<CodeSnippet source={exampleJavascriptApiFilesSendFilesToYourFlowsV22} language="javascript" />
|
||||
|
||||
</TabItem>
|
||||
<TabItem value="curl" label="curl">
|
||||
|
||||
<CodeSnippet source={exampleApiFilesSendFilesToYourFlowsV22} language="bash" />
|
||||
|
||||
</TabItem>
|
||||
</Tabs>
|
||||
|
||||
To get the `Read-File` component's ID, call the [Read flow](/api-flows#read-flow) endpoint or inspect the component in the visual editor.
|
||||
|
||||
If the file path is valid, the flow runs successfully.
|
||||
|
||||
### List files (v2)
|
||||
|
||||
List all files associated with your user account.
|
||||
|
||||
<Tabs>
|
||||
<TabItem value="Python" label="Python" default>
|
||||
|
||||
<CodeSnippet source={examplePythonApiFilesListFilesV2} language="python" />
|
||||
|
||||
</TabItem>
|
||||
<TabItem value="JavaScript" label="JavaScript">
|
||||
|
||||
<CodeSnippet source={exampleJavascriptApiFilesListFilesV2} language="javascript" />
|
||||
|
||||
</TabItem>
|
||||
<TabItem value="curl" label="curl">
|
||||
|
||||
<CodeSnippet source={exampleApiFilesListFilesV2} language="bash" />
|
||||
|
||||
</TabItem>
|
||||
</Tabs>
|
||||
|
||||
<details>
|
||||
<summary>Result</summary>
|
||||
|
||||
<CodeSnippet source={resultApiFilesResultListFilesV2} language="json" />
|
||||
|
||||
</details>
|
||||
|
||||
### Download file (v2)
|
||||
|
||||
Download a specific file by its ID and file extension.
|
||||
|
||||
You must specify the file type you expect in the `--output` value.
|
||||
|
||||
<Tabs>
|
||||
<TabItem value="Python" label="Python" default>
|
||||
|
||||
<CodeSnippet source={examplePythonApiFilesDownloadFileV2} language="python" />
|
||||
|
||||
</TabItem>
|
||||
<TabItem value="JavaScript" label="JavaScript">
|
||||
|
||||
<CodeSnippet source={exampleJavascriptApiFilesDownloadFileV2} language="javascript" />
|
||||
|
||||
</TabItem>
|
||||
<TabItem value="curl" label="curl">
|
||||
|
||||
<CodeSnippet source={exampleApiFilesDownloadFileV2} language="bash" />
|
||||
|
||||
</TabItem>
|
||||
</Tabs>
|
||||
|
||||
<details>
|
||||
<summary>Result</summary>
|
||||
|
||||
<CodeSnippet source={resultApiFilesResultDownloadFileV2} language="text" />
|
||||
|
||||
</details>
|
||||
|
||||
### Edit file name (v2)
|
||||
|
||||
Change a file name.
|
||||
|
||||
<Tabs>
|
||||
<TabItem value="Python" label="Python" default>
|
||||
|
||||
<CodeSnippet source={examplePythonApiFilesEditFileNameV2} language="python" />
|
||||
|
||||
</TabItem>
|
||||
<TabItem value="JavaScript" label="JavaScript">
|
||||
|
||||
<CodeSnippet source={exampleJavascriptApiFilesEditFileNameV2} language="javascript" />
|
||||
|
||||
</TabItem>
|
||||
<TabItem value="curl" label="curl">
|
||||
|
||||
<CodeSnippet source={exampleApiFilesEditFileNameV2} language="bash" />
|
||||
|
||||
</TabItem>
|
||||
</Tabs>
|
||||
|
||||
<details>
|
||||
<summary>Result</summary>
|
||||
|
||||
<CodeSnippet source={resultApiFilesResultEditFileNameV2} language="json" />
|
||||
|
||||
</details>
|
||||
|
||||
### Delete file (v2)
|
||||
|
||||
Delete a specific file by its ID.
|
||||
|
||||
<Tabs>
|
||||
<TabItem value="Python" label="Python" default>
|
||||
|
||||
<CodeSnippet source={examplePythonApiFilesDeleteFileV2} language="python" />
|
||||
|
||||
</TabItem>
|
||||
<TabItem value="JavaScript" label="JavaScript">
|
||||
|
||||
<CodeSnippet source={exampleJavascriptApiFilesDeleteFileV2} language="javascript" />
|
||||
|
||||
</TabItem>
|
||||
<TabItem value="curl" label="curl">
|
||||
|
||||
<CodeSnippet source={exampleApiFilesDeleteFileV2} language="bash" />
|
||||
|
||||
</TabItem>
|
||||
</Tabs>
|
||||
|
||||
<details>
|
||||
<summary>Result</summary>
|
||||
|
||||
<CodeSnippet source={resultApiFilesResultDeleteFileV2} language="json" />
|
||||
|
||||
</details>
|
||||
|
||||
### Delete all files (v2)
|
||||
|
||||
Delete all files associated with your user account.
|
||||
|
||||
<Tabs>
|
||||
<TabItem value="Python" label="Python" default>
|
||||
|
||||
<CodeSnippet source={examplePythonApiFilesDeleteAllFilesV2} language="python" />
|
||||
|
||||
</TabItem>
|
||||
<TabItem value="JavaScript" label="JavaScript">
|
||||
|
||||
<CodeSnippet source={exampleJavascriptApiFilesDeleteAllFilesV2} language="javascript" />
|
||||
|
||||
</TabItem>
|
||||
<TabItem value="curl" label="curl">
|
||||
|
||||
<CodeSnippet source={exampleApiFilesDeleteAllFilesV2} language="bash" />
|
||||
|
||||
</TabItem>
|
||||
</Tabs>
|
||||
|
||||
<details>
|
||||
<summary>Result</summary>
|
||||
|
||||
<CodeSnippet source={resultApiFilesResultDeleteAllFilesV2} language="json" />
|
||||
|
||||
</details>
|
||||
|
||||
## Create upload file (Deprecated)
|
||||
|
||||
This endpoint is deprecated. Use the `/files` endpoints instead.
|
||||
|
||||
## See also
|
||||
|
||||
* [Manage files](/concepts-file-management)
|
||||
@ -0,0 +1,274 @@
|
||||
---
|
||||
title: Flow trigger endpoints
|
||||
slug: /api-flows-run
|
||||
---
|
||||
import CodeSnippet from '@site/src/components/CodeSnippet';
|
||||
import exampleApiFlowsRunRunFlow from '!!raw-loader!@site/docs/API-Reference/curl-examples/api-flows-run/run-flow.sh';
|
||||
import exampleApiFlowsRunStreamLlmTokenResponses from '!!raw-loader!@site/docs/API-Reference/curl-examples/api-flows-run/stream-llm-token-responses.sh';
|
||||
import exampleApiFlowsRunRequestExampleWithAllHeadersAndParameters from '!!raw-loader!@site/docs/API-Reference/curl-examples/api-flows-run/request-example-with-all-headers-and-parameters.sh';
|
||||
import exampleApiFlowsRunPassGlobalVariablesInRequestHeaders from '!!raw-loader!@site/docs/API-Reference/curl-examples/api-flows-run/pass-global-variables-in-request-headers.sh';
|
||||
import exampleApiFlowsRunWebhookRunFlow from '!!raw-loader!@site/docs/API-Reference/curl-examples/api-flows-run/webhook-run-flow.sh';
|
||||
import resultApiFlowsRunResultWebhookRunFlow from '!!raw-loader!@site/docs/API-Reference/curl-examples/api-flows-run/result-webhook-run-flow.json';
|
||||
import examplePythonApiFlowsRunRunFlow from '!!raw-loader!@site/docs/API-Reference/python-examples/api-flows-run/run-flow.py';
|
||||
import exampleJavascriptApiFlowsRunRunFlow from '!!raw-loader!@site/docs/API-Reference/javascript-examples/api-flows-run/run-flow.js';
|
||||
import examplePythonApiFlowsRunStreamLlmTokenResponses from '!!raw-loader!@site/docs/API-Reference/python-examples/api-flows-run/stream-llm-token-responses.py';
|
||||
import exampleJavascriptApiFlowsRunStreamLlmTokenResponses from '!!raw-loader!@site/docs/API-Reference/javascript-examples/api-flows-run/stream-llm-token-responses.js';
|
||||
import examplePythonApiFlowsRunRequestExampleWithAllHeadersAndParameters from '!!raw-loader!@site/docs/API-Reference/python-examples/api-flows-run/request-example-with-all-headers-and-parameters.py';
|
||||
import exampleJavascriptApiFlowsRunRequestExampleWithAllHeadersAndParameters from '!!raw-loader!@site/docs/API-Reference/javascript-examples/api-flows-run/request-example-with-all-headers-and-parameters.js';
|
||||
import examplePythonApiFlowsRunPassGlobalVariablesInRequestHeaders from '!!raw-loader!@site/docs/API-Reference/python-examples/api-flows-run/pass-global-variables-in-request-headers.py';
|
||||
import exampleJavascriptApiFlowsRunPassGlobalVariablesInRequestHeaders from '!!raw-loader!@site/docs/API-Reference/javascript-examples/api-flows-run/pass-global-variables-in-request-headers.js';
|
||||
import examplePythonApiFlowsRunWebhookRunFlow from '!!raw-loader!@site/docs/API-Reference/python-examples/api-flows-run/webhook-run-flow.py';
|
||||
import exampleJavascriptApiFlowsRunWebhookRunFlow from '!!raw-loader!@site/docs/API-Reference/javascript-examples/api-flows-run/webhook-run-flow.js';
|
||||
|
||||
|
||||
|
||||
|
||||
import Tabs from '@theme/Tabs';
|
||||
import TabItem from '@theme/TabItem';
|
||||
|
||||
Use the `/run` and `/webhook` endpoints to run flows.
|
||||
|
||||
To create, read, update, and delete flows, see [Flow management endpoints](/api-flows).
|
||||
|
||||
## Run flow
|
||||
|
||||
:::tip
|
||||
Langflow automatically generates Python, JavaScript, and curl code snippets for the `/v1/run/$FLOW_ID` endpoint for all flows.
|
||||
For more information, see [Generate API code snippets](/concepts-publish#generate-api-code-snippets).
|
||||
:::
|
||||
|
||||
Execute a specified flow by ID or name.
|
||||
Flow IDs can be found on the code snippets on the [**API access** pane](/concepts-publish#api-access) or in a flow's URL.
|
||||
|
||||
The following example runs the **Basic Prompting** template flow with flow parameters passed in the request body.
|
||||
This flow requires a chat input string (`input_value`), and uses default values for all other parameters.
|
||||
|
||||
<Tabs>
|
||||
<TabItem value="Python" label="Python" default>
|
||||
|
||||
<CodeSnippet source={examplePythonApiFlowsRunRunFlow} language="python" />
|
||||
|
||||
</TabItem>
|
||||
<TabItem value="JavaScript" label="JavaScript">
|
||||
|
||||
<CodeSnippet source={exampleJavascriptApiFlowsRunRunFlow} language="javascript" />
|
||||
|
||||
</TabItem>
|
||||
<TabItem value="curl" label="curl">
|
||||
|
||||
<CodeSnippet source={exampleApiFlowsRunRunFlow} language="bash" />
|
||||
|
||||
</TabItem>
|
||||
</Tabs>
|
||||
|
||||
The response from `/v1/run/$FLOW_ID` includes metadata, inputs, and outputs for the run.
|
||||
|
||||
<details>
|
||||
<summary>Result</summary>
|
||||
|
||||
The following example illustrates a response from a Basic Prompting flow:
|
||||
|
||||
```json
|
||||
{
|
||||
"session_id": "chat-123",
|
||||
"outputs": [{
|
||||
"inputs": {
|
||||
"input_value": "Tell me about something interesting!"
|
||||
},
|
||||
"outputs": [{
|
||||
"results": {
|
||||
"message": {
|
||||
"text": "Sure! Have you ever heard of the phenomenon known as \"bioluminescence\"? It's a fascinating natural occurrence where living organisms produce and emit light. This ability is found in various species, including certain types of jellyfish, fireflies, and deep-sea creatures like anglerfish.\n\nBioluminescence occurs through a chemical reaction in which a light-emitting molecule called luciferin reacts with oxygen, catalyzed by an enzyme called luciferase. The result is a beautiful glow that can serve various purposes, such as attracting mates, deterring predators, or luring prey.\n\nOne of the most stunning displays of bioluminescence can be seen in the ocean, where certain plankton emit light when disturbed, creating a mesmerizing blue glow in the water. This phenomenon is often referred to as \"sea sparkle\" and can be seen in coastal areas around the world.\n\nBioluminescence not only captivates our imagination but also has practical applications in science and medicine, including the development of biosensors and imaging techniques. It's a remarkable example of nature's creativity and complexity!",
|
||||
"sender": "Machine",
|
||||
"sender_name": "AI",
|
||||
"session_id": "chat-123",
|
||||
"timestamp": "2025-03-03T17:17:37+00:00",
|
||||
"flow_id": "d2bbd92b-187e-4c84-b2d4-5df365704201",
|
||||
"properties": {
|
||||
"source": {
|
||||
"id": "OpenAIModel-d1wOZ",
|
||||
"display_name": "OpenAI",
|
||||
"source": "gpt-4o-mini"
|
||||
},
|
||||
"icon": "OpenAI"
|
||||
},
|
||||
"component_id": "ChatOutput-ylMzN"
|
||||
}
|
||||
}
|
||||
}]
|
||||
}]
|
||||
}
|
||||
```
|
||||
</details>
|
||||
|
||||
If you are parsing the response in an application, you most likely need to extract the relevant content from the response, rather than pass the entire response back to the user.
|
||||
For an example of a script that extracts data from a Langflow API response, see the [Quickstart](/get-started-quickstart).
|
||||
|
||||
### Stream LLM token responses
|
||||
|
||||
With `/v1/run/$FLOW_ID`, the flow is executed as a batch with optional LLM token response streaming.
|
||||
|
||||
To stream LLM token responses, append the `?stream=true` query parameter to the request:
|
||||
|
||||
<Tabs>
|
||||
<TabItem value="Python" label="Python" default>
|
||||
|
||||
<CodeSnippet source={examplePythonApiFlowsRunStreamLlmTokenResponses} language="python" />
|
||||
|
||||
</TabItem>
|
||||
<TabItem value="JavaScript" label="JavaScript">
|
||||
|
||||
<CodeSnippet source={exampleJavascriptApiFlowsRunStreamLlmTokenResponses} language="javascript" />
|
||||
|
||||
</TabItem>
|
||||
<TabItem value="curl" label="curl">
|
||||
|
||||
<CodeSnippet source={exampleApiFlowsRunStreamLlmTokenResponses} language="bash" />
|
||||
|
||||
</TabItem>
|
||||
</Tabs>
|
||||
|
||||
LLM chat responses are streamed back as `token` events, culminating in a final `end` event that closes the connection.
|
||||
|
||||
<details>
|
||||
<summary>Result</summary>
|
||||
|
||||
The following example is truncated to illustrate a series of `token` events as well as the final `end` event that closes the LLM's token streaming response:
|
||||
|
||||
```text
|
||||
{"event": "add_message", "data": {"timestamp": "2025-03-03T17:20:18", "sender": "User", "sender_name": "User", "session_id": "chat-123", "text": "Tell me about something interesting!", "files": [], "error": false, "edit": false, "properties": {"text_color": "", "background_color": "", "edited": false, "source": {"id": null, "display_name": null, "source": null}, "icon": "", "allow_markdown": false, "positive_feedback": null, "state": "complete", "targets": []}, "category": "message", "content_blocks": [], "id": "0103a21b-ebf7-4c02-9d72-017fb297f812", "flow_id": "d2bbd92b-187e-4c84-b2d4-5df365704201"}}
|
||||
|
||||
{"event": "add_message", "data": {"timestamp": "2025-03-03T17:20:18", "sender": "Machine", "sender_name": "AI", "session_id": "chat-123", "text": "", "files": [], "error": false, "edit": false, "properties": {"text_color": "", "background_color": "", "edited": false, "source": {"id": "OpenAIModel-d1wOZ", "display_name": "OpenAI", "source": "gpt-4o-mini"}, "icon": "OpenAI", "allow_markdown": false, "positive_feedback": null, "state": "complete", "targets": []}, "category": "message", "content_blocks": [], "id": "27b66789-e673-4c65-9e81-021752925161", "flow_id": "d2bbd92b-187e-4c84-b2d4-5df365704201"}}
|
||||
|
||||
{"event": "token", "data": {"chunk": " Have", "id": "27b66789-e673-4c65-9e81-021752925161", "timestamp": "2025-03-03 17:20:18 UTC"}}
|
||||
|
||||
{"event": "token", "data": {"chunk": " you", "id": "27b66789-e673-4c65-9e81-021752925161", "timestamp": "2025-03-03 17:20:18 UTC"}}
|
||||
|
||||
{"event": "token", "data": {"chunk": " ever", "id": "27b66789-e673-4c65-9e81-021752925161", "timestamp": "2025-03-03 17:20:18 UTC"}}
|
||||
|
||||
{"event": "token", "data": {"chunk": " heard", "id": "27b66789-e673-4c65-9e81-021752925161", "timestamp": "2025-03-03 17:20:18 UTC"}}
|
||||
|
||||
{"event": "token", "data": {"chunk": " of", "id": "27b66789-e673-4c65-9e81-021752925161", "timestamp": "2025-03-03 17:20:18 UTC"}}
|
||||
|
||||
{"event": "token", "data": {"chunk": " the", "id": "27b66789-e673-4c65-9e81-021752925161", "timestamp": "2025-03-03 17:20:18 UTC"}}
|
||||
|
||||
{"event": "token", "data": {"chunk": " phenomenon", "id": "27b66789-e673-4c65-9e81-021752925161", "timestamp": "2025-03-03 17:20:18 UTC"}}
|
||||
|
||||
{"event": "end", "data": {"result": {"session_id": "chat-123", "message": "Sure! Have you ever heard of the phenomenon known as \"bioluminescence\"?..."}}}
|
||||
```
|
||||
|
||||
</details>
|
||||
|
||||
### Run endpoint headers
|
||||
|
||||
| Header | Info | Example |
|
||||
|--------|------|---------|
|
||||
| Content-Type | Required. Specifies the JSON format. | "application/json" |
|
||||
| accept | Optional. Specifies the response format. Defaults to JSON if not specified. | "application/json" |
|
||||
| x-api-key | Required. Your Langflow API key for authentication. Can be passed as a header or query parameter. | "sk-..." |
|
||||
| `X-LANGFLOW-GLOBAL-VAR-*` | Optional. Pass global variables to the flow. Variable names are automatically converted to uppercase. These variables take precedence over OS environment variables and are only available during this specific request execution. | `"X-LANGFLOW-GLOBAL-VAR-API_KEY: sk-..."` |
|
||||
|
||||
### Run endpoint parameters
|
||||
|
||||
| Parameter | Type | Info |
|
||||
|-----------|------|------|
|
||||
| flow_id | UUID/string | Required. Part of URL: `/run/$FLOW_ID` |
|
||||
| stream | Boolean | Optional. Query parameter: `/run/$FLOW_ID?stream=true` |
|
||||
| input_value | string | Optional. JSON body field. Main input text/prompt. Default: `null` |
|
||||
| input_type | string | Optional. JSON body field. Input type ("chat" or "text"). Default: `"chat"` |
|
||||
| output_type | string | Optional. JSON body field. Output type ("chat", "any", "debug"). Default: `"chat"` |
|
||||
| output_component | string | Optional. JSON body field. Target component for output. Default: `""` |
|
||||
| tweaks | object | Optional. JSON body field. Component adjustments. Default: `null` |
|
||||
| session_id | string | Optional. JSON body field. Conversation context ID. See [Session ID](/session-id). Default: `null` |
|
||||
|
||||
### Request example with all headers and parameters
|
||||
|
||||
<Tabs>
|
||||
<TabItem value="Python" label="Python" default>
|
||||
|
||||
<CodeSnippet source={examplePythonApiFlowsRunRequestExampleWithAllHeadersAndParameters} language="python" />
|
||||
|
||||
</TabItem>
|
||||
<TabItem value="JavaScript" label="JavaScript">
|
||||
|
||||
<CodeSnippet source={exampleJavascriptApiFlowsRunRequestExampleWithAllHeadersAndParameters} language="javascript" />
|
||||
|
||||
</TabItem>
|
||||
<TabItem value="curl" label="curl">
|
||||
|
||||
<CodeSnippet source={exampleApiFlowsRunRequestExampleWithAllHeadersAndParameters} language="bash" />
|
||||
|
||||
</TabItem>
|
||||
</Tabs>
|
||||
|
||||
### Pass global variables in request headers {#pass-global-variables-in-headers}
|
||||
|
||||
You can pass global variables to your flow using HTTP headers with the format `X-LANGFLOW-GLOBAL-VAR-{VARIABLE_NAME}`.
|
||||
|
||||
Variables passed in headers take precedence over OS environment variables. If a variable is provided in both a header and an environment variable, the header value is used. Variables are only available during this specific request execution and aren't persisted.
|
||||
|
||||
Variable names are automatically converted to uppercase. For example, `X-LANGFLOW-GLOBAL-VAR-api-key` becomes `API_KEY` in your flow.
|
||||
|
||||
You don't need to create these variables in Langflow's Global Variables section first. Pass any variable name using this header format.
|
||||
|
||||
<Tabs>
|
||||
<TabItem value="Python" label="Python" default>
|
||||
|
||||
<CodeSnippet source={examplePythonApiFlowsRunPassGlobalVariablesInRequestHeaders} language="python" />
|
||||
|
||||
</TabItem>
|
||||
<TabItem value="JavaScript" label="JavaScript">
|
||||
|
||||
<CodeSnippet source={exampleJavascriptApiFlowsRunPassGlobalVariablesInRequestHeaders} language="javascript" />
|
||||
|
||||
</TabItem>
|
||||
<TabItem value="curl" label="curl">
|
||||
|
||||
<CodeSnippet source={exampleApiFlowsRunPassGlobalVariablesInRequestHeaders} language="bash" />
|
||||
|
||||
</TabItem>
|
||||
</Tabs>
|
||||
|
||||
If your flow components reference variables that aren't provided in headers or your Langflow database, the flow fails by default. To avoid this, you can set `LANGFLOW_FALLBACK_TO_ENV_VAR=True` in your `.env` file, which allows the flow to use values from OS environment variables if they aren't otherwise specified.
|
||||
|
||||
|
||||
## Webhook run flow
|
||||
|
||||
Use the `/webhook` endpoint to start a flow by sending an HTTP `POST` request.
|
||||
|
||||
:::tip
|
||||
After you add a [**Webhook** component](/webhook) to a flow, open the [**API access** pane](/concepts-publish), and then click the **Webhook curl** tab to get an automatically generated `POST /webhook` request for your flow.
|
||||
For more information, see [Trigger flows with webhooks](/webhook).
|
||||
:::
|
||||
|
||||
<Tabs>
|
||||
<TabItem value="Python" label="Python" default>
|
||||
|
||||
<CodeSnippet source={examplePythonApiFlowsRunWebhookRunFlow} language="python" />
|
||||
|
||||
</TabItem>
|
||||
<TabItem value="JavaScript" label="JavaScript">
|
||||
|
||||
<CodeSnippet source={exampleJavascriptApiFlowsRunWebhookRunFlow} language="javascript" />
|
||||
|
||||
</TabItem>
|
||||
<TabItem value="curl" label="curl">
|
||||
|
||||
<CodeSnippet source={exampleApiFlowsRunWebhookRunFlow} language="bash" />
|
||||
|
||||
</TabItem>
|
||||
</Tabs>
|
||||
|
||||
<details>
|
||||
<summary>Result</summary>
|
||||
|
||||
<CodeSnippet source={resultApiFlowsRunResultWebhookRunFlow} language="json" />
|
||||
|
||||
</details>
|
||||
|
||||
## Deprecated flow trigger endpoints
|
||||
|
||||
The following endpoints are deprecated and replaced by the `/run` endpoint:
|
||||
|
||||
* `/process`
|
||||
* `/predict`
|
||||
330
docs/versioned_docs/version-1.9.0/API-Reference/api-flows.mdx
Normal file
330
docs/versioned_docs/version-1.9.0/API-Reference/api-flows.mdx
Normal file
@ -0,0 +1,330 @@
|
||||
---
|
||||
title: Flow management endpoints
|
||||
slug: /api-flows
|
||||
---
|
||||
import CodeSnippet from '@site/src/components/CodeSnippet';
|
||||
import exampleApiFlowsCreateFlow from '!!raw-loader!@site/docs/API-Reference/curl-examples/api-flows/create-flow.sh';
|
||||
import resultApiFlowsResultCreateFlow from '!!raw-loader!@site/docs/API-Reference/curl-examples/api-flows/result-create-flow.json';
|
||||
import exampleApiFlowsCreateFlows from '!!raw-loader!@site/docs/API-Reference/curl-examples/api-flows/create-flows.sh';
|
||||
import exampleApiFlowsReadFlow from '!!raw-loader!@site/docs/API-Reference/curl-examples/api-flows/read-flow.sh';
|
||||
import resultApiFlowsResultReadFlow from '!!raw-loader!@site/docs/API-Reference/curl-examples/api-flows/result-read-flow.json';
|
||||
import exampleApiFlowsReadFlows from '!!raw-loader!@site/docs/API-Reference/curl-examples/api-flows/read-flows.sh';
|
||||
import exampleApiFlowsReadFlows2 from '!!raw-loader!@site/docs/API-Reference/curl-examples/api-flows/read-flows-2.sh';
|
||||
import exampleApiFlowsReadSampleFlows from '!!raw-loader!@site/docs/API-Reference/curl-examples/api-flows/read-sample-flows.sh';
|
||||
import exampleApiFlowsUpdateFlow from '!!raw-loader!@site/docs/API-Reference/curl-examples/api-flows/update-flow.sh';
|
||||
import resultApiFlowsResultUpdateFlow from '!!raw-loader!@site/docs/API-Reference/curl-examples/api-flows/result-update-flow.json';
|
||||
import exampleApiFlowsDeleteFlow from '!!raw-loader!@site/docs/API-Reference/curl-examples/api-flows/delete-flow.sh';
|
||||
import resultApiFlowsResultDeleteFlow from '!!raw-loader!@site/docs/API-Reference/curl-examples/api-flows/result-delete-flow.json';
|
||||
import exampleApiFlowsExportFlows from '!!raw-loader!@site/docs/API-Reference/curl-examples/api-flows/export-flows.sh';
|
||||
import resultApiFlowsResultExportFlows from '!!raw-loader!@site/docs/API-Reference/curl-examples/api-flows/result-export-flows.txt';
|
||||
import exampleApiFlowsImportFlows from '!!raw-loader!@site/docs/API-Reference/curl-examples/api-flows/import-flows.sh';
|
||||
import Tabs from '@theme/Tabs';
|
||||
import TabItem from '@theme/TabItem';
|
||||
import examplePythonApiFlowsCreateFlow from '!!raw-loader!@site/docs/API-Reference/python-examples/api-flows/create-flow.py';
|
||||
import exampleJavascriptApiFlowsCreateFlow from '!!raw-loader!@site/docs/API-Reference/javascript-examples/api-flows/create-flow.js';
|
||||
import examplePythonApiFlowsCreateFlows from '!!raw-loader!@site/docs/API-Reference/python-examples/api-flows/create-flows.py';
|
||||
import exampleJavascriptApiFlowsCreateFlows from '!!raw-loader!@site/docs/API-Reference/javascript-examples/api-flows/create-flows.js';
|
||||
import examplePythonApiFlowsReadFlow from '!!raw-loader!@site/docs/API-Reference/python-examples/api-flows/read-flow.py';
|
||||
import exampleJavascriptApiFlowsReadFlow from '!!raw-loader!@site/docs/API-Reference/javascript-examples/api-flows/read-flow.js';
|
||||
import examplePythonApiFlowsReadFlows from '!!raw-loader!@site/docs/API-Reference/python-examples/api-flows/read-flows.py';
|
||||
import exampleJavascriptApiFlowsReadFlows from '!!raw-loader!@site/docs/API-Reference/javascript-examples/api-flows/read-flows.js';
|
||||
import examplePythonApiFlowsReadFlows2 from '!!raw-loader!@site/docs/API-Reference/python-examples/api-flows/read-flows-2.py';
|
||||
import exampleJavascriptApiFlowsReadFlows2 from '!!raw-loader!@site/docs/API-Reference/javascript-examples/api-flows/read-flows-2.js';
|
||||
import examplePythonApiFlowsReadSampleFlows from '!!raw-loader!@site/docs/API-Reference/python-examples/api-flows/read-sample-flows.py';
|
||||
import exampleJavascriptApiFlowsReadSampleFlows from '!!raw-loader!@site/docs/API-Reference/javascript-examples/api-flows/read-sample-flows.js';
|
||||
import examplePythonApiFlowsUpdateFlow from '!!raw-loader!@site/docs/API-Reference/python-examples/api-flows/update-flow.py';
|
||||
import exampleJavascriptApiFlowsUpdateFlow from '!!raw-loader!@site/docs/API-Reference/javascript-examples/api-flows/update-flow.js';
|
||||
import examplePythonApiFlowsDeleteFlow from '!!raw-loader!@site/docs/API-Reference/python-examples/api-flows/delete-flow.py';
|
||||
import exampleJavascriptApiFlowsDeleteFlow from '!!raw-loader!@site/docs/API-Reference/javascript-examples/api-flows/delete-flow.js';
|
||||
import examplePythonApiFlowsExportFlows from '!!raw-loader!@site/docs/API-Reference/python-examples/api-flows/export-flows.py';
|
||||
import exampleJavascriptApiFlowsExportFlows from '!!raw-loader!@site/docs/API-Reference/javascript-examples/api-flows/export-flows.js';
|
||||
import examplePythonApiFlowsImportFlows from '!!raw-loader!@site/docs/API-Reference/python-examples/api-flows/import-flows.py';
|
||||
import exampleJavascriptApiFlowsImportFlows from '!!raw-loader!@site/docs/API-Reference/javascript-examples/api-flows/import-flows.js';
|
||||
|
||||
|
||||
|
||||
Use the `/flows` endpoint to create, read, update, and delete flows.
|
||||
|
||||
If you want to use the Langflow API to run a flow, see [Flow trigger endpoints](/api-flows-run).
|
||||
|
||||
## Create flow
|
||||
|
||||
Creates a new flow.
|
||||
|
||||
<Tabs>
|
||||
<TabItem value="Python" label="Python" default>
|
||||
|
||||
<CodeSnippet source={examplePythonApiFlowsCreateFlow} language="python" />
|
||||
|
||||
</TabItem>
|
||||
<TabItem value="JavaScript" label="JavaScript">
|
||||
|
||||
<CodeSnippet source={exampleJavascriptApiFlowsCreateFlow} language="javascript" />
|
||||
|
||||
</TabItem>
|
||||
<TabItem value="curl" label="curl">
|
||||
|
||||
<CodeSnippet source={exampleApiFlowsCreateFlow} language="bash" />
|
||||
|
||||
</TabItem>
|
||||
</Tabs>
|
||||
|
||||
<details>
|
||||
<summary>Result</summary>
|
||||
|
||||
<CodeSnippet source={resultApiFlowsResultCreateFlow} language="json" />
|
||||
|
||||
</details>
|
||||
|
||||
## Create flows
|
||||
|
||||
Creates multiple new flows, returning an array of flow objects.
|
||||
|
||||
<Tabs>
|
||||
<TabItem value="Python" label="Python" default>
|
||||
|
||||
<CodeSnippet source={examplePythonApiFlowsCreateFlows} language="python" />
|
||||
|
||||
</TabItem>
|
||||
<TabItem value="JavaScript" label="JavaScript">
|
||||
|
||||
<CodeSnippet source={exampleJavascriptApiFlowsCreateFlows} language="javascript" />
|
||||
|
||||
</TabItem>
|
||||
<TabItem value="curl" label="curl">
|
||||
|
||||
<CodeSnippet source={exampleApiFlowsCreateFlows} language="bash" />
|
||||
|
||||
</TabItem>
|
||||
</Tabs>
|
||||
|
||||
## Read flow
|
||||
|
||||
Retrieves a specific flow by its ID.
|
||||
|
||||
<Tabs>
|
||||
<TabItem value="Python" label="Python" default>
|
||||
|
||||
<CodeSnippet source={examplePythonApiFlowsReadFlow} language="python" />
|
||||
|
||||
</TabItem>
|
||||
<TabItem value="JavaScript" label="JavaScript">
|
||||
|
||||
<CodeSnippet source={exampleJavascriptApiFlowsReadFlow} language="javascript" />
|
||||
|
||||
</TabItem>
|
||||
<TabItem value="curl" label="curl">
|
||||
|
||||
<CodeSnippet source={exampleApiFlowsReadFlow} language="bash" />
|
||||
|
||||
</TabItem>
|
||||
</Tabs>
|
||||
|
||||
<details>
|
||||
<summary>Result</summary>
|
||||
|
||||
<CodeSnippet source={resultApiFlowsResultReadFlow} language="json" />
|
||||
|
||||
</details>
|
||||
|
||||
## Read flows
|
||||
|
||||
Returns a JSON object containing a list of flows.
|
||||
|
||||
Retrieve all flows with pagination:
|
||||
|
||||
<Tabs>
|
||||
<TabItem value="Python" label="Python" default>
|
||||
|
||||
<CodeSnippet source={examplePythonApiFlowsReadFlows} language="python" />
|
||||
|
||||
</TabItem>
|
||||
<TabItem value="JavaScript" label="JavaScript">
|
||||
|
||||
<CodeSnippet source={exampleJavascriptApiFlowsReadFlows} language="javascript" />
|
||||
|
||||
</TabItem>
|
||||
<TabItem value="curl" label="curl">
|
||||
|
||||
<CodeSnippet source={exampleApiFlowsReadFlows} language="bash" />
|
||||
|
||||
</TabItem>
|
||||
</Tabs>
|
||||
|
||||
To retrieve flows from a specific project, use the `project_id` query parameter:
|
||||
|
||||
<Tabs>
|
||||
<TabItem value="Python" label="Python" default>
|
||||
|
||||
<CodeSnippet source={examplePythonApiFlowsReadFlows2} language="python" />
|
||||
|
||||
</TabItem>
|
||||
<TabItem value="JavaScript" label="JavaScript">
|
||||
|
||||
<CodeSnippet source={exampleJavascriptApiFlowsReadFlows2} language="javascript" />
|
||||
|
||||
</TabItem>
|
||||
<TabItem value="curl" label="curl">
|
||||
|
||||
<CodeSnippet source={exampleApiFlowsReadFlows2} language="bash" />
|
||||
|
||||
</TabItem>
|
||||
</Tabs>
|
||||
|
||||
## Read sample flows
|
||||
|
||||
Retrieves a list of sample flows:
|
||||
|
||||
<Tabs>
|
||||
<TabItem value="Python" label="Python" default>
|
||||
|
||||
<CodeSnippet source={examplePythonApiFlowsReadSampleFlows} language="python" />
|
||||
|
||||
</TabItem>
|
||||
<TabItem value="JavaScript" label="JavaScript">
|
||||
|
||||
<CodeSnippet source={exampleJavascriptApiFlowsReadSampleFlows} language="javascript" />
|
||||
|
||||
</TabItem>
|
||||
<TabItem value="curl" label="curl">
|
||||
|
||||
<CodeSnippet source={exampleApiFlowsReadSampleFlows} language="bash" />
|
||||
|
||||
</TabItem>
|
||||
</Tabs>
|
||||
|
||||
## Update flow
|
||||
|
||||
Updates an existing flow by its ID.
|
||||
|
||||
This example changes the value for `endpoint_name` from a random UUID to `my_new_endpoint_name`.
|
||||
|
||||
<Tabs>
|
||||
<TabItem value="Python" label="Python" default>
|
||||
|
||||
<CodeSnippet source={examplePythonApiFlowsUpdateFlow} language="python" />
|
||||
|
||||
</TabItem>
|
||||
<TabItem value="JavaScript" label="JavaScript">
|
||||
|
||||
<CodeSnippet source={exampleJavascriptApiFlowsUpdateFlow} language="javascript" />
|
||||
|
||||
</TabItem>
|
||||
<TabItem value="curl" label="curl">
|
||||
|
||||
<CodeSnippet source={exampleApiFlowsUpdateFlow} language="bash" />
|
||||
|
||||
</TabItem>
|
||||
</Tabs>
|
||||
|
||||
<details>
|
||||
<summary>Result</summary>
|
||||
|
||||
<CodeSnippet source={resultApiFlowsResultUpdateFlow} language="json" />
|
||||
|
||||
</details>
|
||||
|
||||
## Delete flow
|
||||
|
||||
Deletes a specific flow by its ID.
|
||||
|
||||
<Tabs>
|
||||
<TabItem value="Python" label="Python" default>
|
||||
|
||||
<CodeSnippet source={examplePythonApiFlowsDeleteFlow} language="python" />
|
||||
|
||||
</TabItem>
|
||||
<TabItem value="JavaScript" label="JavaScript">
|
||||
|
||||
<CodeSnippet source={exampleJavascriptApiFlowsDeleteFlow} language="javascript" />
|
||||
|
||||
</TabItem>
|
||||
<TabItem value="curl" label="curl">
|
||||
|
||||
<CodeSnippet source={exampleApiFlowsDeleteFlow} language="bash" />
|
||||
|
||||
</TabItem>
|
||||
</Tabs>
|
||||
|
||||
<details>
|
||||
<summary>Result</summary>
|
||||
|
||||
<CodeSnippet source={resultApiFlowsResultDeleteFlow} language="json" />
|
||||
|
||||
</details>
|
||||
|
||||
## Export flows
|
||||
|
||||
Exports specified flows to a ZIP file.
|
||||
|
||||
This endpoint downloads a ZIP file containing [Langflow JSON files](/concepts-flows-import#langflow-json-file-contents) for each flow ID listed in the request body.
|
||||
|
||||
<Tabs>
|
||||
<TabItem value="Python" label="Python" default>
|
||||
|
||||
<CodeSnippet source={examplePythonApiFlowsExportFlows} language="python" />
|
||||
|
||||
</TabItem>
|
||||
<TabItem value="JavaScript" label="JavaScript">
|
||||
|
||||
<CodeSnippet source={exampleJavascriptApiFlowsExportFlows} language="javascript" />
|
||||
|
||||
</TabItem>
|
||||
<TabItem value="curl" label="curl">
|
||||
|
||||
<CodeSnippet source={exampleApiFlowsExportFlows} language="bash" />
|
||||
|
||||
</TabItem>
|
||||
</Tabs>
|
||||
|
||||
<details>
|
||||
<summary>Result</summary>
|
||||
|
||||
<CodeSnippet source={resultApiFlowsResultExportFlows} language="text" />
|
||||
|
||||
</details>
|
||||
|
||||
## Import flows
|
||||
|
||||
Imports flows by uploading a [Langflow-compatible JSON file](/concepts-flows-import#langflow-json-file-contents).
|
||||
|
||||
To specify a target project for the flow, include the query parameter `folder_id`.
|
||||
The target `folder_id` must already exist before uploading a flow. Call the [/api/v1/projects/](/api-projects#read-projects) endpoint for a list of available folders and projects.
|
||||
|
||||
This example uploads a local file named `agent-with-astra-db-tool.json` to a folder specified by a `FOLDER_ID` variable:
|
||||
|
||||
<Tabs>
|
||||
<TabItem value="Python" label="Python" default>
|
||||
|
||||
<CodeSnippet source={examplePythonApiFlowsImportFlows} language="python" />
|
||||
|
||||
</TabItem>
|
||||
<TabItem value="JavaScript" label="JavaScript">
|
||||
|
||||
<CodeSnippet source={exampleJavascriptApiFlowsImportFlows} language="javascript" />
|
||||
|
||||
</TabItem>
|
||||
<TabItem value="curl" label="curl">
|
||||
|
||||
<CodeSnippet source={exampleApiFlowsImportFlows} language="bash" />
|
||||
|
||||
</TabItem>
|
||||
</Tabs>
|
||||
|
||||
<details>
|
||||
<summary>Result</summary>
|
||||
|
||||
```json
|
||||
[
|
||||
{
|
||||
"name": "agent-with-astra-db-tool",
|
||||
"description": "",
|
||||
"icon": null,
|
||||
"icon_bg_color": null,
|
||||
"gradient": null,
|
||||
"data": {}
|
||||
...
|
||||
}
|
||||
]
|
||||
```
|
||||
</details>
|
||||
96
docs/versioned_docs/version-1.9.0/API-Reference/api-logs.mdx
Normal file
96
docs/versioned_docs/version-1.9.0/API-Reference/api-logs.mdx
Normal file
@ -0,0 +1,96 @@
|
||||
---
|
||||
title: Logs endpoints
|
||||
slug: /api-logs
|
||||
---
|
||||
import CodeSnippet from '@site/src/components/CodeSnippet';
|
||||
import exampleApiLogsStreamLogs from '!!raw-loader!@site/docs/API-Reference/curl-examples/api-logs/stream-logs.sh';
|
||||
import resultApiLogsResultStreamLogs from '!!raw-loader!@site/docs/API-Reference/curl-examples/api-logs/result-stream-logs.txt';
|
||||
import exampleApiLogsRetrieveLogsWithOptionalParameters from '!!raw-loader!@site/docs/API-Reference/curl-examples/api-logs/retrieve-logs-with-optional-parameters.sh';
|
||||
import resultApiLogsResultRetrieveLogsWithOptionalParameters from '!!raw-loader!@site/docs/API-Reference/curl-examples/api-logs/result-retrieve-logs-with-optional-parameters.txt';
|
||||
import Tabs from '@theme/Tabs';
|
||||
import TabItem from '@theme/TabItem';
|
||||
import examplePythonApiLogsStreamLogs from '!!raw-loader!@site/docs/API-Reference/python-examples/api-logs/stream-logs.py';
|
||||
import exampleJavascriptApiLogsStreamLogs from '!!raw-loader!@site/docs/API-Reference/javascript-examples/api-logs/stream-logs.js';
|
||||
import examplePythonApiLogsRetrieveLogsWithOptionalParameters from '!!raw-loader!@site/docs/API-Reference/python-examples/api-logs/retrieve-logs-with-optional-parameters.py';
|
||||
import exampleJavascriptApiLogsRetrieveLogsWithOptionalParameters from '!!raw-loader!@site/docs/API-Reference/javascript-examples/api-logs/retrieve-logs-with-optional-parameters.js';
|
||||
|
||||
|
||||
|
||||
Retrieve logs for your Langflow flows and server.
|
||||
|
||||
## Enable log retrieval
|
||||
|
||||
The `/logs` endpoint requires log retrieval to be enabled in your Langflow instance.
|
||||
|
||||
To enable log retrieval, set the following [environment variables](/environment-variables) in your Langflow `.env` file, and then start Langflow with `uv run langflow run --env-file .env`:
|
||||
|
||||
```text
|
||||
LANGFLOW_ENABLE_LOG_RETRIEVAL=True
|
||||
LANGFLOW_LOG_RETRIEVER_BUFFER_SIZE=10000 // Must be greater than 0
|
||||
LANGFLOW_LOG_LEVEL=DEBUG // Can be DEBUG, ERROR, INFO, WARNING, or CRITICAL
|
||||
```
|
||||
|
||||
## Stream logs
|
||||
|
||||
Stream logs in real-time using Server Sent Events (SSE):
|
||||
|
||||
<Tabs>
|
||||
<TabItem value="Python" label="Python" default>
|
||||
|
||||
<CodeSnippet source={examplePythonApiLogsStreamLogs} language="python" />
|
||||
|
||||
</TabItem>
|
||||
<TabItem value="JavaScript" label="JavaScript">
|
||||
|
||||
<CodeSnippet source={exampleJavascriptApiLogsStreamLogs} language="javascript" />
|
||||
|
||||
</TabItem>
|
||||
<TabItem value="curl" label="curl">
|
||||
|
||||
<CodeSnippet source={exampleApiLogsStreamLogs} language="bash" />
|
||||
|
||||
</TabItem>
|
||||
</Tabs>
|
||||
|
||||
<details>
|
||||
<summary>Result</summary>
|
||||
|
||||
<CodeSnippet source={resultApiLogsResultStreamLogs} language="text" />
|
||||
|
||||
</details>
|
||||
|
||||
## Retrieve logs with optional parameters
|
||||
|
||||
Retrieve logs with optional query parameters:
|
||||
|
||||
- `lines_before`: The number of logs before the timestamp or the last log.
|
||||
- `lines_after`: The number of logs after the timestamp.
|
||||
- `timestamp`: The timestamp to start getting logs from.
|
||||
|
||||
The default values for all three parameters is `0`.
|
||||
With default values, the endpoint returns the last 10 lines of logs.
|
||||
|
||||
<Tabs>
|
||||
<TabItem value="Python" label="Python" default>
|
||||
|
||||
<CodeSnippet source={examplePythonApiLogsRetrieveLogsWithOptionalParameters} language="python" />
|
||||
|
||||
</TabItem>
|
||||
<TabItem value="JavaScript" label="JavaScript">
|
||||
|
||||
<CodeSnippet source={exampleJavascriptApiLogsRetrieveLogsWithOptionalParameters} language="javascript" />
|
||||
|
||||
</TabItem>
|
||||
<TabItem value="curl" label="curl">
|
||||
|
||||
<CodeSnippet source={exampleApiLogsRetrieveLogsWithOptionalParameters} language="bash" />
|
||||
|
||||
</TabItem>
|
||||
</Tabs>
|
||||
|
||||
<details>
|
||||
<summary>Result</summary>
|
||||
|
||||
<CodeSnippet source={resultApiLogsResultRetrieveLogsWithOptionalParameters} language="text" />
|
||||
|
||||
</details>
|
||||
429
docs/versioned_docs/version-1.9.0/API-Reference/api-monitor.mdx
Normal file
429
docs/versioned_docs/version-1.9.0/API-Reference/api-monitor.mdx
Normal file
@ -0,0 +1,429 @@
|
||||
---
|
||||
title: Monitor endpoints
|
||||
slug: /api-monitor
|
||||
---
|
||||
import CodeSnippet from '@site/src/components/CodeSnippet';
|
||||
import exampleApiMonitorGetVertexBuilds from '!!raw-loader!@site/docs/API-Reference/curl-examples/api-monitor/get-vertex-builds.sh';
|
||||
import resultApiMonitorResultGetVertexBuilds from '!!raw-loader!@site/docs/API-Reference/curl-examples/api-monitor/result-get-vertex-builds.json';
|
||||
import exampleApiMonitorDeleteVertexBuilds from '!!raw-loader!@site/docs/API-Reference/curl-examples/api-monitor/delete-vertex-builds.sh';
|
||||
import resultApiMonitorResultDeleteVertexBuilds from '!!raw-loader!@site/docs/API-Reference/curl-examples/api-monitor/result-delete-vertex-builds.txt';
|
||||
import exampleApiMonitorGetMessages from '!!raw-loader!@site/docs/API-Reference/curl-examples/api-monitor/get-messages.sh';
|
||||
import exampleApiMonitorGetMessages2 from '!!raw-loader!@site/docs/API-Reference/curl-examples/api-monitor/get-messages-2.sh';
|
||||
import resultApiMonitorResultGetMessages2 from '!!raw-loader!@site/docs/API-Reference/curl-examples/api-monitor/result-get-messages-2.json';
|
||||
import exampleApiMonitorDeleteMessages from '!!raw-loader!@site/docs/API-Reference/curl-examples/api-monitor/delete-messages.sh';
|
||||
import resultApiMonitorResultDeleteMessages from '!!raw-loader!@site/docs/API-Reference/curl-examples/api-monitor/result-delete-messages.txt';
|
||||
import exampleApiMonitorUpdateMessage from '!!raw-loader!@site/docs/API-Reference/curl-examples/api-monitor/update-message.sh';
|
||||
import resultApiMonitorResultUpdateMessage from '!!raw-loader!@site/docs/API-Reference/curl-examples/api-monitor/result-update-message.json';
|
||||
import exampleApiMonitorUpdateSessionId from '!!raw-loader!@site/docs/API-Reference/curl-examples/api-monitor/update-session-id.sh';
|
||||
import resultApiMonitorResultUpdateSessionId from '!!raw-loader!@site/docs/API-Reference/curl-examples/api-monitor/result-update-session-id.json';
|
||||
import exampleApiMonitorDeleteMessagesBySession from '!!raw-loader!@site/docs/API-Reference/curl-examples/api-monitor/delete-messages-by-session.sh';
|
||||
import resultApiMonitorResultDeleteMessagesBySession from '!!raw-loader!@site/docs/API-Reference/curl-examples/api-monitor/result-delete-messages-by-session.txt';
|
||||
import exampleApiMonitorExampleRequest from '!!raw-loader!@site/docs/API-Reference/curl-examples/api-monitor/example-request.sh';
|
||||
import exampleApiMonitorGetTransactions from '!!raw-loader!@site/docs/API-Reference/curl-examples/api-monitor/get-transactions.sh';
|
||||
import resultApiMonitorResultGetTransactions from '!!raw-loader!@site/docs/API-Reference/curl-examples/api-monitor/result-get-transactions.json';
|
||||
import examplePythonApiMonitorExampleRequest from '!!raw-loader!@site/docs/API-Reference/python-examples/api-monitor/example-request.py';
|
||||
import examplePythonApiMonitorGetVertexBuilds from '!!raw-loader!@site/docs/API-Reference/python-examples/api-monitor/get-vertex-builds.py';
|
||||
import exampleJavascriptApiMonitorGetVertexBuilds from '!!raw-loader!@site/docs/API-Reference/javascript-examples/api-monitor/get-vertex-builds.js';
|
||||
import examplePythonApiMonitorDeleteVertexBuilds from '!!raw-loader!@site/docs/API-Reference/python-examples/api-monitor/delete-vertex-builds.py';
|
||||
import exampleJavascriptApiMonitorDeleteVertexBuilds from '!!raw-loader!@site/docs/API-Reference/javascript-examples/api-monitor/delete-vertex-builds.js';
|
||||
import examplePythonApiMonitorGetMessages from '!!raw-loader!@site/docs/API-Reference/python-examples/api-monitor/get-messages.py';
|
||||
import exampleJavascriptApiMonitorGetMessages from '!!raw-loader!@site/docs/API-Reference/javascript-examples/api-monitor/get-messages.js';
|
||||
import examplePythonApiMonitorGetMessages2 from '!!raw-loader!@site/docs/API-Reference/python-examples/api-monitor/get-messages-2.py';
|
||||
import exampleJavascriptApiMonitorGetMessages2 from '!!raw-loader!@site/docs/API-Reference/javascript-examples/api-monitor/get-messages-2.js';
|
||||
import examplePythonApiMonitorDeleteMessages from '!!raw-loader!@site/docs/API-Reference/python-examples/api-monitor/delete-messages.py';
|
||||
import exampleJavascriptApiMonitorDeleteMessages from '!!raw-loader!@site/docs/API-Reference/javascript-examples/api-monitor/delete-messages.js';
|
||||
import examplePythonApiMonitorUpdateMessage from '!!raw-loader!@site/docs/API-Reference/python-examples/api-monitor/update-message.py';
|
||||
import exampleJavascriptApiMonitorUpdateMessage from '!!raw-loader!@site/docs/API-Reference/javascript-examples/api-monitor/update-message.js';
|
||||
import examplePythonApiMonitorUpdateSessionId from '!!raw-loader!@site/docs/API-Reference/python-examples/api-monitor/update-session-id.py';
|
||||
import exampleJavascriptApiMonitorUpdateSessionId from '!!raw-loader!@site/docs/API-Reference/javascript-examples/api-monitor/update-session-id.js';
|
||||
import examplePythonApiMonitorDeleteMessagesBySession from '!!raw-loader!@site/docs/API-Reference/python-examples/api-monitor/delete-messages-by-session.py';
|
||||
import exampleJavascriptApiMonitorDeleteMessagesBySession from '!!raw-loader!@site/docs/API-Reference/javascript-examples/api-monitor/delete-messages-by-session.js';
|
||||
import examplePythonApiMonitorGetTransactions from '!!raw-loader!@site/docs/API-Reference/python-examples/api-monitor/get-transactions.py';
|
||||
import exampleJavascriptApiMonitorGetTransactions from '!!raw-loader!@site/docs/API-Reference/javascript-examples/api-monitor/get-transactions.js';
|
||||
|
||||
|
||||
|
||||
|
||||
import Tabs from '@theme/Tabs';
|
||||
import TabItem from '@theme/TabItem';
|
||||
|
||||
The `/monitor` endpoints are for internal Langflow functionality, primarily related to running flows in the **Playground**, storing chat history, and generating flow logs.
|
||||
|
||||
This information is primarily for those who are building custom components or contributing to the Langflow codebase in a way that requires calling or understanding these endpoints.
|
||||
|
||||
For typical application development with Langflow, there are more appropriate options for monitoring, debugging, and memory management.
|
||||
For more information, see the following:
|
||||
|
||||
* [Logs](/logging): Langflow log storage locations, customization options, and where to view logs in the visual editor
|
||||
* [Test flows in the Playground](/concepts-playground): Run flows and inspect message history
|
||||
* [Memory management options](/memory): Langflow storage locations and options, including the database, cache, and chat history
|
||||
|
||||
## Vertex builds
|
||||
|
||||
The Vertex build endpoints (`/monitor/builds`) are exclusively for **Playground** functionality.
|
||||
|
||||
When you run a flow in the **Playground**, Langflow calls the `/build/$FLOW_ID/flow` endpoint in [chat.py](https://github.com/langflow-ai/langflow/blob/main/src/backend/base/langflow/api/v1/chat.py#L130). This call retrieves the flow data, builds a graph, and executes the graph. As each component (or node) is executed, the `build_vertex` function calls `build_and_run`, which may call the individual components' `def_build` method, if it exists. If a component doesn't have a `def_build` function, the build still returns a component.
|
||||
|
||||
The `build` function allows components to execute logic at runtime. For example, the [**Recursive Character Text Splitter** component](https://github.com/langflow-ai/langflow/blob/main/src/lfx/src/lfx/components/langchain_utilities/recursive_character.py) is a child of the `LCTextSplitterComponent` class. When text needs to be processed, the parent class's `build` method is called, which creates a `RecursiveCharacterTextSplitter` object and uses it to split the text according to the defined parameters. The split text is then passed on to the next component. This all occurs when the component is built.
|
||||
|
||||
### Get Vertex builds
|
||||
|
||||
Retrieve Vertex builds for a specific flow.
|
||||
|
||||
<Tabs>
|
||||
<TabItem value="Python" label="Python" default>
|
||||
|
||||
<CodeSnippet source={examplePythonApiMonitorGetVertexBuilds} language="python" />
|
||||
|
||||
</TabItem>
|
||||
<TabItem value="JavaScript" label="JavaScript">
|
||||
|
||||
<CodeSnippet source={exampleJavascriptApiMonitorGetVertexBuilds} language="javascript" />
|
||||
|
||||
</TabItem>
|
||||
<TabItem value="curl" label="curl">
|
||||
|
||||
<CodeSnippet source={exampleApiMonitorGetVertexBuilds} language="bash" />
|
||||
|
||||
</TabItem>
|
||||
</Tabs>
|
||||
|
||||
<details>
|
||||
<summary>Result</summary>
|
||||
|
||||
<CodeSnippet source={resultApiMonitorResultGetVertexBuilds} language="json" />
|
||||
|
||||
</details>
|
||||
|
||||
### Delete Vertex builds
|
||||
|
||||
Delete Vertex builds for a specific flow.
|
||||
|
||||
<Tabs>
|
||||
<TabItem value="Python" label="Python" default>
|
||||
|
||||
<CodeSnippet source={examplePythonApiMonitorDeleteVertexBuilds} language="python" />
|
||||
|
||||
</TabItem>
|
||||
<TabItem value="JavaScript" label="JavaScript">
|
||||
|
||||
<CodeSnippet source={exampleJavascriptApiMonitorDeleteVertexBuilds} language="javascript" />
|
||||
|
||||
</TabItem>
|
||||
<TabItem value="curl" label="curl">
|
||||
|
||||
<CodeSnippet source={exampleApiMonitorDeleteVertexBuilds} language="bash" />
|
||||
|
||||
</TabItem>
|
||||
</Tabs>
|
||||
|
||||
<details>
|
||||
<summary>Result</summary>
|
||||
|
||||
<CodeSnippet source={resultApiMonitorResultDeleteVertexBuilds} language="text" />
|
||||
|
||||
</details>
|
||||
|
||||
## Messages endpoints
|
||||
|
||||
The `/monitor/messages` endpoints store, retrieve, edit, and delete records in the message table in [`langflow.db`](/memory)
|
||||
Typically, these are called implicitly when running flows that produce message history, or when inspecting and modifying **Playground** memories.
|
||||
|
||||
### Get messages
|
||||
|
||||
Retrieve a list of all messages:
|
||||
|
||||
<Tabs>
|
||||
<TabItem value="Python" label="Python" default>
|
||||
|
||||
<CodeSnippet source={examplePythonApiMonitorGetMessages} language="python" />
|
||||
|
||||
</TabItem>
|
||||
<TabItem value="JavaScript" label="JavaScript">
|
||||
|
||||
<CodeSnippet source={exampleJavascriptApiMonitorGetMessages} language="javascript" />
|
||||
|
||||
</TabItem>
|
||||
<TabItem value="curl" label="curl">
|
||||
|
||||
<CodeSnippet source={exampleApiMonitorGetMessages} language="bash" />
|
||||
|
||||
</TabItem>
|
||||
</Tabs>
|
||||
|
||||
To filter messages, use the `flow_id`, `session_id`, `sender`, and `sender_name` query parameters.
|
||||
|
||||
To sort the results, use the `order_by` query parameter.
|
||||
|
||||
This example retrieves messages sent by `Machine` and `AI` in a given chat session (`session_id`) and orders the messages by timestamp.
|
||||
|
||||
<Tabs>
|
||||
<TabItem value="Python" label="Python" default>
|
||||
|
||||
<CodeSnippet source={examplePythonApiMonitorGetMessages2} language="python" />
|
||||
|
||||
</TabItem>
|
||||
<TabItem value="JavaScript" label="JavaScript">
|
||||
|
||||
<CodeSnippet source={exampleJavascriptApiMonitorGetMessages2} language="javascript" />
|
||||
|
||||
</TabItem>
|
||||
<TabItem value="curl" label="curl">
|
||||
|
||||
<CodeSnippet source={exampleApiMonitorGetMessages2} language="bash" />
|
||||
|
||||
</TabItem>
|
||||
</Tabs>
|
||||
|
||||
<details>
|
||||
<summary>Result</summary>
|
||||
|
||||
<CodeSnippet source={resultApiMonitorResultGetMessages2} language="json" />
|
||||
|
||||
</details>
|
||||
|
||||
### Delete messages
|
||||
|
||||
Delete specific messages by their IDs.
|
||||
|
||||
This example deletes the message retrieved in the previous `GET /messages` example.
|
||||
|
||||
<Tabs>
|
||||
<TabItem value="Python" label="Python" default>
|
||||
|
||||
<CodeSnippet source={examplePythonApiMonitorDeleteMessages} language="python" />
|
||||
|
||||
</TabItem>
|
||||
<TabItem value="JavaScript" label="JavaScript">
|
||||
|
||||
<CodeSnippet source={exampleJavascriptApiMonitorDeleteMessages} language="javascript" />
|
||||
|
||||
</TabItem>
|
||||
<TabItem value="curl" label="curl">
|
||||
|
||||
<CodeSnippet source={exampleApiMonitorDeleteMessages} language="bash" />
|
||||
|
||||
</TabItem>
|
||||
</Tabs>
|
||||
|
||||
<details>
|
||||
<summary>Result</summary>
|
||||
|
||||
<CodeSnippet source={resultApiMonitorResultDeleteMessages} language="text" />
|
||||
|
||||
</details>
|
||||
|
||||
### Update message
|
||||
|
||||
Update a specific message by its ID.
|
||||
|
||||
This example updates the `text` value of message `3ab66cc6-c048-48f8-ab07-570f5af7b160`.
|
||||
|
||||
<Tabs>
|
||||
<TabItem value="Python" label="Python" default>
|
||||
|
||||
<CodeSnippet source={examplePythonApiMonitorUpdateMessage} language="python" />
|
||||
|
||||
</TabItem>
|
||||
<TabItem value="JavaScript" label="JavaScript">
|
||||
|
||||
<CodeSnippet source={exampleJavascriptApiMonitorUpdateMessage} language="javascript" />
|
||||
|
||||
</TabItem>
|
||||
<TabItem value="curl" label="curl">
|
||||
|
||||
<CodeSnippet source={exampleApiMonitorUpdateMessage} language="bash" />
|
||||
|
||||
</TabItem>
|
||||
</Tabs>
|
||||
|
||||
<details>
|
||||
<summary>Result</summary>
|
||||
|
||||
<CodeSnippet source={resultApiMonitorResultUpdateMessage} language="json" />
|
||||
|
||||
</details>
|
||||
|
||||
### Update session ID
|
||||
|
||||
Update the session ID for messages.
|
||||
|
||||
This example updates the `session_ID` value `01ce083d-748b-4b8d-97b6-33adbb6a528a` to `different_session_id`.
|
||||
|
||||
<Tabs>
|
||||
<TabItem value="Python" label="Python" default>
|
||||
|
||||
<CodeSnippet source={examplePythonApiMonitorUpdateSessionId} language="python" />
|
||||
|
||||
</TabItem>
|
||||
<TabItem value="JavaScript" label="JavaScript">
|
||||
|
||||
<CodeSnippet source={exampleJavascriptApiMonitorUpdateSessionId} language="javascript" />
|
||||
|
||||
</TabItem>
|
||||
<TabItem value="curl" label="curl">
|
||||
|
||||
<CodeSnippet source={exampleApiMonitorUpdateSessionId} language="bash" />
|
||||
|
||||
</TabItem>
|
||||
</Tabs>
|
||||
|
||||
<details>
|
||||
<summary>Result</summary>
|
||||
|
||||
<CodeSnippet source={resultApiMonitorResultUpdateSessionId} language="json" />
|
||||
|
||||
</details>
|
||||
|
||||
### Delete messages by session
|
||||
|
||||
Delete all messages for a specific session.
|
||||
|
||||
<Tabs>
|
||||
<TabItem value="Python" label="Python" default>
|
||||
|
||||
<CodeSnippet source={examplePythonApiMonitorDeleteMessagesBySession} language="python" />
|
||||
|
||||
</TabItem>
|
||||
<TabItem value="JavaScript" label="JavaScript">
|
||||
|
||||
<CodeSnippet source={exampleJavascriptApiMonitorDeleteMessagesBySession} language="javascript" />
|
||||
|
||||
</TabItem>
|
||||
<TabItem value="curl" label="curl">
|
||||
|
||||
<CodeSnippet source={exampleApiMonitorDeleteMessagesBySession} language="bash" />
|
||||
|
||||
</TabItem>
|
||||
</Tabs>
|
||||
|
||||
<details>
|
||||
<summary>Result</summary>
|
||||
|
||||
<CodeSnippet source={resultApiMonitorResultDeleteMessagesBySession} language="text" />
|
||||
|
||||
</details>
|
||||
|
||||
## Get traces
|
||||
|
||||
Retrieve trace metadata and span trees for a specific flow.
|
||||
|
||||
### Example request
|
||||
|
||||
Use `GET /monitor/traces` and filter by `flow_id`:
|
||||
|
||||
<Tabs>
|
||||
<TabItem value="python" label="Python">
|
||||
|
||||
<CodeSnippet source={examplePythonApiMonitorExampleRequest} language="python" />
|
||||
|
||||
</TabItem>
|
||||
<TabItem value="typescript" label="TypeScript">
|
||||
|
||||
```ts
|
||||
const baseUrl = process.env.LANGFLOW_SERVER_URL ?? "http://localhost:7860";
|
||||
const apiKey = process.env.LANGFLOW_API_KEY!;
|
||||
const flowId = "YOUR_FLOW_ID";
|
||||
|
||||
async function listTraces() {
|
||||
const url = new URL("/api/v1/monitor/traces", baseUrl);
|
||||
url.searchParams.set("flow_id", flowId);
|
||||
url.searchParams.set("page", "1");
|
||||
url.searchParams.set("size", "50");
|
||||
|
||||
const res = await fetch(url.toString(), {
|
||||
headers: {
|
||||
accept: "application/json",
|
||||
"x-api-key": apiKey,
|
||||
},
|
||||
});
|
||||
|
||||
if (!res.ok) {
|
||||
throw new Error(`Request failed with status ${res.status}`);
|
||||
}
|
||||
|
||||
const data = await res.json();
|
||||
console.log(data);
|
||||
}
|
||||
|
||||
listTraces().catch(console.error);
|
||||
```
|
||||
|
||||
</TabItem>
|
||||
<TabItem value="curl" label="curl">
|
||||
|
||||
<CodeSnippet source={exampleApiMonitorExampleRequest} language="bash" />
|
||||
|
||||
</TabItem>
|
||||
</Tabs>
|
||||
|
||||
### Example response
|
||||
|
||||
```json
|
||||
{
|
||||
"traces": [
|
||||
{
|
||||
"id": "426656db-fc3c-4a3a-acf8-c60acf099543",
|
||||
"name": "Simple Agent - 9e774f60-857b-44b4-bbcd-87bd23848ee8",
|
||||
"status": "ok",
|
||||
"startTime": "2026-03-03T19:13:30.692628Z",
|
||||
"totalLatencyMs": 18693,
|
||||
"totalTokens": 2050,
|
||||
"flowId": "9e774f60-857b-44b4-bbcd-87bd23848ee8",
|
||||
"sessionId": "9e774f60-857b-44b4-bbcd-87bd23848ee8",
|
||||
"input": {
|
||||
"input_value": "Use tools to teach me about vertex graphs"
|
||||
},
|
||||
"output": {
|
||||
"message": {
|
||||
"text_key": "text",
|
||||
"data": {
|
||||
"timestamp": "2026-03-03 19:13:30 UTC",
|
||||
"sender": "Machine",
|
||||
"sender_name": "AI",
|
||||
"session_id": "9e774f60-857b-44b4-bbcd-87bd23848ee8",
|
||||
"text": "I can teach you the concept, but I couldn’t pull the Wikipedia pages with the tool ... (truncated)"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
],
|
||||
"total": 1,
|
||||
"pages": 1
|
||||
}
|
||||
```
|
||||
|
||||
## Get transactions
|
||||
|
||||
Retrieve all transactions, which are interactions between components, for a specific flow.
|
||||
This information is also available in [flow logs](/logging).
|
||||
|
||||
<Tabs>
|
||||
<TabItem value="Python" label="Python" default>
|
||||
|
||||
<CodeSnippet source={examplePythonApiMonitorGetTransactions} language="python" />
|
||||
|
||||
</TabItem>
|
||||
<TabItem value="JavaScript" label="JavaScript">
|
||||
|
||||
<CodeSnippet source={exampleJavascriptApiMonitorGetTransactions} language="javascript" />
|
||||
|
||||
</TabItem>
|
||||
<TabItem value="curl" label="curl">
|
||||
|
||||
<CodeSnippet source={exampleApiMonitorGetTransactions} language="bash" />
|
||||
|
||||
</TabItem>
|
||||
</Tabs>
|
||||
|
||||
<details>
|
||||
<summary>Result</summary>
|
||||
|
||||
<CodeSnippet source={resultApiMonitorResultGetTransactions} language="json" />
|
||||
|
||||
</details>
|
||||
|
||||
## See also
|
||||
|
||||
- [Use voice mode](/concepts-voice-mode)
|
||||
- [Session ID](/session-id)
|
||||
@ -0,0 +1,529 @@
|
||||
---
|
||||
title: OpenAI Responses API
|
||||
slug: /api-openai-responses
|
||||
---
|
||||
import CodeSnippet from '@site/src/components/CodeSnippet';
|
||||
import exampleApiOpenaiResponsesExampleRequest from '!!raw-loader!@site/docs/API-Reference/curl-examples/api-openai-responses/example-request.sh';
|
||||
import exampleApiOpenaiResponsesExampleStreamingRequest from '!!raw-loader!@site/docs/API-Reference/curl-examples/api-openai-responses/example-streaming-request.sh';
|
||||
import resultApiOpenaiResponsesResultExampleStreamingRequest from '!!raw-loader!@site/docs/API-Reference/curl-examples/api-openai-responses/result-example-streaming-request.json';
|
||||
import exampleApiOpenaiResponsesContinueConversationsWithResponseAndSessionIds from '!!raw-loader!@site/docs/API-Reference/curl-examples/api-openai-responses/continue-conversations-with-response-and-session-ids.sh';
|
||||
import resultApiOpenaiResponsesResultContinueConversationsWithResponseAndSessionIds from '!!raw-loader!@site/docs/API-Reference/curl-examples/api-openai-responses/result-continue-conversations-with-response-and-session-ids.json';
|
||||
import exampleApiOpenaiResponsesContinueConversationsWithResponseAndSessionIds2 from '!!raw-loader!@site/docs/API-Reference/curl-examples/api-openai-responses/continue-conversations-with-response-and-session-ids-2.sh';
|
||||
import resultApiOpenaiResponsesResultContinueConversationsWithResponseAndSessionIds2 from '!!raw-loader!@site/docs/API-Reference/curl-examples/api-openai-responses/result-continue-conversations-with-response-and-session-ids-2.json';
|
||||
import exampleApiOpenaiResponsesContinueConversationsWithResponseAndSessionIds3 from '!!raw-loader!@site/docs/API-Reference/curl-examples/api-openai-responses/continue-conversations-with-response-and-session-ids-3.sh';
|
||||
import exampleApiOpenaiResponsesRetrieveToolCallResults from '!!raw-loader!@site/docs/API-Reference/curl-examples/api-openai-responses/retrieve-tool-call-results.sh';
|
||||
import resultApiOpenaiResponsesResultRetrieveToolCallResults from '!!raw-loader!@site/docs/API-Reference/curl-examples/api-openai-responses/result-retrieve-tool-call-results.json';
|
||||
import exampleApiOpenaiResponsesPassGlobalVariablesToYourFlowsInHeaders from '!!raw-loader!@site/docs/API-Reference/curl-examples/api-openai-responses/pass-global-variables-to-your-flows-in-headers.sh';
|
||||
import exampleApiOpenaiResponsesTokenUsageTracking from '!!raw-loader!@site/docs/API-Reference/curl-examples/api-openai-responses/token-usage-tracking.sh';
|
||||
import examplePythonApiOpenaiResponsesAdditionalConfigurationForOpenaiClientLibraries from '!!raw-loader!@site/docs/API-Reference/python-examples/api-openai-responses/additional-configuration-for-openai-client-libraries.py';
|
||||
import exampleJavascriptApiOpenaiResponsesAdditionalConfigurationForOpenaiClientLibraries from '!!raw-loader!@site/docs/API-Reference/javascript-examples/api-openai-responses/additional-configuration-for-openai-client-libraries.ts';
|
||||
import examplePythonApiOpenaiResponsesTokenUsageTracking from '!!raw-loader!@site/docs/API-Reference/python-examples/api-openai-responses/token-usage-tracking.py';
|
||||
import examplePythonApiOpenaiResponsesExampleRequest from '!!raw-loader!@site/docs/API-Reference/python-examples/api-openai-responses/example-request.py';
|
||||
import exampleJavascriptApiOpenaiResponsesExampleRequest from '!!raw-loader!@site/docs/API-Reference/javascript-examples/api-openai-responses/example-request.js';
|
||||
import examplePythonApiOpenaiResponsesExampleStreamingRequest from '!!raw-loader!@site/docs/API-Reference/python-examples/api-openai-responses/example-streaming-request.py';
|
||||
import exampleJavascriptApiOpenaiResponsesExampleStreamingRequest from '!!raw-loader!@site/docs/API-Reference/javascript-examples/api-openai-responses/example-streaming-request.js';
|
||||
import examplePythonApiOpenaiResponsesContinueConversationsWithResponseAndSessionIds from '!!raw-loader!@site/docs/API-Reference/python-examples/api-openai-responses/continue-conversations-with-response-and-session-ids.py';
|
||||
import exampleJavascriptApiOpenaiResponsesContinueConversationsWithResponseAndSessionIds from '!!raw-loader!@site/docs/API-Reference/javascript-examples/api-openai-responses/continue-conversations-with-response-and-session-ids.js';
|
||||
import examplePythonApiOpenaiResponsesContinueConversationsWithResponseAndSessionIds2 from '!!raw-loader!@site/docs/API-Reference/python-examples/api-openai-responses/continue-conversations-with-response-and-session-ids-2.py';
|
||||
import exampleJavascriptApiOpenaiResponsesContinueConversationsWithResponseAndSessionIds2 from '!!raw-loader!@site/docs/API-Reference/javascript-examples/api-openai-responses/continue-conversations-with-response-and-session-ids-2.js';
|
||||
import examplePythonApiOpenaiResponsesContinueConversationsWithResponseAndSessionIds3 from '!!raw-loader!@site/docs/API-Reference/python-examples/api-openai-responses/continue-conversations-with-response-and-session-ids-3.py';
|
||||
import exampleJavascriptApiOpenaiResponsesContinueConversationsWithResponseAndSessionIds3 from '!!raw-loader!@site/docs/API-Reference/javascript-examples/api-openai-responses/continue-conversations-with-response-and-session-ids-3.js';
|
||||
import examplePythonApiOpenaiResponsesRetrieveToolCallResults from '!!raw-loader!@site/docs/API-Reference/python-examples/api-openai-responses/retrieve-tool-call-results.py';
|
||||
import exampleJavascriptApiOpenaiResponsesRetrieveToolCallResults from '!!raw-loader!@site/docs/API-Reference/javascript-examples/api-openai-responses/retrieve-tool-call-results.js';
|
||||
import examplePythonApiOpenaiResponsesPassGlobalVariablesToYourFlowsInHeaders from '!!raw-loader!@site/docs/API-Reference/python-examples/api-openai-responses/pass-global-variables-to-your-flows-in-headers.py';
|
||||
import exampleJavascriptApiOpenaiResponsesPassGlobalVariablesToYourFlowsInHeaders from '!!raw-loader!@site/docs/API-Reference/javascript-examples/api-openai-responses/pass-global-variables-to-your-flows-in-headers.js';
|
||||
import exampleJavascriptApiOpenaiResponsesTokenUsageTracking from '!!raw-loader!@site/docs/API-Reference/javascript-examples/api-openai-responses/token-usage-tracking.js';
|
||||
|
||||
|
||||
|
||||
|
||||
import Tabs from '@theme/Tabs';
|
||||
import TabItem from '@theme/TabItem';
|
||||
|
||||
Langflow includes an endpoint that is compatible with the [OpenAI Responses API](https://platform.openai.com/docs/api-reference/responses).
|
||||
It is available at `POST /api/v1/responses`.
|
||||
|
||||
This endpoint allows you to use existing OpenAI client libraries with minimal code changes.
|
||||
You only need to replace the `model` name, such as `gpt-4`, with your `flow_id`.
|
||||
You can find Flow IDs in the code snippets on the [**API access** pane](/concepts-publish#api-access) or in a flow's URL.
|
||||
|
||||
## Prerequisites
|
||||
|
||||
To be compatible with Langflow's OpenAI Responses API endpoint, your flow and request must adhere to the following requirements:
|
||||
|
||||
- **Chat Input**: Your flow must contain a **Chat Input** component.
|
||||
Flows without this component return an error when passed to this endpoint.
|
||||
The component types `ChatInput` and `Chat Input` are recognized as chat inputs.
|
||||
- **Tools**: The `tools` parameter isn't supported, and returns an error if provided.
|
||||
- **Model Names**: In your request, the `model` field must contain a valid flow ID or endpoint name.
|
||||
- **Authentication**: All requests require an API key passed in the `x-api-key` header.
|
||||
For more information, see [API keys and authentication](/api-keys-and-authentication).
|
||||
|
||||
### Additional configuration for OpenAI client libraries
|
||||
|
||||
This endpoint is compatible with OpenAI's API, but requires special configuration when using OpenAI client libraries.
|
||||
Langflow uses `x-api-key` headers for authentication, while OpenAI uses `Authorization: Bearer` headers.
|
||||
When sending requests to Langflow with OpenAI client libraries, you must configure custom headers and include an `api_key` configuration.
|
||||
The `api_key` parameter can have any value, such as `"dummy-api-key"` in the client examples, as the actual authentication is handled through the `default_headers` configuration.
|
||||
|
||||
In the following examples, replace the values for `LANGFLOW_SERVER_URL`, `LANGFLOW_API_KEY`, and `FLOW_ID` with values from your deployment.
|
||||
<Tabs groupId="client">
|
||||
<TabItem value="Python" label="OpenAI Python Client" default>
|
||||
|
||||
<CodeSnippet source={examplePythonApiOpenaiResponsesAdditionalConfigurationForOpenaiClientLibraries} language="python" />
|
||||
|
||||
</TabItem>
|
||||
<TabItem value="JavaScript" label="OpenAI TypeScript Client">
|
||||
|
||||
<CodeSnippet source={exampleJavascriptApiOpenaiResponsesAdditionalConfigurationForOpenaiClientLibraries} language="javascript" />
|
||||
|
||||
</TabItem>
|
||||
</Tabs>
|
||||
|
||||
<details closed>
|
||||
<summary>Response</summary>
|
||||
```text
|
||||
Here are the event dates for the second Wednesday of each month in 2026:
|
||||
- January 14, 2026
|
||||
- February 11, 2026
|
||||
- March 11, 2026
|
||||
- April 8, 2026
|
||||
- May 13, 2026
|
||||
- June 10, 2026
|
||||
- July 8, 2026
|
||||
- August 12, 2026
|
||||
- September 9, 2026
|
||||
- October 14, 2026
|
||||
- November 11, 2026
|
||||
- December 9, 2026
|
||||
If you need these in a different format or want a downloadable calendar, let me know!
|
||||
```
|
||||
</details>
|
||||
|
||||
## Example request
|
||||
|
||||
<Tabs>
|
||||
<TabItem value="Python" label="Python" default>
|
||||
|
||||
<CodeSnippet source={examplePythonApiOpenaiResponsesExampleRequest} language="python" />
|
||||
|
||||
</TabItem>
|
||||
<TabItem value="JavaScript" label="JavaScript">
|
||||
|
||||
<CodeSnippet source={exampleJavascriptApiOpenaiResponsesExampleRequest} language="javascript" />
|
||||
|
||||
</TabItem>
|
||||
<TabItem value="curl" label="curl">
|
||||
|
||||
<CodeSnippet source={exampleApiOpenaiResponsesExampleRequest} language="bash" />
|
||||
|
||||
</TabItem>
|
||||
</Tabs>
|
||||
|
||||
### Headers
|
||||
|
||||
| Header | Required | Description | Example |
|
||||
|--------|----------|-------------|---------|
|
||||
| `x-api-key` | Yes | Your Langflow API key for authentication | `"sk-..."` |
|
||||
| `Content-Type` | Yes | Specifies the JSON format | `"application/json"` |
|
||||
| `X-LANGFLOW-GLOBAL-VAR-*` | No | Global variables for the flow | `"X-LANGFLOW-GLOBAL-VAR-API_KEY: sk-..."` For more, see [Pass global variables to your flows in headers](#global-var). |
|
||||
|
||||
### Request body
|
||||
|
||||
| Field | Type | Required | Default | Description |
|
||||
|-------|------|----------|---------|-------------|
|
||||
| `model` | `string` | Yes | - | The flow ID or endpoint name to execute. |
|
||||
| `input` | `string` | Yes | - | The input text to process. |
|
||||
| `stream` | `boolean` | No | `false` | Whether to stream the response. |
|
||||
| `background` | `boolean` | No | `false` | Whether to process in background. |
|
||||
| `tools` | `list[Any]` | No | `null` | Tools are not supported yet. |
|
||||
| `previous_response_id` | `string` | No | `null` | ID of previous response to continue conversation. For more, see [Continue conversations with response and session IDs](#response-id). |
|
||||
| `include` | `list[string]` | No | `null` | Additional response data to include, such as `['tool_call.results']`. For more, see [Retrieve tool call results](#tool-call-results). |
|
||||
|
||||
## Example response
|
||||
|
||||
```json
|
||||
{
|
||||
"id": "e5e8ef8a-7efd-4090-a110-6aca082bceb7",
|
||||
"object": "response",
|
||||
"created_at": 1756837941,
|
||||
"status": "completed",
|
||||
"model": "ced2ec91-f325-4bf0-8754-f3198c2b1563",
|
||||
"output": [
|
||||
{
|
||||
"type": "message",
|
||||
"id": "msg_e5e8ef8a-7efd-4090-a110-6aca082bceb7",
|
||||
"status": "completed",
|
||||
"role": "assistant",
|
||||
"content": [
|
||||
{
|
||||
"type": "output_text",
|
||||
"text": "Hello! I'm here and ready to help. How can I assist you today?",
|
||||
"annotations": []
|
||||
}
|
||||
]
|
||||
}
|
||||
],
|
||||
"parallel_tool_calls": true,
|
||||
"previous_response_id": null,
|
||||
"reasoning": {"effort": null, "summary": null},
|
||||
"store": true,
|
||||
"temperature": 1.0,
|
||||
"text": {"format": {"type": "text"}},
|
||||
"tool_choice": "auto",
|
||||
"tools": [],
|
||||
"top_p": 1.0,
|
||||
"truncation": "disabled",
|
||||
"usage": null,
|
||||
"user": null,
|
||||
"metadata": {}
|
||||
}
|
||||
```
|
||||
|
||||
### Response body
|
||||
|
||||
The response contains fields that Langflow sets dynamically and fields that use OpenAI-compatible defaults.
|
||||
|
||||
The OpenAI-compatible default values shown above are currently fixed and cannot be modified via the request.
|
||||
They are included to maintain API compatibility and provide a consistent response format.
|
||||
|
||||
For your requests, you will only be setting the dynamic fields.
|
||||
The default values are documented here for completeness and to show the full response structure.
|
||||
|
||||
Fields set dynamically by Langflow:
|
||||
|
||||
| Field | Type | Description |
|
||||
|-------|------|-------------|
|
||||
| `id` | `string` | Unique response identifier. |
|
||||
| `created_at` | `int` | Unix timestamp of response creation. |
|
||||
| `model` | `string` | The flow ID that was executed. |
|
||||
| `output` | `list[dict]` | Array of output items (messages, tool calls, etc.). |
|
||||
| `previous_response_id` | `string` | ID of previous response if continuing conversation. |
|
||||
| `usage` | `dict` | Token usage statistics if the `usage` field is available. Contains `prompt_tokens`, `completion_tokens`, and `total_tokens`. |
|
||||
|
||||
<details>
|
||||
<summary>Fields with OpenAI-compatible default values</summary>
|
||||
|
||||
| Field | Type | Default Value | Description |
|
||||
|-------|------|---------------|-------------|
|
||||
| `object` | `string` | `"response"` | Always `"response"`. |
|
||||
| `status` | `string` | `"completed"` | Response status: `"completed"`, `"in_progress"`, or `"failed"`. |
|
||||
| `error` | `dict` | `null` | Error details (if any). |
|
||||
| `incomplete_details` | `dict` | `null` | Incomplete response details (if any). |
|
||||
| `instructions` | `string` | `null` | Response instructions (if any). |
|
||||
| `max_output_tokens` | `int` | `null` | Maximum output tokens (if any). |
|
||||
| `parallel_tool_calls` | `boolean` | `true` | Whether parallel tool calls are enabled. |
|
||||
| `reasoning` | `dict` | `{"effort": null, "summary": null}` | Reasoning information with effort and summary. |
|
||||
| `store` | `boolean` | `true` | Whether response is stored. |
|
||||
| `temperature` | `float` | `1.0` | Temperature setting. |
|
||||
| `text` | `dict` | `{"format": {"type": "text"}}` | Text format configuration. |
|
||||
| `tool_choice` | `string` | `"auto"` | Tool choice setting. |
|
||||
| `tools` | `list[dict]` | `[]` | Available tools. |
|
||||
| `top_p` | `float` | `1.0` | Top-p setting. |
|
||||
| `truncation` | `string` | `"disabled"` | Truncation setting. |
|
||||
| `usage` | `dict` | `null` | Token usage statistics. Set dynamically when available from flow components, otherwise `null`. See [Token usage tracking](#token-usage-tracking). |
|
||||
| `user` | `string` | `null` | User identifier (if any). |
|
||||
| `metadata` | `dict` | `{}` | Additional metadata. |
|
||||
|
||||
</details>
|
||||
|
||||
## Example streaming request
|
||||
|
||||
When you set `"stream": true` with your request, the API returns a stream where each chunk contains a small piece of the response as it's generated. This provides a real-time experience where users can see the AI's output appear word by word, similar to ChatGPT's typing effect.
|
||||
|
||||
<Tabs>
|
||||
<TabItem value="Python" label="Python" default>
|
||||
|
||||
<CodeSnippet source={examplePythonApiOpenaiResponsesExampleStreamingRequest} language="python" />
|
||||
|
||||
</TabItem>
|
||||
<TabItem value="JavaScript" label="JavaScript">
|
||||
|
||||
<CodeSnippet source={exampleJavascriptApiOpenaiResponsesExampleStreamingRequest} language="javascript" />
|
||||
|
||||
</TabItem>
|
||||
<TabItem value="curl" label="curl">
|
||||
|
||||
<CodeSnippet source={exampleApiOpenaiResponsesExampleStreamingRequest} language="bash" />
|
||||
|
||||
</TabItem>
|
||||
</Tabs>
|
||||
|
||||
<details>
|
||||
<summary>Result</summary>
|
||||
|
||||
<CodeSnippet source={resultApiOpenaiResponsesResultExampleStreamingRequest} language="json" />
|
||||
|
||||
</details>
|
||||
|
||||
### Streaming response body
|
||||
|
||||
| Field | Type | Description |
|
||||
|-------|------|-------------|
|
||||
| `id` | `string` | Unique response identifier. |
|
||||
| `object` | `string` | Always `"response.chunk"`. |
|
||||
| `created` | `int` | Unix timestamp of chunk creation. |
|
||||
| `model` | `string` | The flow ID that was executed. |
|
||||
| `delta` | `dict` | The new content chunk. |
|
||||
| `status` | `string` | Response status: `"completed"`, `"in_progress"`, or `"failed"` (optional). |
|
||||
|
||||
The stream continues until a final chunk with `"status": "completed"` indicates the response is finished.
|
||||
|
||||
<details>
|
||||
<summary>Final completion chunk</summary>
|
||||
|
||||
```
|
||||
{
|
||||
"id": "f7fcea36-f128-41c4-9ac1-e683137375d5",
|
||||
"object": "response.chunk",
|
||||
"created": 1756838094,
|
||||
"model": "ced2ec91-f325-4bf0-8754-f3198c2b1563",
|
||||
"delta": {},
|
||||
"status": "completed"
|
||||
}
|
||||
```
|
||||
</details>
|
||||
|
||||
## Continue conversations with response and session IDs {#response-id}
|
||||
|
||||
Conversation continuity allows you to maintain context across multiple API calls, enabling multi-turn conversations with your flows. This is essential for building chat applications where users can have ongoing conversations.
|
||||
|
||||
When you make a request, the API returns a response with an `id` field. You can use this `id` as the `previous_response_id` in your next request to continue the conversation from where it left off.
|
||||
|
||||
First Message:
|
||||
|
||||
<Tabs>
|
||||
<TabItem value="Python" label="Python" default>
|
||||
|
||||
<CodeSnippet source={examplePythonApiOpenaiResponsesContinueConversationsWithResponseAndSessionIds} language="python" />
|
||||
|
||||
</TabItem>
|
||||
<TabItem value="JavaScript" label="JavaScript">
|
||||
|
||||
<CodeSnippet source={exampleJavascriptApiOpenaiResponsesContinueConversationsWithResponseAndSessionIds} language="javascript" />
|
||||
|
||||
</TabItem>
|
||||
<TabItem value="curl" label="curl">
|
||||
|
||||
<CodeSnippet source={exampleApiOpenaiResponsesContinueConversationsWithResponseAndSessionIds} language="bash" />
|
||||
|
||||
</TabItem>
|
||||
</Tabs>
|
||||
|
||||
<details>
|
||||
<summary>Result</summary>
|
||||
|
||||
<CodeSnippet source={resultApiOpenaiResponsesResultContinueConversationsWithResponseAndSessionIds} language="json" />
|
||||
|
||||
</details>
|
||||
|
||||
Follow-up message:
|
||||
|
||||
<Tabs>
|
||||
<TabItem value="Python" label="Python" default>
|
||||
|
||||
<CodeSnippet source={examplePythonApiOpenaiResponsesContinueConversationsWithResponseAndSessionIds2} language="python" />
|
||||
|
||||
</TabItem>
|
||||
<TabItem value="JavaScript" label="JavaScript">
|
||||
|
||||
<CodeSnippet source={exampleJavascriptApiOpenaiResponsesContinueConversationsWithResponseAndSessionIds2} language="javascript" />
|
||||
|
||||
</TabItem>
|
||||
<TabItem value="curl" label="curl">
|
||||
|
||||
<CodeSnippet source={exampleApiOpenaiResponsesContinueConversationsWithResponseAndSessionIds2} language="bash" />
|
||||
|
||||
</TabItem>
|
||||
</Tabs>
|
||||
|
||||
<details>
|
||||
<summary>Result</summary>
|
||||
|
||||
<CodeSnippet source={resultApiOpenaiResponsesResultContinueConversationsWithResponseAndSessionIds2} language="json" />
|
||||
|
||||
</details>
|
||||
|
||||
Optionally, you can use your own session ID values for the `previous_response_id`:
|
||||
|
||||
<Tabs>
|
||||
<TabItem value="Python" label="Python" default>
|
||||
|
||||
<CodeSnippet source={examplePythonApiOpenaiResponsesContinueConversationsWithResponseAndSessionIds3} language="python" />
|
||||
|
||||
</TabItem>
|
||||
<TabItem value="JavaScript" label="JavaScript">
|
||||
|
||||
<CodeSnippet source={exampleJavascriptApiOpenaiResponsesContinueConversationsWithResponseAndSessionIds3} language="javascript" />
|
||||
|
||||
</TabItem>
|
||||
<TabItem value="curl" label="curl">
|
||||
|
||||
<CodeSnippet source={exampleApiOpenaiResponsesContinueConversationsWithResponseAndSessionIds3} language="bash" />
|
||||
|
||||
</TabItem>
|
||||
</Tabs>
|
||||
|
||||
<details>
|
||||
<summary>Result</summary>
|
||||
|
||||
This example uses the same flow as the other `previous_response_id` examples, but the LLM had not yet been introduced to Alice in the specified session:
|
||||
|
||||
```json
|
||||
{
|
||||
"id": "session-alice-1756839048",
|
||||
"object": "response",
|
||||
"created_at": 1756839048,
|
||||
"status": "completed",
|
||||
"model": "ced2ec91-f325-4bf0-8754-f3198c2b1563",
|
||||
"output": [
|
||||
{
|
||||
"type": "message",
|
||||
"id": "msg_session-alice-1756839048",
|
||||
"status": "completed",
|
||||
"role": "assistant",
|
||||
"content": [
|
||||
{
|
||||
"type": "output_text",
|
||||
"text": "I don't have access to your name unless you tell me. If you'd like, you can share your name, and I'll remember it for this conversation!",
|
||||
"annotations": []
|
||||
}
|
||||
]
|
||||
}
|
||||
],
|
||||
"previous_response_id": "session-alice-1756839048"
|
||||
}
|
||||
```
|
||||
|
||||
</details>
|
||||
|
||||
## Retrieve tool call results {#tool-call-results}
|
||||
|
||||
When you send a request to the `/api/v1/responses` endpoint to run a flow that includes tools or function calls, you can retrieve the raw tool execution details by adding `"include": ["tool_call.results"]` to the request payload.
|
||||
|
||||
Without the `include` parameter, tool calls return basic function call information, but not the raw tool results.
|
||||
For example:
|
||||
|
||||
```json
|
||||
{
|
||||
"id": "fc_1",
|
||||
"type": "function_call",
|
||||
"status": "completed",
|
||||
"name": "evaluate_expression",
|
||||
"arguments": "{\"expression\": \"15*23\"}"
|
||||
},
|
||||
```
|
||||
|
||||
To get the raw `results` of each tool execution, add `include: ["tool_call.results"]` to the request payload:
|
||||
|
||||
<Tabs>
|
||||
<TabItem value="Python" label="Python" default>
|
||||
|
||||
<CodeSnippet source={examplePythonApiOpenaiResponsesRetrieveToolCallResults} language="python" />
|
||||
|
||||
</TabItem>
|
||||
<TabItem value="JavaScript" label="JavaScript">
|
||||
|
||||
<CodeSnippet source={exampleJavascriptApiOpenaiResponsesRetrieveToolCallResults} language="javascript" />
|
||||
|
||||
</TabItem>
|
||||
<TabItem value="curl" label="curl">
|
||||
|
||||
<CodeSnippet source={exampleApiOpenaiResponsesRetrieveToolCallResults} language="bash" />
|
||||
|
||||
</TabItem>
|
||||
</Tabs>
|
||||
|
||||
The response now includes the tool call's results.
|
||||
For example:
|
||||
|
||||
```json
|
||||
{
|
||||
"id": "evaluate_expression_1",
|
||||
"type": "tool_call",
|
||||
"tool_name": "evaluate_expression",
|
||||
"queries": ["15*23"],
|
||||
"results": {"result": "345"}
|
||||
}
|
||||
```
|
||||
|
||||
<details>
|
||||
<summary>Result</summary>
|
||||
|
||||
<CodeSnippet source={resultApiOpenaiResponsesResultRetrieveToolCallResults} language="json" />
|
||||
|
||||
</details>
|
||||
|
||||
Variables passed with `X-LANGFLOW-GLOBAL-VAR-{VARIABLE_NAME}` are always available to your flow, regardless of whether they exist in the database.
|
||||
|
||||
If your flow components reference variables that aren't provided in headers or your Langflow database, the flow fails by default.
|
||||
|
||||
To avoid this, you can set the `FALLBACK_TO_ENV_VARS` environment variable is `true`, which allows the flow to use values from the `.env` file if they aren't otherwise specified.
|
||||
|
||||
In the above example, `OPENAI_API_KEY` will fall back to the database variable if not provided in the header.
|
||||
`USER_ID` and `ENVIRONMENT` will fall back to environment variables if `FALLBACK_TO_ENV_VARS` is enabled.
|
||||
Otherwise, the flow fails.
|
||||
|
||||
## Token usage tracking {#token-usage-tracking}
|
||||
|
||||
The OpenAI Responses API endpoint tracks token usage when your flow uses language model components that provide token usage information. The `usage` field in the response contains statistics about the number of tokens used for the request and response.
|
||||
|
||||
Token usage is automatically extracted from the flow execution results when the `usage` field is available.
|
||||
The `usage` field follows OpenAI's format with `prompt_tokens`, `completion_tokens`, and `total_tokens` fields.
|
||||
If token usage information is not available from the flow components, the `usage` field is `null`.
|
||||
|
||||
The `usage` field is always present in the response, either with token counts or as `null`. The conditional checks shown in the examples below are optional defensive programming to handle cases where usage might not be available.
|
||||
|
||||
<Tabs groupId="token-usage">
|
||||
<TabItem value="Python" label="Python" default>
|
||||
|
||||
<CodeSnippet source={examplePythonApiOpenaiResponsesTokenUsageTracking} language="python" />
|
||||
|
||||
</TabItem>
|
||||
<TabItem value="JavaScript" label="JavaScript">
|
||||
|
||||
<CodeSnippet source={exampleJavascriptApiOpenaiResponsesTokenUsageTracking} language="javascript" />
|
||||
|
||||
</TabItem>
|
||||
<TabItem value="curl" label="curl">
|
||||
|
||||
<CodeSnippet source={exampleApiOpenaiResponsesTokenUsageTracking} language="bash" />
|
||||
|
||||
<details>
|
||||
<summary>Response with token usage</summary>
|
||||
|
||||
```json
|
||||
{
|
||||
"id": "a1b2c3d4-e5f6-7890-abcd-ef1234567890",
|
||||
"object": "response",
|
||||
"created_at": 1756837941,
|
||||
"status": "completed",
|
||||
"model": "ced2ec91-f325-4bf0-8754-f3198c2b1563",
|
||||
"output": [
|
||||
{
|
||||
"type": "message",
|
||||
"id": "msg_a1b2c3d4-e5f6-7890-abcd-ef1234567890",
|
||||
"status": "completed",
|
||||
"role": "assistant",
|
||||
"content": [
|
||||
{
|
||||
"type": "output_text",
|
||||
"text": "Quantum computing is a type of computing that uses quantum mechanical phenomena...",
|
||||
"annotations": []
|
||||
}
|
||||
]
|
||||
}
|
||||
],
|
||||
"usage": {
|
||||
"prompt_tokens": 12,
|
||||
"completion_tokens": 145,
|
||||
"total_tokens": 157
|
||||
},
|
||||
"previous_response_id": null
|
||||
}
|
||||
```
|
||||
|
||||
</details>
|
||||
|
||||
</TabItem>
|
||||
</Tabs>
|
||||
259
docs/versioned_docs/version-1.9.0/API-Reference/api-projects.mdx
Normal file
259
docs/versioned_docs/version-1.9.0/API-Reference/api-projects.mdx
Normal file
@ -0,0 +1,259 @@
|
||||
---
|
||||
title: Projects endpoints
|
||||
slug: /api-projects
|
||||
---
|
||||
import CodeSnippet from '@site/src/components/CodeSnippet';
|
||||
import exampleApiProjectsReadProjects from '!!raw-loader!@site/docs/API-Reference/curl-examples/api-projects/read-projects.sh';
|
||||
import resultApiProjectsResultReadProjects from '!!raw-loader!@site/docs/API-Reference/curl-examples/api-projects/result-read-projects.json';
|
||||
import exampleApiProjectsCreateProject from '!!raw-loader!@site/docs/API-Reference/curl-examples/api-projects/create-project.sh';
|
||||
import resultApiProjectsResultCreateProject from '!!raw-loader!@site/docs/API-Reference/curl-examples/api-projects/result-create-project.json';
|
||||
import exampleApiProjectsCreateProject2 from '!!raw-loader!@site/docs/API-Reference/curl-examples/api-projects/create-project-2.sh';
|
||||
import exampleApiProjectsReadProject from '!!raw-loader!@site/docs/API-Reference/curl-examples/api-projects/read-project.sh';
|
||||
import resultApiProjectsResultReadProject from '!!raw-loader!@site/docs/API-Reference/curl-examples/api-projects/result-read-project.json';
|
||||
import exampleApiProjectsUpdateProject from '!!raw-loader!@site/docs/API-Reference/curl-examples/api-projects/update-project.sh';
|
||||
import resultApiProjectsResultUpdateProject from '!!raw-loader!@site/docs/API-Reference/curl-examples/api-projects/result-update-project.json';
|
||||
import exampleApiProjectsDeleteProject from '!!raw-loader!@site/docs/API-Reference/curl-examples/api-projects/delete-project.sh';
|
||||
import resultApiProjectsResultDeleteProject from '!!raw-loader!@site/docs/API-Reference/curl-examples/api-projects/result-delete-project.txt';
|
||||
import exampleApiProjectsExportAProject from '!!raw-loader!@site/docs/API-Reference/curl-examples/api-projects/export-a-project.sh';
|
||||
import exampleApiProjectsImportAProject from '!!raw-loader!@site/docs/API-Reference/curl-examples/api-projects/import-a-project.sh';
|
||||
import Tabs from '@theme/Tabs';
|
||||
import TabItem from '@theme/TabItem';
|
||||
import examplePythonApiProjectsReadProjects from '!!raw-loader!@site/docs/API-Reference/python-examples/api-projects/read-projects.py';
|
||||
import exampleJavascriptApiProjectsReadProjects from '!!raw-loader!@site/docs/API-Reference/javascript-examples/api-projects/read-projects.js';
|
||||
import examplePythonApiProjectsCreateProject from '!!raw-loader!@site/docs/API-Reference/python-examples/api-projects/create-project.py';
|
||||
import exampleJavascriptApiProjectsCreateProject from '!!raw-loader!@site/docs/API-Reference/javascript-examples/api-projects/create-project.js';
|
||||
import examplePythonApiProjectsCreateProject2 from '!!raw-loader!@site/docs/API-Reference/python-examples/api-projects/create-project-2.py';
|
||||
import exampleJavascriptApiProjectsCreateProject2 from '!!raw-loader!@site/docs/API-Reference/javascript-examples/api-projects/create-project-2.js';
|
||||
import examplePythonApiProjectsReadProject from '!!raw-loader!@site/docs/API-Reference/python-examples/api-projects/read-project.py';
|
||||
import exampleJavascriptApiProjectsReadProject from '!!raw-loader!@site/docs/API-Reference/javascript-examples/api-projects/read-project.js';
|
||||
import examplePythonApiProjectsUpdateProject from '!!raw-loader!@site/docs/API-Reference/python-examples/api-projects/update-project.py';
|
||||
import exampleJavascriptApiProjectsUpdateProject from '!!raw-loader!@site/docs/API-Reference/javascript-examples/api-projects/update-project.js';
|
||||
import examplePythonApiProjectsDeleteProject from '!!raw-loader!@site/docs/API-Reference/python-examples/api-projects/delete-project.py';
|
||||
import exampleJavascriptApiProjectsDeleteProject from '!!raw-loader!@site/docs/API-Reference/javascript-examples/api-projects/delete-project.js';
|
||||
import examplePythonApiProjectsExportAProject from '!!raw-loader!@site/docs/API-Reference/python-examples/api-projects/export-a-project.py';
|
||||
import exampleJavascriptApiProjectsExportAProject from '!!raw-loader!@site/docs/API-Reference/javascript-examples/api-projects/export-a-project.js';
|
||||
import examplePythonApiProjectsImportAProject from '!!raw-loader!@site/docs/API-Reference/python-examples/api-projects/import-a-project.py';
|
||||
import exampleJavascriptApiProjectsImportAProject from '!!raw-loader!@site/docs/API-Reference/javascript-examples/api-projects/import-a-project.js';
|
||||
|
||||
|
||||
|
||||
Use the `/projects` endpoint to create, read, update, and delete [Langflow projects](/concepts-flows#projects).
|
||||
|
||||
## Read projects
|
||||
|
||||
Get a list of Langflow projects, including project IDs, names, and descriptions.
|
||||
|
||||
<Tabs>
|
||||
<TabItem value="Python" label="Python" default>
|
||||
|
||||
<CodeSnippet source={examplePythonApiProjectsReadProjects} language="python" />
|
||||
|
||||
</TabItem>
|
||||
<TabItem value="JavaScript" label="JavaScript">
|
||||
|
||||
<CodeSnippet source={exampleJavascriptApiProjectsReadProjects} language="javascript" />
|
||||
|
||||
</TabItem>
|
||||
<TabItem value="curl" label="curl">
|
||||
|
||||
<CodeSnippet source={exampleApiProjectsReadProjects} language="bash" />
|
||||
|
||||
</TabItem>
|
||||
</Tabs>
|
||||
|
||||
<details>
|
||||
<summary>Result</summary>
|
||||
|
||||
<CodeSnippet source={resultApiProjectsResultReadProjects} language="json" />
|
||||
|
||||
</details>
|
||||
|
||||
## Create project
|
||||
|
||||
Create a new project.
|
||||
|
||||
<Tabs>
|
||||
<TabItem value="Python" label="Python" default>
|
||||
|
||||
<CodeSnippet source={examplePythonApiProjectsCreateProject} language="python" />
|
||||
|
||||
</TabItem>
|
||||
<TabItem value="JavaScript" label="JavaScript">
|
||||
|
||||
<CodeSnippet source={exampleJavascriptApiProjectsCreateProject} language="javascript" />
|
||||
|
||||
</TabItem>
|
||||
<TabItem value="curl" label="curl">
|
||||
|
||||
<CodeSnippet source={exampleApiProjectsCreateProject} language="bash" />
|
||||
|
||||
</TabItem>
|
||||
</Tabs>
|
||||
|
||||
<details>
|
||||
<summary>Result</summary>
|
||||
|
||||
<CodeSnippet source={resultApiProjectsResultCreateProject} language="json" />
|
||||
|
||||
</details>
|
||||
|
||||
To add flows and components at project creation, retrieve the `components_list` and `flows_list` values from the [`/all`](/api-reference-api-examples#get-all-components) and [/flows/read](/api-flows#read-flows) endpoints and add them to the request body.
|
||||
|
||||
Adding a flow to a project moves the flow from its previous location. The flow isn't copied.
|
||||
|
||||
<Tabs>
|
||||
<TabItem value="Python" label="Python" default>
|
||||
|
||||
<CodeSnippet source={examplePythonApiProjectsCreateProject2} language="python" />
|
||||
|
||||
</TabItem>
|
||||
<TabItem value="JavaScript" label="JavaScript">
|
||||
|
||||
<CodeSnippet source={exampleJavascriptApiProjectsCreateProject2} language="javascript" />
|
||||
|
||||
</TabItem>
|
||||
<TabItem value="curl" label="curl">
|
||||
|
||||
<CodeSnippet source={exampleApiProjectsCreateProject2} language="bash" />
|
||||
|
||||
</TabItem>
|
||||
</Tabs>
|
||||
|
||||
## Read project
|
||||
|
||||
Retrieve details of a specific project.
|
||||
|
||||
To find the UUID of your project, call the [read projects](#read-projects) endpoint.
|
||||
|
||||
<Tabs>
|
||||
<TabItem value="Python" label="Python" default>
|
||||
|
||||
<CodeSnippet source={examplePythonApiProjectsReadProject} language="python" />
|
||||
|
||||
</TabItem>
|
||||
<TabItem value="JavaScript" label="JavaScript">
|
||||
|
||||
<CodeSnippet source={exampleJavascriptApiProjectsReadProject} language="javascript" />
|
||||
|
||||
</TabItem>
|
||||
<TabItem value="curl" label="curl">
|
||||
|
||||
<CodeSnippet source={exampleApiProjectsReadProject} language="bash" />
|
||||
|
||||
</TabItem>
|
||||
</Tabs>
|
||||
|
||||
<details>
|
||||
<summary>Result</summary>
|
||||
|
||||
<CodeSnippet source={resultApiProjectsResultReadProject} language="json" />
|
||||
|
||||
</details>
|
||||
|
||||
## Update project
|
||||
|
||||
Update the information of a specific project with a `PATCH` request.
|
||||
|
||||
Each PATCH request updates the project with the values you send.
|
||||
Only the fields you include in your request are updated.
|
||||
If you send the same values multiple times, the update is still processed, even if the values are unchanged.
|
||||
|
||||
<Tabs>
|
||||
<TabItem value="Python" label="Python" default>
|
||||
|
||||
<CodeSnippet source={examplePythonApiProjectsUpdateProject} language="python" />
|
||||
|
||||
</TabItem>
|
||||
<TabItem value="JavaScript" label="JavaScript">
|
||||
|
||||
<CodeSnippet source={exampleJavascriptApiProjectsUpdateProject} language="javascript" />
|
||||
|
||||
</TabItem>
|
||||
<TabItem value="curl" label="curl">
|
||||
|
||||
<CodeSnippet source={exampleApiProjectsUpdateProject} language="bash" />
|
||||
|
||||
</TabItem>
|
||||
</Tabs>
|
||||
|
||||
<details>
|
||||
<summary>Result</summary>
|
||||
|
||||
<CodeSnippet source={resultApiProjectsResultUpdateProject} language="json" />
|
||||
|
||||
</details>
|
||||
|
||||
## Delete project
|
||||
|
||||
Delete a specific project.
|
||||
|
||||
<Tabs>
|
||||
<TabItem value="Python" label="Python" default>
|
||||
|
||||
<CodeSnippet source={examplePythonApiProjectsDeleteProject} language="python" />
|
||||
|
||||
</TabItem>
|
||||
<TabItem value="JavaScript" label="JavaScript">
|
||||
|
||||
<CodeSnippet source={exampleJavascriptApiProjectsDeleteProject} language="javascript" />
|
||||
|
||||
</TabItem>
|
||||
<TabItem value="curl" label="curl">
|
||||
|
||||
<CodeSnippet source={exampleApiProjectsDeleteProject} language="bash" />
|
||||
|
||||
</TabItem>
|
||||
</Tabs>
|
||||
|
||||
<details>
|
||||
<summary>Result</summary>
|
||||
|
||||
<CodeSnippet source={resultApiProjectsResultDeleteProject} language="text" />
|
||||
|
||||
</details>
|
||||
|
||||
## Export a project
|
||||
|
||||
Download all flows from a project as a zip file.
|
||||
|
||||
The `--output` flag is optional.
|
||||
|
||||
<Tabs>
|
||||
<TabItem value="Python" label="Python" default>
|
||||
|
||||
<CodeSnippet source={examplePythonApiProjectsExportAProject} language="python" />
|
||||
|
||||
</TabItem>
|
||||
<TabItem value="JavaScript" label="JavaScript">
|
||||
|
||||
<CodeSnippet source={exampleJavascriptApiProjectsExportAProject} language="javascript" />
|
||||
|
||||
</TabItem>
|
||||
<TabItem value="curl" label="curl">
|
||||
|
||||
<CodeSnippet source={exampleApiProjectsExportAProject} language="bash" />
|
||||
|
||||
</TabItem>
|
||||
</Tabs>
|
||||
|
||||
## Import a project
|
||||
|
||||
Import a project and its flows by uploading a Langflow project zip file:
|
||||
|
||||
<Tabs>
|
||||
<TabItem value="Python" label="Python" default>
|
||||
|
||||
<CodeSnippet source={examplePythonApiProjectsImportAProject} language="python" />
|
||||
|
||||
</TabItem>
|
||||
<TabItem value="JavaScript" label="JavaScript">
|
||||
|
||||
<CodeSnippet source={exampleJavascriptApiProjectsImportAProject} language="javascript" />
|
||||
|
||||
</TabItem>
|
||||
<TabItem value="curl" label="curl">
|
||||
|
||||
<CodeSnippet source={exampleApiProjectsImportAProject} language="bash" />
|
||||
|
||||
</TabItem>
|
||||
</Tabs>
|
||||
@ -0,0 +1,440 @@
|
||||
---
|
||||
title: Get started with the Langflow API
|
||||
slug: /api-reference-api-examples
|
||||
---
|
||||
import CodeSnippet from '@site/src/components/CodeSnippet';
|
||||
import exampleApiReferenceApiExamplesFormLangflowApiRequests from '!!raw-loader!@site/docs/API-Reference/curl-examples/api-reference-api-examples/form-langflow-api-requests.sh';
|
||||
import exampleApiReferenceApiExamplesSetEnvironmentVariables from '!!raw-loader!@site/docs/API-Reference/curl-examples/api-reference-api-examples/set-environment-variables.sh';
|
||||
import exampleApiReferenceApiExamplesHealthCheck from '!!raw-loader!@site/docs/API-Reference/curl-examples/api-reference-api-examples/health-check.sh';
|
||||
import resultApiReferenceApiExamplesResultHealthCheck from '!!raw-loader!@site/docs/API-Reference/curl-examples/api-reference-api-examples/result-health-check.json';
|
||||
import exampleApiReferenceApiExamplesGetVersion from '!!raw-loader!@site/docs/API-Reference/curl-examples/api-reference-api-examples/get-version.sh';
|
||||
import resultApiReferenceApiExamplesResultGetVersion from '!!raw-loader!@site/docs/API-Reference/curl-examples/api-reference-api-examples/result-get-version.txt';
|
||||
import exampleApiReferenceApiExamplesGetConfiguration from '!!raw-loader!@site/docs/API-Reference/curl-examples/api-reference-api-examples/get-configuration.sh';
|
||||
import resultApiReferenceApiExamplesResultGetConfiguration from '!!raw-loader!@site/docs/API-Reference/curl-examples/api-reference-api-examples/result-get-configuration.json';
|
||||
import exampleApiReferenceApiExamplesGetAllComponents from '!!raw-loader!@site/docs/API-Reference/curl-examples/api-reference-api-examples/get-all-components.sh';
|
||||
import examplePythonApiReferenceApiExamplesFormLangflowApiRequests from '!!raw-loader!@site/docs/API-Reference/python-examples/api-reference-api-examples/form-langflow-api-requests.py';
|
||||
import exampleJavascriptApiReferenceApiExamplesFormLangflowApiRequests from '!!raw-loader!@site/docs/API-Reference/javascript-examples/api-reference-api-examples/form-langflow-api-requests.js';
|
||||
import examplePythonApiReferenceApiExamplesHealthCheck from '!!raw-loader!@site/docs/API-Reference/python-examples/api-reference-api-examples/health-check.py';
|
||||
import exampleJavascriptApiReferenceApiExamplesHealthCheck from '!!raw-loader!@site/docs/API-Reference/javascript-examples/api-reference-api-examples/health-check.js';
|
||||
import examplePythonApiReferenceApiExamplesGetVersion from '!!raw-loader!@site/docs/API-Reference/python-examples/api-reference-api-examples/get-version.py';
|
||||
import exampleJavascriptApiReferenceApiExamplesGetVersion from '!!raw-loader!@site/docs/API-Reference/javascript-examples/api-reference-api-examples/get-version.js';
|
||||
import examplePythonApiReferenceApiExamplesGetConfiguration from '!!raw-loader!@site/docs/API-Reference/python-examples/api-reference-api-examples/get-configuration.py';
|
||||
import exampleJavascriptApiReferenceApiExamplesGetConfiguration from '!!raw-loader!@site/docs/API-Reference/javascript-examples/api-reference-api-examples/get-configuration.js';
|
||||
import examplePythonApiReferenceApiExamplesGetAllComponents from '!!raw-loader!@site/docs/API-Reference/python-examples/api-reference-api-examples/get-all-components.py';
|
||||
import exampleJavascriptApiReferenceApiExamplesGetAllComponents from '!!raw-loader!@site/docs/API-Reference/javascript-examples/api-reference-api-examples/get-all-components.js';
|
||||
|
||||
|
||||
|
||||
import Tabs from '@theme/Tabs';
|
||||
import TabItem from '@theme/TabItem';
|
||||
|
||||
You can use the Langflow API for programmatic interactions with Langflow, such as the following:
|
||||
|
||||
* Create and edit flows, including file management for flows.
|
||||
* Develop applications that use your flows.
|
||||
* Develop custom components.
|
||||
* Build Langflow as a dependency of a larger application, codebase, or service.
|
||||
* Contribute to the overall Langflow codebase.
|
||||
|
||||
To view and test all available endpoints, you can access the Langflow API's OpenAPI specification at your Langflow deployment's `/docs` endpoint, such as `http://localhost:7860/docs`.
|
||||
|
||||
:::tip Try it
|
||||
For an example of the Langflow API in a script, see the [Langflow quickstart](/get-started-quickstart).
|
||||
|
||||
The quickstart demonstrates how to get automatically generated code snippets for your flows, use a script to run a flow, and extract data from the Langfow API response.
|
||||
:::
|
||||
|
||||
## Form Langflow API requests
|
||||
|
||||
While individual options vary by endpoint, all Langflow API requests share some commonalities, like a URL, method, parameters, and authentication.
|
||||
|
||||
As an example of a Langflow API request, the following curl command calls the `/v1/run` endpoint, and it passes a runtime override (`tweaks`) to the flow's **Chat Output** component:
|
||||
|
||||
<Tabs>
|
||||
<TabItem value="Python" label="Python" default>
|
||||
|
||||
<CodeSnippet source={examplePythonApiReferenceApiExamplesFormLangflowApiRequests} language="python" />
|
||||
|
||||
</TabItem>
|
||||
<TabItem value="JavaScript" label="JavaScript">
|
||||
|
||||
<CodeSnippet source={exampleJavascriptApiReferenceApiExamplesFormLangflowApiRequests} language="javascript" />
|
||||
|
||||
</TabItem>
|
||||
<TabItem value="curl" label="curl">
|
||||
|
||||
<CodeSnippet source={exampleApiReferenceApiExamplesFormLangflowApiRequests} language="bash" />
|
||||
|
||||
</TabItem>
|
||||
</Tabs>
|
||||
|
||||
### Base URL
|
||||
|
||||
By default, local deployments serve the Langflow API at `http://localhost:7860/api`.
|
||||
|
||||
Remotely hosted Langflow deployments are available at the domain set by the hosting service, such as `http://IP_OR_DNS/api` or `http://IP_OR_DNS:LANGFLOW_PORT/api`.
|
||||
|
||||
You can configure the Langflow port number in the `LANGFLOW_PORT` [environment variable](/environment-variables).
|
||||
|
||||
* `https://UUID.ngrok.app/api`
|
||||
* `http://IP_OR_DNS/api`
|
||||
* `http://IP_OR_DNS:LANGFLOW_PORT/api`
|
||||
|
||||
### Authentication
|
||||
|
||||
In Langflow versions 1.5 and later, most API endpoints require authentication with a Langflow API key in either an `x-api-key` header or query parameter.
|
||||
For more information, see [API keys and authentication](/api-keys-and-authentication).
|
||||
|
||||
As with any API, follow industry best practices for storing and referencing sensitive credentials.
|
||||
For example, you can [set environment variables](#set-environment-variables) for your API keys, and then reference those environment variables in your API requests.
|
||||
|
||||
### Methods, paths, and parameters
|
||||
|
||||
Langflow API requests use various methods, paths, path parameters, query parameters, and body parameters.
|
||||
The specific requirements and options depend on the endpoint that you want to call.
|
||||
|
||||
For example, to create a flow, you pass a JSON-formatted flow definition to `POST /v1/flows`.
|
||||
Then, to run your flow, you call `POST /v1/run/$FLOW_ID` with optional run parameters in the request body.
|
||||
|
||||
### API versions
|
||||
|
||||
The Langflow API serves `/v1` and `/v2` endpoints.
|
||||
|
||||
Some endpoints only exist under a single version and some exist under both the `/v1` and `/v2` versions.
|
||||
|
||||
If a request fails or has an unexpected result, make sure your endpoint path has the correct version.
|
||||
|
||||
## Set environment variables
|
||||
|
||||
You can store commonly used values in environment variables to facilitate reuse, simplify token rotation, and securely reference sensitive values.
|
||||
|
||||
You can use any method you prefer to set environment variables, such as `export`, `.env`, `zshrc`, or `.curlrc`.
|
||||
Then, reference those environment variables in your API requests.
|
||||
For example:
|
||||
|
||||
<CodeSnippet source={exampleApiReferenceApiExamplesSetEnvironmentVariables} language="bash" />
|
||||
|
||||
Commonly used values in Langflow API requests include your [Langflow server URL](#base-url), [Langflow API keys](#authentication), flow IDs, and [project IDs](/api-projects#read-projects).
|
||||
|
||||
You can retrieve flow IDs from the [**API access** pane](/concepts-publish#api-access), in a flow's URL, and with [`GET /flows`](/api-flows#read-flows).
|
||||
|
||||
## Try some Langflow API requests
|
||||
|
||||
Once you have your Langflow server URL, try calling these endpoints that return Langflow metadata.
|
||||
|
||||
### Health check
|
||||
|
||||
Returns the health status of the Langflow database and chat services:
|
||||
|
||||
<Tabs>
|
||||
<TabItem value="Python" label="Python" default>
|
||||
|
||||
<CodeSnippet source={examplePythonApiReferenceApiExamplesHealthCheck} language="python" />
|
||||
|
||||
</TabItem>
|
||||
<TabItem value="JavaScript" label="JavaScript">
|
||||
|
||||
<CodeSnippet source={exampleJavascriptApiReferenceApiExamplesHealthCheck} language="javascript" />
|
||||
|
||||
</TabItem>
|
||||
<TabItem value="curl" label="curl">
|
||||
|
||||
<CodeSnippet source={exampleApiReferenceApiExamplesHealthCheck} language="bash" />
|
||||
|
||||
</TabItem>
|
||||
</Tabs>
|
||||
|
||||
<details>
|
||||
<summary>Result</summary>
|
||||
|
||||
<CodeSnippet source={resultApiReferenceApiExamplesResultHealthCheck} language="json" />
|
||||
|
||||
</details>
|
||||
|
||||
Langflow provides an additional `GET /health` endpoint.
|
||||
This endpoint is served by uvicorn before Langflow is fully initialized, so it's not reliable for checking Langflow service health.
|
||||
|
||||
### Get version
|
||||
|
||||
Returns the current Langflow API version:
|
||||
|
||||
<Tabs>
|
||||
<TabItem value="Python" label="Python" default>
|
||||
|
||||
<CodeSnippet source={examplePythonApiReferenceApiExamplesGetVersion} language="python" />
|
||||
|
||||
</TabItem>
|
||||
<TabItem value="JavaScript" label="JavaScript">
|
||||
|
||||
<CodeSnippet source={exampleJavascriptApiReferenceApiExamplesGetVersion} language="javascript" />
|
||||
|
||||
</TabItem>
|
||||
<TabItem value="curl" label="curl">
|
||||
|
||||
<CodeSnippet source={exampleApiReferenceApiExamplesGetVersion} language="bash" />
|
||||
|
||||
</TabItem>
|
||||
</Tabs>
|
||||
|
||||
<details>
|
||||
<summary>Result</summary>
|
||||
|
||||
<CodeSnippet source={resultApiReferenceApiExamplesResultGetVersion} language="text" />
|
||||
|
||||
</details>
|
||||
|
||||
### Get configuration
|
||||
|
||||
Returns configuration details for your Langflow deployment.
|
||||
Requires a [Langflow API key](/api-keys-and-authentication).
|
||||
|
||||
<Tabs>
|
||||
<TabItem value="Python" label="Python" default>
|
||||
|
||||
<CodeSnippet source={examplePythonApiReferenceApiExamplesGetConfiguration} language="python" />
|
||||
|
||||
</TabItem>
|
||||
<TabItem value="JavaScript" label="JavaScript">
|
||||
|
||||
<CodeSnippet source={exampleJavascriptApiReferenceApiExamplesGetConfiguration} language="javascript" />
|
||||
|
||||
</TabItem>
|
||||
<TabItem value="curl" label="curl">
|
||||
|
||||
<CodeSnippet source={exampleApiReferenceApiExamplesGetConfiguration} language="bash" />
|
||||
|
||||
</TabItem>
|
||||
</Tabs>
|
||||
|
||||
<details>
|
||||
<summary>Result</summary>
|
||||
|
||||
<CodeSnippet source={resultApiReferenceApiExamplesResultGetConfiguration} language="json" />
|
||||
|
||||
</details>
|
||||
|
||||
### Get all components
|
||||
|
||||
Returns a dictionary of all Langflow components.
|
||||
Requires a [Langflow API key](/api-keys-and-authentication).
|
||||
|
||||
<Tabs>
|
||||
<TabItem value="Python" label="Python" default>
|
||||
|
||||
<CodeSnippet source={examplePythonApiReferenceApiExamplesGetAllComponents} language="python" />
|
||||
|
||||
</TabItem>
|
||||
<TabItem value="JavaScript" label="JavaScript">
|
||||
|
||||
<CodeSnippet source={exampleJavascriptApiReferenceApiExamplesGetAllComponents} language="javascript" />
|
||||
|
||||
</TabItem>
|
||||
<TabItem value="curl" label="curl">
|
||||
|
||||
<CodeSnippet source={exampleApiReferenceApiExamplesGetAllComponents} language="bash" />
|
||||
|
||||
</TabItem>
|
||||
</Tabs>
|
||||
|
||||
## Available endpoints
|
||||
|
||||
Because you can run Langflow as either an IDE (frontend and backend) or a runtime (headless, backend-only), it serves endpoints that support frontend and backend operations.
|
||||
Many endpoints are for orchestration between the frontend and backend, reading and writing to the Langflow database, or enabling frontend functionality, like the **Playground**.
|
||||
Unless you are contributing to the Langflow codebase, you won't directly call most of the Langflow endpoints.
|
||||
|
||||
For application development, the most commonly used endpoints are the `/run` and `/webhook` [flow trigger endpoints](/api-flows-run).
|
||||
For some use cases, you might use some other endpoints, such as the `/files` endpoints to use files in flows.
|
||||
|
||||
To help you explore the available endpoints, the following lists are sorted by primary use case, although some endpoints might support multiple use cases.
|
||||
|
||||
<Tabs>
|
||||
<TabItem value="Application development" label="Application development" default>
|
||||
|
||||
The following endpoints are useful for developing applications with Langflow and administering Langflow deployments with one or more users.
|
||||
You will most often use the flow trigger endpoints.
|
||||
Other endpoints are helpful for specific use cases, such as administration and flow management in runtime deployments that don't have a visual editor.
|
||||
|
||||
* [Flow trigger endpoints](/api-flows-run):
|
||||
* POST `/v1/run/{flow_id_or_name}`: Run a flow.
|
||||
* POST `/v1/run/advanced/{flow_id}`: Advanced run with explicit `inputs`, `outputs`, `tweaks`, and optional `session_id`.
|
||||
* POST `/v1/webhook/{flow_id_or_name}`: Trigger a flow via webhook payload.
|
||||
|
||||
* [OpenAI Responses API](/api-openai-responses):
|
||||
* POST `/v1/responses`: Execute flows using an OpenAI-compatible request format.
|
||||
|
||||
* Deployment details:
|
||||
* GET `/v1/version`: Return Langflow version. See [Get version](/api-reference-api-examples#get-version).
|
||||
* GET `/v1/config`: Return deployment configuration. See [Get configuration](/api-reference-api-examples#get-configuration).
|
||||
* GET `/health_check`: Health check endpoint that validates database and chat service connectivity. Returns 500 status if any service is unavailable.
|
||||
|
||||
* [Projects endpoints](/api-projects):
|
||||
* POST `/v1/projects/`: Create a project.
|
||||
* GET `/v1/projects/`: List projects.
|
||||
* GET `/v1/projects/{project_id}`: Read a project (with paginated flows support).
|
||||
* PATCH `/v1/projects/{project_id}`: Update project info and membership.
|
||||
* DELETE `/v1/projects/{project_id}`: Delete a project.
|
||||
* GET `/v1/projects/download/{project_id}`: Export all flows in a project as ZIP.
|
||||
* POST `/v1/projects/upload/`: Import a project ZIP (creates project and flows).
|
||||
* GET `/v1/starter-projects/`: Return a list of templates.
|
||||
|
||||
* [Files endpoints](/api-files):
|
||||
* Files (v1)
|
||||
* POST `/v1/files/upload/{flow_id}`: Upload a file to a specific flow.
|
||||
* GET `/v1/files/download/{flow_id}/{file_name}`: Download a file from a flow.
|
||||
* GET `/v1/files/images/{flow_id}/{file_name}`: Stream an image from a flow.
|
||||
* GET `/v1/files/profile_pictures/{folder_name}/{file_name}`: Get a profile picture asset.
|
||||
* GET `/v1/files/profile_pictures/list`: List available profile picture assets.
|
||||
* GET `/v1/files/list/{flow_id}`: List files for a flow.
|
||||
* DELETE `/v1/files/delete/{flow_id}/{file_name}`: Delete a file from a flow.
|
||||
* Files (v2)
|
||||
* POST `/v2/files` (alias `/v2/files/`): Upload a file owned by the current user.
|
||||
* GET `/v2/files` (alias `/v2/files/`): List files owned by the current user.
|
||||
* DELETE `/v2/files/batch/`: Delete multiple files by IDs.
|
||||
* POST `/v2/files/batch/`: Download multiple files as a ZIP by IDs.
|
||||
* GET `/v2/files/{file_id}`: Download a file by ID (or return raw content internally).
|
||||
* PUT `/v2/files/{file_id}`: Edit a file name by ID.
|
||||
* DELETE `/v2/files/{file_id}`: Delete a file by ID.
|
||||
* DELETE `/v2/files` (alias `/v2/files/`): Delete all files for the current user.
|
||||
|
||||
* [API keys and authentication](/api-keys-and-authentication):
|
||||
* GET `/v1/api_key/`: List API keys for the current user.
|
||||
* POST `/v1/api_key/`: Create a new API key.
|
||||
* DELETE `/v1/api_key/{api_key_id}`: Delete an API key.
|
||||
* POST `/v1/api_key/store`: Save an encrypted Store API key (cookie set).
|
||||
|
||||
* [Flow management endpoints](/api-flows):
|
||||
* POST `/v1/flows/`: Create a flow.
|
||||
* GET `/v1/flows/`: List flows (supports pagination and filters).
|
||||
* GET `/v1/flows/{flow_id}`: Read a flow by ID.
|
||||
* GET `/v1/flows/public_flow/{flow_id}`: Read a public flow by ID.
|
||||
* PATCH `/v1/flows/{flow_id}`: Update a flow.
|
||||
* DELETE `/v1/flows/{flow_id}`: Delete a flow.
|
||||
* POST `/v1/flows/batch/`: Create multiple flows.
|
||||
* POST `/v1/flows/upload/`: Import flows from a JSON file.
|
||||
* DELETE `/v1/flows/`: Delete multiple flows by IDs.
|
||||
* POST `/v1/flows/download/`: Export flows to a ZIP file.
|
||||
* GET `/v1/flows/basic_examples/`: List basic example flows.
|
||||
|
||||
* [Users endpoints](/api-users):
|
||||
* POST `/v1/users/`: Add a user (superuser required when auth enabled).
|
||||
* GET `/v1/users/whoami`: Return the current authenticated user.
|
||||
* GET `/v1/users/`: List all users (superuser required).
|
||||
* PATCH `/v1/users/{user_id}`: Update a user (with role checks).
|
||||
* PATCH `/v1/users/{user_id}/reset-password`: Reset own password.
|
||||
* DELETE `/v1/users/{user_id}`: Delete a user (cannot delete yourself).
|
||||
|
||||
* Custom components: You might use these endpoints when developing custom Langflow components for your own use or to share with the Langflow community:
|
||||
* GET `/v1/all`: Return all available Langflow component types. See [Get all components](/api-reference-api-examples#get-all-components).
|
||||
* POST `/v1/custom_component`: Build a custom component from code and return its node.
|
||||
* POST `/v1/custom_component/update`: Update an existing custom component's build config and outputs.
|
||||
* POST `/v1/validate/code`: Validate a Python code snippet for a custom component.
|
||||
* POST `/v1/validate/prompt`: Validate a prompt payload.
|
||||
|
||||
</TabItem>
|
||||
<TabItem value="Codebase contribution" label="Codebase development">
|
||||
|
||||
The following endpoints are most often used when contributing to the Langflow codebase, and you need to understand or call endpoints that support frontend-to-backend orchestration or other internal functionality.
|
||||
|
||||
* Base (metadata):
|
||||
* GET `/v1/all`: Return all available Langflow component types. See [Get all components](/api-reference-api-examples#get-all-components).
|
||||
* GET `/v1/version`: Return Langflow version. See [Get version](/api-reference-api-examples#get-version).
|
||||
* GET `/v1/config`: Return deployment configuration. See [Get configuration](/api-reference-api-examples#get-configuration).
|
||||
* GET `/v1/starter-projects/`: Return a list of templates.
|
||||
|
||||
* [Build endpoints](/api-build) (internal editor support):
|
||||
* POST `/v1/build/{flow_id}/flow`: Start a flow build and return a job ID.
|
||||
* GET `/v1/build/{job_id}/events`: Stream or fetch build events.
|
||||
* POST `/v1/build/{job_id}/cancel`: Cancel a build job.
|
||||
* POST `/v1/build_public_tmp/{flow_id}/flow`: Build a public flow without auth.
|
||||
* POST `/v1/validate/prompt`: Validate a prompt payload.
|
||||
|
||||
* [API keys and authentication](/api-keys-and-authentication):
|
||||
* POST `/v1/login`: Login and set tokens as cookies.
|
||||
* GET `/v1/auto_login`: Auto-login (if enabled) and set tokens.
|
||||
* POST `/v1/refresh`: Refresh tokens using refresh cookie.
|
||||
* POST `/v1/logout`: Logout and clear cookies.
|
||||
|
||||
* [Monitor endpoints](/api-monitor):
|
||||
* GET `/v1/monitor/builds`: Get vertex builds for a flow.
|
||||
* DELETE `/v1/monitor/builds`: Delete vertex builds for a flow.
|
||||
* GET `/v1/monitor/messages/sessions`: List message session IDs (auth required).
|
||||
* GET `/v1/monitor/messages`: List messages with optional filters.
|
||||
* DELETE `/v1/monitor/messages`: Delete messages by IDs (auth required).
|
||||
* PUT `/v1/monitor/messages/{message_id}`: Update a message.
|
||||
* PATCH `/v1/monitor/messages/session/{old_session_id}`: Change a session ID for all messages in that session.
|
||||
* DELETE `/v1/monitor/messages/session/{session_id}`: Delete messages by session.
|
||||
* GET `/v1/monitor/transactions`: List transactions for a flow (paginated).
|
||||
|
||||
* Variables:
|
||||
* POST `/v1/variables/`: Create a variable, such as an API key, for the user.
|
||||
* GET `/v1/variables/`: List variables for the user.
|
||||
* PATCH `/v1/variables/{variable_id}`: Update a variable.
|
||||
* DELETE `/v1/variables/{variable_id}`: Delete a variable.
|
||||
|
||||
* [Use voice mode](/concepts-voice-mode):
|
||||
* WS `/v1/voice/ws/flow_as_tool/{flow_id}`: Bi-directional voice session exposing the flow as a tool.
|
||||
* WS `/v1/voice/ws/flow_as_tool/{flow_id}/{session_id}`: Same as above with explicit session ID.
|
||||
* WS `/v1/voice/ws/flow_tts/{flow_id}`: Voice-to-text session that runs a flow and returns TTS.
|
||||
* WS `/v1/voice/ws/flow_tts/{flow_id}/{session_id}`: Same as above with explicit session ID.
|
||||
* GET `/v1/voice/elevenlabs/voice_ids`: List available ElevenLabs voice IDs for the user.
|
||||
|
||||
* MCP servers: The following endpoints are for managing Langflow MCP servers and MCP server connections.
|
||||
They aren't typically called directly; instead, they are used to drive internal functionality in the Langflow frontend and when running flows that call MCP servers.
|
||||
Langflow MCP servers support both streamable HTTP and SSE transport.
|
||||
* HEAD `/v1/mcp/streamable`: Health check for streamable HTTP MCP.
|
||||
* GET `/v1/mcp/streamable`: Open streamable HTTP connection for MCP server.
|
||||
* POST `/v1/mcp/streamable`: Post messages to the MCP server via streamable HTTP.
|
||||
* DELETE `/v1/mcp/streamable`: Close streamable HTTP connection.
|
||||
* HEAD `/v1/mcp/sse` (LEGACY): Health check for MCP SSE.
|
||||
* GET `/v1/mcp/sse` (LEGACY): Open SSE stream for MCP server events.
|
||||
* POST `/v1/mcp/` (LEGACY): Post messages to the MCP server.
|
||||
* GET `/v1/mcp/project/{project_id}`: List MCP-enabled tools and project auth settings.
|
||||
* HEAD `/v1/mcp/project/{project_id}/streamable`: Health check for project streamable HTTP MCP.
|
||||
* GET `/v1/mcp/project/{project_id}/streamable`: Open project-scoped streamable HTTP connection.
|
||||
* POST `/v1/mcp/project/{project_id}/streamable`: Post messages to project MCP server via streamable HTTP.
|
||||
* DELETE `/v1/mcp/project/{project_id}/streamable`: Close project streamable HTTP connection.
|
||||
* HEAD `/v1/mcp/project/{project_id}/sse` (LEGACY): Health check for project SSE.
|
||||
* GET `/v1/mcp/project/{project_id}/sse` (LEGACY): Open project-scoped MCP SSE.
|
||||
* POST `/v1/mcp/project/{project_id}` (LEGACY): Post messages to project MCP server.
|
||||
* PATCH `/v1/mcp/project/{project_id}`: Update MCP settings for flows and project auth settings.
|
||||
* POST `/v1/mcp/project/{project_id}/install`: Install MCP client config for Cursor/Windsurf/Claude (local only).
|
||||
* GET `/v1/mcp/project/{project_id}/installed`: Check which clients have MCP config installed.
|
||||
|
||||
* Custom components: You might use these endpoints when developing custom Langflow components for your own use or to share with the Langflow community:
|
||||
* GET `/v1/all`: Return all available Langflow component types. See [Get all components](/api-reference-api-examples#get-all-components).
|
||||
* POST `/v1/custom_component`: Build a custom component from code and return its node.
|
||||
* POST `/v1/custom_component/update`: Update an existing custom component's build config and outputs.
|
||||
* POST `/v1/validate/code`: Validate a Python code snippet for a custom component.
|
||||
* POST `/v1/validate/prompt`: Validate a prompt payload.
|
||||
|
||||
</TabItem>
|
||||
<TabItem value="Deprecated" label="Deprecated">
|
||||
|
||||
The following endpoints are deprecated:
|
||||
|
||||
* POST `/v1/predict/{flow_id}`: Use [`/v1/run/{flow_id}`](/api-flows-run) instead.
|
||||
* POST `/v1/process/{flow_id}`: Use [`/v1/run/{flow_id}`](/api-flows-run) instead.
|
||||
* GET `/v1/task/{task_id}`: Deprecated functionality.
|
||||
* POST `/v1/upload/{flow_id}`: Use [`/files`](/api-files) instead.
|
||||
* POST `/v1/build/{flow_id}/vertices`: Replaced by [`/monitor/builds`](/api-monitor).
|
||||
* POST `/v1/build/{flow_id}/vertices/{vertex_id}`: Replaced by [`/monitor/builds`](/api-monitor).
|
||||
* GET `/v1/build/{flow_id}/{vertex_id}/stream`: Replaced by [`/monitor/builds`](/api-monitor).
|
||||
* GET `/v1/store/check/`: Return whether the Store feature is enabled.
|
||||
* GET `/v1/store/check/api_key`: Check if a Store API key exists and is valid.
|
||||
* POST `/v1/store/components/`: Share a component to the Store.
|
||||
* PATCH `/v1/store/components/{component_id}`: Update a shared component.
|
||||
* GET `/v1/store/components/`: List available Store components (filters supported).
|
||||
* GET `/v1/store/components/{component_id}`: Download a component from the Store.
|
||||
* GET `/v1/store/tags`: List Store tags.
|
||||
* GET `/v1/store/users/likes`: List components liked by the current user.
|
||||
* POST `/v1/store/users/likes/{component_id}`: Like a component.
|
||||
|
||||
</TabItem>
|
||||
</Tabs>
|
||||
|
||||
## Next steps
|
||||
|
||||
* Use the Langflow API to [run a flow](/api-flows-run).
|
||||
* Use the Langflow API to [upload files](/api-files).
|
||||
* Use the Langflow API to [get flow logs](/api-logs).
|
||||
* Explore all endpoints in the [Langflow API specification](/api).
|
||||
225
docs/versioned_docs/version-1.9.0/API-Reference/api-users.mdx
Normal file
225
docs/versioned_docs/version-1.9.0/API-Reference/api-users.mdx
Normal file
@ -0,0 +1,225 @@
|
||||
---
|
||||
title: Users endpoints
|
||||
slug: /api-users
|
||||
---
|
||||
import CodeSnippet from '@site/src/components/CodeSnippet';
|
||||
import exampleApiUsersAddUser from '!!raw-loader!@site/docs/API-Reference/curl-examples/api-users/add-user.sh';
|
||||
import resultApiUsersResultAddUser from '!!raw-loader!@site/docs/API-Reference/curl-examples/api-users/result-add-user.json';
|
||||
import exampleApiUsersGetCurrentUser from '!!raw-loader!@site/docs/API-Reference/curl-examples/api-users/get-current-user.sh';
|
||||
import resultApiUsersResultGetCurrentUser from '!!raw-loader!@site/docs/API-Reference/curl-examples/api-users/result-get-current-user.json';
|
||||
import exampleApiUsersListAllUsers from '!!raw-loader!@site/docs/API-Reference/curl-examples/api-users/list-all-users.sh';
|
||||
import resultApiUsersResultListAllUsers from '!!raw-loader!@site/docs/API-Reference/curl-examples/api-users/result-list-all-users.json';
|
||||
import exampleApiUsersUpdateUser from '!!raw-loader!@site/docs/API-Reference/curl-examples/api-users/update-user.sh';
|
||||
import resultApiUsersResultUpdateUser from '!!raw-loader!@site/docs/API-Reference/curl-examples/api-users/result-update-user.json';
|
||||
import exampleApiUsersResetPassword from '!!raw-loader!@site/docs/API-Reference/curl-examples/api-users/reset-password.sh';
|
||||
import resultApiUsersResultResetPassword from '!!raw-loader!@site/docs/API-Reference/curl-examples/api-users/result-reset-password.json';
|
||||
import exampleApiUsersDeleteUser from '!!raw-loader!@site/docs/API-Reference/curl-examples/api-users/delete-user.sh';
|
||||
import resultApiUsersResultDeleteUser from '!!raw-loader!@site/docs/API-Reference/curl-examples/api-users/result-delete-user.json';
|
||||
import Tabs from '@theme/Tabs';
|
||||
import TabItem from '@theme/TabItem';
|
||||
import examplePythonApiUsersAddUser from '!!raw-loader!@site/docs/API-Reference/python-examples/api-users/add-user.py';
|
||||
import exampleJavascriptApiUsersAddUser from '!!raw-loader!@site/docs/API-Reference/javascript-examples/api-users/add-user.js';
|
||||
import examplePythonApiUsersGetCurrentUser from '!!raw-loader!@site/docs/API-Reference/python-examples/api-users/get-current-user.py';
|
||||
import exampleJavascriptApiUsersGetCurrentUser from '!!raw-loader!@site/docs/API-Reference/javascript-examples/api-users/get-current-user.js';
|
||||
import examplePythonApiUsersListAllUsers from '!!raw-loader!@site/docs/API-Reference/python-examples/api-users/list-all-users.py';
|
||||
import exampleJavascriptApiUsersListAllUsers from '!!raw-loader!@site/docs/API-Reference/javascript-examples/api-users/list-all-users.js';
|
||||
import examplePythonApiUsersUpdateUser from '!!raw-loader!@site/docs/API-Reference/python-examples/api-users/update-user.py';
|
||||
import exampleJavascriptApiUsersUpdateUser from '!!raw-loader!@site/docs/API-Reference/javascript-examples/api-users/update-user.js';
|
||||
import examplePythonApiUsersResetPassword from '!!raw-loader!@site/docs/API-Reference/python-examples/api-users/reset-password.py';
|
||||
import exampleJavascriptApiUsersResetPassword from '!!raw-loader!@site/docs/API-Reference/javascript-examples/api-users/reset-password.js';
|
||||
import examplePythonApiUsersDeleteUser from '!!raw-loader!@site/docs/API-Reference/python-examples/api-users/delete-user.py';
|
||||
import exampleJavascriptApiUsersDeleteUser from '!!raw-loader!@site/docs/API-Reference/javascript-examples/api-users/delete-user.js';
|
||||
|
||||
|
||||
|
||||
Use the `/users` endpoint to manage user accounts in Langflow.
|
||||
|
||||
## Add user
|
||||
|
||||
Create a new user account with a given username and password.
|
||||
|
||||
Requires authentication as a superuser if the Langflow server has authentication enabled.
|
||||
|
||||
<Tabs>
|
||||
<TabItem value="Python" label="Python" default>
|
||||
|
||||
<CodeSnippet source={examplePythonApiUsersAddUser} language="python" />
|
||||
|
||||
</TabItem>
|
||||
<TabItem value="JavaScript" label="JavaScript">
|
||||
|
||||
<CodeSnippet source={exampleJavascriptApiUsersAddUser} language="javascript" />
|
||||
|
||||
</TabItem>
|
||||
<TabItem value="curl" label="curl">
|
||||
|
||||
<CodeSnippet source={exampleApiUsersAddUser} language="bash" />
|
||||
|
||||
</TabItem>
|
||||
</Tabs>
|
||||
|
||||
The request returns an object describing the new user.
|
||||
The user's UUID is stored in `user_id` in the Langflow database, and returned as `id` in the `/users` API response.
|
||||
This `user_id` key is specifically for Langflow user management.
|
||||
|
||||
<details>
|
||||
<summary>Result</summary>
|
||||
|
||||
<CodeSnippet source={resultApiUsersResultAddUser} language="json" />
|
||||
|
||||
</details>
|
||||
|
||||
## Get current user
|
||||
|
||||
Retrieve information about the authenticated user.
|
||||
|
||||
<Tabs>
|
||||
<TabItem value="Python" label="Python" default>
|
||||
|
||||
<CodeSnippet source={examplePythonApiUsersGetCurrentUser} language="python" />
|
||||
|
||||
</TabItem>
|
||||
<TabItem value="JavaScript" label="JavaScript">
|
||||
|
||||
<CodeSnippet source={exampleJavascriptApiUsersGetCurrentUser} language="javascript" />
|
||||
|
||||
</TabItem>
|
||||
<TabItem value="curl" label="curl">
|
||||
|
||||
<CodeSnippet source={exampleApiUsersGetCurrentUser} language="bash" />
|
||||
|
||||
</TabItem>
|
||||
</Tabs>
|
||||
|
||||
<details>
|
||||
<summary>Result</summary>
|
||||
|
||||
<CodeSnippet source={resultApiUsersResultGetCurrentUser} language="json" />
|
||||
|
||||
</details>
|
||||
|
||||
## List all users
|
||||
|
||||
Get a paginated list of all users in the system.
|
||||
|
||||
Requires authentication as a superuser if the Langflow server has authentication enabled.
|
||||
|
||||
<Tabs>
|
||||
<TabItem value="Python" label="Python" default>
|
||||
|
||||
<CodeSnippet source={examplePythonApiUsersListAllUsers} language="python" />
|
||||
|
||||
</TabItem>
|
||||
<TabItem value="JavaScript" label="JavaScript">
|
||||
|
||||
<CodeSnippet source={exampleJavascriptApiUsersListAllUsers} language="javascript" />
|
||||
|
||||
</TabItem>
|
||||
<TabItem value="curl" label="curl">
|
||||
|
||||
<CodeSnippet source={exampleApiUsersListAllUsers} language="bash" />
|
||||
|
||||
</TabItem>
|
||||
</Tabs>
|
||||
|
||||
<details>
|
||||
<summary>Result</summary>
|
||||
|
||||
<CodeSnippet source={resultApiUsersResultListAllUsers} language="json" />
|
||||
|
||||
</details>
|
||||
|
||||
## Update user
|
||||
|
||||
Modify an existing user's information with a PATCH request.
|
||||
|
||||
Requires authentication as a superuser if the Langflow server has authentication enabled.
|
||||
|
||||
This example activates the specified user's account and makes them a superuser:
|
||||
|
||||
<Tabs>
|
||||
<TabItem value="Python" label="Python" default>
|
||||
|
||||
<CodeSnippet source={examplePythonApiUsersUpdateUser} language="python" />
|
||||
|
||||
</TabItem>
|
||||
<TabItem value="JavaScript" label="JavaScript">
|
||||
|
||||
<CodeSnippet source={exampleJavascriptApiUsersUpdateUser} language="javascript" />
|
||||
|
||||
</TabItem>
|
||||
<TabItem value="curl" label="curl">
|
||||
|
||||
<CodeSnippet source={exampleApiUsersUpdateUser} language="bash" />
|
||||
|
||||
</TabItem>
|
||||
</Tabs>
|
||||
|
||||
<details>
|
||||
<summary>Result</summary>
|
||||
|
||||
<CodeSnippet source={resultApiUsersResultUpdateUser} language="json" />
|
||||
|
||||
</details>
|
||||
|
||||
## Reset password
|
||||
|
||||
Change the specified user's password to a new secure value.
|
||||
|
||||
Requires authentication as the target user.
|
||||
|
||||
<Tabs>
|
||||
<TabItem value="Python" label="Python" default>
|
||||
|
||||
<CodeSnippet source={examplePythonApiUsersResetPassword} language="python" />
|
||||
|
||||
</TabItem>
|
||||
<TabItem value="JavaScript" label="JavaScript">
|
||||
|
||||
<CodeSnippet source={exampleJavascriptApiUsersResetPassword} language="javascript" />
|
||||
|
||||
</TabItem>
|
||||
<TabItem value="curl" label="curl">
|
||||
|
||||
<CodeSnippet source={exampleApiUsersResetPassword} language="bash" />
|
||||
|
||||
</TabItem>
|
||||
</Tabs>
|
||||
|
||||
<details>
|
||||
<summary>Result</summary>
|
||||
|
||||
<CodeSnippet source={resultApiUsersResultResetPassword} language="json" />
|
||||
|
||||
</details>
|
||||
|
||||
## Delete user
|
||||
|
||||
Remove a user account from the system.
|
||||
|
||||
Requires authentication as a superuser if the Langflow server has authentication enabled.
|
||||
|
||||
<Tabs>
|
||||
<TabItem value="Python" label="Python" default>
|
||||
|
||||
<CodeSnippet source={examplePythonApiUsersDeleteUser} language="python" />
|
||||
|
||||
</TabItem>
|
||||
<TabItem value="JavaScript" label="JavaScript">
|
||||
|
||||
<CodeSnippet source={exampleJavascriptApiUsersDeleteUser} language="javascript" />
|
||||
|
||||
</TabItem>
|
||||
<TabItem value="curl" label="curl">
|
||||
|
||||
<CodeSnippet source={exampleApiUsersDeleteUser} language="bash" />
|
||||
|
||||
</TabItem>
|
||||
</Tabs>
|
||||
|
||||
<details>
|
||||
<summary>Result</summary>
|
||||
|
||||
<CodeSnippet source={resultApiUsersResultDeleteUser} language="json" />
|
||||
|
||||
</details>
|
||||
@ -0,0 +1,4 @@
|
||||
curl -X GET \
|
||||
"$LANGFLOW_URL/api/v1/build/123e4567-e89b-12d3-a456-426614174000/events" \
|
||||
-H "accept: application/json" \
|
||||
-H "x-api-key: $LANGFLOW_API_KEY"
|
||||
@ -0,0 +1,4 @@
|
||||
curl -X GET \
|
||||
"$LANGFLOW_URL/api/v1/build/123e4567-e89b-12d3-a456-426614174000/events?stream=false" \
|
||||
-H "accept: application/json" \
|
||||
-H "x-api-key: $LANGFLOW_API_KEY"
|
||||
@ -0,0 +1,10 @@
|
||||
curl -X POST \
|
||||
"$LANGFLOW_URL/api/v1/build/$FLOW_ID/flow" \
|
||||
-H "accept: application/json" \
|
||||
-H "Content-Type: application/json" \
|
||||
-H "x-api-key: $LANGFLOW_API_KEY" \
|
||||
-d '{
|
||||
"inputs": {
|
||||
"input_value": "Tell me a story"
|
||||
}
|
||||
}'
|
||||
@ -0,0 +1,15 @@
|
||||
curl -X POST \
|
||||
"$LANGFLOW_URL/api/v1/build/$FLOW_ID/flow" \
|
||||
-H "accept: application/json" \
|
||||
-H "Content-Type: application/json" \
|
||||
-H "x-api-key: $LANGFLOW_API_KEY" \
|
||||
-d '{
|
||||
"data": {
|
||||
"nodes": [],
|
||||
"edges": []
|
||||
},
|
||||
"inputs": {
|
||||
"input_value": "Your custom input here",
|
||||
"session": "session_id"
|
||||
}
|
||||
}'
|
||||
@ -0,0 +1,7 @@
|
||||
{"event": "vertices_sorted", "data": {"ids": ["ChatInput-XtBLx"], "to_run": ["Prompt-x74Ze", "ChatOutput-ylMzN", "ChatInput-XtBLx", "OpenAIModel-d1wOZ"]}}
|
||||
|
||||
{"event": "add_message", "data": {"timestamp": "2025-03-03T17:42:23", "sender": "User", "sender_name": "User", "session_id": "d2bbd92b-187e-4c84-b2d4-5df365704201", "text": "Tell me a story", "files": [], "error": false, "edit": false, "properties": {"text_color": "", "background_color": "", "edited": false, "source": {"id": null, "display_name": null, "source": null}, "icon": "", "allow_markdown": false, "positive_feedback": null, "state": "complete", "targets": []}, "category": "message", "content_blocks": [], "id": "28879bd8-6a68-4dd5-b658-74d643a4dd92", "flow_id": "d2bbd92b-187e-4c84-b2d4-5df365704201"}}
|
||||
|
||||
// ... Additional events as the flow executes ...
|
||||
|
||||
{"event": "end", "data": {}}
|
||||
@ -0,0 +1,3 @@
|
||||
{
|
||||
"job_id": "123e4567-e89b-12d3-a456-426614174000"
|
||||
}
|
||||
@ -0,0 +1 @@
|
||||
{ "job_id": "0bcc7f23-40b4-4bfa-9b8a-a44181fd1175" }
|
||||
@ -0,0 +1,6 @@
|
||||
curl -X POST \
|
||||
"$LANGFLOW_URL/api/v1/build/$FLOW_ID/flow" \
|
||||
-H "accept: application/json" \
|
||||
-H "Content-Type: application/json" \
|
||||
-H "x-api-key: $LANGFLOW_API_KEY" \
|
||||
-d '{"stop_component_id": "OpenAIModel-Uksag"}'
|
||||
@ -0,0 +1,4 @@
|
||||
curl -X DELETE \
|
||||
"$LANGFLOW_URL/api/v2/files" \
|
||||
-H "accept: application/json" \
|
||||
-H "x-api-key: $LANGFLOW_API_KEY"
|
||||
@ -0,0 +1,4 @@
|
||||
curl -X DELETE \
|
||||
"$LANGFLOW_URL/api/v1/files/delete/$FLOW_ID/2024-12-30_15-19-43_your_file.txt" \
|
||||
-H "accept: application/json" \
|
||||
-H "x-api-key: $LANGFLOW_API_KEY"
|
||||
@ -0,0 +1,4 @@
|
||||
curl -X DELETE \
|
||||
"$LANGFLOW_URL/api/v2/files/$FILE_ID" \
|
||||
-H "accept: application/json" \
|
||||
-H "x-api-key: $LANGFLOW_API_KEY"
|
||||
@ -0,0 +1,5 @@
|
||||
curl -X GET \
|
||||
"$LANGFLOW_URL/api/v1/files/download/$FLOW_ID/2024-12-30_15-19-43_your_file.txt" \
|
||||
-H "accept: application/json" \
|
||||
-H "x-api-key: $LANGFLOW_API_KEY" \
|
||||
--output downloaded_file.txt
|
||||
@ -0,0 +1,5 @@
|
||||
curl -X GET \
|
||||
"$LANGFLOW_URL/api/v2/files/c7b22c4c-d5e0-4ec9-af97-5d85b7657a34" \
|
||||
-H "accept: application/json" \
|
||||
-H "x-api-key: $LANGFLOW_API_KEY" \
|
||||
--output downloaded_file.txt
|
||||
@ -0,0 +1,4 @@
|
||||
curl -X PUT \
|
||||
"$LANGFLOW_URL/api/v2/files/$FILE_ID?name=new_file_name" \
|
||||
-H "accept: application/json" \
|
||||
-H "x-api-key: $LANGFLOW_API_KEY"
|
||||
@ -0,0 +1,4 @@
|
||||
curl -X GET \
|
||||
"$LANGFLOW_URL/api/v1/files/list/$FLOW_ID" \
|
||||
-H "accept: application/json" \
|
||||
-H "x-api-key: $LANGFLOW_API_KEY"
|
||||
@ -0,0 +1,4 @@
|
||||
curl -X GET \
|
||||
"$LANGFLOW_URL/api/v2/files" \
|
||||
-H "accept: application/json" \
|
||||
-H "x-api-key: $LANGFLOW_API_KEY"
|
||||
@ -0,0 +1,3 @@
|
||||
{
|
||||
"message": "All files deleted successfully"
|
||||
}
|
||||
@ -0,0 +1,3 @@
|
||||
{
|
||||
"message": "File 2024-12-30_15-19-43_your_file.txt deleted successfully"
|
||||
}
|
||||
@ -0,0 +1,3 @@
|
||||
{
|
||||
"message": "File deleted successfully"
|
||||
}
|
||||
@ -0,0 +1 @@
|
||||
File contents downloaded to downloaded_file.txt
|
||||
@ -0,0 +1 @@
|
||||
File contents downloaded to downloaded_file.txt
|
||||
@ -0,0 +1,7 @@
|
||||
{
|
||||
"id": "76543e40-f388-4cb3-b0ee-a1e870aca3d3",
|
||||
"name": "new_file_name",
|
||||
"path": "6f17a73e-97d7-4519-a8d9-8e4c0be411bb/76543e40-f388-4cb3-b0ee-a1e870aca3d3.png",
|
||||
"size": 2728251,
|
||||
"provider": null
|
||||
}
|
||||
@ -0,0 +1,3 @@
|
||||
{
|
||||
"files": ["2024-12-30_15-19-43_your_file.txt"]
|
||||
}
|
||||
@ -0,0 +1,9 @@
|
||||
[
|
||||
{
|
||||
"id": "c7b22c4c-d5e0-4ec9-af97-5d85b7657a34",
|
||||
"name": "your_file",
|
||||
"path": "6f17a73e-97d7-4519-a8d9-8e4c0be411bb/c7b22c4c-d5e0-4ec9-af97-5d85b7657a34.txt",
|
||||
"size": 1234,
|
||||
"provider": null
|
||||
}
|
||||
]
|
||||
@ -0,0 +1,4 @@
|
||||
{
|
||||
"flowId": "92f9a4c5-cfc8-4656-ae63-1f0881163c28",
|
||||
"file_path": "92f9a4c5-cfc8-4656-ae63-1f0881163c28/2024-12-30_15-19-43_your_file.txt"
|
||||
}
|
||||
@ -0,0 +1 @@
|
||||
{"id":"07e5b864-e367-4f52-b647-a48035ae7e5e","username":"langflow","profile_image":null,"store_api_key":null,"is_active":true,"is_superuser":true,"create_at":"2025-05-08T17:59:07.855965","updated_at":"2025-05-28T19:00:42.556460","last_login_at":"2025-05-28T19:00:42.554338","optins":{"github_starred":false,"dialog_dismissed":true,"discord_clicked":false,"mcp_dialog_dismissed":true}}
|
||||
@ -0,0 +1,16 @@
|
||||
curl --request POST \
|
||||
--url "$LANGFLOW_URL/api/v1/run/$FLOW_ID" \
|
||||
--header "Content-Type: application/json" \
|
||||
--header "x-api-key: $LANGFLOW_API_KEY" \
|
||||
--data '{
|
||||
"input_value": "what do you see?",
|
||||
"output_type": "chat",
|
||||
"input_type": "text",
|
||||
"tweaks": {
|
||||
"Read-File-1olS3": {
|
||||
"path": [
|
||||
"07e5b864-e367-4f52-b647-a48035ae7e5e/3a290013-fe1e-4d3d-a454-cacae81288f3.pdf"
|
||||
]
|
||||
}
|
||||
}
|
||||
}'
|
||||
@ -0,0 +1,10 @@
|
||||
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
|
||||
DEFAULT_UPLOAD_FILE="$SCRIPT_DIR/../../fixtures/sample-upload.txt"
|
||||
UPLOAD_FILE="${SAMPLE_UPLOAD_FILE:-$DEFAULT_UPLOAD_FILE}"
|
||||
|
||||
curl -X POST \
|
||||
"$LANGFLOW_URL/api/v2/files" \
|
||||
-H "accept: application/json" \
|
||||
-H "Content-Type: multipart/form-data" \
|
||||
-H "x-api-key: $LANGFLOW_API_KEY" \
|
||||
-F "file=@${UPLOAD_FILE}"
|
||||
@ -0,0 +1,10 @@
|
||||
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
|
||||
DEFAULT_UPLOAD_FILE="$SCRIPT_DIR/../../fixtures/sample-upload.txt"
|
||||
UPLOAD_FILE="${SAMPLE_UPLOAD_FILE:-$DEFAULT_UPLOAD_FILE}"
|
||||
|
||||
curl -X POST \
|
||||
"$LANGFLOW_URL/api/v1/files/upload/$FLOW_ID" \
|
||||
-H "accept: application/json" \
|
||||
-H "Content-Type: multipart/form-data" \
|
||||
-H "x-api-key: $LANGFLOW_API_KEY" \
|
||||
-F "file=@${UPLOAD_FILE}"
|
||||
@ -0,0 +1,10 @@
|
||||
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
|
||||
DEFAULT_UPLOAD_FILE="$SCRIPT_DIR/../../fixtures/sample-upload.txt"
|
||||
UPLOAD_FILE="${SAMPLE_UPLOAD_FILE:-$DEFAULT_UPLOAD_FILE}"
|
||||
|
||||
curl -X POST \
|
||||
"$LANGFLOW_URL/api/v2/files" \
|
||||
-H "accept: application/json" \
|
||||
-H "Content-Type: multipart/form-data" \
|
||||
-H "x-api-key: $LANGFLOW_API_KEY" \
|
||||
-F "file=@${UPLOAD_FILE}"
|
||||
@ -0,0 +1,4 @@
|
||||
curl -X GET \
|
||||
"$LANGFLOW_URL/api/v1/users/whoami" \
|
||||
-H "accept: application/json" \
|
||||
-H "x-api-key: $LANGFLOW_API_KEY"
|
||||
@ -0,0 +1,14 @@
|
||||
curl -X POST \
|
||||
"$LANGFLOW_URL/api/v1/run/a430cc57-06bb-4c11-be39-d3d4de68d2c4?stream=false" \
|
||||
-H "Content-Type: application/json" \
|
||||
-H "x-api-key: $LANGFLOW_API_KEY" \
|
||||
-d '{
|
||||
"output_type": "chat",
|
||||
"input_type": "chat",
|
||||
"tweaks": {
|
||||
"ChatInput-b67sL": {
|
||||
"files": "a430cc57-06bb-4c11-be39-d3d4de68d2c4/2024-11-27_14-47-50_image-file.png",
|
||||
"input_value": "describe this image"
|
||||
}
|
||||
}
|
||||
}'
|
||||
@ -0,0 +1,8 @@
|
||||
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
|
||||
DEFAULT_IMAGE_FILE="$SCRIPT_DIR/../../fixtures/sample-upload.png"
|
||||
IMAGE_FILE="${SAMPLE_IMAGE_FILE:-$DEFAULT_IMAGE_FILE}"
|
||||
|
||||
curl -X POST "$LANGFLOW_URL/api/v1/files/upload/$FLOW_ID" \
|
||||
-H "Content-Type: multipart/form-data" \
|
||||
-H "x-api-key: $LANGFLOW_API_KEY" \
|
||||
-F "file=@${IMAGE_FILE}"
|
||||
@ -0,0 +1,12 @@
|
||||
curl -X POST \
|
||||
"$LANGFLOW_SERVER_URL/api/v1/run/$FLOW_ID" \
|
||||
-H "Content-Type: application/json" \
|
||||
-H "x-api-key: $LANGFLOW_API_KEY" \
|
||||
-H "X-LANGFLOW-GLOBAL-VAR-OPENAI_API_KEY: sk-..." \
|
||||
-H "X-LANGFLOW-GLOBAL-VAR-USER_ID: user123" \
|
||||
-H "X-LANGFLOW-GLOBAL-VAR-ENVIRONMENT: production" \
|
||||
-d '{
|
||||
"input_value": "Tell me about something interesting!",
|
||||
"input_type": "chat",
|
||||
"output_type": "chat"
|
||||
}'
|
||||
@ -0,0 +1,17 @@
|
||||
curl -X POST \
|
||||
"$LANGFLOW_SERVER_URL/api/v1/run/$FLOW_ID?stream=true" \
|
||||
-H "Content-Type: application/json" \
|
||||
-H "accept: application/json" \
|
||||
-H "x-api-key: $LANGFLOW_API_KEY" \
|
||||
-d '{
|
||||
"input_value": "Tell me a story",
|
||||
"input_type": "chat",
|
||||
"output_type": "chat",
|
||||
"output_component": "chat_output",
|
||||
"session_id": "chat-123",
|
||||
"tweaks": {
|
||||
"component_id": {
|
||||
"parameter_name": "value"
|
||||
}
|
||||
}
|
||||
}'
|
||||
@ -0,0 +1,4 @@
|
||||
{
|
||||
"message": "Task started in the background",
|
||||
"status": "in progress"
|
||||
}
|
||||
@ -0,0 +1,11 @@
|
||||
curl -X POST \
|
||||
"$LANGFLOW_SERVER_URL/api/v1/run/$FLOW_ID" \
|
||||
-H "Content-Type: application/json" \
|
||||
-H "x-api-key: $LANGFLOW_API_KEY" \
|
||||
-d '{
|
||||
"input_value": "Tell me about something interesting!",
|
||||
"session_id": "chat-123",
|
||||
"input_type": "chat",
|
||||
"output_type": "chat",
|
||||
"output_component": ""
|
||||
}'
|
||||
@ -0,0 +1,9 @@
|
||||
curl -X POST \
|
||||
"$LANGFLOW_SERVER_URL/api/v1/run/$FLOW_ID?stream=true" \
|
||||
-H "accept: application/json" \
|
||||
-H "Content-Type: application/json" \
|
||||
-H "x-api-key: $LANGFLOW_API_KEY" \
|
||||
-d '{
|
||||
"message": "Tell me something interesting!",
|
||||
"session_id": "chat-123"
|
||||
}'
|
||||
@ -0,0 +1,5 @@
|
||||
curl -X POST \
|
||||
"$LANGFLOW_SERVER_URL/api/v1/webhook/$FLOW_ID" \
|
||||
-H "Content-Type: application/json" \
|
||||
-H "x-api-key: $LANGFLOW_API_KEY" \
|
||||
-d '{"data": "example-data"}'
|
||||
@ -0,0 +1,20 @@
|
||||
curl -X POST \
|
||||
"$LANGFLOW_URL/api/v1/flows/" \
|
||||
-H "accept: application/json" \
|
||||
-H "Content-Type: application/json" \
|
||||
-H "x-api-key: $LANGFLOW_API_KEY" \
|
||||
-d '{
|
||||
"name": "string2",
|
||||
"description": "string",
|
||||
"icon": "string",
|
||||
"icon_bg_color": "#FF0000",
|
||||
"gradient": "string",
|
||||
"data": {},
|
||||
"is_component": false,
|
||||
"updated_at": "2024-12-30T15:48:01.519Z",
|
||||
"webhook": false,
|
||||
"endpoint_name": "string",
|
||||
"tags": [
|
||||
"string"
|
||||
]
|
||||
}'
|
||||
@ -0,0 +1,45 @@
|
||||
curl -X POST \
|
||||
"$LANGFLOW_URL/api/v1/flows/batch/" \
|
||||
-H "accept: application/json" \
|
||||
-H "Content-Type: application/json" \
|
||||
-H "x-api-key: $LANGFLOW_API_KEY" \
|
||||
-d '{
|
||||
"flows": [
|
||||
{
|
||||
"name": "string",
|
||||
"description": "string",
|
||||
"icon": "string",
|
||||
"icon_bg_color": "string",
|
||||
"gradient": "string",
|
||||
"data": {},
|
||||
"is_component": false,
|
||||
"updated_at": "2024-12-30T18:36:02.737Z",
|
||||
"webhook": false,
|
||||
"endpoint_name": "string",
|
||||
"tags": [
|
||||
"string"
|
||||
],
|
||||
"locked": false,
|
||||
"user_id": "3fa85f64-5717-4562-b3fc-2c963f66afa6",
|
||||
"project_id": "3fa85f64-5717-4562-b3fc-2c963f66afa6"
|
||||
},
|
||||
{
|
||||
"name": "string",
|
||||
"description": "string",
|
||||
"icon": "string",
|
||||
"icon_bg_color": "string",
|
||||
"gradient": "string",
|
||||
"data": {},
|
||||
"is_component": false,
|
||||
"updated_at": "2024-12-30T18:36:02.737Z",
|
||||
"webhook": false,
|
||||
"endpoint_name": "string",
|
||||
"tags": [
|
||||
"string"
|
||||
],
|
||||
"locked": false,
|
||||
"user_id": "3fa85f64-5717-4562-b3fc-2c963f66afa6",
|
||||
"project_id": "3fa85f64-5717-4562-b3fc-2c963f66afa6"
|
||||
}
|
||||
]
|
||||
}'
|
||||
@ -0,0 +1,4 @@
|
||||
curl -X DELETE \
|
||||
"$LANGFLOW_URL/api/v1/flows/$FLOW_ID" \
|
||||
-H "accept: application/json" \
|
||||
-H "x-api-key: $LANGFLOW_API_KEY"
|
||||
@ -0,0 +1,10 @@
|
||||
curl -X POST \
|
||||
"$LANGFLOW_URL/api/v1/flows/download/" \
|
||||
-H "accept: application/json" \
|
||||
-H "Content-Type: application/json" \
|
||||
-H "x-api-key: $LANGFLOW_API_KEY" \
|
||||
-d '[
|
||||
"e1e40c77-0541-41a9-88ab-ddb3419398b5",
|
||||
"92f9a4c5-cfc8-4656-ae63-1f0881163c28"
|
||||
]' \
|
||||
--output langflow-flows.zip
|
||||
@ -0,0 +1,10 @@
|
||||
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
|
||||
DEFAULT_FLOW_IMPORT_FILE="$SCRIPT_DIR/../../fixtures/flow-import.json"
|
||||
FLOW_IMPORT_FILE="${FLOW_IMPORT_FILE:-$DEFAULT_FLOW_IMPORT_FILE}"
|
||||
|
||||
curl -X POST \
|
||||
"$LANGFLOW_URL/api/v1/flows/upload/?folder_id=$FOLDER_ID" \
|
||||
-H "accept: application/json" \
|
||||
-H "Content-Type: multipart/form-data" \
|
||||
-H "x-api-key: $LANGFLOW_API_KEY" \
|
||||
-F "file=@${FLOW_IMPORT_FILE};type=application/json"
|
||||
@ -0,0 +1,4 @@
|
||||
curl -X GET \
|
||||
"$LANGFLOW_URL/api/v1/flows/$FLOW_ID" \
|
||||
-H "accept: application/json" \
|
||||
-H "x-api-key: $LANGFLOW_API_KEY"
|
||||
@ -0,0 +1,4 @@
|
||||
curl -X GET \
|
||||
"$LANGFLOW_URL/api/v1/flows/?remove_example_flows=true&components_only=false&get_all=false&project_id=$PROJECT_ID&header_flows=false&page=1&size=1" \
|
||||
-H "accept: application/json" \
|
||||
-H "x-api-key: $LANGFLOW_API_KEY"
|
||||
@ -0,0 +1,4 @@
|
||||
curl -X GET \
|
||||
"$LANGFLOW_URL/api/v1/flows/?remove_example_flows=false&components_only=false&get_all=true&header_flows=false&page=1&size=50" \
|
||||
-H "accept: application/json" \
|
||||
-H "x-api-key: $LANGFLOW_API_KEY"
|
||||
@ -0,0 +1,4 @@
|
||||
curl -X GET \
|
||||
"$LANGFLOW_URL/api/v1/flows/basic_examples/" \
|
||||
-H "accept: application/json" \
|
||||
-H "x-api-key: $LANGFLOW_API_KEY"
|
||||
@ -0,0 +1,17 @@
|
||||
{
|
||||
"name": "string2",
|
||||
"description": "string",
|
||||
"icon": "string",
|
||||
"icon_bg_color": "#FF0000",
|
||||
"gradient": "string",
|
||||
"data": {},
|
||||
"is_component": false,
|
||||
"updated_at": "2025-02-04T21:07:36+00:00",
|
||||
"webhook": false,
|
||||
"endpoint_name": "string",
|
||||
"tags": ["string"],
|
||||
"locked": false,
|
||||
"id": "e8d81c37-714b-49ae-ba82-e61141f020ee",
|
||||
"user_id": "f58396d4-a387-4bb8-b749-f40825c3d9f3",
|
||||
"project_id": "1415de42-8f01-4f36-bf34-539f23e47466"
|
||||
}
|
||||
@ -0,0 +1,3 @@
|
||||
{
|
||||
"message": "Flow deleted successfully"
|
||||
}
|
||||
@ -0,0 +1,3 @@
|
||||
% Total % Received % Xferd Average Speed Time Time Time Current
|
||||
Dload Upload Total Spent Left Speed
|
||||
100 76437 0 76353 100 84 4516k 5088 --:--:-- --:--:-- --:--:-- 4665k
|
||||
@ -0,0 +1,12 @@
|
||||
{
|
||||
"name": "Basic Prompting",
|
||||
"description": "Perform basic prompting with an OpenAI model.",
|
||||
"icon": "Braces",
|
||||
"icon_bg_color": null,
|
||||
"gradient": "2",
|
||||
"data": {
|
||||
"nodes": [
|
||||
...
|
||||
]
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,17 @@
|
||||
{
|
||||
"name": "string",
|
||||
"description": "string",
|
||||
"icon": "Braces",
|
||||
"icon_bg_color": null,
|
||||
"gradient": "2",
|
||||
"data": {},
|
||||
"is_component": false,
|
||||
"updated_at": "2024-12-30T18:30:22+00:00",
|
||||
"webhook": false,
|
||||
"endpoint_name": "my_new_endpoint_name",
|
||||
"tags": null,
|
||||
"locked": true,
|
||||
"id": "01ce083d-748b-4b8d-97b6-33adbb6a528a",
|
||||
"user_id": "f58396d4-a387-4bb8-b749-f40825c3d9f3",
|
||||
"project_id": "3fa85f64-5717-4562-b3fc-2c963f66afa6"
|
||||
}
|
||||
@ -0,0 +1,13 @@
|
||||
curl -X PATCH \
|
||||
"$LANGFLOW_URL/api/v1/flows/$FLOW_ID" \
|
||||
-H "accept: application/json" \
|
||||
-H "Content-Type: application/json" \
|
||||
-H "x-api-key: $LANGFLOW_API_KEY" \
|
||||
-d '{
|
||||
"name": "string",
|
||||
"description": "string",
|
||||
"data": {},
|
||||
"project_id": "3fa85f64-5717-4562-b3fc-2c963f66afa6",
|
||||
"endpoint_name": "my_new_endpoint_name",
|
||||
"locked": true
|
||||
}'
|
||||
@ -0,0 +1,12 @@
|
||||
{
|
||||
"1736354770500": "2025-01-08T11:46:10.500363-0500 DEBUG Creating starter project Document Q&A\n",
|
||||
"1736354770511": "2025-01-08T11:46:10.511146-0500 DEBUG Creating starter project Image Sentiment Analysis\n",
|
||||
"1736354770521": "2025-01-08T11:46:10.521018-0500 DEBUG Creating starter project SEO Keyword Generator\n",
|
||||
"1736354770532": "2025-01-08T11:46:10.532677-0500 DEBUG Creating starter project Sequential Tasks Agents\n",
|
||||
"1736354770544": "2025-01-08T11:46:10.544010-0500 DEBUG Creating starter project Custom Component Generator\n",
|
||||
"1736354770555": "2025-01-08T11:46:10.555513-0500 DEBUG Creating starter project Prompt Chaining\n",
|
||||
"1736354770588": "2025-01-08T11:46:10.588105-0500 DEBUG Create service ServiceType.CHAT_SERVICE\n",
|
||||
"1736354771021": "2025-01-08T11:46:11.021817-0500 DEBUG Telemetry data sent successfully.\n",
|
||||
"1736354775619": "2025-01-08T11:46:15.619545-0500 DEBUG Create service ServiceType.STORE_SERVICE\n",
|
||||
"1736354775699": "2025-01-08T11:46:15.699661-0500 DEBUG File 046-rocket.svg retrieved successfully from flow /Users/USER/Library/Caches/langflow/profile_pictures/Space.\n"
|
||||
}
|
||||
@ -0,0 +1,17 @@
|
||||
keepalive
|
||||
|
||||
{"1736355791151": "2025-01-08T12:03:11.151218-0500 DEBUG Building Chat Input\n"}
|
||||
|
||||
{"1736355791485": "2025-01-08T12:03:11.485380-0500 DEBUG consumed event add_message-153bcd5d-ef4d-4ece-8cc0-47c6b6a9ef92 (time in queue, 0.0000, client 0.0001)\n"}
|
||||
|
||||
{"1736355791499": "2025-01-08T12:03:11.499704-0500 DEBUG consumed event end_vertex-3d7125cd-7b8a-44eb-9113-ed5b785e3cf3 (time in queue, 0.0056, client 0.0047)\n"}
|
||||
|
||||
{"1736355791502": "2025-01-08T12:03:11.502510-0500 DEBUG consumed event end-40d0b363-5618-4a23-bbae-487cd0b9594d (time in queue, 0.0001, client 0.0004)\n"}
|
||||
|
||||
{"1736355791513": "2025-01-08T12:03:11.513097-0500 DEBUG Logged vertex build: 729ff2f8-6b01-48c8-9ad0-3743c2af9e8a\n"}
|
||||
|
||||
{"1736355791834": "2025-01-08T12:03:11.834982-0500 DEBUG Telemetry data sent successfully.\n"}
|
||||
|
||||
{"1736355791941": "2025-01-08T12:03:11.941840-0500 DEBUG Telemetry data sent successfully.\n"}
|
||||
|
||||
keepalive
|
||||
@ -0,0 +1,4 @@
|
||||
curl -X GET \
|
||||
"$LANGFLOW_URL/logs?lines_before=0&lines_after=0×tamp=0" \
|
||||
-H "accept: application/json" \
|
||||
-H "x-api-key: $LANGFLOW_API_KEY"
|
||||
@ -0,0 +1,4 @@
|
||||
curl -X GET \
|
||||
"$LANGFLOW_URL/logs-stream" \
|
||||
-H "accept: text/event-stream" \
|
||||
-H "x-api-key: $LANGFLOW_API_KEY"
|
||||
@ -0,0 +1,4 @@
|
||||
curl -X DELETE \
|
||||
"$LANGFLOW_URL/api/v1/monitor/messages/session/different_session_id_2" \
|
||||
-H "accept: */*" \
|
||||
-H "x-api-key: $LANGFLOW_API_KEY"
|
||||
@ -0,0 +1,6 @@
|
||||
curl -v -X DELETE \
|
||||
"$LANGFLOW_URL/api/v1/monitor/messages" \
|
||||
-H "accept: */*" \
|
||||
-H "Content-Type: application/json" \
|
||||
-H "x-api-key: $LANGFLOW_API_KEY" \
|
||||
-d '["MESSAGE_ID_1", "MESSAGE_ID_2"]'
|
||||
@ -0,0 +1,4 @@
|
||||
curl -X DELETE \
|
||||
"$LANGFLOW_URL/api/v1/monitor/builds?flow_id=$FLOW_ID" \
|
||||
-H "accept: */*" \
|
||||
-H "x-api-key: $LANGFLOW_API_KEY"
|
||||
@ -0,0 +1,8 @@
|
||||
export LANGFLOW_SERVER_URL="http://localhost:7860"
|
||||
export LANGFLOW_API_KEY="YOUR_LANGFLOW_API_KEY"
|
||||
export FLOW_ID="YOUR_FLOW_ID"
|
||||
|
||||
curl -s "$LANGFLOW_SERVER_URL/api/v1/monitor/traces?flow_id=$FLOW_ID&page=1&size=50" \
|
||||
-H "accept: application/json" \
|
||||
-H "x-api-key: $LANGFLOW_API_KEY" \
|
||||
| jq .
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user