diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index eb0d7df83c..899821a340 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -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 diff --git a/docs/docusaurus.config.js b/docs/docusaurus.config.js index ac0a628fe0..2e716892c5 100644 --- a/docs/docusaurus.config.js +++ b/docs/docusaurus.config.js @@ -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: [ diff --git a/docs/sidebars.js b/docs/sidebars.js index 020a83d037..29b97bee19 100644 --- a/docs/sidebars.js +++ b/docs/sidebars.js @@ -491,10 +491,6 @@ module.exports = { id: "API-Reference/api-flows-run", label: "Flow trigger endpoints", }, - "API-Reference/api-reference-api-examples", - "API-Reference/typescript-client", - "API-Reference/flow-devops-sdk", - "API-Reference/api-flows-run", { type: "category", label: "Developer API (Beta)", diff --git a/docs/versioned_docs/version-1.9.0/API-Reference/README.md b/docs/versioned_docs/version-1.9.0/API-Reference/README.md new file mode 100644 index 0000000000..72500fe345 --- /dev/null +++ b/docs/versioned_docs/version-1.9.0/API-Reference/README.md @@ -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` \ No newline at end of file diff --git a/docs/versioned_docs/version-1.9.0/API-Reference/api-build.mdx b/docs/versioned_docs/version-1.9.0/API-Reference/api-build.mdx new file mode 100644 index 0000000000..de826d955f --- /dev/null +++ b/docs/versioned_docs/version-1.9.0/API-Reference/api-build.mdx @@ -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: + + + + + + + + + + + + + + + + + + + +
+ Result + + + +
+ +2. After receiving a job ID from the build endpoint, use the `/build/$JOB_ID/events` endpoint to stream the execution results: + + + + + + + + + + + + + + + + + + + +
+ Result + + + +
+ +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`. + + + + + + + + + + + + + + + + + + + +## 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: + + + + + + + + + + + + + + + + + + + +### 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. + + + + + + + + + + + + + + + + + + + +
+Result + + + +
+ +## See also + +- [Get Vertex builds](/api-monitor#get-vertex-builds) +- [Delete Vertex builds](/api-monitor#delete-vertex-builds) +- [Session ID](/session-id) diff --git a/docs/versioned_docs/version-1.9.0/API-Reference/api-files.mdx b/docs/versioned_docs/version-1.9.0/API-Reference/api-files.mdx new file mode 100644 index 0000000000..558bc4b395 --- /dev/null +++ b/docs/versioned_docs/version-1.9.0/API-Reference/api-files.mdx @@ -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. + + + + + + + + + + + + + + + + + + + +Replace `FILE_NAME.txt` with the name and extension of the file you want to upload. +Not all file types are supported. + +
+Result + + + +
+ +### 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: + + + + + + + + + + + + + + + + + + + + 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`. + + + + + + + + + + + + + + + + + + + + :::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. + + + + + + + + + + + + + + + + + + + +
+Result + + + +
+ +### Download file (v1) + +Download a specific file from a flow. + + + + + + + + + + + + + + + + + + + +
+Result + + + +
+ +### Delete file (v1) + +Delete a specific file from a flow. + + + + + + + + + + + + + + + + + + + +
+Result + + + +
+ +## 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: + + + + + + + + + + + + + + + + + + + +
+ Result + + + +
+ +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`. + + + + + + + + + + + + + + + + + + + + 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. + + + + + + + + + + + + + + + + + + + + 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: + + + + + + + + + + + + + + + + + + + + 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. + + + + + + + + + + + + + + + + + + + +
+Result + + + +
+ +### 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. + + + + + + + + + + + + + + + + + + + +
+Result + + + +
+ +### Edit file name (v2) + +Change a file name. + + + + + + + + + + + + + + + + + + + +
+Result + + + +
+ +### Delete file (v2) + +Delete a specific file by its ID. + + + + + + + + + + + + + + + + + + + +
+Result + + + +
+ +### Delete all files (v2) + +Delete all files associated with your user account. + + + + + + + + + + + + + + + + + + + +
+Result + + + +
+ +## Create upload file (Deprecated) + +This endpoint is deprecated. Use the `/files` endpoints instead. + +## See also + +* [Manage files](/concepts-file-management) diff --git a/docs/versioned_docs/version-1.9.0/API-Reference/api-flows-run.mdx b/docs/versioned_docs/version-1.9.0/API-Reference/api-flows-run.mdx new file mode 100644 index 0000000000..f3ce210aae --- /dev/null +++ b/docs/versioned_docs/version-1.9.0/API-Reference/api-flows-run.mdx @@ -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. + + + + + + + + + + + + + + + + + + + +The response from `/v1/run/$FLOW_ID` includes metadata, inputs, and outputs for the run. + +
+Result + +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" + } + } + }] + }] +} +``` +
+ +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: + + + + + + + + + + + + + + + + + + + +LLM chat responses are streamed back as `token` events, culminating in a final `end` event that closes the connection. + +
+Result + +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\"?..."}}} +``` + +
+ +### 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 + + + + + + + + + + + + + + + + + + + +### 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. + + + + + + + + + + + + + + + + + + + +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). +::: + + + + + + + + + + + + + + + + + + + +
+Result + + + +
+ +## Deprecated flow trigger endpoints + +The following endpoints are deprecated and replaced by the `/run` endpoint: + +* `/process` +* `/predict` diff --git a/docs/versioned_docs/version-1.9.0/API-Reference/api-flows.mdx b/docs/versioned_docs/version-1.9.0/API-Reference/api-flows.mdx new file mode 100644 index 0000000000..a778bb53a9 --- /dev/null +++ b/docs/versioned_docs/version-1.9.0/API-Reference/api-flows.mdx @@ -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. + + + + + + + + + + + + + + + + + + + +
+Result + + + +
+ +## Create flows + +Creates multiple new flows, returning an array of flow objects. + + + + + + + + + + + + + + + + + + + +## Read flow + +Retrieves a specific flow by its ID. + + + + + + + + + + + + + + + + + + + +
+Result + + + +
+ +## Read flows + +Returns a JSON object containing a list of flows. + +Retrieve all flows with pagination: + + + + + + + + + + + + + + + + + + + +To retrieve flows from a specific project, use the `project_id` query parameter: + + + + + + + + + + + + + + + + + + + +## Read sample flows + +Retrieves a list of sample flows: + + + + + + + + + + + + + + + + + + + +## 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`. + + + + + + + + + + + + + + + + + + + +
+Result + + + +
+ +## Delete flow + +Deletes a specific flow by its ID. + + + + + + + + + + + + + + + + + + + +
+Result + + + +
+ +## 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. + + + + + + + + + + + + + + + + + + + +
+Result + + + +
+ +## 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: + + + + + + + + + + + + + + + + + + + +
+Result + +```json +[ + { + "name": "agent-with-astra-db-tool", + "description": "", + "icon": null, + "icon_bg_color": null, + "gradient": null, + "data": {} + ... + } +] +``` +
diff --git a/docs/versioned_docs/version-1.9.0/API-Reference/api-logs.mdx b/docs/versioned_docs/version-1.9.0/API-Reference/api-logs.mdx new file mode 100644 index 0000000000..ed7f3e3eaf --- /dev/null +++ b/docs/versioned_docs/version-1.9.0/API-Reference/api-logs.mdx @@ -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): + + + + + + + + + + + + + + + + + + + +
+Result + + + +
+ +## 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. + + + + + + + + + + + + + + + + + + + +
+Result + + + +
diff --git a/docs/versioned_docs/version-1.9.0/API-Reference/api-monitor.mdx b/docs/versioned_docs/version-1.9.0/API-Reference/api-monitor.mdx new file mode 100644 index 0000000000..9b0b639a10 --- /dev/null +++ b/docs/versioned_docs/version-1.9.0/API-Reference/api-monitor.mdx @@ -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. + + + + + + + + + + + + + + + + + + + +
+Result + + + +
+ +### Delete Vertex builds + +Delete Vertex builds for a specific flow. + + + + + + + + + + + + + + + + + + + +
+Result + + + +
+ +## 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: + + + + + + + + + + + + + + + + + + + +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. + + + + + + + + + + + + + + + + + + + +
+Result + + + +
+ +### Delete messages + +Delete specific messages by their IDs. + +This example deletes the message retrieved in the previous `GET /messages` example. + + + + + + + + + + + + + + + + + + + +
+Result + + + +
+ +### Update message + +Update a specific message by its ID. + +This example updates the `text` value of message `3ab66cc6-c048-48f8-ab07-570f5af7b160`. + + + + + + + + + + + + + + + + + + + +
+Result + + + +
+ +### 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`. + + + + + + + + + + + + + + + + + + + +
+Result + + + +
+ +### Delete messages by session + +Delete all messages for a specific session. + + + + + + + + + + + + + + + + + + + +
+Result + + + +
+ +## Get traces + + Retrieve trace metadata and span trees for a specific flow. + +### Example request + +Use `GET /monitor/traces` and filter by `flow_id`: + + + + + + + + + +```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); +``` + + + + + + + + + +### 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). + + + + + + + + + + + + + + + + + + + +
+Result + + + +
+ +## See also + +- [Use voice mode](/concepts-voice-mode) +- [Session ID](/session-id) diff --git a/docs/versioned_docs/version-1.9.0/API-Reference/api-openai-responses.mdx b/docs/versioned_docs/version-1.9.0/API-Reference/api-openai-responses.mdx new file mode 100644 index 0000000000..01e3c21f88 --- /dev/null +++ b/docs/versioned_docs/version-1.9.0/API-Reference/api-openai-responses.mdx @@ -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. + + + + + + + + + + + + + +
+Response +```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! +``` +
+ +## Example request + + + + + + + + + + + + + + + + + + + +### 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`. | + +
+Fields with OpenAI-compatible default values + +| 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. | + +
+ +## 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. + + + + + + + + + + + + + + + + + + + +
+Result + + + +
+ +### 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. + +
+Final completion chunk + +``` +{ + "id": "f7fcea36-f128-41c4-9ac1-e683137375d5", + "object": "response.chunk", + "created": 1756838094, + "model": "ced2ec91-f325-4bf0-8754-f3198c2b1563", + "delta": {}, + "status": "completed" +} +``` +
+ +## 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: + + + + + + + + + + + + + + + + + + + +
+Result + + + +
+ +Follow-up message: + + + + + + + + + + + + + + + + + + + +
+Result + + + +
+ +Optionally, you can use your own session ID values for the `previous_response_id`: + + + + + + + + + + + + + + + + + + + +
+Result + +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" +} +``` + +
+ +## 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: + + + + + + + + + + + + + + + + + + + +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"} +} +``` + +
+Result + + + +
+ +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. + + + + + + + + + + + + + + + + +
+Response with token usage + +```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 +} +``` + +
+ +
+
diff --git a/docs/versioned_docs/version-1.9.0/API-Reference/api-projects.mdx b/docs/versioned_docs/version-1.9.0/API-Reference/api-projects.mdx new file mode 100644 index 0000000000..e4945aff97 --- /dev/null +++ b/docs/versioned_docs/version-1.9.0/API-Reference/api-projects.mdx @@ -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. + + + + + + + + + + + + + + + + + + + +
+Result + + + +
+ +## Create project + +Create a new project. + + + + + + + + + + + + + + + + + + + +
+Result + + + +
+ +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. + + + + + + + + + + + + + + + + + + + +## Read project + +Retrieve details of a specific project. + +To find the UUID of your project, call the [read projects](#read-projects) endpoint. + + + + + + + + + + + + + + + + + + + +
+Result + + + +
+ +## 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. + + + + + + + + + + + + + + + + + + + +
+Result + + + +
+ +## Delete project + +Delete a specific project. + + + + + + + + + + + + + + + + + + + +
+Result + + + +
+ +## Export a project + +Download all flows from a project as a zip file. + +The `--output` flag is optional. + + + + + + + + + + + + + + + + + + + +## Import a project + +Import a project and its flows by uploading a Langflow project zip file: + + + + + + + + + + + + + + + + + + diff --git a/docs/versioned_docs/version-1.9.0/API-Reference/api-reference-api-examples.mdx b/docs/versioned_docs/version-1.9.0/API-Reference/api-reference-api-examples.mdx new file mode 100644 index 0000000000..2d41039c8a --- /dev/null +++ b/docs/versioned_docs/version-1.9.0/API-Reference/api-reference-api-examples.mdx @@ -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: + + + + + + + + + + + + + + + + + + + +### 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: + + + +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: + + + + + + + + + + + + + + + + + + + +
+Result + + + +
+ +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: + + + + + + + + + + + + + + + + + + + +
+Result + + + +
+ +### Get configuration + +Returns configuration details for your Langflow deployment. +Requires a [Langflow API key](/api-keys-and-authentication). + + + + + + + + + + + + + + + + + + + +
+Result + + + +
+ +### Get all components + +Returns a dictionary of all Langflow components. +Requires a [Langflow API key](/api-keys-and-authentication). + + + + + + + + + + + + + + + + + + + +## 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. + + + + +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. + + + + +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. + + + + +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. + + + + +## 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). diff --git a/docs/versioned_docs/version-1.9.0/API-Reference/api-users.mdx b/docs/versioned_docs/version-1.9.0/API-Reference/api-users.mdx new file mode 100644 index 0000000000..5da898cd67 --- /dev/null +++ b/docs/versioned_docs/version-1.9.0/API-Reference/api-users.mdx @@ -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. + + + + + + + + + + + + + + + + + + + +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. + +
+Result + + + +
+ +## Get current user + +Retrieve information about the authenticated user. + + + + + + + + + + + + + + + + + + + +
+Result + + + +
+ +## 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. + + + + + + + + + + + + + + + + + + + +
+Result + + + +
+ +## 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: + + + + + + + + + + + + + + + + + + + +
+Result + + + +
+ +## Reset password + +Change the specified user's password to a new secure value. + +Requires authentication as the target user. + + + + + + + + + + + + + + + + + + + +
+Result + + + +
+ +## Delete user + +Remove a user account from the system. + +Requires authentication as a superuser if the Langflow server has authentication enabled. + + + + + + + + + + + + + + + + + + + +
+Result + + + +
diff --git a/docs/versioned_docs/version-1.9.0/API-Reference/curl-examples/api-build/build-flow-and-stream-events-2.sh b/docs/versioned_docs/version-1.9.0/API-Reference/curl-examples/api-build/build-flow-and-stream-events-2.sh new file mode 100644 index 0000000000..465dff08ef --- /dev/null +++ b/docs/versioned_docs/version-1.9.0/API-Reference/curl-examples/api-build/build-flow-and-stream-events-2.sh @@ -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" diff --git a/docs/versioned_docs/version-1.9.0/API-Reference/curl-examples/api-build/build-flow-and-stream-events-3.sh b/docs/versioned_docs/version-1.9.0/API-Reference/curl-examples/api-build/build-flow-and-stream-events-3.sh new file mode 100644 index 0000000000..1cb3f245e0 --- /dev/null +++ b/docs/versioned_docs/version-1.9.0/API-Reference/curl-examples/api-build/build-flow-and-stream-events-3.sh @@ -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" diff --git a/docs/versioned_docs/version-1.9.0/API-Reference/curl-examples/api-build/build-flow-and-stream-events.sh b/docs/versioned_docs/version-1.9.0/API-Reference/curl-examples/api-build/build-flow-and-stream-events.sh new file mode 100644 index 0000000000..e256df56e9 --- /dev/null +++ b/docs/versioned_docs/version-1.9.0/API-Reference/curl-examples/api-build/build-flow-and-stream-events.sh @@ -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" + } + }' diff --git a/docs/versioned_docs/version-1.9.0/API-Reference/curl-examples/api-build/override-flow-parameters.sh b/docs/versioned_docs/version-1.9.0/API-Reference/curl-examples/api-build/override-flow-parameters.sh new file mode 100644 index 0000000000..0ad3e28cfe --- /dev/null +++ b/docs/versioned_docs/version-1.9.0/API-Reference/curl-examples/api-build/override-flow-parameters.sh @@ -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" + } + }' diff --git a/docs/versioned_docs/version-1.9.0/API-Reference/curl-examples/api-build/result-build-flow-and-stream-events-2.json b/docs/versioned_docs/version-1.9.0/API-Reference/curl-examples/api-build/result-build-flow-and-stream-events-2.json new file mode 100644 index 0000000000..ece8751026 --- /dev/null +++ b/docs/versioned_docs/version-1.9.0/API-Reference/curl-examples/api-build/result-build-flow-and-stream-events-2.json @@ -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": {}} diff --git a/docs/versioned_docs/version-1.9.0/API-Reference/curl-examples/api-build/result-build-flow-and-stream-events.json b/docs/versioned_docs/version-1.9.0/API-Reference/curl-examples/api-build/result-build-flow-and-stream-events.json new file mode 100644 index 0000000000..91ecc694d9 --- /dev/null +++ b/docs/versioned_docs/version-1.9.0/API-Reference/curl-examples/api-build/result-build-flow-and-stream-events.json @@ -0,0 +1,3 @@ +{ + "job_id": "123e4567-e89b-12d3-a456-426614174000" +} diff --git a/docs/versioned_docs/version-1.9.0/API-Reference/curl-examples/api-build/result-override-flow-parameters.json b/docs/versioned_docs/version-1.9.0/API-Reference/curl-examples/api-build/result-override-flow-parameters.json new file mode 100644 index 0000000000..ecf947abcc --- /dev/null +++ b/docs/versioned_docs/version-1.9.0/API-Reference/curl-examples/api-build/result-override-flow-parameters.json @@ -0,0 +1 @@ +{ "job_id": "0bcc7f23-40b4-4bfa-9b8a-a44181fd1175" } diff --git a/docs/versioned_docs/version-1.9.0/API-Reference/curl-examples/api-build/set-start-and-stop-points.sh b/docs/versioned_docs/version-1.9.0/API-Reference/curl-examples/api-build/set-start-and-stop-points.sh new file mode 100644 index 0000000000..484d0357c4 --- /dev/null +++ b/docs/versioned_docs/version-1.9.0/API-Reference/curl-examples/api-build/set-start-and-stop-points.sh @@ -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"}' diff --git a/docs/versioned_docs/version-1.9.0/API-Reference/curl-examples/api-files/delete-all-files-v2.sh b/docs/versioned_docs/version-1.9.0/API-Reference/curl-examples/api-files/delete-all-files-v2.sh new file mode 100644 index 0000000000..0c443c5b8e --- /dev/null +++ b/docs/versioned_docs/version-1.9.0/API-Reference/curl-examples/api-files/delete-all-files-v2.sh @@ -0,0 +1,4 @@ +curl -X DELETE \ + "$LANGFLOW_URL/api/v2/files" \ + -H "accept: application/json" \ + -H "x-api-key: $LANGFLOW_API_KEY" diff --git a/docs/versioned_docs/version-1.9.0/API-Reference/curl-examples/api-files/delete-file-v1.sh b/docs/versioned_docs/version-1.9.0/API-Reference/curl-examples/api-files/delete-file-v1.sh new file mode 100644 index 0000000000..a3ec4c1a64 --- /dev/null +++ b/docs/versioned_docs/version-1.9.0/API-Reference/curl-examples/api-files/delete-file-v1.sh @@ -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" diff --git a/docs/versioned_docs/version-1.9.0/API-Reference/curl-examples/api-files/delete-file-v2.sh b/docs/versioned_docs/version-1.9.0/API-Reference/curl-examples/api-files/delete-file-v2.sh new file mode 100644 index 0000000000..c897b79d42 --- /dev/null +++ b/docs/versioned_docs/version-1.9.0/API-Reference/curl-examples/api-files/delete-file-v2.sh @@ -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" diff --git a/docs/versioned_docs/version-1.9.0/API-Reference/curl-examples/api-files/download-file-v1.sh b/docs/versioned_docs/version-1.9.0/API-Reference/curl-examples/api-files/download-file-v1.sh new file mode 100644 index 0000000000..a75a55bee3 --- /dev/null +++ b/docs/versioned_docs/version-1.9.0/API-Reference/curl-examples/api-files/download-file-v1.sh @@ -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 diff --git a/docs/versioned_docs/version-1.9.0/API-Reference/curl-examples/api-files/download-file-v2.sh b/docs/versioned_docs/version-1.9.0/API-Reference/curl-examples/api-files/download-file-v2.sh new file mode 100644 index 0000000000..20c868fc49 --- /dev/null +++ b/docs/versioned_docs/version-1.9.0/API-Reference/curl-examples/api-files/download-file-v2.sh @@ -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 diff --git a/docs/versioned_docs/version-1.9.0/API-Reference/curl-examples/api-files/edit-file-name-v2.sh b/docs/versioned_docs/version-1.9.0/API-Reference/curl-examples/api-files/edit-file-name-v2.sh new file mode 100644 index 0000000000..5a831da3c8 --- /dev/null +++ b/docs/versioned_docs/version-1.9.0/API-Reference/curl-examples/api-files/edit-file-name-v2.sh @@ -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" diff --git a/docs/versioned_docs/version-1.9.0/API-Reference/curl-examples/api-files/list-files-v1.sh b/docs/versioned_docs/version-1.9.0/API-Reference/curl-examples/api-files/list-files-v1.sh new file mode 100644 index 0000000000..040d72230d --- /dev/null +++ b/docs/versioned_docs/version-1.9.0/API-Reference/curl-examples/api-files/list-files-v1.sh @@ -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" diff --git a/docs/versioned_docs/version-1.9.0/API-Reference/curl-examples/api-files/list-files-v2.sh b/docs/versioned_docs/version-1.9.0/API-Reference/curl-examples/api-files/list-files-v2.sh new file mode 100644 index 0000000000..c99d450573 --- /dev/null +++ b/docs/versioned_docs/version-1.9.0/API-Reference/curl-examples/api-files/list-files-v2.sh @@ -0,0 +1,4 @@ +curl -X GET \ + "$LANGFLOW_URL/api/v2/files" \ + -H "accept: application/json" \ + -H "x-api-key: $LANGFLOW_API_KEY" diff --git a/docs/versioned_docs/version-1.9.0/API-Reference/curl-examples/api-files/result-delete-all-files-v2.json b/docs/versioned_docs/version-1.9.0/API-Reference/curl-examples/api-files/result-delete-all-files-v2.json new file mode 100644 index 0000000000..90d8bd5c44 --- /dev/null +++ b/docs/versioned_docs/version-1.9.0/API-Reference/curl-examples/api-files/result-delete-all-files-v2.json @@ -0,0 +1,3 @@ +{ + "message": "All files deleted successfully" +} diff --git a/docs/versioned_docs/version-1.9.0/API-Reference/curl-examples/api-files/result-delete-file-v1.json b/docs/versioned_docs/version-1.9.0/API-Reference/curl-examples/api-files/result-delete-file-v1.json new file mode 100644 index 0000000000..9ba62fe3da --- /dev/null +++ b/docs/versioned_docs/version-1.9.0/API-Reference/curl-examples/api-files/result-delete-file-v1.json @@ -0,0 +1,3 @@ +{ + "message": "File 2024-12-30_15-19-43_your_file.txt deleted successfully" +} diff --git a/docs/versioned_docs/version-1.9.0/API-Reference/curl-examples/api-files/result-delete-file-v2.json b/docs/versioned_docs/version-1.9.0/API-Reference/curl-examples/api-files/result-delete-file-v2.json new file mode 100644 index 0000000000..0d5d491f18 --- /dev/null +++ b/docs/versioned_docs/version-1.9.0/API-Reference/curl-examples/api-files/result-delete-file-v2.json @@ -0,0 +1,3 @@ +{ + "message": "File deleted successfully" +} diff --git a/docs/versioned_docs/version-1.9.0/API-Reference/curl-examples/api-files/result-download-file-v1.txt b/docs/versioned_docs/version-1.9.0/API-Reference/curl-examples/api-files/result-download-file-v1.txt new file mode 100644 index 0000000000..4921b2a3b5 --- /dev/null +++ b/docs/versioned_docs/version-1.9.0/API-Reference/curl-examples/api-files/result-download-file-v1.txt @@ -0,0 +1 @@ +File contents downloaded to downloaded_file.txt diff --git a/docs/versioned_docs/version-1.9.0/API-Reference/curl-examples/api-files/result-download-file-v2.txt b/docs/versioned_docs/version-1.9.0/API-Reference/curl-examples/api-files/result-download-file-v2.txt new file mode 100644 index 0000000000..4921b2a3b5 --- /dev/null +++ b/docs/versioned_docs/version-1.9.0/API-Reference/curl-examples/api-files/result-download-file-v2.txt @@ -0,0 +1 @@ +File contents downloaded to downloaded_file.txt diff --git a/docs/versioned_docs/version-1.9.0/API-Reference/curl-examples/api-files/result-edit-file-name-v2.json b/docs/versioned_docs/version-1.9.0/API-Reference/curl-examples/api-files/result-edit-file-name-v2.json new file mode 100644 index 0000000000..c9fbe8f494 --- /dev/null +++ b/docs/versioned_docs/version-1.9.0/API-Reference/curl-examples/api-files/result-edit-file-name-v2.json @@ -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 +} diff --git a/docs/versioned_docs/version-1.9.0/API-Reference/curl-examples/api-files/result-list-files-v1.json b/docs/versioned_docs/version-1.9.0/API-Reference/curl-examples/api-files/result-list-files-v1.json new file mode 100644 index 0000000000..3e6abd62a9 --- /dev/null +++ b/docs/versioned_docs/version-1.9.0/API-Reference/curl-examples/api-files/result-list-files-v1.json @@ -0,0 +1,3 @@ +{ + "files": ["2024-12-30_15-19-43_your_file.txt"] +} diff --git a/docs/versioned_docs/version-1.9.0/API-Reference/curl-examples/api-files/result-list-files-v2.json b/docs/versioned_docs/version-1.9.0/API-Reference/curl-examples/api-files/result-list-files-v2.json new file mode 100644 index 0000000000..d95c1f19de --- /dev/null +++ b/docs/versioned_docs/version-1.9.0/API-Reference/curl-examples/api-files/result-list-files-v2.json @@ -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 + } +] diff --git a/docs/versioned_docs/version-1.9.0/API-Reference/curl-examples/api-files/result-upload-file-v1.json b/docs/versioned_docs/version-1.9.0/API-Reference/curl-examples/api-files/result-upload-file-v1.json new file mode 100644 index 0000000000..4e17a96826 --- /dev/null +++ b/docs/versioned_docs/version-1.9.0/API-Reference/curl-examples/api-files/result-upload-file-v1.json @@ -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" +} diff --git a/docs/versioned_docs/version-1.9.0/API-Reference/curl-examples/api-files/result-upload-file-v2.txt b/docs/versioned_docs/version-1.9.0/API-Reference/curl-examples/api-files/result-upload-file-v2.txt new file mode 100644 index 0000000000..b61e201b1c --- /dev/null +++ b/docs/versioned_docs/version-1.9.0/API-Reference/curl-examples/api-files/result-upload-file-v2.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}} diff --git a/docs/versioned_docs/version-1.9.0/API-Reference/curl-examples/api-files/send-files-to-your-flows-v2-2.sh b/docs/versioned_docs/version-1.9.0/API-Reference/curl-examples/api-files/send-files-to-your-flows-v2-2.sh new file mode 100644 index 0000000000..c5257ed340 --- /dev/null +++ b/docs/versioned_docs/version-1.9.0/API-Reference/curl-examples/api-files/send-files-to-your-flows-v2-2.sh @@ -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" + ] + } + } +}' diff --git a/docs/versioned_docs/version-1.9.0/API-Reference/curl-examples/api-files/send-files-to-your-flows-v2.sh b/docs/versioned_docs/version-1.9.0/API-Reference/curl-examples/api-files/send-files-to-your-flows-v2.sh new file mode 100644 index 0000000000..06cb36a4e1 --- /dev/null +++ b/docs/versioned_docs/version-1.9.0/API-Reference/curl-examples/api-files/send-files-to-your-flows-v2.sh @@ -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}" diff --git a/docs/versioned_docs/version-1.9.0/API-Reference/curl-examples/api-files/upload-file-v1.sh b/docs/versioned_docs/version-1.9.0/API-Reference/curl-examples/api-files/upload-file-v1.sh new file mode 100644 index 0000000000..6edf907472 --- /dev/null +++ b/docs/versioned_docs/version-1.9.0/API-Reference/curl-examples/api-files/upload-file-v1.sh @@ -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}" diff --git a/docs/versioned_docs/version-1.9.0/API-Reference/curl-examples/api-files/upload-file-v2-2.sh b/docs/versioned_docs/version-1.9.0/API-Reference/curl-examples/api-files/upload-file-v2-2.sh new file mode 100644 index 0000000000..06cb36a4e1 --- /dev/null +++ b/docs/versioned_docs/version-1.9.0/API-Reference/curl-examples/api-files/upload-file-v2-2.sh @@ -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}" diff --git a/docs/versioned_docs/version-1.9.0/API-Reference/curl-examples/api-files/upload-file-v2.sh b/docs/versioned_docs/version-1.9.0/API-Reference/curl-examples/api-files/upload-file-v2.sh new file mode 100644 index 0000000000..85ca53f1d8 --- /dev/null +++ b/docs/versioned_docs/version-1.9.0/API-Reference/curl-examples/api-files/upload-file-v2.sh @@ -0,0 +1,4 @@ +curl -X GET \ + "$LANGFLOW_URL/api/v1/users/whoami" \ + -H "accept: application/json" \ + -H "x-api-key: $LANGFLOW_API_KEY" diff --git a/docs/versioned_docs/version-1.9.0/API-Reference/curl-examples/api-files/upload-image-files-v1-2.sh b/docs/versioned_docs/version-1.9.0/API-Reference/curl-examples/api-files/upload-image-files-v1-2.sh new file mode 100644 index 0000000000..0ecd6335a9 --- /dev/null +++ b/docs/versioned_docs/version-1.9.0/API-Reference/curl-examples/api-files/upload-image-files-v1-2.sh @@ -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" + } + } + }' diff --git a/docs/versioned_docs/version-1.9.0/API-Reference/curl-examples/api-files/upload-image-files-v1.sh b/docs/versioned_docs/version-1.9.0/API-Reference/curl-examples/api-files/upload-image-files-v1.sh new file mode 100644 index 0000000000..90d879f8a8 --- /dev/null +++ b/docs/versioned_docs/version-1.9.0/API-Reference/curl-examples/api-files/upload-image-files-v1.sh @@ -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}" diff --git a/docs/versioned_docs/version-1.9.0/API-Reference/curl-examples/api-flows-run/pass-global-variables-in-request-headers.sh b/docs/versioned_docs/version-1.9.0/API-Reference/curl-examples/api-flows-run/pass-global-variables-in-request-headers.sh new file mode 100644 index 0000000000..be973988fb --- /dev/null +++ b/docs/versioned_docs/version-1.9.0/API-Reference/curl-examples/api-flows-run/pass-global-variables-in-request-headers.sh @@ -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" + }' diff --git a/docs/versioned_docs/version-1.9.0/API-Reference/curl-examples/api-flows-run/request-example-with-all-headers-and-parameters.sh b/docs/versioned_docs/version-1.9.0/API-Reference/curl-examples/api-flows-run/request-example-with-all-headers-and-parameters.sh new file mode 100644 index 0000000000..a5d61fb803 --- /dev/null +++ b/docs/versioned_docs/version-1.9.0/API-Reference/curl-examples/api-flows-run/request-example-with-all-headers-and-parameters.sh @@ -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" + } + } + }' diff --git a/docs/versioned_docs/version-1.9.0/API-Reference/curl-examples/api-flows-run/result-webhook-run-flow.json b/docs/versioned_docs/version-1.9.0/API-Reference/curl-examples/api-flows-run/result-webhook-run-flow.json new file mode 100644 index 0000000000..43d35d1f94 --- /dev/null +++ b/docs/versioned_docs/version-1.9.0/API-Reference/curl-examples/api-flows-run/result-webhook-run-flow.json @@ -0,0 +1,4 @@ +{ + "message": "Task started in the background", + "status": "in progress" +} diff --git a/docs/versioned_docs/version-1.9.0/API-Reference/curl-examples/api-flows-run/run-flow.sh b/docs/versioned_docs/version-1.9.0/API-Reference/curl-examples/api-flows-run/run-flow.sh new file mode 100644 index 0000000000..629efe9cd4 --- /dev/null +++ b/docs/versioned_docs/version-1.9.0/API-Reference/curl-examples/api-flows-run/run-flow.sh @@ -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": "" + }' diff --git a/docs/versioned_docs/version-1.9.0/API-Reference/curl-examples/api-flows-run/stream-llm-token-responses.sh b/docs/versioned_docs/version-1.9.0/API-Reference/curl-examples/api-flows-run/stream-llm-token-responses.sh new file mode 100644 index 0000000000..adefe07440 --- /dev/null +++ b/docs/versioned_docs/version-1.9.0/API-Reference/curl-examples/api-flows-run/stream-llm-token-responses.sh @@ -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" + }' diff --git a/docs/versioned_docs/version-1.9.0/API-Reference/curl-examples/api-flows-run/webhook-run-flow.sh b/docs/versioned_docs/version-1.9.0/API-Reference/curl-examples/api-flows-run/webhook-run-flow.sh new file mode 100644 index 0000000000..03e57dd474 --- /dev/null +++ b/docs/versioned_docs/version-1.9.0/API-Reference/curl-examples/api-flows-run/webhook-run-flow.sh @@ -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"}' diff --git a/docs/versioned_docs/version-1.9.0/API-Reference/curl-examples/api-flows/create-flow.sh b/docs/versioned_docs/version-1.9.0/API-Reference/curl-examples/api-flows/create-flow.sh new file mode 100644 index 0000000000..ef3ee320f6 --- /dev/null +++ b/docs/versioned_docs/version-1.9.0/API-Reference/curl-examples/api-flows/create-flow.sh @@ -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" + ] +}' diff --git a/docs/versioned_docs/version-1.9.0/API-Reference/curl-examples/api-flows/create-flows.sh b/docs/versioned_docs/version-1.9.0/API-Reference/curl-examples/api-flows/create-flows.sh new file mode 100644 index 0000000000..b74f5737cd --- /dev/null +++ b/docs/versioned_docs/version-1.9.0/API-Reference/curl-examples/api-flows/create-flows.sh @@ -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" + } + ] +}' diff --git a/docs/versioned_docs/version-1.9.0/API-Reference/curl-examples/api-flows/delete-flow.sh b/docs/versioned_docs/version-1.9.0/API-Reference/curl-examples/api-flows/delete-flow.sh new file mode 100644 index 0000000000..65289ac50b --- /dev/null +++ b/docs/versioned_docs/version-1.9.0/API-Reference/curl-examples/api-flows/delete-flow.sh @@ -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" diff --git a/docs/versioned_docs/version-1.9.0/API-Reference/curl-examples/api-flows/export-flows.sh b/docs/versioned_docs/version-1.9.0/API-Reference/curl-examples/api-flows/export-flows.sh new file mode 100644 index 0000000000..3148fc4a30 --- /dev/null +++ b/docs/versioned_docs/version-1.9.0/API-Reference/curl-examples/api-flows/export-flows.sh @@ -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 diff --git a/docs/versioned_docs/version-1.9.0/API-Reference/curl-examples/api-flows/import-flows.sh b/docs/versioned_docs/version-1.9.0/API-Reference/curl-examples/api-flows/import-flows.sh new file mode 100644 index 0000000000..3134d05d28 --- /dev/null +++ b/docs/versioned_docs/version-1.9.0/API-Reference/curl-examples/api-flows/import-flows.sh @@ -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" diff --git a/docs/versioned_docs/version-1.9.0/API-Reference/curl-examples/api-flows/read-flow.sh b/docs/versioned_docs/version-1.9.0/API-Reference/curl-examples/api-flows/read-flow.sh new file mode 100644 index 0000000000..9d3725acfc --- /dev/null +++ b/docs/versioned_docs/version-1.9.0/API-Reference/curl-examples/api-flows/read-flow.sh @@ -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" diff --git a/docs/versioned_docs/version-1.9.0/API-Reference/curl-examples/api-flows/read-flows-2.sh b/docs/versioned_docs/version-1.9.0/API-Reference/curl-examples/api-flows/read-flows-2.sh new file mode 100644 index 0000000000..c1bb6a1b28 --- /dev/null +++ b/docs/versioned_docs/version-1.9.0/API-Reference/curl-examples/api-flows/read-flows-2.sh @@ -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" diff --git a/docs/versioned_docs/version-1.9.0/API-Reference/curl-examples/api-flows/read-flows.sh b/docs/versioned_docs/version-1.9.0/API-Reference/curl-examples/api-flows/read-flows.sh new file mode 100644 index 0000000000..c877359d05 --- /dev/null +++ b/docs/versioned_docs/version-1.9.0/API-Reference/curl-examples/api-flows/read-flows.sh @@ -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" diff --git a/docs/versioned_docs/version-1.9.0/API-Reference/curl-examples/api-flows/read-sample-flows.sh b/docs/versioned_docs/version-1.9.0/API-Reference/curl-examples/api-flows/read-sample-flows.sh new file mode 100644 index 0000000000..c9388a8a3f --- /dev/null +++ b/docs/versioned_docs/version-1.9.0/API-Reference/curl-examples/api-flows/read-sample-flows.sh @@ -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" diff --git a/docs/versioned_docs/version-1.9.0/API-Reference/curl-examples/api-flows/result-create-flow.json b/docs/versioned_docs/version-1.9.0/API-Reference/curl-examples/api-flows/result-create-flow.json new file mode 100644 index 0000000000..784546b475 --- /dev/null +++ b/docs/versioned_docs/version-1.9.0/API-Reference/curl-examples/api-flows/result-create-flow.json @@ -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" +} diff --git a/docs/versioned_docs/version-1.9.0/API-Reference/curl-examples/api-flows/result-delete-flow.json b/docs/versioned_docs/version-1.9.0/API-Reference/curl-examples/api-flows/result-delete-flow.json new file mode 100644 index 0000000000..5f2f03e818 --- /dev/null +++ b/docs/versioned_docs/version-1.9.0/API-Reference/curl-examples/api-flows/result-delete-flow.json @@ -0,0 +1,3 @@ +{ + "message": "Flow deleted successfully" +} diff --git a/docs/versioned_docs/version-1.9.0/API-Reference/curl-examples/api-flows/result-export-flows.txt b/docs/versioned_docs/version-1.9.0/API-Reference/curl-examples/api-flows/result-export-flows.txt new file mode 100644 index 0000000000..cb2e1f5179 --- /dev/null +++ b/docs/versioned_docs/version-1.9.0/API-Reference/curl-examples/api-flows/result-export-flows.txt @@ -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 diff --git a/docs/versioned_docs/version-1.9.0/API-Reference/curl-examples/api-flows/result-read-flow.json b/docs/versioned_docs/version-1.9.0/API-Reference/curl-examples/api-flows/result-read-flow.json new file mode 100644 index 0000000000..1c331b28df --- /dev/null +++ b/docs/versioned_docs/version-1.9.0/API-Reference/curl-examples/api-flows/result-read-flow.json @@ -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": [ + ... + ] + } +} diff --git a/docs/versioned_docs/version-1.9.0/API-Reference/curl-examples/api-flows/result-update-flow.json b/docs/versioned_docs/version-1.9.0/API-Reference/curl-examples/api-flows/result-update-flow.json new file mode 100644 index 0000000000..480af39d1a --- /dev/null +++ b/docs/versioned_docs/version-1.9.0/API-Reference/curl-examples/api-flows/result-update-flow.json @@ -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" +} diff --git a/docs/versioned_docs/version-1.9.0/API-Reference/curl-examples/api-flows/update-flow.sh b/docs/versioned_docs/version-1.9.0/API-Reference/curl-examples/api-flows/update-flow.sh new file mode 100644 index 0000000000..437dc476a6 --- /dev/null +++ b/docs/versioned_docs/version-1.9.0/API-Reference/curl-examples/api-flows/update-flow.sh @@ -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 +}' diff --git a/docs/versioned_docs/version-1.9.0/API-Reference/curl-examples/api-logs/result-retrieve-logs-with-optional-parameters.txt b/docs/versioned_docs/version-1.9.0/API-Reference/curl-examples/api-logs/result-retrieve-logs-with-optional-parameters.txt new file mode 100644 index 0000000000..5960117df3 --- /dev/null +++ b/docs/versioned_docs/version-1.9.0/API-Reference/curl-examples/api-logs/result-retrieve-logs-with-optional-parameters.txt @@ -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" +} diff --git a/docs/versioned_docs/version-1.9.0/API-Reference/curl-examples/api-logs/result-stream-logs.txt b/docs/versioned_docs/version-1.9.0/API-Reference/curl-examples/api-logs/result-stream-logs.txt new file mode 100644 index 0000000000..511dbb5770 --- /dev/null +++ b/docs/versioned_docs/version-1.9.0/API-Reference/curl-examples/api-logs/result-stream-logs.txt @@ -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 diff --git a/docs/versioned_docs/version-1.9.0/API-Reference/curl-examples/api-logs/retrieve-logs-with-optional-parameters.sh b/docs/versioned_docs/version-1.9.0/API-Reference/curl-examples/api-logs/retrieve-logs-with-optional-parameters.sh new file mode 100644 index 0000000000..0a17a8e0f8 --- /dev/null +++ b/docs/versioned_docs/version-1.9.0/API-Reference/curl-examples/api-logs/retrieve-logs-with-optional-parameters.sh @@ -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" diff --git a/docs/versioned_docs/version-1.9.0/API-Reference/curl-examples/api-logs/stream-logs.sh b/docs/versioned_docs/version-1.9.0/API-Reference/curl-examples/api-logs/stream-logs.sh new file mode 100644 index 0000000000..7d44689d02 --- /dev/null +++ b/docs/versioned_docs/version-1.9.0/API-Reference/curl-examples/api-logs/stream-logs.sh @@ -0,0 +1,4 @@ +curl -X GET \ + "$LANGFLOW_URL/logs-stream" \ + -H "accept: text/event-stream" \ + -H "x-api-key: $LANGFLOW_API_KEY" diff --git a/docs/versioned_docs/version-1.9.0/API-Reference/curl-examples/api-monitor/delete-messages-by-session.sh b/docs/versioned_docs/version-1.9.0/API-Reference/curl-examples/api-monitor/delete-messages-by-session.sh new file mode 100644 index 0000000000..d1cbe97356 --- /dev/null +++ b/docs/versioned_docs/version-1.9.0/API-Reference/curl-examples/api-monitor/delete-messages-by-session.sh @@ -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" diff --git a/docs/versioned_docs/version-1.9.0/API-Reference/curl-examples/api-monitor/delete-messages.sh b/docs/versioned_docs/version-1.9.0/API-Reference/curl-examples/api-monitor/delete-messages.sh new file mode 100644 index 0000000000..33fe9aa933 --- /dev/null +++ b/docs/versioned_docs/version-1.9.0/API-Reference/curl-examples/api-monitor/delete-messages.sh @@ -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"]' diff --git a/docs/versioned_docs/version-1.9.0/API-Reference/curl-examples/api-monitor/delete-vertex-builds.sh b/docs/versioned_docs/version-1.9.0/API-Reference/curl-examples/api-monitor/delete-vertex-builds.sh new file mode 100644 index 0000000000..6fd258daa8 --- /dev/null +++ b/docs/versioned_docs/version-1.9.0/API-Reference/curl-examples/api-monitor/delete-vertex-builds.sh @@ -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" diff --git a/docs/versioned_docs/version-1.9.0/API-Reference/curl-examples/api-monitor/example-request.sh b/docs/versioned_docs/version-1.9.0/API-Reference/curl-examples/api-monitor/example-request.sh new file mode 100644 index 0000000000..7963ac2a7e --- /dev/null +++ b/docs/versioned_docs/version-1.9.0/API-Reference/curl-examples/api-monitor/example-request.sh @@ -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 . diff --git a/docs/versioned_docs/version-1.9.0/API-Reference/curl-examples/api-monitor/get-messages-2.sh b/docs/versioned_docs/version-1.9.0/API-Reference/curl-examples/api-monitor/get-messages-2.sh new file mode 100644 index 0000000000..bbdfdf59a9 --- /dev/null +++ b/docs/versioned_docs/version-1.9.0/API-Reference/curl-examples/api-monitor/get-messages-2.sh @@ -0,0 +1,4 @@ +curl -X GET \ + "$LANGFLOW_URL/api/v1/monitor/messages?flow_id=$FLOW_ID&session_id=01ce083d-748b-4b8d-97b6-33adbb6a528a&sender=Machine&sender_name=AI&order_by=timestamp" \ + -H "accept: application/json" \ + -H "x-api-key: $LANGFLOW_API_KEY" diff --git a/docs/versioned_docs/version-1.9.0/API-Reference/curl-examples/api-monitor/get-messages.sh b/docs/versioned_docs/version-1.9.0/API-Reference/curl-examples/api-monitor/get-messages.sh new file mode 100644 index 0000000000..b1553bb3b4 --- /dev/null +++ b/docs/versioned_docs/version-1.9.0/API-Reference/curl-examples/api-monitor/get-messages.sh @@ -0,0 +1,4 @@ +curl -X GET \ + "$LANGFLOW_URL/api/v1/monitor/messages" \ + -H "accept: application/json" \ + -H "x-api-key: $LANGFLOW_API_KEY" diff --git a/docs/versioned_docs/version-1.9.0/API-Reference/curl-examples/api-monitor/get-transactions.sh b/docs/versioned_docs/version-1.9.0/API-Reference/curl-examples/api-monitor/get-transactions.sh new file mode 100644 index 0000000000..187986b18d --- /dev/null +++ b/docs/versioned_docs/version-1.9.0/API-Reference/curl-examples/api-monitor/get-transactions.sh @@ -0,0 +1,4 @@ +curl -X GET \ + "$LANGFLOW_URL/api/v1/monitor/transactions?flow_id=$FLOW_ID&page=1&size=50" \ + -H "accept: application/json" \ + -H "x-api-key: $LANGFLOW_API_KEY" diff --git a/docs/versioned_docs/version-1.9.0/API-Reference/curl-examples/api-monitor/get-vertex-builds.sh b/docs/versioned_docs/version-1.9.0/API-Reference/curl-examples/api-monitor/get-vertex-builds.sh new file mode 100644 index 0000000000..6e3bdfa84e --- /dev/null +++ b/docs/versioned_docs/version-1.9.0/API-Reference/curl-examples/api-monitor/get-vertex-builds.sh @@ -0,0 +1,4 @@ +curl -X GET \ + "$LANGFLOW_URL/api/v1/monitor/builds?flow_id=$FLOW_ID" \ + -H "accept: application/json" \ + -H "x-api-key: $LANGFLOW_API_KEY" diff --git a/docs/versioned_docs/version-1.9.0/API-Reference/curl-examples/api-monitor/result-delete-messages-by-session.txt b/docs/versioned_docs/version-1.9.0/API-Reference/curl-examples/api-monitor/result-delete-messages-by-session.txt new file mode 100644 index 0000000000..58e46abbc9 --- /dev/null +++ b/docs/versioned_docs/version-1.9.0/API-Reference/curl-examples/api-monitor/result-delete-messages-by-session.txt @@ -0,0 +1 @@ +HTTP/1.1 204 No Content diff --git a/docs/versioned_docs/version-1.9.0/API-Reference/curl-examples/api-monitor/result-delete-messages.txt b/docs/versioned_docs/version-1.9.0/API-Reference/curl-examples/api-monitor/result-delete-messages.txt new file mode 100644 index 0000000000..bd3152a3b7 --- /dev/null +++ b/docs/versioned_docs/version-1.9.0/API-Reference/curl-examples/api-monitor/result-delete-messages.txt @@ -0,0 +1 @@ +204 No Content diff --git a/docs/versioned_docs/version-1.9.0/API-Reference/curl-examples/api-monitor/result-delete-vertex-builds.txt b/docs/versioned_docs/version-1.9.0/API-Reference/curl-examples/api-monitor/result-delete-vertex-builds.txt new file mode 100644 index 0000000000..bd3152a3b7 --- /dev/null +++ b/docs/versioned_docs/version-1.9.0/API-Reference/curl-examples/api-monitor/result-delete-vertex-builds.txt @@ -0,0 +1 @@ +204 No Content diff --git a/docs/versioned_docs/version-1.9.0/API-Reference/curl-examples/api-monitor/result-get-messages-2.json b/docs/versioned_docs/version-1.9.0/API-Reference/curl-examples/api-monitor/result-get-messages-2.json new file mode 100644 index 0000000000..d15a45a10c --- /dev/null +++ b/docs/versioned_docs/version-1.9.0/API-Reference/curl-examples/api-monitor/result-get-messages-2.json @@ -0,0 +1,30 @@ +[ + { + "id": "1c1d6134-9b8b-4079-931c-84dcaddf19ba", + "flow_id": "01ce083d-748b-4b8d-97b6-33adbb6a528a", + "timestamp": "2024-12-23 19:20:11 UTC", + "sender": "Machine", + "sender_name": "AI", + "session_id": "01ce083d-748b-4b8d-97b6-33adbb6a528a", + "text": "Hello! It's great to see you here! What exciting project or idea are you thinking about diving into today? Whether it's something fresh and innovative or a classic concept with a twist, I'm here to help you get started! Let's brainstorm together!", + "files": "[]", + "edit": false, + "properties": { + "text_color": "", + "background_color": "", + "edited": false, + "source": { + "id": "OpenAIModel-7AjrN", + "display_name": "OpenAI", + "source": "gpt-4o-mini" + }, + "icon": "OpenAI", + "allow_markdown": false, + "positive_feedback": null, + "state": "complete", + "targets": [] + }, + "category": "message", + "content_blocks": [] + } +] diff --git a/docs/versioned_docs/version-1.9.0/API-Reference/curl-examples/api-monitor/result-get-transactions.json b/docs/versioned_docs/version-1.9.0/API-Reference/curl-examples/api-monitor/result-get-transactions.json new file mode 100644 index 0000000000..d84ddf400a --- /dev/null +++ b/docs/versioned_docs/version-1.9.0/API-Reference/curl-examples/api-monitor/result-get-transactions.json @@ -0,0 +1,19 @@ +{ + "items": [ + { + "timestamp": "2024-12-23T20:05:01.061Z", + "vertex_id": "string", + "target_id": "string", + "inputs": {}, + "outputs": {}, + "status": "string", + "error": "string", + "flow_id": "3fa85f64-5717-4562-b3fc-2c963f66afa6", + "id": "3fa85f64-5717-4562-b3fc-2c963f66afa6" + } + ], + "total": 0, + "page": 1, + "size": 1, + "pages": 0 +} diff --git a/docs/versioned_docs/version-1.9.0/API-Reference/curl-examples/api-monitor/result-get-vertex-builds.json b/docs/versioned_docs/version-1.9.0/API-Reference/curl-examples/api-monitor/result-get-vertex-builds.json new file mode 100644 index 0000000000..4d42f8fabc --- /dev/null +++ b/docs/versioned_docs/version-1.9.0/API-Reference/curl-examples/api-monitor/result-get-vertex-builds.json @@ -0,0 +1,357 @@ +{ + "vertex_builds": { + "ChatInput-NCmix": [ + { + "data": { + "results": { + "message": { + "text_key": "text", + "data": { + "timestamp": "2024-12-23 19:10:57", + "sender": "User", + "sender_name": "User", + "session_id": "01ce083d-748b-4b8d-97b6-33adbb6a528a", + "text": "Hello", + "files": [], + "error": "False", + "edit": "False", + "properties": { + "text_color": "", + "background_color": "", + "edited": "False", + "source": { + "id": "None", + "display_name": "None", + "source": "None" + }, + "icon": "", + "allow_markdown": "False", + "positive_feedback": "None", + "state": "complete", + "targets": [] + }, + "category": "message", + "content_blocks": [], + "id": "c95bed34-f906-4aa6-84e4-68553f6db772", + "flow_id": "01ce083d-748b-4b8d-97b6-33adbb6a528a" + }, + "default_value": "", + "text": "Hello", + "sender": "User", + "sender_name": "User", + "files": [], + "session_id": "01ce083d-748b-4b8d-97b6-33adbb6a528a", + "timestamp": "2024-12-23 19:10:57+00:00", + "flow_id": "01ce083d-748b-4b8d-97b6-33adbb6a528a", + "error": "False", + "edit": "False", + "properties": { + "text_color": "", + "background_color": "", + "edited": "False", + "source": { + "id": "None", + "display_name": "None", + "source": "None" + }, + "icon": "", + "allow_markdown": "False", + "positive_feedback": "None", + "state": "complete", + "targets": [] + }, + "category": "message", + "content_blocks": [] + } + }, + "outputs": { + "message": { + "message": { + "timestamp": "2024-12-23T19:10:57", + "sender": "User", + "sender_name": "User", + "session_id": "01ce083d-748b-4b8d-97b6-33adbb6a528a", + "text": "Hello", + "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": "c95bed34-f906-4aa6-84e4-68553f6db772", + "flow_id": "01ce083d-748b-4b8d-97b6-33adbb6a528a" + }, + "type": "object" + } + }, + "logs": { "message": [] }, + "message": { + "message": "Hello", + "sender": "User", + "sender_name": "User", + "files": [], + "type": "object" + }, + "artifacts": { + "message": "Hello", + "sender": "User", + "sender_name": "User", + "files": [], + "type": "object" + }, + "timedelta": 0.015060124918818474, + "duration": "15 ms", + "used_frozen_result": false + }, + "artifacts": { + "message": "Hello", + "sender": "User", + "sender_name": "User", + "files": [], + "type": "object" + }, + "params": "- Files: []\n Message: Hello\n Sender: User\n Sender Name: User\n Type: object\n", + "valid": true, + "build_id": "40aa200e-74db-4651-b698-f80301d2b26b", + "id": "ChatInput-NCmix", + "timestamp": "2024-12-23T19:10:58.772766Z", + "flow_id": "01ce083d-748b-4b8d-97b6-33adbb6a528a" + } + ], + "Prompt-BEn9c": [ + { + "data": { + "results": {}, + "outputs": { + "prompt": { + "message": "Answer the user as if you were a GenAI expert, enthusiastic about helping them get started building something fresh.", + "type": "text" + } + }, + "logs": { "prompt": [] }, + "message": { + "prompt": { + "repr": "Answer the user as if you were a GenAI expert, enthusiastic about helping them get started building something fresh.", + "raw": "Answer the user as if you were a GenAI expert, enthusiastic about helping them get started building something fresh.", + "type": "text" + } + }, + "artifacts": { + "prompt": { + "repr": "Answer the user as if you were a GenAI expert, enthusiastic about helping them get started building something fresh.", + "raw": "Answer the user as if you were a GenAI expert, enthusiastic about helping them get started building something fresh.", + "type": "text" + } + }, + "timedelta": 0.0057758750626817346, + "duration": "6 ms", + "used_frozen_result": false + }, + "artifacts": { + "prompt": { + "repr": "Answer the user as if you were a GenAI expert, enthusiastic about helping them get started building something fresh.", + "raw": "Answer the user as if you were a GenAI expert, enthusiastic about helping them get started building something fresh.", + "type": "text" + } + }, + "params": "None", + "valid": true, + "build_id": "39bbbfde-97fd-42a5-a9ed-d42a5c5d532b", + "id": "Prompt-BEn9c", + "timestamp": "2024-12-23T19:10:58.781019Z", + "flow_id": "01ce083d-748b-4b8d-97b6-33adbb6a528a" + } + ], + "OpenAIModel-7AjrN": [ + { + "data": { + "results": {}, + "outputs": { + "text_output": { + "message": "Hello! 🌟 I'm excited to help you get started on your journey to building something fresh! What do you have in mind? Whether it's a project, an idea, or a concept, let's dive in and make it happen!", + "type": "text" + }, + "model_output": { "message": "", "type": "unknown" } + }, + "logs": { "text_output": [] }, + "message": { + "text_output": { + "repr": "Hello! 🌟 I'm excited to help you get started on your journey to building something fresh! What do you have in mind? Whether it's a project, an idea, or a concept, let's dive in and make it happen!", + "raw": "Hello! 🌟 I'm excited to help you get started on your journey to building something fresh! What do you have in mind? Whether it's a project, an idea, or a concept, let's dive in and make it happen!", + "type": "text" + } + }, + "artifacts": { + "text_output": { + "repr": "Hello! 🌟 I'm excited to help you get started on your journey to building something fresh! What do you have in mind? Whether it's a project, an idea, or a concept, let's dive in and make it happen!", + "raw": "Hello! 🌟 I'm excited to help you get started on your journey to building something fresh! What do you have in mind? Whether it's a project, an idea, or a concept, let's dive in and make it happen!", + "type": "text" + } + }, + "timedelta": 1.034765167045407, + "duration": "1.03 seconds", + "used_frozen_result": false + }, + "artifacts": { + "text_output": { + "repr": "Hello! 🌟 I'm excited to help you get started on your journey to building something fresh! What do you have in mind? Whether it's a project, an idea, or a concept, let's dive in and make it happen!", + "raw": "Hello! 🌟 I'm excited to help you get started on your journey to building something fresh! What do you have in mind? Whether it's a project, an idea, or a concept, let's dive in and make it happen!", + "type": "text" + } + }, + "params": "None", + "valid": true, + "build_id": "4f0ae730-a266-4d35-b89f-7b825c620a0f", + "id": "OpenAIModel-7AjrN", + "timestamp": "2024-12-23T19:10:58.790484Z", + "flow_id": "01ce083d-748b-4b8d-97b6-33adbb6a528a" + } + ], + "ChatOutput-sfUhT": [ + { + "data": { + "results": { + "message": { + "text_key": "text", + "data": { + "timestamp": "2024-12-23 19:10:58", + "sender": "Machine", + "sender_name": "AI", + "session_id": "01ce083d-748b-4b8d-97b6-33adbb6a528a", + "text": "Hello! 🌟 I'm excited to help you get started on your journey to building something fresh! What do you have in mind? Whether it's a project, an idea, or a concept, let's dive in and make it happen!", + "files": [], + "error": "False", + "edit": "False", + "properties": { + "text_color": "", + "background_color": "", + "edited": "False", + "source": { + "id": "OpenAIModel-7AjrN", + "display_name": "OpenAI", + "source": "gpt-4o-mini" + }, + "icon": "OpenAI", + "allow_markdown": "False", + "positive_feedback": "None", + "state": "complete", + "targets": [] + }, + "category": "message", + "content_blocks": [], + "id": "5688356d-9f30-40ca-9907-79a7a2fc16fd", + "flow_id": "01ce083d-748b-4b8d-97b6-33adbb6a528a" + }, + "default_value": "", + "text": "Hello! 🌟 I'm excited to help you get started on your journey to building something fresh! What do you have in mind? Whether it's a project, an idea, or a concept, let's dive in and make it happen!", + "sender": "Machine", + "sender_name": "AI", + "files": [], + "session_id": "01ce083d-748b-4b8d-97b6-33adbb6a528a", + "timestamp": "2024-12-23 19:10:58+00:00", + "flow_id": "01ce083d-748b-4b8d-97b6-33adbb6a528a", + "error": "False", + "edit": "False", + "properties": { + "text_color": "", + "background_color": "", + "edited": "False", + "source": { + "id": "OpenAIModel-7AjrN", + "display_name": "OpenAI", + "source": "gpt-4o-mini" + }, + "icon": "OpenAI", + "allow_markdown": "False", + "positive_feedback": "None", + "state": "complete", + "targets": [] + }, + "category": "message", + "content_blocks": [] + } + }, + "outputs": { + "message": { + "message": { + "timestamp": "2024-12-23T19:10:58", + "sender": "Machine", + "sender_name": "AI", + "session_id": "01ce083d-748b-4b8d-97b6-33adbb6a528a", + "text": "Hello! 🌟 I'm excited to help you get started on your journey to building something fresh! What do you have in mind? Whether it's a project, an idea, or a concept, let's dive in and make it happen!", + "files": [], + "error": false, + "edit": false, + "properties": { + "text_color": "", + "background_color": "", + "edited": false, + "source": { + "id": "OpenAIModel-7AjrN", + "display_name": "OpenAI", + "source": "gpt-4o-mini" + }, + "icon": "OpenAI", + "allow_markdown": false, + "positive_feedback": null, + "state": "complete", + "targets": [] + }, + "category": "message", + "content_blocks": [], + "id": "5688356d-9f30-40ca-9907-79a7a2fc16fd", + "flow_id": "01ce083d-748b-4b8d-97b6-33adbb6a528a" + }, + "type": "object" + } + }, + "logs": { "message": [] }, + "message": { + "message": "Hello! 🌟 I'm excited to help you get started on your journey to building something fresh! What do you have in mind? Whether it's a project, an idea, or a concept, let's dive in and make it happen!", + "sender": "Machine", + "sender_name": "AI", + "files": [], + "type": "object" + }, + "artifacts": { + "message": "Hello! 🌟 I'm excited to help you get started on your journey to building something fresh! What do you have in mind? Whether it's a project, an idea, or a concept, let's dive in and make it happen!", + "sender": "Machine", + "sender_name": "AI", + "files": [], + "type": "object" + }, + "timedelta": 0.017838125000707805, + "duration": "18 ms", + "used_frozen_result": false + }, + "artifacts": { + "message": "Hello! 🌟 I'm excited to help you get started on your journey to building something fresh! What do you have in mind? Whether it's a project, an idea, or a concept, let's dive in and make it happen!", + "sender": "Machine", + "sender_name": "AI", + "files": [], + "type": "object" + }, + "params": "- Files: []\n Message: Hello! 🌟 I'm excited to help you get started on your journey to building\n something fresh! What do you have in mind? Whether it's a project, an idea, or\n a concept, let's dive in and make it happen!\n Sender: Machine\n Sender Name: AI\n Type: object\n", + "valid": true, + "build_id": "1e8b908b-aba7-403b-9e9b-eca92bb78668", + "id": "ChatOutput-sfUhT", + "timestamp": "2024-12-23T19:10:58.813268Z", + "flow_id": "01ce083d-748b-4b8d-97b6-33adbb6a528a" + } + ] + } +} diff --git a/docs/versioned_docs/version-1.9.0/API-Reference/curl-examples/api-monitor/result-update-message.json b/docs/versioned_docs/version-1.9.0/API-Reference/curl-examples/api-monitor/result-update-message.json new file mode 100644 index 0000000000..c6cd0df00a --- /dev/null +++ b/docs/versioned_docs/version-1.9.0/API-Reference/curl-examples/api-monitor/result-update-message.json @@ -0,0 +1,25 @@ +{ + "timestamp": "2024-12-23T18:49:06", + "sender": "string", + "sender_name": "string", + "session_id": "01ce083d-748b-4b8d-97b6-33adbb6a528a", + "text": "testing 1234", + "files": ["string"], + "error": true, + "edit": true, + "properties": { + "text_color": "string", + "background_color": "string", + "edited": false, + "source": { "id": "string", "display_name": "string", "source": "string" }, + "icon": "string", + "allow_markdown": false, + "positive_feedback": true, + "state": "complete", + "targets": [] + }, + "category": "message", + "content_blocks": [], + "id": "3ab66cc6-c048-48f8-ab07-570f5af7b160", + "flow_id": "01ce083d-748b-4b8d-97b6-33adbb6a528a" +} diff --git a/docs/versioned_docs/version-1.9.0/API-Reference/curl-examples/api-monitor/result-update-session-id.json b/docs/versioned_docs/version-1.9.0/API-Reference/curl-examples/api-monitor/result-update-session-id.json new file mode 100644 index 0000000000..f58222e791 --- /dev/null +++ b/docs/versioned_docs/version-1.9.0/API-Reference/curl-examples/api-monitor/result-update-session-id.json @@ -0,0 +1,30 @@ +[ + { + "id": "8dd7f064-e63a-4773-b472-ca0475249dfd", + "flow_id": "01ce083d-748b-4b8d-97b6-33adbb6a528a", + "timestamp": "2024-12-23 18:49:55 UTC", + "sender": "User", + "sender_name": "User", + "session_id": "different_session_id", + "text": "message", + "files": "[]", + "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": [] + } +] diff --git a/docs/versioned_docs/version-1.9.0/API-Reference/curl-examples/api-monitor/update-message.sh b/docs/versioned_docs/version-1.9.0/API-Reference/curl-examples/api-monitor/update-message.sh new file mode 100644 index 0000000000..9d3cf32c30 --- /dev/null +++ b/docs/versioned_docs/version-1.9.0/API-Reference/curl-examples/api-monitor/update-message.sh @@ -0,0 +1,8 @@ +curl -X PUT \ + "$LANGFLOW_URL/api/v1/monitor/messages/3ab66cc6-c048-48f8-ab07-570f5af7b160" \ + -H "accept: application/json" \ + -H "Content-Type: application/json" \ + -H "x-api-key: $LANGFLOW_API_KEY" \ + -d '{ + "text": "testing 1234" +}' diff --git a/docs/versioned_docs/version-1.9.0/API-Reference/curl-examples/api-monitor/update-session-id.sh b/docs/versioned_docs/version-1.9.0/API-Reference/curl-examples/api-monitor/update-session-id.sh new file mode 100644 index 0000000000..93bf53f650 --- /dev/null +++ b/docs/versioned_docs/version-1.9.0/API-Reference/curl-examples/api-monitor/update-session-id.sh @@ -0,0 +1,4 @@ +curl -X PATCH \ + "$LANGFLOW_URL/api/v1/monitor/messages/session/01ce083d-748b-4b8d-97b6-33adbb6a528a?new_session_id=different_session_id" \ + -H "accept: application/json" \ + -H "x-api-key: $LANGFLOW_API_KEY" diff --git a/docs/versioned_docs/version-1.9.0/API-Reference/curl-examples/api-openai-responses/continue-conversations-with-response-and-session-ids-2.sh b/docs/versioned_docs/version-1.9.0/API-Reference/curl-examples/api-openai-responses/continue-conversations-with-response-and-session-ids-2.sh new file mode 100644 index 0000000000..1c131abda9 --- /dev/null +++ b/docs/versioned_docs/version-1.9.0/API-Reference/curl-examples/api-openai-responses/continue-conversations-with-response-and-session-ids-2.sh @@ -0,0 +1,13 @@ +BASE_URL="${LANGFLOW_SERVER_URL:-$LANGFLOW_URL}" + +curl -X POST \ + "$BASE_URL/api/v1/responses" \ + -H "x-api-key: $LANGFLOW_API_KEY" \ + -H "Content-Type: application/json" \ + -d @- </tmp/langflow-curl-example.out 2>/tmp/langflow-curl-example.err; then + echo "FAIL $rel (execution)" + print_failure_logs "/tmp/langflow-curl-example.out" "/tmp/langflow-curl-example.err" + ((FAIL+=1)) + continue + fi + fi + + echo "PASS $rel" + ((PASS+=1)) +done + +echo +echo "Summary: PASS=$PASS FAIL=$FAIL SKIP=$SKIP TOTAL=${#SH_FILES[@]}" + +if [[ $FAIL -gt 0 ]]; then + exit 1 +fi diff --git a/docs/versioned_docs/version-1.9.0/API-Reference/curl-examples/workflows-api/example-asynchronous-request.sh b/docs/versioned_docs/version-1.9.0/API-Reference/curl-examples/workflows-api/example-asynchronous-request.sh new file mode 100644 index 0000000000..acaf1d8566 --- /dev/null +++ b/docs/versioned_docs/version-1.9.0/API-Reference/curl-examples/workflows-api/example-asynchronous-request.sh @@ -0,0 +1,14 @@ +curl -X POST \ + "$LANGFLOW_SERVER_URL/api/v2/workflows" \ + -H "Content-Type: application/json" \ + -H "x-api-key: $LANGFLOW_API_KEY" \ + -d '{ + "flow_id": "flow_67ccd2be17f0819081ff3bb2cf6508e60bb6a6b452d3795b", + "background": true, + "stream": false, + "inputs": { + "ChatInput-abc.input_type": "chat", + "ChatInput-abc.input_value": "Process this in the background", + "ChatInput-abc.session_id": "session-456" + } + }' diff --git a/docs/versioned_docs/version-1.9.0/API-Reference/curl-examples/workflows-api/example-request-2.sh b/docs/versioned_docs/version-1.9.0/API-Reference/curl-examples/workflows-api/example-request-2.sh new file mode 100644 index 0000000000..25d897dd39 --- /dev/null +++ b/docs/versioned_docs/version-1.9.0/API-Reference/curl-examples/workflows-api/example-request-2.sh @@ -0,0 +1,7 @@ +curl -X POST \ + "$LANGFLOW_SERVER_URL/api/v2/workflows/stop" \ + -H "Content-Type: application/json" \ + -H "x-api-key: $LANGFLOW_API_KEY" \ + -d '{ + "job_id": "job_id_1234567890" + }' diff --git a/docs/versioned_docs/version-1.9.0/API-Reference/curl-examples/workflows-api/example-request.sh b/docs/versioned_docs/version-1.9.0/API-Reference/curl-examples/workflows-api/example-request.sh new file mode 100644 index 0000000000..6f9553582b --- /dev/null +++ b/docs/versioned_docs/version-1.9.0/API-Reference/curl-examples/workflows-api/example-request.sh @@ -0,0 +1,4 @@ +curl -X GET \ + "$LANGFLOW_SERVER_URL/api/v2/workflows?job_id=job_id_1234567890" \ + -H "accept: application/json" \ + -H "x-api-key: $LANGFLOW_API_KEY" diff --git a/docs/versioned_docs/version-1.9.0/API-Reference/curl-examples/workflows-api/example-synchronous-request.sh b/docs/versioned_docs/version-1.9.0/API-Reference/curl-examples/workflows-api/example-synchronous-request.sh new file mode 100644 index 0000000000..8f488efff9 --- /dev/null +++ b/docs/versioned_docs/version-1.9.0/API-Reference/curl-examples/workflows-api/example-synchronous-request.sh @@ -0,0 +1,13 @@ +curl -X POST \ + "$LANGFLOW_SERVER_URL/api/v2/workflows" \ + -H "Content-Type: application/json" \ + -H "x-api-key: $LANGFLOW_API_KEY" \ + -d '{ + "flow_id": "flow_67ccd2be17f0819081ff3bb2cf6508e60bb6a6b452d3795b", + "background": false, + "inputs": { + "ChatInput-abc.input_type": "chat", + "ChatInput-abc.input_value": "what is 2+2", + "ChatInput-abc.session_id": "session-123" + } + }' diff --git a/docs/versioned_docs/version-1.9.0/API-Reference/fixtures/flow-import.json b/docs/versioned_docs/version-1.9.0/API-Reference/fixtures/flow-import.json new file mode 100644 index 0000000000..2f16c446b1 --- /dev/null +++ b/docs/versioned_docs/version-1.9.0/API-Reference/fixtures/flow-import.json @@ -0,0 +1,8 @@ +{ + "name": "Fixture Flow", + "description": "Fixture flow used by docs API example automation.", + "data": { + "nodes": [], + "edges": [] + } +} diff --git a/docs/versioned_docs/version-1.9.0/API-Reference/fixtures/project-import.json b/docs/versioned_docs/version-1.9.0/API-Reference/fixtures/project-import.json new file mode 100644 index 0000000000..d3a6e2df49 --- /dev/null +++ b/docs/versioned_docs/version-1.9.0/API-Reference/fixtures/project-import.json @@ -0,0 +1,14 @@ +{ + "folder_name": "API fixture project", + "folder_description": "Imported via docs API examples", + "flows": [ + { + "name": "Fixture Flow", + "description": "Fixture flow used by project import examples", + "data": { + "nodes": [], + "edges": [] + } + } + ] +} diff --git a/docs/versioned_docs/version-1.9.0/API-Reference/fixtures/project-import.zip b/docs/versioned_docs/version-1.9.0/API-Reference/fixtures/project-import.zip new file mode 100644 index 0000000000..7165f7bbcb --- /dev/null +++ b/docs/versioned_docs/version-1.9.0/API-Reference/fixtures/project-import.zip @@ -0,0 +1,3 @@ +Placeholder zip fixture. +When using scripts/test-api-examples-local.sh in execute mode, this is replaced +by a real exported project archive via PROJECT_IMPORT_FILE. diff --git a/docs/versioned_docs/version-1.9.0/API-Reference/fixtures/sample-upload.png b/docs/versioned_docs/version-1.9.0/API-Reference/fixtures/sample-upload.png new file mode 100644 index 0000000000..9017ae78ad --- /dev/null +++ b/docs/versioned_docs/version-1.9.0/API-Reference/fixtures/sample-upload.png @@ -0,0 +1,2 @@ +PNG fixture placeholder for docs API examples. +This file is used as a deterministic upload fixture in test runs. diff --git a/docs/versioned_docs/version-1.9.0/API-Reference/fixtures/sample-upload.txt b/docs/versioned_docs/version-1.9.0/API-Reference/fixtures/sample-upload.txt new file mode 100644 index 0000000000..2e35b2b687 --- /dev/null +++ b/docs/versioned_docs/version-1.9.0/API-Reference/fixtures/sample-upload.txt @@ -0,0 +1,2 @@ +This is a stock fixture file used by API example upload tests. +It is intentionally small and stable for local/CI automation. diff --git a/docs/versioned_docs/version-1.9.0/API-Reference/flow-devops-sdk.mdx b/docs/versioned_docs/version-1.9.0/API-Reference/flow-devops-sdk.mdx new file mode 100644 index 0000000000..9cda7c297e --- /dev/null +++ b/docs/versioned_docs/version-1.9.0/API-Reference/flow-devops-sdk.mdx @@ -0,0 +1,227 @@ +--- +title: Flow DevOps Toolkit SDK +slug: /flow-devops-sdk +--- + +Use the Flow DevOps Toolkit SDK to version, test, and deploy your flows. + +Instead of manually exporting, sharing, and importing flow JSON files from the Langflow UI, the Flow DevOps toolkit offers terminal-based workflows for versioning, environment variables, testing, and deployment. + +## Prerequisites + +- [Install and start Langflow](/get-started-installation) +- Create a [Langflow API key](/api-keys-and-authentication) +- Install the Langflow `lfx` package + + To install the `lfx` package from PyPI, do the following: + + 1. Create a virtual environment: + ```bash + uv venv VENV_NAME + ``` + + 2. Activate the virtual environment. + ```bash + source VENV_NAME/bin/activate + ``` + 3. Install the Langflow LFX package in the virtual environment: + ```bash + uv pip install lfx + ``` + 4. Run Flow DevOps Toolkit commands in the virtual environment that has LFX installed. + + Alternatively, you can run `uvx lfx` commands, or run LFX from the `src/lfx` directory in a cloned Langflow repo. + For more information, see the [Langflow LFX README](https://github.com/langflow-ai/langflow/blob/main/src/lfx/README.md). + +## Create a project and version a flow + +1. Create a flow in the Langflow UI, such as the Simple Agent starter flow in the [Quickstart](/get-started-quickstart). +2. Open a terminal session within the virtual environment that has `lfx` installed. +3. To initialize a project, run: + ```bash + lfx init PROJECT_NAME + ``` + + Replace `PROJECT_NAME` with a name for your project folder. + `lfx init` creates a scaffold for your project. + The output is similar to the following: + + ```text + demo-project/ + ├── .github/ + │ └── workflows/ + │ ├── langflow-push.yml # CI workflow + │ ├── langflow-test.yml # CI workflow + │ └── langflow-validate.yml # CI workflow + ├── .gitignore # ignores legacy credentials file + ├── .lfx/ + │ └── 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 + │ └── ci-validate.sh # generic CI script + ├── flows/ + │ └── .gitkeep # versioned empty directory + └── tests/ + ├── __init__.py + └── test_flows.py # flow_runner example tests + + ✔ Project scaffolded. Next steps: + 1. Edit `.lfx/environments.yaml` with your instance URL + 2. export LANGFLOW_LOCAL_API_KEY= (Settings -> API Keys) + 3. lfx pull --env local --output-dir flows/ + ``` + + The project scaffold includes the following tools for building flows: + + * `.github/workflows`: GitHub CI tooling. + * `.lfx/environments.yaml`: Control your project's URL and API keys as environment variables for local, staging, and production environments. + * `ci/` Shell scripts for pushing, testing, and validating flows. + * `flows/`: An empty directory to store flows that includes a `.gitkeep` file for flow versioning. + * `tests/test_flows.py`: Example tests that you can modify to test flows. + +4. Add your Langflow API key to your `.env` file, or export it within the terminal session. + The Flow DevOps SDK includes `url` and `api_key_env` environment variables for `local`, `staging`, and `production` environments. + The variable name for the API key differs between environments, so ensure you're adding the correct variable. + For example, to add a Langflow API key to a local Langflow server, set: + + ```text + export LANGFLOW_LOCAL_API_KEY=LANGFLOW_API_KEY + ``` + +5. To test server authentication with your API key, run: + + ```bash + lfx login + ``` + + The Flow DevOps SDK tests your key against the URL and confirms the connection is working. + If the test reports `Authentication failed`, create and export a new key and try again. + +6. To check the connected server for existing flows, run: + + ```bash + lfx pull + ``` + + The Flow DevOps SDK lists your server's flows. Output is similar to the following (from a project directory such as `demo-project/`): + + ```text + Pulling all flows from http://localhost:7860 + Pulled 'Simple Agent' -> flows/Simple_Agent.json + + ┌────────────────┬──────────────────────────────────────┬───────────────────────────┬──────────┐ + │ Name │ ID │ File │ Status │ + ├────────────────┼──────────────────────────────────────┼───────────────────────────┼──────────┤ + │ Simple Agent │ c2f91b01-9a73-4c62-b7f0-e15bc3bd6802 │ flows/Simple_Agent.json │ CREATED │ + └────────────────┴──────────────────────────────────────┴───────────────────────────┴──────────┘ + + 1 updated. + ``` + + `lfx pull` pulls flow changes on the server to JSON files under `flows/` in your project (for example `demo-project/flows`). + If you run `lfx pull` again, the Flow DevOps SDK reports a Status of `Unchanged`. + You will pull changes in the next steps. +7. In the Langflow UI, open the Simple Agent flow and change the flow. + For example, change the **Chat Input** to a different input string. + Save the flow. +8. Return to your terminal, and run `lfx status`. + The Flow DevOps SDK reports the flow's Status as `UPDATED`, because the hash of the flow JSON has changed with your update. +9. To pull the reported changes from the Langflow server to your local project folder, run `lfx pull`. +10. To _push_ flow changes from flows stored locally in `demo-project/flows` to the Langflow server, run `lfx push`. + +## Validate flows + +The Flow DevOps SDK can validate that local flows are correctly formed before pushing to the Langflow with `lfx validate`. + +1. To test the Simple Agent starter flow, pass the flow JSON path to the `lfx validate` command: + ``` + lfx validate flows/Simple_Agent.json + ``` +2. Once validated, push flow changes to the server with `lfx push`. + +## Generate requirements.txt for flows + +The Flow DevOps SDK can generate a `requirements.txt` file for a flow. + +A flow JSON describes nodes and wiring, and does not list the PyPI packages components import at runtime. +Generate a `requirements.txt` file to capture the minimal Python dependencies, so you can install a matching environment for the flow. + +1. From your project directory, point `lfx requirements` at a flow JSON file. + To print the requirements to the terminal: + + ``` + lfx requirements flows/Simple_Agent.json + ``` + + To write a `requirements.txt` file instead of printing, use `-o` or `--output`: + + ``` + lfx requirements flows/Simple_Agent.json -o requirements.txt + ``` + +2. Optionally, you can now share and serve the flow by keeping the flow JSON and `requirements.txt` in the same environment. + To serve the flow without the Langflow UI, do the following: + + 1. Create a virtual environment: + ``` + uv venv VENV_NAME + ``` + + 2. Activate the virtual environment. + ``` + source VENV_NAME/bin/activate + ``` + + 3. Install the dependencies from `requirements.txt` in the virtual environment: + ```bash + uv pip install -r requirements.txt + ``` + + 4. To set a Langflow API key, run: + ``` + 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: + ``` + 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). + +## 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`. diff --git a/docs/versioned_docs/version-1.9.0/API-Reference/javascript-examples/api-build/build-flow-and-stream-events-2.js b/docs/versioned_docs/version-1.9.0/API-Reference/javascript-examples/api-build/build-flow-and-stream-events-2.js new file mode 100644 index 0000000000..1ddefa0d59 --- /dev/null +++ b/docs/versioned_docs/version-1.9.0/API-Reference/javascript-examples/api-build/build-flow-and-stream-events-2.js @@ -0,0 +1,19 @@ +const url = `${process.env.LANGFLOW_URL ?? ""}/api/v1/build/123e4567-e89b-12d3-a456-426614174000/events`; + +const options = { + method: 'GET', + headers: { + "accept": `application/json`, + "x-api-key": `${process.env.LANGFLOW_API_KEY ?? ""}`, + }, +}; + +fetch(url, options) + .then(async (response) => { + if (!response.ok) { + throw new Error(`HTTP ${response.status}`); + } + const text = await response.text(); + console.log(text); + }) + .catch((error) => console.error(error)); diff --git a/docs/versioned_docs/version-1.9.0/API-Reference/javascript-examples/api-build/build-flow-and-stream-events-3.js b/docs/versioned_docs/version-1.9.0/API-Reference/javascript-examples/api-build/build-flow-and-stream-events-3.js new file mode 100644 index 0000000000..5f1df507f3 --- /dev/null +++ b/docs/versioned_docs/version-1.9.0/API-Reference/javascript-examples/api-build/build-flow-and-stream-events-3.js @@ -0,0 +1,19 @@ +const url = `${process.env.LANGFLOW_URL ?? ""}/api/v1/build/123e4567-e89b-12d3-a456-426614174000/events?stream=false`; + +const options = { + method: 'GET', + headers: { + "accept": `application/json`, + "x-api-key": `${process.env.LANGFLOW_API_KEY ?? ""}`, + }, +}; + +fetch(url, options) + .then(async (response) => { + if (!response.ok) { + throw new Error(`HTTP ${response.status}`); + } + const text = await response.text(); + console.log(text); + }) + .catch((error) => console.error(error)); diff --git a/docs/versioned_docs/version-1.9.0/API-Reference/javascript-examples/api-build/build-flow-and-stream-events.js b/docs/versioned_docs/version-1.9.0/API-Reference/javascript-examples/api-build/build-flow-and-stream-events.js new file mode 100644 index 0000000000..66b268752d --- /dev/null +++ b/docs/versioned_docs/version-1.9.0/API-Reference/javascript-examples/api-build/build-flow-and-stream-events.js @@ -0,0 +1,25 @@ +const url = `${process.env.LANGFLOW_URL ?? ""}/api/v1/build/${process.env.FLOW_ID ?? ""}/flow`; + +const options = { + method: 'POST', + headers: { + "accept": `application/json`, + "Content-Type": `application/json`, + "x-api-key": `${process.env.LANGFLOW_API_KEY ?? ""}`, + }, + body: JSON.stringify({ + "inputs": { + "input_value": "Tell me a story" + } +}), +}; + +fetch(url, options) + .then(async (response) => { + if (!response.ok) { + throw new Error(`HTTP ${response.status}`); + } + const text = await response.text(); + console.log(text); + }) + .catch((error) => console.error(error)); diff --git a/docs/versioned_docs/version-1.9.0/API-Reference/javascript-examples/api-build/override-flow-parameters.js b/docs/versioned_docs/version-1.9.0/API-Reference/javascript-examples/api-build/override-flow-parameters.js new file mode 100644 index 0000000000..dfc29818e6 --- /dev/null +++ b/docs/versioned_docs/version-1.9.0/API-Reference/javascript-examples/api-build/override-flow-parameters.js @@ -0,0 +1,30 @@ +const url = `${process.env.LANGFLOW_URL ?? ""}/api/v1/build/${process.env.FLOW_ID ?? ""}/flow`; + +const options = { + method: 'POST', + headers: { + "accept": `application/json`, + "Content-Type": `application/json`, + "x-api-key": `${process.env.LANGFLOW_API_KEY ?? ""}`, + }, + body: JSON.stringify({ + "data": { + "nodes": [], + "edges": [] + }, + "inputs": { + "input_value": "Your custom input here", + "session": "session_id" + } +}), +}; + +fetch(url, options) + .then(async (response) => { + if (!response.ok) { + throw new Error(`HTTP ${response.status}`); + } + const text = await response.text(); + console.log(text); + }) + .catch((error) => console.error(error)); diff --git a/docs/versioned_docs/version-1.9.0/API-Reference/javascript-examples/api-build/set-start-and-stop-points.js b/docs/versioned_docs/version-1.9.0/API-Reference/javascript-examples/api-build/set-start-and-stop-points.js new file mode 100644 index 0000000000..278e779dda --- /dev/null +++ b/docs/versioned_docs/version-1.9.0/API-Reference/javascript-examples/api-build/set-start-and-stop-points.js @@ -0,0 +1,23 @@ +const url = `${process.env.LANGFLOW_URL ?? ""}/api/v1/build/${process.env.FLOW_ID ?? ""}/flow`; + +const options = { + method: 'POST', + headers: { + "accept": `application/json`, + "Content-Type": `application/json`, + "x-api-key": `${process.env.LANGFLOW_API_KEY ?? ""}`, + }, + body: JSON.stringify({ + "stop_component_id": "OpenAIModel-Uksag" +}), +}; + +fetch(url, options) + .then(async (response) => { + if (!response.ok) { + throw new Error(`HTTP ${response.status}`); + } + const text = await response.text(); + console.log(text); + }) + .catch((error) => console.error(error)); diff --git a/docs/versioned_docs/version-1.9.0/API-Reference/javascript-examples/api-files/delete-all-files-v2.js b/docs/versioned_docs/version-1.9.0/API-Reference/javascript-examples/api-files/delete-all-files-v2.js new file mode 100644 index 0000000000..3ed460ff02 --- /dev/null +++ b/docs/versioned_docs/version-1.9.0/API-Reference/javascript-examples/api-files/delete-all-files-v2.js @@ -0,0 +1,19 @@ +const url = `${process.env.LANGFLOW_URL ?? ""}/api/v2/files`; + +const options = { + method: 'DELETE', + headers: { + "accept": `application/json`, + "x-api-key": `${process.env.LANGFLOW_API_KEY ?? ""}`, + }, +}; + +fetch(url, options) + .then(async (response) => { + if (!response.ok) { + throw new Error(`HTTP ${response.status}`); + } + const text = await response.text(); + console.log(text); + }) + .catch((error) => console.error(error)); diff --git a/docs/versioned_docs/version-1.9.0/API-Reference/javascript-examples/api-files/delete-file-v1.js b/docs/versioned_docs/version-1.9.0/API-Reference/javascript-examples/api-files/delete-file-v1.js new file mode 100644 index 0000000000..4013ebebc1 --- /dev/null +++ b/docs/versioned_docs/version-1.9.0/API-Reference/javascript-examples/api-files/delete-file-v1.js @@ -0,0 +1,19 @@ +const url = `${process.env.LANGFLOW_URL ?? ""}/api/v1/files/delete/${process.env.FLOW_ID ?? ""}/2024-12-30_15-19-43_your_file.txt`; + +const options = { + method: 'DELETE', + headers: { + "accept": `application/json`, + "x-api-key": `${process.env.LANGFLOW_API_KEY ?? ""}`, + }, +}; + +fetch(url, options) + .then(async (response) => { + if (!response.ok) { + throw new Error(`HTTP ${response.status}`); + } + const text = await response.text(); + console.log(text); + }) + .catch((error) => console.error(error)); diff --git a/docs/versioned_docs/version-1.9.0/API-Reference/javascript-examples/api-files/delete-file-v2.js b/docs/versioned_docs/version-1.9.0/API-Reference/javascript-examples/api-files/delete-file-v2.js new file mode 100644 index 0000000000..c2609c8f75 --- /dev/null +++ b/docs/versioned_docs/version-1.9.0/API-Reference/javascript-examples/api-files/delete-file-v2.js @@ -0,0 +1,19 @@ +const url = `${process.env.LANGFLOW_URL ?? ""}/api/v2/files/${process.env.FILE_ID ?? ""}`; + +const options = { + method: 'DELETE', + headers: { + "accept": `application/json`, + "x-api-key": `${process.env.LANGFLOW_API_KEY ?? ""}`, + }, +}; + +fetch(url, options) + .then(async (response) => { + if (!response.ok) { + throw new Error(`HTTP ${response.status}`); + } + const text = await response.text(); + console.log(text); + }) + .catch((error) => console.error(error)); diff --git a/docs/versioned_docs/version-1.9.0/API-Reference/javascript-examples/api-files/download-file-v1.js b/docs/versioned_docs/version-1.9.0/API-Reference/javascript-examples/api-files/download-file-v1.js new file mode 100644 index 0000000000..f7ef3be343 --- /dev/null +++ b/docs/versioned_docs/version-1.9.0/API-Reference/javascript-examples/api-files/download-file-v1.js @@ -0,0 +1,19 @@ +const url = `${process.env.LANGFLOW_URL ?? ""}/api/v1/files/download/${process.env.FLOW_ID ?? ""}/2024-12-30_15-19-43_your_file.txt`; + +const options = { + method: 'GET', + headers: { + "accept": `application/json`, + "x-api-key": `${process.env.LANGFLOW_API_KEY ?? ""}`, + }, +}; + +fetch(url, options) + .then(async (response) => { + if (!response.ok) { + throw new Error(`HTTP ${response.status}`); + } + const data = await response.arrayBuffer(); + console.log("Received binary response for downloaded_file.txt", data.byteLength); + }) + .catch((error) => console.error(error)); diff --git a/docs/versioned_docs/version-1.9.0/API-Reference/javascript-examples/api-files/download-file-v2.js b/docs/versioned_docs/version-1.9.0/API-Reference/javascript-examples/api-files/download-file-v2.js new file mode 100644 index 0000000000..e14cb3baf5 --- /dev/null +++ b/docs/versioned_docs/version-1.9.0/API-Reference/javascript-examples/api-files/download-file-v2.js @@ -0,0 +1,19 @@ +const url = `${process.env.LANGFLOW_URL ?? ""}/api/v2/files/c7b22c4c-d5e0-4ec9-af97-5d85b7657a34`; + +const options = { + method: 'GET', + headers: { + "accept": `application/json`, + "x-api-key": `${process.env.LANGFLOW_API_KEY ?? ""}`, + }, +}; + +fetch(url, options) + .then(async (response) => { + if (!response.ok) { + throw new Error(`HTTP ${response.status}`); + } + const data = await response.arrayBuffer(); + console.log("Received binary response for downloaded_file.txt", data.byteLength); + }) + .catch((error) => console.error(error)); diff --git a/docs/versioned_docs/version-1.9.0/API-Reference/javascript-examples/api-files/edit-file-name-v2.js b/docs/versioned_docs/version-1.9.0/API-Reference/javascript-examples/api-files/edit-file-name-v2.js new file mode 100644 index 0000000000..644729d9ea --- /dev/null +++ b/docs/versioned_docs/version-1.9.0/API-Reference/javascript-examples/api-files/edit-file-name-v2.js @@ -0,0 +1,19 @@ +const url = `${process.env.LANGFLOW_URL ?? ""}/api/v2/files/${process.env.FILE_ID ?? ""}?name=new_file_name`; + +const options = { + method: 'PUT', + headers: { + "accept": `application/json`, + "x-api-key": `${process.env.LANGFLOW_API_KEY ?? ""}`, + }, +}; + +fetch(url, options) + .then(async (response) => { + if (!response.ok) { + throw new Error(`HTTP ${response.status}`); + } + const text = await response.text(); + console.log(text); + }) + .catch((error) => console.error(error)); diff --git a/docs/versioned_docs/version-1.9.0/API-Reference/javascript-examples/api-files/list-files-v1.js b/docs/versioned_docs/version-1.9.0/API-Reference/javascript-examples/api-files/list-files-v1.js new file mode 100644 index 0000000000..792490acfa --- /dev/null +++ b/docs/versioned_docs/version-1.9.0/API-Reference/javascript-examples/api-files/list-files-v1.js @@ -0,0 +1,19 @@ +const url = `${process.env.LANGFLOW_URL ?? ""}/api/v1/files/list/${process.env.FLOW_ID ?? ""}`; + +const options = { + method: 'GET', + headers: { + "accept": `application/json`, + "x-api-key": `${process.env.LANGFLOW_API_KEY ?? ""}`, + }, +}; + +fetch(url, options) + .then(async (response) => { + if (!response.ok) { + throw new Error(`HTTP ${response.status}`); + } + const text = await response.text(); + console.log(text); + }) + .catch((error) => console.error(error)); diff --git a/docs/versioned_docs/version-1.9.0/API-Reference/javascript-examples/api-files/list-files-v2.js b/docs/versioned_docs/version-1.9.0/API-Reference/javascript-examples/api-files/list-files-v2.js new file mode 100644 index 0000000000..e4a143a0f9 --- /dev/null +++ b/docs/versioned_docs/version-1.9.0/API-Reference/javascript-examples/api-files/list-files-v2.js @@ -0,0 +1,19 @@ +const url = `${process.env.LANGFLOW_URL ?? ""}/api/v2/files`; + +const options = { + method: 'GET', + headers: { + "accept": `application/json`, + "x-api-key": `${process.env.LANGFLOW_API_KEY ?? ""}`, + }, +}; + +fetch(url, options) + .then(async (response) => { + if (!response.ok) { + throw new Error(`HTTP ${response.status}`); + } + const text = await response.text(); + console.log(text); + }) + .catch((error) => console.error(error)); diff --git a/docs/versioned_docs/version-1.9.0/API-Reference/javascript-examples/api-files/send-files-to-your-flows-v2-2.js b/docs/versioned_docs/version-1.9.0/API-Reference/javascript-examples/api-files/send-files-to-your-flows-v2-2.js new file mode 100644 index 0000000000..3a1b93da94 --- /dev/null +++ b/docs/versioned_docs/version-1.9.0/API-Reference/javascript-examples/api-files/send-files-to-your-flows-v2-2.js @@ -0,0 +1,31 @@ +const url = `${process.env.LANGFLOW_URL ?? ""}/api/v1/run/${process.env.FLOW_ID ?? ""}`; + +const options = { + method: 'POST', + headers: { + "Content-Type": `application/json`, + "x-api-key": `${process.env.LANGFLOW_API_KEY ?? ""}`, + }, + body: JSON.stringify({ + "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" + ] + } + } +}), +}; + +fetch(url, options) + .then(async (response) => { + if (!response.ok) { + throw new Error(`HTTP ${response.status}`); + } + const text = await response.text(); + console.log(text); + }) + .catch((error) => console.error(error)); diff --git a/docs/versioned_docs/version-1.9.0/API-Reference/javascript-examples/api-files/send-files-to-your-flows-v2.js b/docs/versioned_docs/version-1.9.0/API-Reference/javascript-examples/api-files/send-files-to-your-flows-v2.js new file mode 100644 index 0000000000..d393f65650 --- /dev/null +++ b/docs/versioned_docs/version-1.9.0/API-Reference/javascript-examples/api-files/send-files-to-your-flows-v2.js @@ -0,0 +1,32 @@ +const fs = require("fs"); +const path = require("path"); + +const fixturesDir = path.join(__dirname, "../../fixtures"); +const defaultUpload = path.join(fixturesDir, "sample-upload.txt"); +const uploadPath = process.env.SAMPLE_UPLOAD_FILE || defaultUpload; +const uploadBuf = fs.readFileSync(uploadPath); +const uploadName = path.basename(uploadPath); + +const url = `${process.env.LANGFLOW_URL ?? ""}/api/v2/files`; + +const formData = new FormData(); +formData.append("file", new Blob([uploadBuf]), uploadName); + +const options = { + method: "POST", + headers: { + accept: "application/json", + "x-api-key": `${process.env.LANGFLOW_API_KEY ?? ""}`, + }, + body: formData, +}; + +fetch(url, options) + .then(async (response) => { + if (!response.ok) { + throw new Error(`HTTP ${response.status}`); + } + const text = await response.text(); + console.log(text); + }) + .catch((error) => console.error(error)); diff --git a/docs/versioned_docs/version-1.9.0/API-Reference/javascript-examples/api-files/upload-file-v1.js b/docs/versioned_docs/version-1.9.0/API-Reference/javascript-examples/api-files/upload-file-v1.js new file mode 100644 index 0000000000..5d19b43068 --- /dev/null +++ b/docs/versioned_docs/version-1.9.0/API-Reference/javascript-examples/api-files/upload-file-v1.js @@ -0,0 +1,32 @@ +const fs = require("fs"); +const path = require("path"); + +const fixturesDir = path.join(__dirname, "../../fixtures"); +const defaultUpload = path.join(fixturesDir, "sample-upload.txt"); +const uploadPath = process.env.SAMPLE_UPLOAD_FILE || defaultUpload; +const uploadBuf = fs.readFileSync(uploadPath); +const uploadName = path.basename(uploadPath); + +const url = `${process.env.LANGFLOW_URL ?? ""}/api/v1/files/upload/${process.env.FLOW_ID ?? ""}`; + +const formData = new FormData(); +formData.append("file", new Blob([uploadBuf]), uploadName); + +const options = { + method: "POST", + headers: { + accept: "application/json", + "x-api-key": `${process.env.LANGFLOW_API_KEY ?? ""}`, + }, + body: formData, +}; + +fetch(url, options) + .then(async (response) => { + if (!response.ok) { + throw new Error(`HTTP ${response.status}`); + } + const text = await response.text(); + console.log(text); + }) + .catch((error) => console.error(error)); diff --git a/docs/versioned_docs/version-1.9.0/API-Reference/javascript-examples/api-files/upload-file-v2-2.js b/docs/versioned_docs/version-1.9.0/API-Reference/javascript-examples/api-files/upload-file-v2-2.js new file mode 100644 index 0000000000..d393f65650 --- /dev/null +++ b/docs/versioned_docs/version-1.9.0/API-Reference/javascript-examples/api-files/upload-file-v2-2.js @@ -0,0 +1,32 @@ +const fs = require("fs"); +const path = require("path"); + +const fixturesDir = path.join(__dirname, "../../fixtures"); +const defaultUpload = path.join(fixturesDir, "sample-upload.txt"); +const uploadPath = process.env.SAMPLE_UPLOAD_FILE || defaultUpload; +const uploadBuf = fs.readFileSync(uploadPath); +const uploadName = path.basename(uploadPath); + +const url = `${process.env.LANGFLOW_URL ?? ""}/api/v2/files`; + +const formData = new FormData(); +formData.append("file", new Blob([uploadBuf]), uploadName); + +const options = { + method: "POST", + headers: { + accept: "application/json", + "x-api-key": `${process.env.LANGFLOW_API_KEY ?? ""}`, + }, + body: formData, +}; + +fetch(url, options) + .then(async (response) => { + if (!response.ok) { + throw new Error(`HTTP ${response.status}`); + } + const text = await response.text(); + console.log(text); + }) + .catch((error) => console.error(error)); diff --git a/docs/versioned_docs/version-1.9.0/API-Reference/javascript-examples/api-files/upload-file-v2.js b/docs/versioned_docs/version-1.9.0/API-Reference/javascript-examples/api-files/upload-file-v2.js new file mode 100644 index 0000000000..cd2867a7ef --- /dev/null +++ b/docs/versioned_docs/version-1.9.0/API-Reference/javascript-examples/api-files/upload-file-v2.js @@ -0,0 +1,19 @@ +const url = `${process.env.LANGFLOW_URL ?? ""}/api/v1/users/whoami`; + +const options = { + method: 'GET', + headers: { + "accept": `application/json`, + "x-api-key": `${process.env.LANGFLOW_API_KEY ?? ""}`, + }, +}; + +fetch(url, options) + .then(async (response) => { + if (!response.ok) { + throw new Error(`HTTP ${response.status}`); + } + const text = await response.text(); + console.log(text); + }) + .catch((error) => console.error(error)); diff --git a/docs/versioned_docs/version-1.9.0/API-Reference/javascript-examples/api-files/upload-image-files-v1-2.js b/docs/versioned_docs/version-1.9.0/API-Reference/javascript-examples/api-files/upload-image-files-v1-2.js new file mode 100644 index 0000000000..4a8ab155dd --- /dev/null +++ b/docs/versioned_docs/version-1.9.0/API-Reference/javascript-examples/api-files/upload-image-files-v1-2.js @@ -0,0 +1,29 @@ +const url = `${process.env.LANGFLOW_URL ?? ""}/api/v1/run/a430cc57-06bb-4c11-be39-d3d4de68d2c4?stream=false`; + +const options = { + method: 'POST', + headers: { + "Content-Type": `application/json`, + "x-api-key": `${process.env.LANGFLOW_API_KEY ?? ""}`, + }, + body: JSON.stringify({ + "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" + } + } +}), +}; + +fetch(url, options) + .then(async (response) => { + if (!response.ok) { + throw new Error(`HTTP ${response.status}`); + } + const text = await response.text(); + console.log(text); + }) + .catch((error) => console.error(error)); diff --git a/docs/versioned_docs/version-1.9.0/API-Reference/javascript-examples/api-files/upload-image-files-v1.js b/docs/versioned_docs/version-1.9.0/API-Reference/javascript-examples/api-files/upload-image-files-v1.js new file mode 100644 index 0000000000..90b1a897b7 --- /dev/null +++ b/docs/versioned_docs/version-1.9.0/API-Reference/javascript-examples/api-files/upload-image-files-v1.js @@ -0,0 +1,31 @@ +const fs = require("fs"); +const path = require("path"); + +const fixturesDir = path.join(__dirname, "../../fixtures"); +const defaultImage = path.join(fixturesDir, "sample-upload.png"); +const imagePath = process.env.SAMPLE_IMAGE_FILE || defaultImage; +const imageBuf = fs.readFileSync(imagePath); +const imageName = path.basename(imagePath); + +const url = `${process.env.LANGFLOW_URL ?? ""}/api/v1/files/upload/${process.env.FLOW_ID ?? ""}`; + +const formData = new FormData(); +formData.append("file", new Blob([imageBuf]), imageName); + +const options = { + method: "POST", + headers: { + "x-api-key": `${process.env.LANGFLOW_API_KEY ?? ""}`, + }, + body: formData, +}; + +fetch(url, options) + .then(async (response) => { + if (!response.ok) { + throw new Error(`HTTP ${response.status}`); + } + const text = await response.text(); + console.log(text); + }) + .catch((error) => console.error(error)); diff --git a/docs/versioned_docs/version-1.9.0/API-Reference/javascript-examples/api-flows-run/pass-global-variables-in-request-headers.js b/docs/versioned_docs/version-1.9.0/API-Reference/javascript-examples/api-flows-run/pass-global-variables-in-request-headers.js new file mode 100644 index 0000000000..007f4fbba6 --- /dev/null +++ b/docs/versioned_docs/version-1.9.0/API-Reference/javascript-examples/api-flows-run/pass-global-variables-in-request-headers.js @@ -0,0 +1,27 @@ +const url = `${process.env.LANGFLOW_SERVER_URL ?? ""}/api/v1/run/${process.env.FLOW_ID ?? ""}`; + +const options = { + method: 'POST', + headers: { + "Content-Type": `application/json`, + "x-api-key": `${process.env.LANGFLOW_API_KEY ?? ""}`, + "X-LANGFLOW-GLOBAL-VAR-OPENAI_API_KEY": `sk-...`, + "X-LANGFLOW-GLOBAL-VAR-USER_ID": `user123`, + "X-LANGFLOW-GLOBAL-VAR-ENVIRONMENT": `production`, + }, + body: JSON.stringify({ + "input_value": "Tell me about something interesting!", + "input_type": "chat", + "output_type": "chat" +}), +}; + +fetch(url, options) + .then(async (response) => { + if (!response.ok) { + throw new Error(`HTTP ${response.status}`); + } + const text = await response.text(); + console.log(text); + }) + .catch((error) => console.error(error)); diff --git a/docs/versioned_docs/version-1.9.0/API-Reference/javascript-examples/api-flows-run/request-example-with-all-headers-and-parameters.js b/docs/versioned_docs/version-1.9.0/API-Reference/javascript-examples/api-flows-run/request-example-with-all-headers-and-parameters.js new file mode 100644 index 0000000000..33eebcac86 --- /dev/null +++ b/docs/versioned_docs/version-1.9.0/API-Reference/javascript-examples/api-flows-run/request-example-with-all-headers-and-parameters.js @@ -0,0 +1,32 @@ +const url = `${process.env.LANGFLOW_SERVER_URL ?? ""}/api/v1/run/${process.env.FLOW_ID ?? ""}?stream=true`; + +const options = { + method: 'POST', + headers: { + "Content-Type": `application/json`, + "accept": `application/json`, + "x-api-key": `${process.env.LANGFLOW_API_KEY ?? ""}`, + }, + body: JSON.stringify({ + "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" + } + } +}), +}; + +fetch(url, options) + .then(async (response) => { + if (!response.ok) { + throw new Error(`HTTP ${response.status}`); + } + const text = await response.text(); + console.log(text); + }) + .catch((error) => console.error(error)); diff --git a/docs/versioned_docs/version-1.9.0/API-Reference/javascript-examples/api-flows-run/run-flow.js b/docs/versioned_docs/version-1.9.0/API-Reference/javascript-examples/api-flows-run/run-flow.js new file mode 100644 index 0000000000..907eebc445 --- /dev/null +++ b/docs/versioned_docs/version-1.9.0/API-Reference/javascript-examples/api-flows-run/run-flow.js @@ -0,0 +1,26 @@ +const url = `${process.env.LANGFLOW_SERVER_URL ?? ""}/api/v1/run/${process.env.FLOW_ID ?? ""}`; + +const options = { + method: 'POST', + headers: { + "Content-Type": `application/json`, + "x-api-key": `${process.env.LANGFLOW_API_KEY ?? ""}`, + }, + body: JSON.stringify({ + "input_value": "Tell me about something interesting!", + "session_id": "chat-123", + "input_type": "chat", + "output_type": "chat", + "output_component": "" +}), +}; + +fetch(url, options) + .then(async (response) => { + if (!response.ok) { + throw new Error(`HTTP ${response.status}`); + } + const text = await response.text(); + console.log(text); + }) + .catch((error) => console.error(error)); diff --git a/docs/versioned_docs/version-1.9.0/API-Reference/javascript-examples/api-flows-run/stream-llm-token-responses.js b/docs/versioned_docs/version-1.9.0/API-Reference/javascript-examples/api-flows-run/stream-llm-token-responses.js new file mode 100644 index 0000000000..b5d1278bd9 --- /dev/null +++ b/docs/versioned_docs/version-1.9.0/API-Reference/javascript-examples/api-flows-run/stream-llm-token-responses.js @@ -0,0 +1,24 @@ +const url = `${process.env.LANGFLOW_SERVER_URL ?? ""}/api/v1/run/${process.env.FLOW_ID ?? ""}?stream=true`; + +const options = { + method: 'POST', + headers: { + "accept": `application/json`, + "Content-Type": `application/json`, + "x-api-key": `${process.env.LANGFLOW_API_KEY ?? ""}`, + }, + body: JSON.stringify({ + "message": "Tell me something interesting!", + "session_id": "chat-123" +}), +}; + +fetch(url, options) + .then(async (response) => { + if (!response.ok) { + throw new Error(`HTTP ${response.status}`); + } + const text = await response.text(); + console.log(text); + }) + .catch((error) => console.error(error)); diff --git a/docs/versioned_docs/version-1.9.0/API-Reference/javascript-examples/api-flows-run/webhook-run-flow.js b/docs/versioned_docs/version-1.9.0/API-Reference/javascript-examples/api-flows-run/webhook-run-flow.js new file mode 100644 index 0000000000..b618609ef8 --- /dev/null +++ b/docs/versioned_docs/version-1.9.0/API-Reference/javascript-examples/api-flows-run/webhook-run-flow.js @@ -0,0 +1,22 @@ +const url = `${process.env.LANGFLOW_SERVER_URL ?? ""}/api/v1/webhook/${process.env.FLOW_ID ?? ""}`; + +const options = { + method: 'POST', + headers: { + "Content-Type": `application/json`, + "x-api-key": `${process.env.LANGFLOW_API_KEY ?? ""}`, + }, + body: JSON.stringify({ + "data": "example-data" +}), +}; + +fetch(url, options) + .then(async (response) => { + if (!response.ok) { + throw new Error(`HTTP ${response.status}`); + } + const text = await response.text(); + console.log(text); + }) + .catch((error) => console.error(error)); diff --git a/docs/versioned_docs/version-1.9.0/API-Reference/javascript-examples/api-flows/create-flow.js b/docs/versioned_docs/version-1.9.0/API-Reference/javascript-examples/api-flows/create-flow.js new file mode 100644 index 0000000000..c100edcacb --- /dev/null +++ b/docs/versioned_docs/version-1.9.0/API-Reference/javascript-examples/api-flows/create-flow.js @@ -0,0 +1,35 @@ +const url = `${process.env.LANGFLOW_URL ?? ""}/api/v1/flows/`; + +const options = { + method: 'POST', + headers: { + "accept": `application/json`, + "Content-Type": `application/json`, + "x-api-key": `${process.env.LANGFLOW_API_KEY ?? ""}`, + }, + body: JSON.stringify({ + "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" + ] +}), +}; + +fetch(url, options) + .then(async (response) => { + if (!response.ok) { + throw new Error(`HTTP ${response.status}`); + } + const text = await response.text(); + console.log(text); + }) + .catch((error) => console.error(error)); diff --git a/docs/versioned_docs/version-1.9.0/API-Reference/javascript-examples/api-flows/create-flows.js b/docs/versioned_docs/version-1.9.0/API-Reference/javascript-examples/api-flows/create-flows.js new file mode 100644 index 0000000000..c528a1a763 --- /dev/null +++ b/docs/versioned_docs/version-1.9.0/API-Reference/javascript-examples/api-flows/create-flows.js @@ -0,0 +1,60 @@ +const url = `${process.env.LANGFLOW_URL ?? ""}/api/v1/flows/batch/`; + +const options = { + method: 'POST', + headers: { + "accept": `application/json`, + "Content-Type": `application/json`, + "x-api-key": `${process.env.LANGFLOW_API_KEY ?? ""}`, + }, + body: JSON.stringify({ + "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" + } + ] +}), +}; + +fetch(url, options) + .then(async (response) => { + if (!response.ok) { + throw new Error(`HTTP ${response.status}`); + } + const text = await response.text(); + console.log(text); + }) + .catch((error) => console.error(error)); diff --git a/docs/versioned_docs/version-1.9.0/API-Reference/javascript-examples/api-flows/delete-flow.js b/docs/versioned_docs/version-1.9.0/API-Reference/javascript-examples/api-flows/delete-flow.js new file mode 100644 index 0000000000..7bdb9f78db --- /dev/null +++ b/docs/versioned_docs/version-1.9.0/API-Reference/javascript-examples/api-flows/delete-flow.js @@ -0,0 +1,19 @@ +const url = `${process.env.LANGFLOW_URL ?? ""}/api/v1/flows/${process.env.FLOW_ID ?? ""}`; + +const options = { + method: 'DELETE', + headers: { + "accept": `application/json`, + "x-api-key": `${process.env.LANGFLOW_API_KEY ?? ""}`, + }, +}; + +fetch(url, options) + .then(async (response) => { + if (!response.ok) { + throw new Error(`HTTP ${response.status}`); + } + const text = await response.text(); + console.log(text); + }) + .catch((error) => console.error(error)); diff --git a/docs/versioned_docs/version-1.9.0/API-Reference/javascript-examples/api-flows/export-flows.js b/docs/versioned_docs/version-1.9.0/API-Reference/javascript-examples/api-flows/export-flows.js new file mode 100644 index 0000000000..69758b9e21 --- /dev/null +++ b/docs/versioned_docs/version-1.9.0/API-Reference/javascript-examples/api-flows/export-flows.js @@ -0,0 +1,24 @@ +const url = `${process.env.LANGFLOW_URL ?? ""}/api/v1/flows/download/`; + +const options = { + method: 'POST', + headers: { + "accept": `application/json`, + "Content-Type": `application/json`, + "x-api-key": `${process.env.LANGFLOW_API_KEY ?? ""}`, + }, + body: JSON.stringify([ + "e1e40c77-0541-41a9-88ab-ddb3419398b5", + "92f9a4c5-cfc8-4656-ae63-1f0881163c28" +]), +}; + +fetch(url, options) + .then(async (response) => { + if (!response.ok) { + throw new Error(`HTTP ${response.status}`); + } + const data = await response.arrayBuffer(); + console.log("Received binary response for langflow-flows.zip", data.byteLength); + }) + .catch((error) => console.error(error)); diff --git a/docs/versioned_docs/version-1.9.0/API-Reference/javascript-examples/api-flows/import-flows.js b/docs/versioned_docs/version-1.9.0/API-Reference/javascript-examples/api-flows/import-flows.js new file mode 100644 index 0000000000..0c136874ba --- /dev/null +++ b/docs/versioned_docs/version-1.9.0/API-Reference/javascript-examples/api-flows/import-flows.js @@ -0,0 +1,32 @@ +const fs = require("fs"); +const path = require("path"); + +const fixturesDir = path.join(__dirname, "../../fixtures"); +const defaultFlowImport = path.join(fixturesDir, "flow-import.json"); +const flowImportPath = process.env.FLOW_IMPORT_FILE || defaultFlowImport; +const flowBuf = fs.readFileSync(flowImportPath); +const flowName = path.basename(flowImportPath); + +const url = `${process.env.LANGFLOW_URL ?? ""}/api/v1/flows/upload/?folder_id=${process.env.FOLDER_ID ?? ""}`; + +const formData = new FormData(); +formData.append("file", new Blob([flowBuf], { type: "application/json" }), flowName); + +const options = { + method: "POST", + headers: { + accept: "application/json", + "x-api-key": `${process.env.LANGFLOW_API_KEY ?? ""}`, + }, + body: formData, +}; + +fetch(url, options) + .then(async (response) => { + if (!response.ok) { + throw new Error(`HTTP ${response.status}`); + } + const text = await response.text(); + console.log(text); + }) + .catch((error) => console.error(error)); diff --git a/docs/versioned_docs/version-1.9.0/API-Reference/javascript-examples/api-flows/read-flow.js b/docs/versioned_docs/version-1.9.0/API-Reference/javascript-examples/api-flows/read-flow.js new file mode 100644 index 0000000000..29c8bbbf1f --- /dev/null +++ b/docs/versioned_docs/version-1.9.0/API-Reference/javascript-examples/api-flows/read-flow.js @@ -0,0 +1,19 @@ +const url = `${process.env.LANGFLOW_URL ?? ""}/api/v1/flows/${process.env.FLOW_ID ?? ""}`; + +const options = { + method: 'GET', + headers: { + "accept": `application/json`, + "x-api-key": `${process.env.LANGFLOW_API_KEY ?? ""}`, + }, +}; + +fetch(url, options) + .then(async (response) => { + if (!response.ok) { + throw new Error(`HTTP ${response.status}`); + } + const text = await response.text(); + console.log(text); + }) + .catch((error) => console.error(error)); diff --git a/docs/versioned_docs/version-1.9.0/API-Reference/javascript-examples/api-flows/read-flows-2.js b/docs/versioned_docs/version-1.9.0/API-Reference/javascript-examples/api-flows/read-flows-2.js new file mode 100644 index 0000000000..b627fed111 --- /dev/null +++ b/docs/versioned_docs/version-1.9.0/API-Reference/javascript-examples/api-flows/read-flows-2.js @@ -0,0 +1,19 @@ +const url = `${process.env.LANGFLOW_URL ?? ""}/api/v1/flows/?remove_example_flows=true&components_only=false&get_all=false&project_id=${process.env.PROJECT_ID ?? ""}&header_flows=false&page=1&size=1`; + +const options = { + method: 'GET', + headers: { + "accept": `application/json`, + "x-api-key": `${process.env.LANGFLOW_API_KEY ?? ""}`, + }, +}; + +fetch(url, options) + .then(async (response) => { + if (!response.ok) { + throw new Error(`HTTP ${response.status}`); + } + const text = await response.text(); + console.log(text); + }) + .catch((error) => console.error(error)); diff --git a/docs/versioned_docs/version-1.9.0/API-Reference/javascript-examples/api-flows/read-flows.js b/docs/versioned_docs/version-1.9.0/API-Reference/javascript-examples/api-flows/read-flows.js new file mode 100644 index 0000000000..388c32437d --- /dev/null +++ b/docs/versioned_docs/version-1.9.0/API-Reference/javascript-examples/api-flows/read-flows.js @@ -0,0 +1,19 @@ +const url = `${process.env.LANGFLOW_URL ?? ""}/api/v1/flows/?remove_example_flows=false&components_only=false&get_all=true&header_flows=false&page=1&size=50`; + +const options = { + method: 'GET', + headers: { + "accept": `application/json`, + "x-api-key": `${process.env.LANGFLOW_API_KEY ?? ""}`, + }, +}; + +fetch(url, options) + .then(async (response) => { + if (!response.ok) { + throw new Error(`HTTP ${response.status}`); + } + const text = await response.text(); + console.log(text); + }) + .catch((error) => console.error(error)); diff --git a/docs/versioned_docs/version-1.9.0/API-Reference/javascript-examples/api-flows/read-sample-flows.js b/docs/versioned_docs/version-1.9.0/API-Reference/javascript-examples/api-flows/read-sample-flows.js new file mode 100644 index 0000000000..fc65058315 --- /dev/null +++ b/docs/versioned_docs/version-1.9.0/API-Reference/javascript-examples/api-flows/read-sample-flows.js @@ -0,0 +1,19 @@ +const url = `${process.env.LANGFLOW_URL ?? ""}/api/v1/flows/basic_examples/`; + +const options = { + method: 'GET', + headers: { + "accept": `application/json`, + "x-api-key": `${process.env.LANGFLOW_API_KEY ?? ""}`, + }, +}; + +fetch(url, options) + .then(async (response) => { + if (!response.ok) { + throw new Error(`HTTP ${response.status}`); + } + const text = await response.text(); + console.log(text); + }) + .catch((error) => console.error(error)); diff --git a/docs/versioned_docs/version-1.9.0/API-Reference/javascript-examples/api-flows/update-flow.js b/docs/versioned_docs/version-1.9.0/API-Reference/javascript-examples/api-flows/update-flow.js new file mode 100644 index 0000000000..50c3d3f748 --- /dev/null +++ b/docs/versioned_docs/version-1.9.0/API-Reference/javascript-examples/api-flows/update-flow.js @@ -0,0 +1,28 @@ +const url = `${process.env.LANGFLOW_URL ?? ""}/api/v1/flows/${process.env.FLOW_ID ?? ""}`; + +const options = { + method: 'PATCH', + headers: { + "accept": `application/json`, + "Content-Type": `application/json`, + "x-api-key": `${process.env.LANGFLOW_API_KEY ?? ""}`, + }, + body: JSON.stringify({ + "name": "string", + "description": "string", + "data": {}, + "project_id": "3fa85f64-5717-4562-b3fc-2c963f66afa6", + "endpoint_name": "my_new_endpoint_name", + "locked": true +}), +}; + +fetch(url, options) + .then(async (response) => { + if (!response.ok) { + throw new Error(`HTTP ${response.status}`); + } + const text = await response.text(); + console.log(text); + }) + .catch((error) => console.error(error)); diff --git a/docs/versioned_docs/version-1.9.0/API-Reference/javascript-examples/api-logs/retrieve-logs-with-optional-parameters.js b/docs/versioned_docs/version-1.9.0/API-Reference/javascript-examples/api-logs/retrieve-logs-with-optional-parameters.js new file mode 100644 index 0000000000..2ba7ac18cd --- /dev/null +++ b/docs/versioned_docs/version-1.9.0/API-Reference/javascript-examples/api-logs/retrieve-logs-with-optional-parameters.js @@ -0,0 +1,19 @@ +const url = `${process.env.LANGFLOW_URL ?? ""}/logs?lines_before=0&lines_after=0×tamp=0`; + +const options = { + method: 'GET', + headers: { + "accept": `application/json`, + "x-api-key": `${process.env.LANGFLOW_API_KEY ?? ""}`, + }, +}; + +fetch(url, options) + .then(async (response) => { + if (!response.ok) { + throw new Error(`HTTP ${response.status}`); + } + const text = await response.text(); + console.log(text); + }) + .catch((error) => console.error(error)); diff --git a/docs/versioned_docs/version-1.9.0/API-Reference/javascript-examples/api-logs/stream-logs.js b/docs/versioned_docs/version-1.9.0/API-Reference/javascript-examples/api-logs/stream-logs.js new file mode 100644 index 0000000000..8ab251fc20 --- /dev/null +++ b/docs/versioned_docs/version-1.9.0/API-Reference/javascript-examples/api-logs/stream-logs.js @@ -0,0 +1,19 @@ +const url = `${process.env.LANGFLOW_URL ?? ""}/logs-stream`; + +const options = { + method: 'GET', + headers: { + "accept": `text/event-stream`, + "x-api-key": `${process.env.LANGFLOW_API_KEY ?? ""}`, + }, +}; + +fetch(url, options) + .then(async (response) => { + if (!response.ok) { + throw new Error(`HTTP ${response.status}`); + } + const text = await response.text(); + console.log(text); + }) + .catch((error) => console.error(error)); diff --git a/docs/versioned_docs/version-1.9.0/API-Reference/javascript-examples/api-monitor/delete-messages-by-session.js b/docs/versioned_docs/version-1.9.0/API-Reference/javascript-examples/api-monitor/delete-messages-by-session.js new file mode 100644 index 0000000000..772e4713e7 --- /dev/null +++ b/docs/versioned_docs/version-1.9.0/API-Reference/javascript-examples/api-monitor/delete-messages-by-session.js @@ -0,0 +1,19 @@ +const url = `${process.env.LANGFLOW_URL ?? ""}/api/v1/monitor/messages/session/different_session_id_2`; + +const options = { + method: 'DELETE', + headers: { + "accept": `*/*`, + "x-api-key": `${process.env.LANGFLOW_API_KEY ?? ""}`, + }, +}; + +fetch(url, options) + .then(async (response) => { + if (!response.ok) { + throw new Error(`HTTP ${response.status}`); + } + const text = await response.text(); + console.log(text); + }) + .catch((error) => console.error(error)); diff --git a/docs/versioned_docs/version-1.9.0/API-Reference/javascript-examples/api-monitor/delete-messages.js b/docs/versioned_docs/version-1.9.0/API-Reference/javascript-examples/api-monitor/delete-messages.js new file mode 100644 index 0000000000..b63cf9a7a9 --- /dev/null +++ b/docs/versioned_docs/version-1.9.0/API-Reference/javascript-examples/api-monitor/delete-messages.js @@ -0,0 +1,24 @@ +const url = `${process.env.LANGFLOW_URL ?? ""}/api/v1/monitor/messages`; + +const options = { + method: 'DELETE', + headers: { + "accept": `*/*`, + "Content-Type": `application/json`, + "x-api-key": `${process.env.LANGFLOW_API_KEY ?? ""}`, + }, + body: JSON.stringify([ + "MESSAGE_ID_1", + "MESSAGE_ID_2" +]), +}; + +fetch(url, options) + .then(async (response) => { + if (!response.ok) { + throw new Error(`HTTP ${response.status}`); + } + const text = await response.text(); + console.log(text); + }) + .catch((error) => console.error(error)); diff --git a/docs/versioned_docs/version-1.9.0/API-Reference/javascript-examples/api-monitor/delete-vertex-builds.js b/docs/versioned_docs/version-1.9.0/API-Reference/javascript-examples/api-monitor/delete-vertex-builds.js new file mode 100644 index 0000000000..eedb1a8071 --- /dev/null +++ b/docs/versioned_docs/version-1.9.0/API-Reference/javascript-examples/api-monitor/delete-vertex-builds.js @@ -0,0 +1,19 @@ +const url = `${process.env.LANGFLOW_URL ?? ""}/api/v1/monitor/builds?flow_id=${process.env.FLOW_ID ?? ""}`; + +const options = { + method: 'DELETE', + headers: { + "accept": `*/*`, + "x-api-key": `${process.env.LANGFLOW_API_KEY ?? ""}`, + }, +}; + +fetch(url, options) + .then(async (response) => { + if (!response.ok) { + throw new Error(`HTTP ${response.status}`); + } + const text = await response.text(); + console.log(text); + }) + .catch((error) => console.error(error)); diff --git a/docs/versioned_docs/version-1.9.0/API-Reference/javascript-examples/api-monitor/get-messages-2.js b/docs/versioned_docs/version-1.9.0/API-Reference/javascript-examples/api-monitor/get-messages-2.js new file mode 100644 index 0000000000..c42cc040f9 --- /dev/null +++ b/docs/versioned_docs/version-1.9.0/API-Reference/javascript-examples/api-monitor/get-messages-2.js @@ -0,0 +1,19 @@ +const url = `${process.env.LANGFLOW_URL ?? ""}/api/v1/monitor/messages?flow_id=${process.env.FLOW_ID ?? ""}&session_id=01ce083d-748b-4b8d-97b6-33adbb6a528a&sender=Machine&sender_name=AI&order_by=timestamp`; + +const options = { + method: 'GET', + headers: { + "accept": `application/json`, + "x-api-key": `${process.env.LANGFLOW_API_KEY ?? ""}`, + }, +}; + +fetch(url, options) + .then(async (response) => { + if (!response.ok) { + throw new Error(`HTTP ${response.status}`); + } + const text = await response.text(); + console.log(text); + }) + .catch((error) => console.error(error)); diff --git a/docs/versioned_docs/version-1.9.0/API-Reference/javascript-examples/api-monitor/get-messages.js b/docs/versioned_docs/version-1.9.0/API-Reference/javascript-examples/api-monitor/get-messages.js new file mode 100644 index 0000000000..d0ac813b17 --- /dev/null +++ b/docs/versioned_docs/version-1.9.0/API-Reference/javascript-examples/api-monitor/get-messages.js @@ -0,0 +1,19 @@ +const url = `${process.env.LANGFLOW_URL ?? ""}/api/v1/monitor/messages`; + +const options = { + method: 'GET', + headers: { + "accept": `application/json`, + "x-api-key": `${process.env.LANGFLOW_API_KEY ?? ""}`, + }, +}; + +fetch(url, options) + .then(async (response) => { + if (!response.ok) { + throw new Error(`HTTP ${response.status}`); + } + const text = await response.text(); + console.log(text); + }) + .catch((error) => console.error(error)); diff --git a/docs/versioned_docs/version-1.9.0/API-Reference/javascript-examples/api-monitor/get-transactions.js b/docs/versioned_docs/version-1.9.0/API-Reference/javascript-examples/api-monitor/get-transactions.js new file mode 100644 index 0000000000..9f0d4faf4a --- /dev/null +++ b/docs/versioned_docs/version-1.9.0/API-Reference/javascript-examples/api-monitor/get-transactions.js @@ -0,0 +1,19 @@ +const url = `${process.env.LANGFLOW_URL ?? ""}/api/v1/monitor/transactions?flow_id=${process.env.FLOW_ID ?? ""}&page=1&size=50`; + +const options = { + method: 'GET', + headers: { + "accept": `application/json`, + "x-api-key": `${process.env.LANGFLOW_API_KEY ?? ""}`, + }, +}; + +fetch(url, options) + .then(async (response) => { + if (!response.ok) { + throw new Error(`HTTP ${response.status}`); + } + const text = await response.text(); + console.log(text); + }) + .catch((error) => console.error(error)); diff --git a/docs/versioned_docs/version-1.9.0/API-Reference/javascript-examples/api-monitor/get-vertex-builds.js b/docs/versioned_docs/version-1.9.0/API-Reference/javascript-examples/api-monitor/get-vertex-builds.js new file mode 100644 index 0000000000..ec64328848 --- /dev/null +++ b/docs/versioned_docs/version-1.9.0/API-Reference/javascript-examples/api-monitor/get-vertex-builds.js @@ -0,0 +1,19 @@ +const url = `${process.env.LANGFLOW_URL ?? ""}/api/v1/monitor/builds?flow_id=${process.env.FLOW_ID ?? ""}`; + +const options = { + method: 'GET', + headers: { + "accept": `application/json`, + "x-api-key": `${process.env.LANGFLOW_API_KEY ?? ""}`, + }, +}; + +fetch(url, options) + .then(async (response) => { + if (!response.ok) { + throw new Error(`HTTP ${response.status}`); + } + const text = await response.text(); + console.log(text); + }) + .catch((error) => console.error(error)); diff --git a/docs/versioned_docs/version-1.9.0/API-Reference/javascript-examples/api-monitor/update-message.js b/docs/versioned_docs/version-1.9.0/API-Reference/javascript-examples/api-monitor/update-message.js new file mode 100644 index 0000000000..5e7a8b1cc5 --- /dev/null +++ b/docs/versioned_docs/version-1.9.0/API-Reference/javascript-examples/api-monitor/update-message.js @@ -0,0 +1,23 @@ +const url = `${process.env.LANGFLOW_URL ?? ""}/api/v1/monitor/messages/3ab66cc6-c048-48f8-ab07-570f5af7b160`; + +const options = { + method: 'PUT', + headers: { + "accept": `application/json`, + "Content-Type": `application/json`, + "x-api-key": `${process.env.LANGFLOW_API_KEY ?? ""}`, + }, + body: JSON.stringify({ + "text": "testing 1234" +}), +}; + +fetch(url, options) + .then(async (response) => { + if (!response.ok) { + throw new Error(`HTTP ${response.status}`); + } + const text = await response.text(); + console.log(text); + }) + .catch((error) => console.error(error)); diff --git a/docs/versioned_docs/version-1.9.0/API-Reference/javascript-examples/api-monitor/update-session-id.js b/docs/versioned_docs/version-1.9.0/API-Reference/javascript-examples/api-monitor/update-session-id.js new file mode 100644 index 0000000000..812d079d27 --- /dev/null +++ b/docs/versioned_docs/version-1.9.0/API-Reference/javascript-examples/api-monitor/update-session-id.js @@ -0,0 +1,19 @@ +const url = `${process.env.LANGFLOW_URL ?? ""}/api/v1/monitor/messages/session/01ce083d-748b-4b8d-97b6-33adbb6a528a?new_session_id=different_session_id`; + +const options = { + method: 'PATCH', + headers: { + "accept": `application/json`, + "x-api-key": `${process.env.LANGFLOW_API_KEY ?? ""}`, + }, +}; + +fetch(url, options) + .then(async (response) => { + if (!response.ok) { + throw new Error(`HTTP ${response.status}`); + } + const text = await response.text(); + console.log(text); + }) + .catch((error) => console.error(error)); diff --git a/docs/versioned_docs/version-1.9.0/API-Reference/javascript-examples/api-openai-responses/additional-configuration-for-openai-client-libraries.ts b/docs/versioned_docs/version-1.9.0/API-Reference/javascript-examples/api-openai-responses/additional-configuration-for-openai-client-libraries.ts new file mode 100644 index 0000000000..a6963443b3 --- /dev/null +++ b/docs/versioned_docs/version-1.9.0/API-Reference/javascript-examples/api-openai-responses/additional-configuration-for-openai-client-libraries.ts @@ -0,0 +1,16 @@ +import OpenAI from "openai"; + +const client = new OpenAI({ + baseURL: "LANGFLOW_SERVER_URL/api/v1/", + defaultHeaders: { + "x-api-key": "LANGFLOW_API_KEY" + }, + apiKey: "dummy-api-key" // Required by OpenAI SDK but not used by Langflow +}); + +const response = await client.responses.create({ + model: "FLOW_ID", + input: "There is an event that happens on the second wednesday of every month. What are the event dates in 2026?" +}); + +console.log(response.output_text); diff --git a/docs/versioned_docs/version-1.9.0/API-Reference/javascript-examples/api-openai-responses/continue-conversations-with-response-and-session-ids-2.js b/docs/versioned_docs/version-1.9.0/API-Reference/javascript-examples/api-openai-responses/continue-conversations-with-response-and-session-ids-2.js new file mode 100644 index 0000000000..293b21a5cd --- /dev/null +++ b/docs/versioned_docs/version-1.9.0/API-Reference/javascript-examples/api-openai-responses/continue-conversations-with-response-and-session-ids-2.js @@ -0,0 +1,24 @@ +const url = `http://${process.env.LANGFLOW_SERVER_URL ?? ""}/api/v1/responses`; + +const options = { + method: 'POST', + headers: { + "x-api-key": `${process.env.LANGFLOW_API_KEY ?? ""}`, + "Content-Type": `application/json`, + }, + body: JSON.stringify({ + "model": "ced2ec91-f325-4bf0-8754-f3198c2b1563", + "input": "What's my name?", + "previous_response_id": "c45f4ac8-772b-4675-8551-c560b1afd590" +}), +}; + +fetch(url, options) + .then(async (response) => { + if (!response.ok) { + throw new Error(`HTTP ${response.status}`); + } + const text = await response.text(); + console.log(text); + }) + .catch((error) => console.error(error)); diff --git a/docs/versioned_docs/version-1.9.0/API-Reference/javascript-examples/api-openai-responses/continue-conversations-with-response-and-session-ids-3.js b/docs/versioned_docs/version-1.9.0/API-Reference/javascript-examples/api-openai-responses/continue-conversations-with-response-and-session-ids-3.js new file mode 100644 index 0000000000..d05446c855 --- /dev/null +++ b/docs/versioned_docs/version-1.9.0/API-Reference/javascript-examples/api-openai-responses/continue-conversations-with-response-and-session-ids-3.js @@ -0,0 +1,24 @@ +const url = `http://${process.env.LANGFLOW_SERVER_URL ?? ""}/api/v1/responses`; + +const options = { + method: 'POST', + headers: { + "x-api-key": `${process.env.LANGFLOW_API_KEY ?? ""}`, + "Content-Type": `application/json`, + }, + body: JSON.stringify({ + "model": "ced2ec91-f325-4bf0-8754-f3198c2b1563", + "input": "What's my name?", + "previous_response_id": "session-alice-1756839048" +}), +}; + +fetch(url, options) + .then(async (response) => { + if (!response.ok) { + throw new Error(`HTTP ${response.status}`); + } + const text = await response.text(); + console.log(text); + }) + .catch((error) => console.error(error)); diff --git a/docs/versioned_docs/version-1.9.0/API-Reference/javascript-examples/api-openai-responses/continue-conversations-with-response-and-session-ids.js b/docs/versioned_docs/version-1.9.0/API-Reference/javascript-examples/api-openai-responses/continue-conversations-with-response-and-session-ids.js new file mode 100644 index 0000000000..d8690e2fd1 --- /dev/null +++ b/docs/versioned_docs/version-1.9.0/API-Reference/javascript-examples/api-openai-responses/continue-conversations-with-response-and-session-ids.js @@ -0,0 +1,23 @@ +const url = `http://${process.env.LANGFLOW_SERVER_URL ?? ""}/api/v1/responses`; + +const options = { + method: 'POST', + headers: { + "x-api-key": `${process.env.LANGFLOW_API_KEY ?? ""}`, + "Content-Type": `application/json`, + }, + body: JSON.stringify({ + "model": "$FLOW_ID", + "input": "Hello, my name is Alice" +}), +}; + +fetch(url, options) + .then(async (response) => { + if (!response.ok) { + throw new Error(`HTTP ${response.status}`); + } + const text = await response.text(); + console.log(text); + }) + .catch((error) => console.error(error)); diff --git a/docs/versioned_docs/version-1.9.0/API-Reference/javascript-examples/api-openai-responses/example-request.js b/docs/versioned_docs/version-1.9.0/API-Reference/javascript-examples/api-openai-responses/example-request.js new file mode 100644 index 0000000000..e3ea6b71eb --- /dev/null +++ b/docs/versioned_docs/version-1.9.0/API-Reference/javascript-examples/api-openai-responses/example-request.js @@ -0,0 +1,24 @@ +const url = `${process.env.LANGFLOW_SERVER_URL ?? ""}/api/v1/responses`; + +const options = { + method: 'POST', + headers: { + "x-api-key": `${process.env.LANGFLOW_API_KEY ?? ""}`, + "Content-Type": `application/json`, + }, + body: JSON.stringify({ + "model": "$YOUR_FLOW_ID", + "input": "Hello, how are you?", + "stream": false +}), +}; + +fetch(url, options) + .then(async (response) => { + if (!response.ok) { + throw new Error(`HTTP ${response.status}`); + } + const text = await response.text(); + console.log(text); + }) + .catch((error) => console.error(error)); diff --git a/docs/versioned_docs/version-1.9.0/API-Reference/javascript-examples/api-openai-responses/example-streaming-request.js b/docs/versioned_docs/version-1.9.0/API-Reference/javascript-examples/api-openai-responses/example-streaming-request.js new file mode 100644 index 0000000000..3913a454fb --- /dev/null +++ b/docs/versioned_docs/version-1.9.0/API-Reference/javascript-examples/api-openai-responses/example-streaming-request.js @@ -0,0 +1,24 @@ +const url = `${process.env.LANGFLOW_SERVER_URL ?? ""}/api/v1/responses`; + +const options = { + method: 'POST', + headers: { + "x-api-key": `${process.env.LANGFLOW_API_KEY ?? ""}`, + "Content-Type": `application/json`, + }, + body: JSON.stringify({ + "model": "$FLOW_ID", + "input": "Tell me a story about a robot", + "stream": true +}), +}; + +fetch(url, options) + .then(async (response) => { + if (!response.ok) { + throw new Error(`HTTP ${response.status}`); + } + const text = await response.text(); + console.log(text); + }) + .catch((error) => console.error(error)); diff --git a/docs/versioned_docs/version-1.9.0/API-Reference/javascript-examples/api-openai-responses/pass-global-variables-to-your-flows-in-headers.js b/docs/versioned_docs/version-1.9.0/API-Reference/javascript-examples/api-openai-responses/pass-global-variables-to-your-flows-in-headers.js new file mode 100644 index 0000000000..af937dfbff --- /dev/null +++ b/docs/versioned_docs/version-1.9.0/API-Reference/javascript-examples/api-openai-responses/pass-global-variables-to-your-flows-in-headers.js @@ -0,0 +1,26 @@ +const url = `${process.env.LANGFLOW_SERVER_URL ?? ""}/api/v1/responses`; + +const options = { + method: 'POST', + headers: { + "x-api-key": `${process.env.LANGFLOW_API_KEY ?? ""}`, + "Content-Type": `application/json`, + "X-LANGFLOW-GLOBAL-VAR-OPENAI_API_KEY": `sk-...`, + "X-LANGFLOW-GLOBAL-VAR-USER_ID": `user123`, + "X-LANGFLOW-GLOBAL-VAR-ENVIRONMENT": `production`, + }, + body: JSON.stringify({ + "model": "your-flow-id", + "input": "Hello" +}), +}; + +fetch(url, options) + .then(async (response) => { + if (!response.ok) { + throw new Error(`HTTP ${response.status}`); + } + const text = await response.text(); + console.log(text); + }) + .catch((error) => console.error(error)); diff --git a/docs/versioned_docs/version-1.9.0/API-Reference/javascript-examples/api-openai-responses/retrieve-tool-call-results.js b/docs/versioned_docs/version-1.9.0/API-Reference/javascript-examples/api-openai-responses/retrieve-tool-call-results.js new file mode 100644 index 0000000000..7fc86bd8d2 --- /dev/null +++ b/docs/versioned_docs/version-1.9.0/API-Reference/javascript-examples/api-openai-responses/retrieve-tool-call-results.js @@ -0,0 +1,27 @@ +const url = `http://${process.env.LANGFLOW_SERVER_URL ?? ""}/api/v1/responses`; + +const options = { + method: 'POST', + headers: { + "Content-Type": `application/json`, + "x-api-key": `${process.env.LANGFLOW_API_KEY ?? ""}`, + }, + body: JSON.stringify({ + "model": "FLOW_ID", + "input": "Calculate 23 * 15 and show me the result", + "stream": false, + "include": [ + "tool_call.results" + ] +}), +}; + +fetch(url, options) + .then(async (response) => { + if (!response.ok) { + throw new Error(`HTTP ${response.status}`); + } + const text = await response.text(); + console.log(text); + }) + .catch((error) => console.error(error)); diff --git a/docs/versioned_docs/version-1.9.0/API-Reference/javascript-examples/api-openai-responses/token-usage-tracking.js b/docs/versioned_docs/version-1.9.0/API-Reference/javascript-examples/api-openai-responses/token-usage-tracking.js new file mode 100644 index 0000000000..6070462e56 --- /dev/null +++ b/docs/versioned_docs/version-1.9.0/API-Reference/javascript-examples/api-openai-responses/token-usage-tracking.js @@ -0,0 +1,24 @@ +const url = `${process.env.LANGFLOW_SERVER_URL ?? ""}/api/v1/responses`; + +const options = { + method: 'POST', + headers: { + "x-api-key": `${process.env.LANGFLOW_API_KEY ?? ""}`, + "Content-Type": `application/json`, + }, + body: JSON.stringify({ + "model": "FLOW_ID", + "input": "Explain quantum computing in simple terms", + "stream": false +}), +}; + +fetch(url, options) + .then(async (response) => { + if (!response.ok) { + throw new Error(`HTTP ${response.status}`); + } + const text = await response.text(); + console.log(text); + }) + .catch((error) => console.error(error)); diff --git a/docs/versioned_docs/version-1.9.0/API-Reference/javascript-examples/api-projects/create-project-2.js b/docs/versioned_docs/version-1.9.0/API-Reference/javascript-examples/api-projects/create-project-2.js new file mode 100644 index 0000000000..f9431cf899 --- /dev/null +++ b/docs/versioned_docs/version-1.9.0/API-Reference/javascript-examples/api-projects/create-project-2.js @@ -0,0 +1,30 @@ +const url = `${process.env.LANGFLOW_URL ?? ""}/api/v1/projects/`; + +const options = { + method: 'POST', + headers: { + "accept": `application/json`, + "Content-Type": `application/json`, + "x-api-key": `${process.env.LANGFLOW_API_KEY ?? ""}`, + }, + body: JSON.stringify({ + "name": "new_project_name", + "description": "string", + "components_list": [ + "3fa85f64-5717-4562-b3fc-2c963f66afa6" + ], + "flows_list": [ + "3fa85f64-5717-4562-b3fc-2c963f66afa6" + ] +}), +}; + +fetch(url, options) + .then(async (response) => { + if (!response.ok) { + throw new Error(`HTTP ${response.status}`); + } + const text = await response.text(); + console.log(text); + }) + .catch((error) => console.error(error)); diff --git a/docs/versioned_docs/version-1.9.0/API-Reference/javascript-examples/api-projects/create-project.js b/docs/versioned_docs/version-1.9.0/API-Reference/javascript-examples/api-projects/create-project.js new file mode 100644 index 0000000000..2adaad9e2f --- /dev/null +++ b/docs/versioned_docs/version-1.9.0/API-Reference/javascript-examples/api-projects/create-project.js @@ -0,0 +1,25 @@ +const url = `${process.env.LANGFLOW_URL ?? ""}/api/v1/projects/`; + +const options = { + method: 'POST', + headers: { + "Content-Type": `application/json`, + "x-api-key": `${process.env.LANGFLOW_API_KEY ?? ""}`, + }, + body: JSON.stringify({ + "name": "new_project_name", + "description": "string", + "components_list": [], + "flows_list": [] +}), +}; + +fetch(url, options) + .then(async (response) => { + if (!response.ok) { + throw new Error(`HTTP ${response.status}`); + } + const text = await response.text(); + console.log(text); + }) + .catch((error) => console.error(error)); diff --git a/docs/versioned_docs/version-1.9.0/API-Reference/javascript-examples/api-projects/delete-project.js b/docs/versioned_docs/version-1.9.0/API-Reference/javascript-examples/api-projects/delete-project.js new file mode 100644 index 0000000000..1228eba5b8 --- /dev/null +++ b/docs/versioned_docs/version-1.9.0/API-Reference/javascript-examples/api-projects/delete-project.js @@ -0,0 +1,19 @@ +const url = `${process.env.LANGFLOW_URL ?? ""}/api/v1/projects/${process.env.PROJECT_ID ?? ""}`; + +const options = { + method: 'DELETE', + headers: { + "accept": `*/*`, + "x-api-key": `${process.env.LANGFLOW_API_KEY ?? ""}`, + }, +}; + +fetch(url, options) + .then(async (response) => { + if (!response.ok) { + throw new Error(`HTTP ${response.status}`); + } + const text = await response.text(); + console.log(text); + }) + .catch((error) => console.error(error)); diff --git a/docs/versioned_docs/version-1.9.0/API-Reference/javascript-examples/api-projects/export-a-project.js b/docs/versioned_docs/version-1.9.0/API-Reference/javascript-examples/api-projects/export-a-project.js new file mode 100644 index 0000000000..53fdbac4ae --- /dev/null +++ b/docs/versioned_docs/version-1.9.0/API-Reference/javascript-examples/api-projects/export-a-project.js @@ -0,0 +1,19 @@ +const url = `${process.env.LANGFLOW_URL ?? ""}/api/v1/projects/download/${process.env.PROJECT_ID ?? ""}`; + +const options = { + method: 'GET', + headers: { + "accept": `application/json`, + "x-api-key": `${process.env.LANGFLOW_API_KEY ?? ""}`, + }, +}; + +fetch(url, options) + .then(async (response) => { + if (!response.ok) { + throw new Error(`HTTP ${response.status}`); + } + const data = await response.arrayBuffer(); + console.log("Received binary response for langflow-project.zip", data.byteLength); + }) + .catch((error) => console.error(error)); diff --git a/docs/versioned_docs/version-1.9.0/API-Reference/javascript-examples/api-projects/import-a-project.js b/docs/versioned_docs/version-1.9.0/API-Reference/javascript-examples/api-projects/import-a-project.js new file mode 100644 index 0000000000..be86f382a3 --- /dev/null +++ b/docs/versioned_docs/version-1.9.0/API-Reference/javascript-examples/api-projects/import-a-project.js @@ -0,0 +1,32 @@ +const fs = require("fs"); +const path = require("path"); + +const fixturesDir = path.join(__dirname, "../../fixtures"); +const defaultProjectZip = path.join(fixturesDir, "project-import.zip"); +const projectPath = process.env.PROJECT_IMPORT_FILE || defaultProjectZip; +const projectBuf = fs.readFileSync(projectPath); +const projectName = path.basename(projectPath); + +const url = `${process.env.LANGFLOW_URL ?? ""}/api/v1/projects/upload/`; + +const formData = new FormData(); +formData.append("file", new Blob([projectBuf], { type: "application/zip" }), projectName); + +const options = { + method: "POST", + headers: { + accept: "application/json", + "x-api-key": `${process.env.LANGFLOW_API_KEY ?? ""}`, + }, + body: formData, +}; + +fetch(url, options) + .then(async (response) => { + if (!response.ok) { + throw new Error(`HTTP ${response.status}`); + } + const text = await response.text(); + console.log(text); + }) + .catch((error) => console.error(error)); diff --git a/docs/versioned_docs/version-1.9.0/API-Reference/javascript-examples/api-projects/read-project.js b/docs/versioned_docs/version-1.9.0/API-Reference/javascript-examples/api-projects/read-project.js new file mode 100644 index 0000000000..a3c50d6cc7 --- /dev/null +++ b/docs/versioned_docs/version-1.9.0/API-Reference/javascript-examples/api-projects/read-project.js @@ -0,0 +1,19 @@ +const url = `${process.env.LANGFLOW_URL ?? ""}/api/v1/projects/${process.env.PROJECT_ID ?? ""}`; + +const options = { + method: 'GET', + headers: { + "accept": `application/json`, + "x-api-key": `${process.env.LANGFLOW_API_KEY ?? ""}`, + }, +}; + +fetch(url, options) + .then(async (response) => { + if (!response.ok) { + throw new Error(`HTTP ${response.status}`); + } + const text = await response.text(); + console.log(text); + }) + .catch((error) => console.error(error)); diff --git a/docs/versioned_docs/version-1.9.0/API-Reference/javascript-examples/api-projects/read-projects.js b/docs/versioned_docs/version-1.9.0/API-Reference/javascript-examples/api-projects/read-projects.js new file mode 100644 index 0000000000..3fa382000c --- /dev/null +++ b/docs/versioned_docs/version-1.9.0/API-Reference/javascript-examples/api-projects/read-projects.js @@ -0,0 +1,19 @@ +const url = `${process.env.LANGFLOW_URL ?? ""}/api/v1/projects/`; + +const options = { + method: 'GET', + headers: { + "accept": `application/json`, + "x-api-key": `${process.env.LANGFLOW_API_KEY ?? ""}`, + }, +}; + +fetch(url, options) + .then(async (response) => { + if (!response.ok) { + throw new Error(`HTTP ${response.status}`); + } + const text = await response.text(); + console.log(text); + }) + .catch((error) => console.error(error)); diff --git a/docs/versioned_docs/version-1.9.0/API-Reference/javascript-examples/api-projects/update-project.js b/docs/versioned_docs/version-1.9.0/API-Reference/javascript-examples/api-projects/update-project.js new file mode 100644 index 0000000000..759ab42da8 --- /dev/null +++ b/docs/versioned_docs/version-1.9.0/API-Reference/javascript-examples/api-projects/update-project.js @@ -0,0 +1,30 @@ +const url = `${process.env.LANGFLOW_URL ?? ""}/api/v1/projects/b408ddb9-6266-4431-9be8-e04a62758331`; + +const options = { + method: 'PATCH', + headers: { + "accept": `application/json`, + "x-api-key": `${process.env.LANGFLOW_API_KEY ?? ""}`, + }, + body: JSON.stringify({ + "name": "string", + "description": "string", + "parent_id": "3fa85f64-5717-4562-b3fc-2c963f66afa6", + "components": [ + "3fa85f64-5717-4562-b3fc-2c963f66afa6" + ], + "flows": [ + "3fa85f64-5717-4562-b3fc-2c963f66afa6" + ] +}), +}; + +fetch(url, options) + .then(async (response) => { + if (!response.ok) { + throw new Error(`HTTP ${response.status}`); + } + const text = await response.text(); + console.log(text); + }) + .catch((error) => console.error(error)); diff --git a/docs/versioned_docs/version-1.9.0/API-Reference/javascript-examples/api-reference-api-examples/form-langflow-api-requests.js b/docs/versioned_docs/version-1.9.0/API-Reference/javascript-examples/api-reference-api-examples/form-langflow-api-requests.js new file mode 100644 index 0000000000..731aa47661 --- /dev/null +++ b/docs/versioned_docs/version-1.9.0/API-Reference/javascript-examples/api-reference-api-examples/form-langflow-api-requests.js @@ -0,0 +1,29 @@ +const url = `${process.env.LANGFLOW_SERVER_URL ?? ""}/api/v1/run/${process.env.FLOW_ID ?? ""}?stream=false`; + +const options = { + method: 'POST', + headers: { + "Content-Type": `application/json`, + "x-api-key": `${process.env.LANGFLOW_API_KEY ?? ""}`, + }, + body: JSON.stringify({ + "input_value": "hello world!", + "output_type": "chat", + "input_type": "chat", + "tweaks": { + "ChatOutput-6zcZt": { + "should_store_message": true + } + } +}), +}; + +fetch(url, options) + .then(async (response) => { + if (!response.ok) { + throw new Error(`HTTP ${response.status}`); + } + const text = await response.text(); + console.log(text); + }) + .catch((error) => console.error(error)); diff --git a/docs/versioned_docs/version-1.9.0/API-Reference/javascript-examples/api-reference-api-examples/get-all-components.js b/docs/versioned_docs/version-1.9.0/API-Reference/javascript-examples/api-reference-api-examples/get-all-components.js new file mode 100644 index 0000000000..34cdb80294 --- /dev/null +++ b/docs/versioned_docs/version-1.9.0/API-Reference/javascript-examples/api-reference-api-examples/get-all-components.js @@ -0,0 +1,19 @@ +const url = `${process.env.LANGFLOW_SERVER_URL ?? ""}/api/v1/all`; + +const options = { + method: 'GET', + headers: { + "accept": `application/json`, + "x-api-key": `${process.env.LANGFLOW_API_KEY ?? ""}`, + }, +}; + +fetch(url, options) + .then(async (response) => { + if (!response.ok) { + throw new Error(`HTTP ${response.status}`); + } + const text = await response.text(); + console.log(text); + }) + .catch((error) => console.error(error)); diff --git a/docs/versioned_docs/version-1.9.0/API-Reference/javascript-examples/api-reference-api-examples/get-configuration.js b/docs/versioned_docs/version-1.9.0/API-Reference/javascript-examples/api-reference-api-examples/get-configuration.js new file mode 100644 index 0000000000..a995626d86 --- /dev/null +++ b/docs/versioned_docs/version-1.9.0/API-Reference/javascript-examples/api-reference-api-examples/get-configuration.js @@ -0,0 +1,19 @@ +const url = `${process.env.LANGFLOW_SERVER_URL ?? ""}/api/v1/config`; + +const options = { + method: 'GET', + headers: { + "accept": `application/json`, + "x-api-key": `${process.env.LANGFLOW_API_KEY ?? ""}`, + }, +}; + +fetch(url, options) + .then(async (response) => { + if (!response.ok) { + throw new Error(`HTTP ${response.status}`); + } + const text = await response.text(); + console.log(text); + }) + .catch((error) => console.error(error)); diff --git a/docs/versioned_docs/version-1.9.0/API-Reference/javascript-examples/api-reference-api-examples/get-version.js b/docs/versioned_docs/version-1.9.0/API-Reference/javascript-examples/api-reference-api-examples/get-version.js new file mode 100644 index 0000000000..5d2c577ffe --- /dev/null +++ b/docs/versioned_docs/version-1.9.0/API-Reference/javascript-examples/api-reference-api-examples/get-version.js @@ -0,0 +1,18 @@ +const url = `${process.env.LANGFLOW_SERVER_URL ?? ""}/api/v1/version`; + +const options = { + method: 'GET', + headers: { + "accept": `application/json`, + }, +}; + +fetch(url, options) + .then(async (response) => { + if (!response.ok) { + throw new Error(`HTTP ${response.status}`); + } + const text = await response.text(); + console.log(text); + }) + .catch((error) => console.error(error)); diff --git a/docs/versioned_docs/version-1.9.0/API-Reference/javascript-examples/api-reference-api-examples/health-check.js b/docs/versioned_docs/version-1.9.0/API-Reference/javascript-examples/api-reference-api-examples/health-check.js new file mode 100644 index 0000000000..06fc235985 --- /dev/null +++ b/docs/versioned_docs/version-1.9.0/API-Reference/javascript-examples/api-reference-api-examples/health-check.js @@ -0,0 +1,18 @@ +const url = `${process.env.LANGFLOW_SERVER_URL ?? ""}/health_check`; + +const options = { + method: 'GET', + headers: { + "accept": `application/json`, + }, +}; + +fetch(url, options) + .then(async (response) => { + if (!response.ok) { + throw new Error(`HTTP ${response.status}`); + } + const text = await response.text(); + console.log(text); + }) + .catch((error) => console.error(error)); diff --git a/docs/versioned_docs/version-1.9.0/API-Reference/javascript-examples/api-users/add-user.js b/docs/versioned_docs/version-1.9.0/API-Reference/javascript-examples/api-users/add-user.js new file mode 100644 index 0000000000..40a0421eaf --- /dev/null +++ b/docs/versioned_docs/version-1.9.0/API-Reference/javascript-examples/api-users/add-user.js @@ -0,0 +1,23 @@ +const url = `${process.env.LANGFLOW_URL ?? ""}/api/v1/users/`; + +const options = { + method: 'POST', + headers: { + "Content-Type": `application/json`, + "x-api-key": `${process.env.LANGFLOW_API_KEY ?? ""}`, + }, + body: JSON.stringify({ + "username": "newuser2", + "password": "securepassword123" +}), +}; + +fetch(url, options) + .then(async (response) => { + if (!response.ok) { + throw new Error(`HTTP ${response.status}`); + } + const text = await response.text(); + console.log(text); + }) + .catch((error) => console.error(error)); diff --git a/docs/versioned_docs/version-1.9.0/API-Reference/javascript-examples/api-users/delete-user.js b/docs/versioned_docs/version-1.9.0/API-Reference/javascript-examples/api-users/delete-user.js new file mode 100644 index 0000000000..7b35fb3c29 --- /dev/null +++ b/docs/versioned_docs/version-1.9.0/API-Reference/javascript-examples/api-users/delete-user.js @@ -0,0 +1,19 @@ +const url = `${process.env.LANGFLOW_URL ?? ""}/api/v1/users/10c1c6a2-ab8a-4748-8700-0e4832fd5ce8`; + +const options = { + method: 'DELETE', + headers: { + "accept": `application/json`, + "x-api-key": `${process.env.LANGFLOW_API_KEY ?? ""}`, + }, +}; + +fetch(url, options) + .then(async (response) => { + if (!response.ok) { + throw new Error(`HTTP ${response.status}`); + } + const text = await response.text(); + console.log(text); + }) + .catch((error) => console.error(error)); diff --git a/docs/versioned_docs/version-1.9.0/API-Reference/javascript-examples/api-users/get-current-user.js b/docs/versioned_docs/version-1.9.0/API-Reference/javascript-examples/api-users/get-current-user.js new file mode 100644 index 0000000000..cd2867a7ef --- /dev/null +++ b/docs/versioned_docs/version-1.9.0/API-Reference/javascript-examples/api-users/get-current-user.js @@ -0,0 +1,19 @@ +const url = `${process.env.LANGFLOW_URL ?? ""}/api/v1/users/whoami`; + +const options = { + method: 'GET', + headers: { + "accept": `application/json`, + "x-api-key": `${process.env.LANGFLOW_API_KEY ?? ""}`, + }, +}; + +fetch(url, options) + .then(async (response) => { + if (!response.ok) { + throw new Error(`HTTP ${response.status}`); + } + const text = await response.text(); + console.log(text); + }) + .catch((error) => console.error(error)); diff --git a/docs/versioned_docs/version-1.9.0/API-Reference/javascript-examples/api-users/list-all-users.js b/docs/versioned_docs/version-1.9.0/API-Reference/javascript-examples/api-users/list-all-users.js new file mode 100644 index 0000000000..b57191b615 --- /dev/null +++ b/docs/versioned_docs/version-1.9.0/API-Reference/javascript-examples/api-users/list-all-users.js @@ -0,0 +1,19 @@ +const url = `${process.env.LANGFLOW_URL ?? ""}/api/v1/users/?skip=0&limit=10`; + +const options = { + method: 'GET', + headers: { + "accept": `application/json`, + "x-api-key": `${process.env.LANGFLOW_API_KEY ?? ""}`, + }, +}; + +fetch(url, options) + .then(async (response) => { + if (!response.ok) { + throw new Error(`HTTP ${response.status}`); + } + const text = await response.text(); + console.log(text); + }) + .catch((error) => console.error(error)); diff --git a/docs/versioned_docs/version-1.9.0/API-Reference/javascript-examples/api-users/reset-password.js b/docs/versioned_docs/version-1.9.0/API-Reference/javascript-examples/api-users/reset-password.js new file mode 100644 index 0000000000..483aebcd48 --- /dev/null +++ b/docs/versioned_docs/version-1.9.0/API-Reference/javascript-examples/api-users/reset-password.js @@ -0,0 +1,22 @@ +const url = `${process.env.LANGFLOW_URL ?? ""}/api/v1/users/10c1c6a2-ab8a-4748-8700-0e4832fd5ce8/reset-password`; + +const options = { + method: 'PATCH', + headers: { + "Content-Type": `application/json`, + "x-api-key": `${process.env.LANGFLOW_API_KEY ?? ""}`, + }, + body: JSON.stringify({ + "password": "newsecurepassword123" +}), +}; + +fetch(url, options) + .then(async (response) => { + if (!response.ok) { + throw new Error(`HTTP ${response.status}`); + } + const text = await response.text(); + console.log(text); + }) + .catch((error) => console.error(error)); diff --git a/docs/versioned_docs/version-1.9.0/API-Reference/javascript-examples/api-users/update-user.js b/docs/versioned_docs/version-1.9.0/API-Reference/javascript-examples/api-users/update-user.js new file mode 100644 index 0000000000..269625feaf --- /dev/null +++ b/docs/versioned_docs/version-1.9.0/API-Reference/javascript-examples/api-users/update-user.js @@ -0,0 +1,23 @@ +const url = `${process.env.LANGFLOW_URL ?? ""}/api/v1/users/10c1c6a2-ab8a-4748-8700-0e4832fd5ce8`; + +const options = { + method: 'PATCH', + headers: { + "Content-Type": `application/json`, + "x-api-key": `${process.env.LANGFLOW_API_KEY ?? ""}`, + }, + body: JSON.stringify({ + "is_active": true, + "is_superuser": true +}), +}; + +fetch(url, options) + .then(async (response) => { + if (!response.ok) { + throw new Error(`HTTP ${response.status}`); + } + const text = await response.text(); + console.log(text); + }) + .catch((error) => console.error(error)); diff --git a/docs/versioned_docs/version-1.9.0/API-Reference/javascript-examples/test-javascript-examples.sh b/docs/versioned_docs/version-1.9.0/API-Reference/javascript-examples/test-javascript-examples.sh new file mode 100644 index 0000000000..866b1e418a --- /dev/null +++ b/docs/versioned_docs/version-1.9.0/API-Reference/javascript-examples/test-javascript-examples.sh @@ -0,0 +1,186 @@ +#!/usr/bin/env bash +set -euo pipefail + +SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)" +ROOT_DIR="$(cd "$SCRIPT_DIR/../../../.." && pwd)" +EXAMPLES_DIR="$SCRIPT_DIR" +TEST_SCRIPT_NAME="$(basename "${BASH_SOURCE[0]}")" + +MODE="syntax" + +load_repo_env() { + local env_file="$ROOT_DIR/.env" + if [[ -f "$env_file" ]]; then + set -a + # shellcheck source=/dev/null + source "$env_file" + set +a + fi +} + +print_help() { + cat <<'EOF' +Usage: + test-javascript-examples.sh [--execute] + +Modes: + (default) Syntax check only (`node --check`) + --execute Execute examples after syntax checks + +EOF +} + +while [[ $# -gt 0 ]]; do + case "$1" in + --execute) + MODE="execute" + shift + ;; + --help|-h) + print_help + exit 0 + ;; + *) + echo "Unknown argument: $1" + print_help + exit 1 + ;; + esac +done + +if ! command -v node >/dev/null 2>&1; then + echo "Node.js is required to test JavaScript examples." + exit 1 +fi + +JS_FILES=() +while IFS= read -r line; do + if [[ "$(basename "$line")" == "$TEST_SCRIPT_NAME" ]]; then + continue + fi + JS_FILES+=("$line") +done < <(python3 - "$EXAMPLES_DIR" <<'PY' +import sys +from pathlib import Path + +root = Path(sys.argv[1]) +for p in sorted(root.rglob("*.js")): + print(p) +PY +) + +if [[ ${#JS_FILES[@]} -eq 0 ]]; then + echo "No .js examples found in $EXAMPLES_DIR" + exit 1 +fi + +PASS=0 +FAIL=0 +SKIP=0 + +echo "Testing ${#JS_FILES[@]} JavaScript examples in '$MODE' mode..." +if [[ "$MODE" == "execute" ]]; then + load_repo_env +fi + +has_placeholder_file_inputs() { + python3 - "$1" <<'PY' +import sys +text = open(sys.argv[1], encoding="utf-8").read() +needles = ("FILE_NAME", "PATH/TO/FILE", "") +print("yes" if any(n in text for n in needles) else "no") +PY +} + +has_missing_required_env() { + python3 - "$1" <<'PY' +import os +import re +import sys + +text = open(sys.argv[1], encoding="utf-8").read() +vars_to_check = ["FLOW_ID", "PROJECT_ID", "FOLDER_ID", "SESSION_ID", "JOB_ID", "USER_ID"] + +for name in vars_to_check: + if re.search(rf"process\.env\.{name}\b", text) and not os.getenv(name): + print(name) + raise SystemExit(0) + +print("") +PY +} + +print_failure_logs() { + local out_file="$1" + local err_file="$2" + if [[ -s "$err_file" ]]; then + echo " stderr (last 12 lines):" + python3 - "$err_file" <<'PY' +import sys +from pathlib import Path + +lines = Path(sys.argv[1]).read_text(encoding="utf-8", errors="replace").splitlines() +for line in lines[-12:]: + print(line) +PY + fi + if [[ -s "$out_file" ]]; then + echo " stdout (last 12 lines):" + python3 - "$out_file" <<'PY' +import sys +from pathlib import Path + +lines = Path(sys.argv[1]).read_text(encoding="utf-8", errors="replace").splitlines() +for line in lines[-12:]: + print(line) +PY + fi +} + +for file in "${JS_FILES[@]}"; do + rel="${file#"$ROOT_DIR"/}" + + if ! node --check "$file" >/tmp/langflow-js-check.out 2>/tmp/langflow-js-check.err; then + echo "FAIL $rel (node --check)" + ((FAIL+=1)) + continue + fi + + if [[ "$MODE" == "execute" ]]; then + if [[ -z "${LANGFLOW_API_KEY:-}" || ( -z "${LANGFLOW_URL:-}" && -z "${LANGFLOW_SERVER_URL:-}" ) ]]; then + echo "SKIP $rel (set LANGFLOW_API_KEY and LANGFLOW_URL or LANGFLOW_SERVER_URL to execute)" + ((SKIP+=1)) + continue + fi + + if [[ "$(has_placeholder_file_inputs "$file")" == "yes" ]]; then + echo "SKIP $rel (placeholder file input values)" + ((SKIP+=1)) + continue + fi + + missing_env="$(has_missing_required_env "$file")" + if [[ -n "$missing_env" ]]; then + echo "SKIP $rel (missing required env: $missing_env)" + ((SKIP+=1)) + continue + fi + + if ! node "$file" >/tmp/langflow-js-example.out 2>/tmp/langflow-js-example.err; then + echo "FAIL $rel (execution)" + print_failure_logs "/tmp/langflow-js-example.out" "/tmp/langflow-js-example.err" + ((FAIL+=1)) + continue + fi + fi + + echo "PASS $rel" + ((PASS+=1)) +done + +echo +echo "Summary: PASS=$PASS FAIL=$FAIL SKIP=$SKIP TOTAL=${#JS_FILES[@]}" + +if [[ $FAIL -gt 0 ]]; then + exit 1 +fi diff --git a/docs/versioned_docs/version-1.9.0/API-Reference/javascript-examples/workflows-api/example-asynchronous-request.js b/docs/versioned_docs/version-1.9.0/API-Reference/javascript-examples/workflows-api/example-asynchronous-request.js new file mode 100644 index 0000000000..06ead61bdd --- /dev/null +++ b/docs/versioned_docs/version-1.9.0/API-Reference/javascript-examples/workflows-api/example-asynchronous-request.js @@ -0,0 +1,29 @@ +const url = `${process.env.LANGFLOW_SERVER_URL ?? ""}/api/v2/workflows`; + +const options = { + method: 'POST', + headers: { + "Content-Type": `application/json`, + "x-api-key": `${process.env.LANGFLOW_API_KEY ?? ""}`, + }, + body: JSON.stringify({ + "flow_id": "flow_67ccd2be17f0819081ff3bb2cf6508e60bb6a6b452d3795b", + "background": true, + "stream": false, + "inputs": { + "ChatInput-abc.input_type": "chat", + "ChatInput-abc.input_value": "Process this in the background", + "ChatInput-abc.session_id": "session-456" + } +}), +}; + +fetch(url, options) + .then(async (response) => { + if (!response.ok) { + throw new Error(`HTTP ${response.status}`); + } + const text = await response.text(); + console.log(text); + }) + .catch((error) => console.error(error)); diff --git a/docs/versioned_docs/version-1.9.0/API-Reference/javascript-examples/workflows-api/example-request-2.js b/docs/versioned_docs/version-1.9.0/API-Reference/javascript-examples/workflows-api/example-request-2.js new file mode 100644 index 0000000000..5784aabeea --- /dev/null +++ b/docs/versioned_docs/version-1.9.0/API-Reference/javascript-examples/workflows-api/example-request-2.js @@ -0,0 +1,22 @@ +const url = `${process.env.LANGFLOW_SERVER_URL ?? ""}/api/v2/workflows/stop`; + +const options = { + method: 'POST', + headers: { + "Content-Type": `application/json`, + "x-api-key": `${process.env.LANGFLOW_API_KEY ?? ""}`, + }, + body: JSON.stringify({ + "job_id": "job_id_1234567890" +}), +}; + +fetch(url, options) + .then(async (response) => { + if (!response.ok) { + throw new Error(`HTTP ${response.status}`); + } + const text = await response.text(); + console.log(text); + }) + .catch((error) => console.error(error)); diff --git a/docs/versioned_docs/version-1.9.0/API-Reference/javascript-examples/workflows-api/example-request.js b/docs/versioned_docs/version-1.9.0/API-Reference/javascript-examples/workflows-api/example-request.js new file mode 100644 index 0000000000..51670600b4 --- /dev/null +++ b/docs/versioned_docs/version-1.9.0/API-Reference/javascript-examples/workflows-api/example-request.js @@ -0,0 +1,19 @@ +const url = `${process.env.LANGFLOW_SERVER_URL ?? ""}/api/v2/workflows?job_id=job_id_1234567890`; + +const options = { + method: 'GET', + headers: { + "accept": `application/json`, + "x-api-key": `${process.env.LANGFLOW_API_KEY ?? ""}`, + }, +}; + +fetch(url, options) + .then(async (response) => { + if (!response.ok) { + throw new Error(`HTTP ${response.status}`); + } + const text = await response.text(); + console.log(text); + }) + .catch((error) => console.error(error)); diff --git a/docs/versioned_docs/version-1.9.0/API-Reference/javascript-examples/workflows-api/example-synchronous-request.js b/docs/versioned_docs/version-1.9.0/API-Reference/javascript-examples/workflows-api/example-synchronous-request.js new file mode 100644 index 0000000000..5b1b401d4d --- /dev/null +++ b/docs/versioned_docs/version-1.9.0/API-Reference/javascript-examples/workflows-api/example-synchronous-request.js @@ -0,0 +1,28 @@ +const url = `${process.env.LANGFLOW_SERVER_URL ?? ""}/api/v2/workflows`; + +const options = { + method: 'POST', + headers: { + "Content-Type": `application/json`, + "x-api-key": `${process.env.LANGFLOW_API_KEY ?? ""}`, + }, + body: JSON.stringify({ + "flow_id": "flow_67ccd2be17f0819081ff3bb2cf6508e60bb6a6b452d3795b", + "background": false, + "inputs": { + "ChatInput-abc.input_type": "chat", + "ChatInput-abc.input_value": "what is 2+2", + "ChatInput-abc.session_id": "session-123" + } +}), +}; + +fetch(url, options) + .then(async (response) => { + if (!response.ok) { + throw new Error(`HTTP ${response.status}`); + } + const text = await response.text(); + console.log(text); + }) + .catch((error) => console.error(error)); diff --git a/docs/versioned_docs/version-1.9.0/API-Reference/python-examples/.gitignore b/docs/versioned_docs/version-1.9.0/API-Reference/python-examples/.gitignore new file mode 100644 index 0000000000..7a60b85e14 --- /dev/null +++ b/docs/versioned_docs/version-1.9.0/API-Reference/python-examples/.gitignore @@ -0,0 +1,2 @@ +__pycache__/ +*.pyc diff --git a/docs/versioned_docs/version-1.9.0/API-Reference/python-examples/api-build/build-flow-and-stream-events-2.py b/docs/versioned_docs/version-1.9.0/API-Reference/python-examples/api-build/build-flow-and-stream-events-2.py new file mode 100644 index 0000000000..c2360306e8 --- /dev/null +++ b/docs/versioned_docs/version-1.9.0/API-Reference/python-examples/api-build/build-flow-and-stream-events-2.py @@ -0,0 +1,15 @@ +import os + +import requests + +url = f"{os.getenv('LANGFLOW_URL', '')}/api/v1/build/{os.getenv('JOB_ID', '')}/events" + +headers = { + "accept": "application/json", + "x-api-key": f"{os.getenv('LANGFLOW_API_KEY', '')}", +} + +response = requests.request("GET", url, headers=headers) +response.raise_for_status() + +print(response.text) diff --git a/docs/versioned_docs/version-1.9.0/API-Reference/python-examples/api-build/build-flow-and-stream-events-3.py b/docs/versioned_docs/version-1.9.0/API-Reference/python-examples/api-build/build-flow-and-stream-events-3.py new file mode 100644 index 0000000000..30a03f92ff --- /dev/null +++ b/docs/versioned_docs/version-1.9.0/API-Reference/python-examples/api-build/build-flow-and-stream-events-3.py @@ -0,0 +1,18 @@ +import os + +import requests + +base = os.environ.get("LANGFLOW_URL") or os.environ.get("LANGFLOW_SERVER_URL", "") +job_id = os.environ.get("JOB_ID", "") +api_key = os.environ.get("LANGFLOW_API_KEY", "") + +# Use the API's `event_delivery` query param to avoid keeping a streaming connection open. +# For local smoke tests, polling returns a finite JSON response. +url = f"{base}/api/v1/build/{job_id}/events?event_delivery=polling" + +headers = {"accept": "application/json", "x-api-key": api_key} + +response = requests.get(url, headers=headers, timeout=60) +response.raise_for_status() + +print(response.text) diff --git a/docs/versioned_docs/version-1.9.0/API-Reference/python-examples/api-build/build-flow-and-stream-events.py b/docs/versioned_docs/version-1.9.0/API-Reference/python-examples/api-build/build-flow-and-stream-events.py new file mode 100644 index 0000000000..eb70384c6d --- /dev/null +++ b/docs/versioned_docs/version-1.9.0/API-Reference/python-examples/api-build/build-flow-and-stream-events.py @@ -0,0 +1,18 @@ +import os + +import requests + +url = f"{os.getenv('LANGFLOW_URL', '')}/api/v1/build/{os.getenv('FLOW_ID', '')}/flow" + +headers = { + "accept": "application/json", + "Content-Type": "application/json", + "x-api-key": f"{os.getenv('LANGFLOW_API_KEY', '')}", +} + +payload = {"inputs": {"input_value": "Tell me a story"}} + +response = requests.request("POST", url, headers=headers, json=payload) +response.raise_for_status() + +print(response.text) diff --git a/docs/versioned_docs/version-1.9.0/API-Reference/python-examples/api-build/override-flow-parameters.py b/docs/versioned_docs/version-1.9.0/API-Reference/python-examples/api-build/override-flow-parameters.py new file mode 100644 index 0000000000..ee97927249 --- /dev/null +++ b/docs/versioned_docs/version-1.9.0/API-Reference/python-examples/api-build/override-flow-parameters.py @@ -0,0 +1,21 @@ +import os + +import requests + +url = f"{os.getenv('LANGFLOW_URL', '')}/api/v1/build/{os.getenv('FLOW_ID', '')}/flow" + +headers = { + "accept": "application/json", + "Content-Type": "application/json", + "x-api-key": f"{os.getenv('LANGFLOW_API_KEY', '')}", +} + +payload = { + "data": {"nodes": [], "edges": []}, + "inputs": {"input_value": "Your custom input here", "session": "session_id"}, +} + +response = requests.request("POST", url, headers=headers, json=payload) +response.raise_for_status() + +print(response.text) diff --git a/docs/versioned_docs/version-1.9.0/API-Reference/python-examples/api-build/set-start-and-stop-points.py b/docs/versioned_docs/version-1.9.0/API-Reference/python-examples/api-build/set-start-and-stop-points.py new file mode 100644 index 0000000000..d9d490b22d --- /dev/null +++ b/docs/versioned_docs/version-1.9.0/API-Reference/python-examples/api-build/set-start-and-stop-points.py @@ -0,0 +1,18 @@ +import os + +import requests + +url = f"{os.getenv('LANGFLOW_URL', '')}/api/v1/build/{os.getenv('FLOW_ID', '')}/flow" + +headers = { + "accept": "application/json", + "Content-Type": "application/json", + "x-api-key": f"{os.getenv('LANGFLOW_API_KEY', '')}", +} + +payload = {"stop_component_id": "OpenAIModel-Uksag"} + +response = requests.request("POST", url, headers=headers, json=payload) +response.raise_for_status() + +print(response.text) diff --git a/docs/versioned_docs/version-1.9.0/API-Reference/python-examples/api-files/delete-all-files-v2.py b/docs/versioned_docs/version-1.9.0/API-Reference/python-examples/api-files/delete-all-files-v2.py new file mode 100644 index 0000000000..fd0a1b5d89 --- /dev/null +++ b/docs/versioned_docs/version-1.9.0/API-Reference/python-examples/api-files/delete-all-files-v2.py @@ -0,0 +1,15 @@ +import os + +import requests + +url = f"{os.getenv('LANGFLOW_URL', '')}/api/v2/files" + +headers = { + "accept": "application/json", + "x-api-key": f"{os.getenv('LANGFLOW_API_KEY', '')}", +} + +response = requests.request("DELETE", url, headers=headers) +response.raise_for_status() + +print(response.text) diff --git a/docs/versioned_docs/version-1.9.0/API-Reference/python-examples/api-files/delete-file-v1.py b/docs/versioned_docs/version-1.9.0/API-Reference/python-examples/api-files/delete-file-v1.py new file mode 100644 index 0000000000..0ca36294f5 --- /dev/null +++ b/docs/versioned_docs/version-1.9.0/API-Reference/python-examples/api-files/delete-file-v1.py @@ -0,0 +1,17 @@ +import os + +import requests + +url = ( + f"{os.getenv('LANGFLOW_URL', '')}/api/v1/files/delete/{os.getenv('FLOW_ID', '')}/2024-12-30_15-19-43_your_file.txt" +) + +headers = { + "accept": "application/json", + "x-api-key": f"{os.getenv('LANGFLOW_API_KEY', '')}", +} + +response = requests.request("DELETE", url, headers=headers) +response.raise_for_status() + +print(response.text) diff --git a/docs/versioned_docs/version-1.9.0/API-Reference/python-examples/api-files/delete-file-v2.py b/docs/versioned_docs/version-1.9.0/API-Reference/python-examples/api-files/delete-file-v2.py new file mode 100644 index 0000000000..78d1597d2e --- /dev/null +++ b/docs/versioned_docs/version-1.9.0/API-Reference/python-examples/api-files/delete-file-v2.py @@ -0,0 +1,15 @@ +import os + +import requests + +url = f"{os.getenv('LANGFLOW_URL', '')}/api/v2/files/{os.getenv('FILE_ID', '')}" + +headers = { + "accept": "application/json", + "x-api-key": f"{os.getenv('LANGFLOW_API_KEY', '')}", +} + +response = requests.request("DELETE", url, headers=headers) +response.raise_for_status() + +print(response.text) diff --git a/docs/versioned_docs/version-1.9.0/API-Reference/python-examples/api-files/download-file-v1.py b/docs/versioned_docs/version-1.9.0/API-Reference/python-examples/api-files/download-file-v1.py new file mode 100644 index 0000000000..6e09676694 --- /dev/null +++ b/docs/versioned_docs/version-1.9.0/API-Reference/python-examples/api-files/download-file-v1.py @@ -0,0 +1,35 @@ +import json +import os +from pathlib import Path + +import requests + +base = os.environ.get("LANGFLOW_URL", "") +flow_id = os.environ.get("FLOW_ID", "") +api_key = os.environ.get("LANGFLOW_API_KEY", "") + +fixtures = Path(__file__).resolve().parents[2] / "fixtures" +upload_path = Path(os.environ.get("SAMPLE_UPLOAD_FILE", str(fixtures / "sample-upload.txt"))) + +headers = {"accept": "application/json", "x-api-key": api_key} + +upload = requests.post( + f"{base}/api/v1/files/upload/{flow_id}", + headers=headers, + files={"file": (upload_path.name, upload_path.read_bytes(), "text/plain")}, + timeout=30, +) +upload.raise_for_status() +meta = upload.json() +file_name = meta["file_path"].split("/")[-1] + +download = requests.get( + f"{base}/api/v1/files/download/{flow_id}/{file_name}", + headers=headers, + timeout=30, +) +download.raise_for_status() + +out_path = Path("downloaded_file.txt") +out_path.write_bytes(download.content) +print(json.dumps({"saved_bytes": len(download.content), "path": str(out_path), "upload": meta})) diff --git a/docs/versioned_docs/version-1.9.0/API-Reference/python-examples/api-files/download-file-v2.py b/docs/versioned_docs/version-1.9.0/API-Reference/python-examples/api-files/download-file-v2.py new file mode 100644 index 0000000000..e878b26760 --- /dev/null +++ b/docs/versioned_docs/version-1.9.0/API-Reference/python-examples/api-files/download-file-v2.py @@ -0,0 +1,33 @@ +import json +import os +from pathlib import Path + +import requests + +base = os.environ.get("LANGFLOW_URL", "") +api_key = os.environ.get("LANGFLOW_API_KEY", "") + +fixtures = Path(__file__).resolve().parents[2] / "fixtures" +upload_path = Path(os.environ.get("SAMPLE_UPLOAD_FILE", str(fixtures / "sample-upload.txt"))) + +headers = {"accept": "application/json", "x-api-key": api_key} + +upload = requests.post( + f"{base}/api/v2/files", + headers=headers, + files={"file": (upload_path.name, upload_path.read_bytes(), "text/plain")}, + timeout=30, +) +upload.raise_for_status() +file_id = upload.json()["id"] + +download = requests.get( + f"{base}/api/v2/files/{file_id}", + headers=headers, + timeout=30, +) +download.raise_for_status() + +out_path = Path("downloaded_file.txt") +out_path.write_bytes(download.content) +print(json.dumps({"saved_bytes": len(download.content), "file_id": str(file_id), "path": str(out_path)})) diff --git a/docs/versioned_docs/version-1.9.0/API-Reference/python-examples/api-files/edit-file-name-v2.py b/docs/versioned_docs/version-1.9.0/API-Reference/python-examples/api-files/edit-file-name-v2.py new file mode 100644 index 0000000000..d833ccbdf9 --- /dev/null +++ b/docs/versioned_docs/version-1.9.0/API-Reference/python-examples/api-files/edit-file-name-v2.py @@ -0,0 +1,30 @@ +import json +import os +from pathlib import Path +from urllib.parse import quote + +import requests + +base = os.environ.get("LANGFLOW_URL", "") +api_key = os.environ.get("LANGFLOW_API_KEY", "") + +fixtures = Path(__file__).resolve().parents[2] / "fixtures" +upload_path = Path(os.environ.get("SAMPLE_UPLOAD_FILE", str(fixtures / "sample-upload.txt"))) + +headers = {"accept": "application/json", "x-api-key": api_key} + +upload = requests.post( + f"{base}/api/v2/files", + headers=headers, + files={"file": (upload_path.name, upload_path.read_bytes(), "text/plain")}, + timeout=30, +) +upload.raise_for_status() +file_id = upload.json()["id"] + +new_name = os.environ.get("RENAMED_FILE_BASENAME", "renamed-sample-upload") +url = f"{base}/api/v2/files/{file_id}?name={quote(new_name)}" + +response = requests.put(url, headers=headers, timeout=30) +response.raise_for_status() +print(json.dumps(response.json())) diff --git a/docs/versioned_docs/version-1.9.0/API-Reference/python-examples/api-files/list-files-v1.py b/docs/versioned_docs/version-1.9.0/API-Reference/python-examples/api-files/list-files-v1.py new file mode 100644 index 0000000000..8ea27291fd --- /dev/null +++ b/docs/versioned_docs/version-1.9.0/API-Reference/python-examples/api-files/list-files-v1.py @@ -0,0 +1,15 @@ +import os + +import requests + +url = f"{os.getenv('LANGFLOW_URL', '')}/api/v1/files/list/{os.getenv('FLOW_ID', '')}" + +headers = { + "accept": "application/json", + "x-api-key": f"{os.getenv('LANGFLOW_API_KEY', '')}", +} + +response = requests.request("GET", url, headers=headers) +response.raise_for_status() + +print(response.text) diff --git a/docs/versioned_docs/version-1.9.0/API-Reference/python-examples/api-files/list-files-v2.py b/docs/versioned_docs/version-1.9.0/API-Reference/python-examples/api-files/list-files-v2.py new file mode 100644 index 0000000000..af09a94319 --- /dev/null +++ b/docs/versioned_docs/version-1.9.0/API-Reference/python-examples/api-files/list-files-v2.py @@ -0,0 +1,15 @@ +import os + +import requests + +url = f"{os.getenv('LANGFLOW_URL', '')}/api/v2/files" + +headers = { + "accept": "application/json", + "x-api-key": f"{os.getenv('LANGFLOW_API_KEY', '')}", +} + +response = requests.request("GET", url, headers=headers) +response.raise_for_status() + +print(response.text) diff --git a/docs/versioned_docs/version-1.9.0/API-Reference/python-examples/api-files/send-files-to-your-flows-v2-2.py b/docs/versioned_docs/version-1.9.0/API-Reference/python-examples/api-files/send-files-to-your-flows-v2-2.py new file mode 100644 index 0000000000..6e0f8610d4 --- /dev/null +++ b/docs/versioned_docs/version-1.9.0/API-Reference/python-examples/api-files/send-files-to-your-flows-v2-2.py @@ -0,0 +1,24 @@ +import os + +import requests + +url = f"{os.getenv('LANGFLOW_URL', '')}/api/v1/run/{os.getenv('FLOW_ID', '')}" + +headers = { + "Content-Type": "application/json", + "x-api-key": f"{os.getenv('LANGFLOW_API_KEY', '')}", +} + +payload = { + "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"]} + }, +} + +response = requests.request("POST", url, headers=headers, json=payload) +response.raise_for_status() + +print(response.text) diff --git a/docs/versioned_docs/version-1.9.0/API-Reference/python-examples/api-files/send-files-to-your-flows-v2.py b/docs/versioned_docs/version-1.9.0/API-Reference/python-examples/api-files/send-files-to-your-flows-v2.py new file mode 100644 index 0000000000..5f44e42003 --- /dev/null +++ b/docs/versioned_docs/version-1.9.0/API-Reference/python-examples/api-files/send-files-to-your-flows-v2.py @@ -0,0 +1,23 @@ +import os + +import requests + +url = f"{os.getenv('LANGFLOW_URL', '')}/api/v2/files" + +headers = { + "accept": "application/json", + "x-api-key": f"{os.getenv('LANGFLOW_API_KEY', '')}", +} + +files = { + "file": open(os.getenv("SAMPLE_UPLOAD_FILE", "docs/docs/API-Reference/fixtures/sample-upload.txt"), "rb"), +} + +response = requests.request("POST", url, headers=headers, files=files) +response.raise_for_status() + +print(response.text) + +for _f in files.values(): + if hasattr(_f, "close"): + _f.close() diff --git a/docs/versioned_docs/version-1.9.0/API-Reference/python-examples/api-files/upload-file-v1.py b/docs/versioned_docs/version-1.9.0/API-Reference/python-examples/api-files/upload-file-v1.py new file mode 100644 index 0000000000..51ddef206e --- /dev/null +++ b/docs/versioned_docs/version-1.9.0/API-Reference/python-examples/api-files/upload-file-v1.py @@ -0,0 +1,23 @@ +import os + +import requests + +url = f"{os.getenv('LANGFLOW_URL', '')}/api/v1/files/upload/{os.getenv('FLOW_ID', '')}" + +headers = { + "accept": "application/json", + "x-api-key": f"{os.getenv('LANGFLOW_API_KEY', '')}", +} + +files = { + "file": open(os.getenv("SAMPLE_UPLOAD_FILE", "docs/docs/API-Reference/fixtures/sample-upload.txt"), "rb"), +} + +response = requests.request("POST", url, headers=headers, files=files) +response.raise_for_status() + +print(response.text) + +for _f in files.values(): + if hasattr(_f, "close"): + _f.close() diff --git a/docs/versioned_docs/version-1.9.0/API-Reference/python-examples/api-files/upload-file-v2-2.py b/docs/versioned_docs/version-1.9.0/API-Reference/python-examples/api-files/upload-file-v2-2.py new file mode 100644 index 0000000000..5f44e42003 --- /dev/null +++ b/docs/versioned_docs/version-1.9.0/API-Reference/python-examples/api-files/upload-file-v2-2.py @@ -0,0 +1,23 @@ +import os + +import requests + +url = f"{os.getenv('LANGFLOW_URL', '')}/api/v2/files" + +headers = { + "accept": "application/json", + "x-api-key": f"{os.getenv('LANGFLOW_API_KEY', '')}", +} + +files = { + "file": open(os.getenv("SAMPLE_UPLOAD_FILE", "docs/docs/API-Reference/fixtures/sample-upload.txt"), "rb"), +} + +response = requests.request("POST", url, headers=headers, files=files) +response.raise_for_status() + +print(response.text) + +for _f in files.values(): + if hasattr(_f, "close"): + _f.close() diff --git a/docs/versioned_docs/version-1.9.0/API-Reference/python-examples/api-files/upload-file-v2.py b/docs/versioned_docs/version-1.9.0/API-Reference/python-examples/api-files/upload-file-v2.py new file mode 100644 index 0000000000..43e3d6271a --- /dev/null +++ b/docs/versioned_docs/version-1.9.0/API-Reference/python-examples/api-files/upload-file-v2.py @@ -0,0 +1,15 @@ +import os + +import requests + +url = f"{os.getenv('LANGFLOW_URL', '')}/api/v1/users/whoami" + +headers = { + "accept": "application/json", + "x-api-key": f"{os.getenv('LANGFLOW_API_KEY', '')}", +} + +response = requests.request("GET", url, headers=headers) +response.raise_for_status() + +print(response.text) diff --git a/docs/versioned_docs/version-1.9.0/API-Reference/python-examples/api-files/upload-image-files-v1-2.py b/docs/versioned_docs/version-1.9.0/API-Reference/python-examples/api-files/upload-image-files-v1-2.py new file mode 100644 index 0000000000..8f9d0a1091 --- /dev/null +++ b/docs/versioned_docs/version-1.9.0/API-Reference/python-examples/api-files/upload-image-files-v1-2.py @@ -0,0 +1,26 @@ +import json +import os +from pathlib import Path + +import requests + +base = os.environ.get("LANGFLOW_URL", "") +flow_id = os.environ.get("FLOW_ID", "") +api_key = os.environ.get("LANGFLOW_API_KEY", "") + +fixtures = Path(__file__).resolve().parents[2] / "fixtures" +image_path = Path(os.environ.get("SAMPLE_IMAGE_FILE", str(fixtures / "sample-upload.png"))) + +headers = {"accept": "application/json", "x-api-key": api_key} + +upload = requests.post( + f"{base}/api/v1/files/upload/{flow_id}", + headers=headers, + files={"file": (image_path.name, image_path.read_bytes(), "image/png")}, + timeout=30, +) +upload.raise_for_status() + +listed = requests.get(f"{base}/api/v1/files/list/{flow_id}", headers=headers, timeout=30) +listed.raise_for_status() +print(json.dumps({"upload": upload.json(), "list": listed.json()})) diff --git a/docs/versioned_docs/version-1.9.0/API-Reference/python-examples/api-files/upload-image-files-v1.py b/docs/versioned_docs/version-1.9.0/API-Reference/python-examples/api-files/upload-image-files-v1.py new file mode 100644 index 0000000000..62556297e4 --- /dev/null +++ b/docs/versioned_docs/version-1.9.0/API-Reference/python-examples/api-files/upload-image-files-v1.py @@ -0,0 +1,22 @@ +import os + +import requests + +url = f"{os.getenv('LANGFLOW_URL', '')}/api/v1/files/upload/{os.getenv('FLOW_ID', '')}" + +headers = { + "x-api-key": f"{os.getenv('LANGFLOW_API_KEY', '')}", +} + +files = { + "file": open(os.getenv("SAMPLE_IMAGE_FILE", "docs/docs/API-Reference/fixtures/sample-upload.png"), "rb"), +} + +response = requests.request("POST", url, headers=headers, files=files) +response.raise_for_status() + +print(response.text) + +for _f in files.values(): + if hasattr(_f, "close"): + _f.close() diff --git a/docs/versioned_docs/version-1.9.0/API-Reference/python-examples/api-flows-run/pass-global-variables-in-request-headers.py b/docs/versioned_docs/version-1.9.0/API-Reference/python-examples/api-flows-run/pass-global-variables-in-request-headers.py new file mode 100644 index 0000000000..b489a48e71 --- /dev/null +++ b/docs/versioned_docs/version-1.9.0/API-Reference/python-examples/api-flows-run/pass-global-variables-in-request-headers.py @@ -0,0 +1,24 @@ +import os + +import requests + +base = os.environ.get("LANGFLOW_URL") or os.environ.get("LANGFLOW_SERVER_URL", "") +flow_id = os.environ.get("FLOW_ID", "") +api_key = os.environ.get("LANGFLOW_API_KEY", "") + +headers = { + "Content-Type": "application/json", + "x-api-key": api_key, + "X-LANGFLOW-GLOBAL-VAR-USER_ID": "user123", + "X-LANGFLOW-GLOBAL-VAR-ENVIRONMENT": "production", +} + +payload = { + "input_value": "Tell me about something interesting!", + "input_type": "chat", + "output_type": "chat", +} + +response = requests.post(f"{base}/api/v1/run/{flow_id}", headers=headers, json=payload, timeout=60) +response.raise_for_status() +print(response.text) diff --git a/docs/versioned_docs/version-1.9.0/API-Reference/python-examples/api-flows-run/request-example-with-all-headers-and-parameters.py b/docs/versioned_docs/version-1.9.0/API-Reference/python-examples/api-flows-run/request-example-with-all-headers-and-parameters.py new file mode 100644 index 0000000000..55797681d0 --- /dev/null +++ b/docs/versioned_docs/version-1.9.0/API-Reference/python-examples/api-flows-run/request-example-with-all-headers-and-parameters.py @@ -0,0 +1,30 @@ +import os + +import requests + +base = os.environ.get("LANGFLOW_URL") or os.environ.get("LANGFLOW_SERVER_URL", "") +flow_id = os.environ.get("FLOW_ID", "") +api_key = os.environ.get("LANGFLOW_API_KEY", "") + +headers = { + "Content-Type": "application/json", + "accept": "application/json", + "x-api-key": api_key, +} + +payload = { + "input_value": "Tell me a story", + "input_type": "chat", + "output_type": "chat", + "output_component": "chat_output", + "session_id": "chat-123", +} + +response = requests.post( + f"{base}/api/v1/run/{flow_id}?stream=false", + headers=headers, + json=payload, + timeout=60, +) +response.raise_for_status() +print(response.text) diff --git a/docs/versioned_docs/version-1.9.0/API-Reference/python-examples/api-flows-run/run-flow.py b/docs/versioned_docs/version-1.9.0/API-Reference/python-examples/api-flows-run/run-flow.py new file mode 100644 index 0000000000..18fcb41b2a --- /dev/null +++ b/docs/versioned_docs/version-1.9.0/API-Reference/python-examples/api-flows-run/run-flow.py @@ -0,0 +1,26 @@ +import os + +import requests + +base = os.environ.get("LANGFLOW_URL") or os.environ.get("LANGFLOW_SERVER_URL", "") +flow_id = os.environ.get("FLOW_ID", "") +api_key = os.environ.get("LANGFLOW_API_KEY", "") + +url = f"{base}/api/v1/run/{flow_id}" + +headers = { + "Content-Type": "application/json", + "x-api-key": api_key, +} + +payload = { + "input_value": "Tell me about something interesting!", + "session_id": "chat-123", + "input_type": "chat", + "output_type": "chat", + "output_component": "", +} + +response = requests.post(url, headers=headers, json=payload, timeout=60) +response.raise_for_status() +print(response.text) diff --git a/docs/versioned_docs/version-1.9.0/API-Reference/python-examples/api-flows-run/stream-llm-token-responses.py b/docs/versioned_docs/version-1.9.0/API-Reference/python-examples/api-flows-run/stream-llm-token-responses.py new file mode 100644 index 0000000000..484a5e0491 --- /dev/null +++ b/docs/versioned_docs/version-1.9.0/API-Reference/python-examples/api-flows-run/stream-llm-token-responses.py @@ -0,0 +1,18 @@ +import os + +import requests + +url = f"{os.getenv('LANGFLOW_SERVER_URL', '')}/api/v1/run/{os.getenv('FLOW_ID', '')}?stream=true" + +headers = { + "accept": "application/json", + "Content-Type": "application/json", + "x-api-key": f"{os.getenv('LANGFLOW_API_KEY', '')}", +} + +payload = {"message": "Tell me something interesting!", "session_id": "chat-123"} + +response = requests.request("POST", url, headers=headers, json=payload) +response.raise_for_status() + +print(response.text) diff --git a/docs/versioned_docs/version-1.9.0/API-Reference/python-examples/api-flows-run/webhook-run-flow.py b/docs/versioned_docs/version-1.9.0/API-Reference/python-examples/api-flows-run/webhook-run-flow.py new file mode 100644 index 0000000000..60952fd586 --- /dev/null +++ b/docs/versioned_docs/version-1.9.0/API-Reference/python-examples/api-flows-run/webhook-run-flow.py @@ -0,0 +1,23 @@ +import os + +import requests + +base = os.environ.get("LANGFLOW_URL") or os.environ.get("LANGFLOW_SERVER_URL", "") +flow_id = os.environ.get("FLOW_ID", "") +api_key = os.environ.get("LANGFLOW_API_KEY", "") + +headers = { + "Content-Type": "application/json", + "x-api-key": api_key, +} + +payload = {"data": "example-data"} + +response = requests.post( + f"{base}/api/v1/webhook/{flow_id}", + headers=headers, + json=payload, + timeout=60, +) +response.raise_for_status() +print(response.text) diff --git a/docs/versioned_docs/version-1.9.0/API-Reference/python-examples/api-flows/create-flow.py b/docs/versioned_docs/version-1.9.0/API-Reference/python-examples/api-flows/create-flow.py new file mode 100644 index 0000000000..f91f54654b --- /dev/null +++ b/docs/versioned_docs/version-1.9.0/API-Reference/python-examples/api-flows/create-flow.py @@ -0,0 +1,30 @@ +import os + +import requests + +url = f"{os.getenv('LANGFLOW_URL', '')}/api/v1/flows/" + +headers = { + "accept": "application/json", + "Content-Type": "application/json", + "x-api-key": f"{os.getenv('LANGFLOW_API_KEY', '')}", +} + +payload = { + "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"], +} + +response = requests.request("POST", url, headers=headers, json=payload) +response.raise_for_status() + +print(response.text) diff --git a/docs/versioned_docs/version-1.9.0/API-Reference/python-examples/api-flows/create-flows.py b/docs/versioned_docs/version-1.9.0/API-Reference/python-examples/api-flows/create-flows.py new file mode 100644 index 0000000000..4e59315e8f --- /dev/null +++ b/docs/versioned_docs/version-1.9.0/API-Reference/python-examples/api-flows/create-flows.py @@ -0,0 +1,28 @@ +import os +import uuid + +import requests + +base = os.environ.get("LANGFLOW_URL", "") +api_key = os.environ.get("LANGFLOW_API_KEY", "") +folder_id = (os.environ.get("PROJECT_ID") or os.environ.get("FOLDER_ID") or "").strip() + +headers = {"accept": "application/json", "Content-Type": "application/json", "x-api-key": api_key} + + +def _flow_doc(suffix: str) -> dict: + doc = { + "name": f"batch-flow-{uuid.uuid4().hex[:8]}", + "description": f"Docs batch example {suffix}", + "data": {"nodes": [], "edges": []}, + } + if folder_id: + doc["folder_id"] = folder_id + return doc + + +payload = {"flows": [_flow_doc("A"), _flow_doc("B")]} + +response = requests.post(f"{base}/api/v1/flows/batch/", headers=headers, json=payload, timeout=30) +response.raise_for_status() +print(response.text) diff --git a/docs/versioned_docs/version-1.9.0/API-Reference/python-examples/api-flows/delete-flow.py b/docs/versioned_docs/version-1.9.0/API-Reference/python-examples/api-flows/delete-flow.py new file mode 100644 index 0000000000..d7510dae4f --- /dev/null +++ b/docs/versioned_docs/version-1.9.0/API-Reference/python-examples/api-flows/delete-flow.py @@ -0,0 +1,25 @@ +import os + +import requests + +base = os.environ.get("LANGFLOW_URL", "") +api_key = os.environ.get("LANGFLOW_API_KEY", "") + +headers = {"accept": "application/json", "Content-Type": "application/json", "x-api-key": api_key} + +create = requests.post( + f"{base}/api/v1/flows/", + headers=headers, + json={ + "name": "docs-example-delete-me", + "description": "Temporary flow for delete-flow example", + "data": {"nodes": [], "edges": []}, + }, + timeout=30, +) +create.raise_for_status() +flow_id = create.json()["id"] + +delete = requests.delete(f"{base}/api/v1/flows/{flow_id}", headers=headers, timeout=30) +delete.raise_for_status() +print(delete.text) diff --git a/docs/versioned_docs/version-1.9.0/API-Reference/python-examples/api-flows/export-flows.py b/docs/versioned_docs/version-1.9.0/API-Reference/python-examples/api-flows/export-flows.py new file mode 100644 index 0000000000..7e763b380d --- /dev/null +++ b/docs/versioned_docs/version-1.9.0/API-Reference/python-examples/api-flows/export-flows.py @@ -0,0 +1,40 @@ +import os + +import requests + +base = os.environ.get("LANGFLOW_URL", "") +api_key = os.environ.get("LANGFLOW_API_KEY", "") +flow_id = os.environ.get("FLOW_ID", "") +folder_id = os.environ.get("PROJECT_ID") or os.environ.get("FOLDER_ID", "") + +headers = { + "accept": "application/json", + "Content-Type": "application/json", + "x-api-key": api_key, +} + +# Export needs at least two flows to return a ZIP; a single id returns JSON. +extra = requests.post( + f"{base}/api/v1/flows/", + headers=headers, + json={ + "name": "docs-export-temp-flow", + "description": "Temporary second flow for export example", + "data": {"nodes": [], "edges": []}, + **({"folder_id": folder_id} if folder_id else {}), + }, + timeout=30, +) +extra.raise_for_status() +extra_id = extra.json()["id"] + +payload = [flow_id, extra_id] + +response = requests.post(f"{base}/api/v1/flows/download/", headers=headers, json=payload, timeout=60) +response.raise_for_status() + +with open("langflow-flows.zip", "wb") as f: + f.write(response.content) +print("Saved response to langflow-flows.zip") + +requests.delete(f"{base}/api/v1/flows/{extra_id}", headers=headers, timeout=30) diff --git a/docs/versioned_docs/version-1.9.0/API-Reference/python-examples/api-flows/import-flows.py b/docs/versioned_docs/version-1.9.0/API-Reference/python-examples/api-flows/import-flows.py new file mode 100644 index 0000000000..1721620ca1 --- /dev/null +++ b/docs/versioned_docs/version-1.9.0/API-Reference/python-examples/api-flows/import-flows.py @@ -0,0 +1,23 @@ +import os + +import requests + +url = f"{os.getenv('LANGFLOW_URL', '')}/api/v1/flows/upload/?folder_id={os.getenv('FOLDER_ID', '')}" + +headers = { + "accept": "application/json", + "x-api-key": f"{os.getenv('LANGFLOW_API_KEY', '')}", +} + +files = { + "file": open(os.getenv("FLOW_IMPORT_FILE", "docs/docs/API-Reference/fixtures/flow-import.json"), "rb"), +} + +response = requests.request("POST", url, headers=headers, files=files) +response.raise_for_status() + +print(response.text) + +for _f in files.values(): + if hasattr(_f, "close"): + _f.close() diff --git a/docs/versioned_docs/version-1.9.0/API-Reference/python-examples/api-flows/read-flow.py b/docs/versioned_docs/version-1.9.0/API-Reference/python-examples/api-flows/read-flow.py new file mode 100644 index 0000000000..d362b3fb1a --- /dev/null +++ b/docs/versioned_docs/version-1.9.0/API-Reference/python-examples/api-flows/read-flow.py @@ -0,0 +1,15 @@ +import os + +import requests + +url = f"{os.getenv('LANGFLOW_URL', '')}/api/v1/flows/{os.getenv('FLOW_ID', '')}" + +headers = { + "accept": "application/json", + "x-api-key": f"{os.getenv('LANGFLOW_API_KEY', '')}", +} + +response = requests.request("GET", url, headers=headers) +response.raise_for_status() + +print(response.text) diff --git a/docs/versioned_docs/version-1.9.0/API-Reference/python-examples/api-flows/read-flows-2.py b/docs/versioned_docs/version-1.9.0/API-Reference/python-examples/api-flows/read-flows-2.py new file mode 100644 index 0000000000..334a50ae4b --- /dev/null +++ b/docs/versioned_docs/version-1.9.0/API-Reference/python-examples/api-flows/read-flows-2.py @@ -0,0 +1,15 @@ +import os + +import requests + +url = f"{os.getenv('LANGFLOW_URL', '')}/api/v1/flows/?remove_example_flows=true&components_only=false&get_all=false&project_id={os.getenv('PROJECT_ID', '')}&header_flows=false&page=1&size=1" + +headers = { + "accept": "application/json", + "x-api-key": f"{os.getenv('LANGFLOW_API_KEY', '')}", +} + +response = requests.request("GET", url, headers=headers) +response.raise_for_status() + +print(response.text) diff --git a/docs/versioned_docs/version-1.9.0/API-Reference/python-examples/api-flows/read-flows.py b/docs/versioned_docs/version-1.9.0/API-Reference/python-examples/api-flows/read-flows.py new file mode 100644 index 0000000000..9e78b333ba --- /dev/null +++ b/docs/versioned_docs/version-1.9.0/API-Reference/python-examples/api-flows/read-flows.py @@ -0,0 +1,15 @@ +import os + +import requests + +url = f"{os.getenv('LANGFLOW_URL', '')}/api/v1/flows/?remove_example_flows=false&components_only=false&get_all=true&header_flows=false&page=1&size=50" + +headers = { + "accept": "application/json", + "x-api-key": f"{os.getenv('LANGFLOW_API_KEY', '')}", +} + +response = requests.request("GET", url, headers=headers) +response.raise_for_status() + +print(response.text) diff --git a/docs/versioned_docs/version-1.9.0/API-Reference/python-examples/api-flows/read-sample-flows.py b/docs/versioned_docs/version-1.9.0/API-Reference/python-examples/api-flows/read-sample-flows.py new file mode 100644 index 0000000000..988347fdd0 --- /dev/null +++ b/docs/versioned_docs/version-1.9.0/API-Reference/python-examples/api-flows/read-sample-flows.py @@ -0,0 +1,15 @@ +import os + +import requests + +url = f"{os.getenv('LANGFLOW_URL', '')}/api/v1/flows/basic_examples/" + +headers = { + "accept": "application/json", + "x-api-key": f"{os.getenv('LANGFLOW_API_KEY', '')}", +} + +response = requests.request("GET", url, headers=headers) +response.raise_for_status() + +print(response.text) diff --git a/docs/versioned_docs/version-1.9.0/API-Reference/python-examples/api-flows/update-flow.py b/docs/versioned_docs/version-1.9.0/API-Reference/python-examples/api-flows/update-flow.py new file mode 100644 index 0000000000..6be601aca0 --- /dev/null +++ b/docs/versioned_docs/version-1.9.0/API-Reference/python-examples/api-flows/update-flow.py @@ -0,0 +1,20 @@ +import os +import uuid + +import requests + +base = os.environ.get("LANGFLOW_URL") or os.environ.get("LANGFLOW_SERVER_URL", "") +flow_id = os.environ.get("FLOW_ID", "") +api_key = os.environ.get("LANGFLOW_API_KEY", "") + +headers = {"accept": "application/json", "Content-Type": "application/json", "x-api-key": api_key} + +payload = { + "name": f"docs-example-updated-flow-{uuid.uuid4().hex[:8]}", + "description": "Updated via API docs Python example", + "locked": False, +} + +response = requests.patch(f"{base}/api/v1/flows/{flow_id}", headers=headers, json=payload, timeout=30) +response.raise_for_status() +print(response.text) diff --git a/docs/versioned_docs/version-1.9.0/API-Reference/python-examples/api-logs/retrieve-logs-with-optional-parameters.py b/docs/versioned_docs/version-1.9.0/API-Reference/python-examples/api-logs/retrieve-logs-with-optional-parameters.py new file mode 100644 index 0000000000..a46b913a94 --- /dev/null +++ b/docs/versioned_docs/version-1.9.0/API-Reference/python-examples/api-logs/retrieve-logs-with-optional-parameters.py @@ -0,0 +1,15 @@ +import os + +import requests + +url = f"{os.getenv('LANGFLOW_URL', '')}/logs?lines_before=0&lines_after=0×tamp=0" + +headers = { + "accept": "application/json", + "x-api-key": f"{os.getenv('LANGFLOW_API_KEY', '')}", +} + +response = requests.request("GET", url, headers=headers) +response.raise_for_status() + +print(response.text) diff --git a/docs/versioned_docs/version-1.9.0/API-Reference/python-examples/api-logs/stream-logs.py b/docs/versioned_docs/version-1.9.0/API-Reference/python-examples/api-logs/stream-logs.py new file mode 100644 index 0000000000..799e5f2d50 --- /dev/null +++ b/docs/versioned_docs/version-1.9.0/API-Reference/python-examples/api-logs/stream-logs.py @@ -0,0 +1,27 @@ +import os + +import requests + +base = os.environ.get("LANGFLOW_URL") or os.environ.get("LANGFLOW_SERVER_URL", "") +api_key = os.environ.get("LANGFLOW_API_KEY", "") + +# `/logs-stream` is an SSE endpoint. For doc example stability, only read a small +# number of events, then close the connection. +url = f"{base}/logs-stream" +headers = {"accept": "text/event-stream", "x-api-key": api_key} + +response = requests.get(url, headers=headers, stream=True, timeout=30) +response.raise_for_status() + +events_read = 0 +chunks: list[str] = [] +for line in response.iter_lines(decode_unicode=True): + if line: + chunks.append(line) + events_read += 1 + if events_read >= 3: + break + +response.close() + +print("\n".join(chunks)) diff --git a/docs/versioned_docs/version-1.9.0/API-Reference/python-examples/api-monitor/delete-messages-by-session.py b/docs/versioned_docs/version-1.9.0/API-Reference/python-examples/api-monitor/delete-messages-by-session.py new file mode 100644 index 0000000000..fef7a96efd --- /dev/null +++ b/docs/versioned_docs/version-1.9.0/API-Reference/python-examples/api-monitor/delete-messages-by-session.py @@ -0,0 +1,15 @@ +import os + +import requests + +url = f"{os.getenv('LANGFLOW_URL', '')}/api/v1/monitor/messages/session/different_session_id_2" + +headers = { + "accept": "*/*", + "x-api-key": f"{os.getenv('LANGFLOW_API_KEY', '')}", +} + +response = requests.request("DELETE", url, headers=headers) +response.raise_for_status() + +print(response.text) diff --git a/docs/versioned_docs/version-1.9.0/API-Reference/python-examples/api-monitor/delete-messages.py b/docs/versioned_docs/version-1.9.0/API-Reference/python-examples/api-monitor/delete-messages.py new file mode 100644 index 0000000000..05b117b925 --- /dev/null +++ b/docs/versioned_docs/version-1.9.0/API-Reference/python-examples/api-monitor/delete-messages.py @@ -0,0 +1,29 @@ +import os +from uuid import UUID + +import requests + +base = os.environ.get("LANGFLOW_URL", "") +api_key = os.environ.get("LANGFLOW_API_KEY", "") +flow_id = os.environ.get("FLOW_ID", "") + +headers = {"accept": "*/*", "Content-Type": "application/json", "x-api-key": api_key} + +list_resp = requests.get( + f"{base}/api/v1/monitor/messages", + headers=headers, + params={"flow_id": flow_id}, + timeout=30, +) +list_resp.raise_for_status() +messages = list_resp.json() +if not messages: + print("No messages to delete.") + raise SystemExit(0) + +ids = [UUID(str(m["id"])) for m in messages[:2]] +params = [("message_ids", str(i)) for i in ids] + +response = requests.delete(f"{base}/api/v1/monitor/messages", headers=headers, params=params, timeout=30) +response.raise_for_status() +print(response.status_code) diff --git a/docs/versioned_docs/version-1.9.0/API-Reference/python-examples/api-monitor/delete-vertex-builds.py b/docs/versioned_docs/version-1.9.0/API-Reference/python-examples/api-monitor/delete-vertex-builds.py new file mode 100644 index 0000000000..9f8ce6c404 --- /dev/null +++ b/docs/versioned_docs/version-1.9.0/API-Reference/python-examples/api-monitor/delete-vertex-builds.py @@ -0,0 +1,15 @@ +import os + +import requests + +url = f"{os.getenv('LANGFLOW_URL', '')}/api/v1/monitor/builds?flow_id={os.getenv('FLOW_ID', '')}" + +headers = { + "accept": "*/*", + "x-api-key": f"{os.getenv('LANGFLOW_API_KEY', '')}", +} + +response = requests.request("DELETE", url, headers=headers) +response.raise_for_status() + +print(response.text) diff --git a/docs/versioned_docs/version-1.9.0/API-Reference/python-examples/api-monitor/example-request.py b/docs/versioned_docs/version-1.9.0/API-Reference/python-examples/api-monitor/example-request.py new file mode 100644 index 0000000000..55c9c0988a --- /dev/null +++ b/docs/versioned_docs/version-1.9.0/API-Reference/python-examples/api-monitor/example-request.py @@ -0,0 +1,16 @@ +import os + +import requests + +base_url = os.environ.get("LANGFLOW_URL") or os.environ.get("LANGFLOW_SERVER_URL", "http://127.0.0.1:7860") +api_key = os.environ.get("LANGFLOW_API_KEY", "") +flow_id = os.environ.get("FLOW_ID", "") + +response = requests.get( + f"{base_url}/api/v1/monitor/traces", + params={"flow_id": flow_id, "page": 1, "size": 50}, + headers={"x-api-key": api_key, "accept": "application/json"}, + timeout=30, +) +response.raise_for_status() +print(response.json()) diff --git a/docs/versioned_docs/version-1.9.0/API-Reference/python-examples/api-monitor/get-messages-2.py b/docs/versioned_docs/version-1.9.0/API-Reference/python-examples/api-monitor/get-messages-2.py new file mode 100644 index 0000000000..fd40c0d12e --- /dev/null +++ b/docs/versioned_docs/version-1.9.0/API-Reference/python-examples/api-monitor/get-messages-2.py @@ -0,0 +1,15 @@ +import os + +import requests + +url = f"{os.getenv('LANGFLOW_URL', '')}/api/v1/monitor/messages?flow_id={os.getenv('FLOW_ID', '')}&session_id=01ce083d-748b-4b8d-97b6-33adbb6a528a&sender=Machine&sender_name=AI&order_by=timestamp" + +headers = { + "accept": "application/json", + "x-api-key": f"{os.getenv('LANGFLOW_API_KEY', '')}", +} + +response = requests.request("GET", url, headers=headers) +response.raise_for_status() + +print(response.text) diff --git a/docs/versioned_docs/version-1.9.0/API-Reference/python-examples/api-monitor/get-messages.py b/docs/versioned_docs/version-1.9.0/API-Reference/python-examples/api-monitor/get-messages.py new file mode 100644 index 0000000000..7a8e1d2c53 --- /dev/null +++ b/docs/versioned_docs/version-1.9.0/API-Reference/python-examples/api-monitor/get-messages.py @@ -0,0 +1,15 @@ +import os + +import requests + +url = f"{os.getenv('LANGFLOW_URL', '')}/api/v1/monitor/messages" + +headers = { + "accept": "application/json", + "x-api-key": f"{os.getenv('LANGFLOW_API_KEY', '')}", +} + +response = requests.request("GET", url, headers=headers) +response.raise_for_status() + +print(response.text) diff --git a/docs/versioned_docs/version-1.9.0/API-Reference/python-examples/api-monitor/get-transactions.py b/docs/versioned_docs/version-1.9.0/API-Reference/python-examples/api-monitor/get-transactions.py new file mode 100644 index 0000000000..6f65f04749 --- /dev/null +++ b/docs/versioned_docs/version-1.9.0/API-Reference/python-examples/api-monitor/get-transactions.py @@ -0,0 +1,15 @@ +import os + +import requests + +url = f"{os.getenv('LANGFLOW_URL', '')}/api/v1/monitor/transactions?flow_id={os.getenv('FLOW_ID', '')}&page=1&size=50" + +headers = { + "accept": "application/json", + "x-api-key": f"{os.getenv('LANGFLOW_API_KEY', '')}", +} + +response = requests.request("GET", url, headers=headers) +response.raise_for_status() + +print(response.text) diff --git a/docs/versioned_docs/version-1.9.0/API-Reference/python-examples/api-monitor/get-vertex-builds.py b/docs/versioned_docs/version-1.9.0/API-Reference/python-examples/api-monitor/get-vertex-builds.py new file mode 100644 index 0000000000..01be1fb644 --- /dev/null +++ b/docs/versioned_docs/version-1.9.0/API-Reference/python-examples/api-monitor/get-vertex-builds.py @@ -0,0 +1,15 @@ +import os + +import requests + +url = f"{os.getenv('LANGFLOW_URL', '')}/api/v1/monitor/builds?flow_id={os.getenv('FLOW_ID', '')}" + +headers = { + "accept": "application/json", + "x-api-key": f"{os.getenv('LANGFLOW_API_KEY', '')}", +} + +response = requests.request("GET", url, headers=headers) +response.raise_for_status() + +print(response.text) diff --git a/docs/versioned_docs/version-1.9.0/API-Reference/python-examples/api-monitor/update-message.py b/docs/versioned_docs/version-1.9.0/API-Reference/python-examples/api-monitor/update-message.py new file mode 100644 index 0000000000..1449f3cbd0 --- /dev/null +++ b/docs/versioned_docs/version-1.9.0/API-Reference/python-examples/api-monitor/update-message.py @@ -0,0 +1,33 @@ +import os + +import requests + +base = os.environ.get("LANGFLOW_URL", "") +api_key = os.environ.get("LANGFLOW_API_KEY", "") +flow_id = os.environ.get("FLOW_ID", "") + +headers = {"accept": "application/json", "Content-Type": "application/json", "x-api-key": api_key} + +list_resp = requests.get( + f"{base}/api/v1/monitor/messages", + headers=headers, + params={"flow_id": flow_id}, + timeout=30, +) +list_resp.raise_for_status() +messages = list_resp.json() +if not messages: + print("No messages to update.") + raise SystemExit(0) + +message_id = messages[0]["id"] +payload = {"text": "testing 1234"} + +response = requests.put( + f"{base}/api/v1/monitor/messages/{message_id}", + headers=headers, + json=payload, + timeout=30, +) +response.raise_for_status() +print(response.text) diff --git a/docs/versioned_docs/version-1.9.0/API-Reference/python-examples/api-monitor/update-session-id.py b/docs/versioned_docs/version-1.9.0/API-Reference/python-examples/api-monitor/update-session-id.py new file mode 100644 index 0000000000..e5ded7f252 --- /dev/null +++ b/docs/versioned_docs/version-1.9.0/API-Reference/python-examples/api-monitor/update-session-id.py @@ -0,0 +1,33 @@ +import os + +import requests + +base = os.environ.get("LANGFLOW_URL", "") +api_key = os.environ.get("LANGFLOW_API_KEY", "") +flow_id = os.environ.get("FLOW_ID", "") + +headers = {"accept": "application/json", "x-api-key": api_key} + +list_resp = requests.get( + f"{base}/api/v1/monitor/messages", + headers=headers, + params={"flow_id": flow_id}, + timeout=30, +) +list_resp.raise_for_status() +messages = list_resp.json() +if not messages: + print("No messages; cannot migrate session id.") + raise SystemExit(0) + +old_session_id = messages[0]["session_id"] +new_session_id = f"{old_session_id}-migrated" + +response = requests.patch( + f"{base}/api/v1/monitor/messages/session/{old_session_id}", + headers=headers, + params={"new_session_id": new_session_id}, + timeout=30, +) +response.raise_for_status() +print(response.text) diff --git a/docs/versioned_docs/version-1.9.0/API-Reference/python-examples/api-openai-responses/additional-configuration-for-openai-client-libraries.py b/docs/versioned_docs/version-1.9.0/API-Reference/python-examples/api-openai-responses/additional-configuration-for-openai-client-libraries.py new file mode 100644 index 0000000000..3e8bae8034 --- /dev/null +++ b/docs/versioned_docs/version-1.9.0/API-Reference/python-examples/api-openai-responses/additional-configuration-for-openai-client-libraries.py @@ -0,0 +1,27 @@ +import os + +from openai import OpenAI + +base = (os.environ.get("LANGFLOW_URL") or os.environ.get("LANGFLOW_SERVER_URL", "")).rstrip("/") +api_key = os.environ.get("LANGFLOW_API_KEY", "") +flow_id = os.environ.get("FLOW_ID", "") + +client = OpenAI( + base_url=f"{base}/api/v1/", + default_headers={"x-api-key": api_key}, + api_key="dummy-api-key", # Required by OpenAI SDK but not used by Langflow +) + +try: + response = client.responses.create( + model=flow_id, + input="There is an event that happens on the second wednesday of every month. What are the event dates in 2026?", + ) +except Exception as exc: + # Empty bootstrap flows return an error body; use a flow with ChatInput + ChatOutput in the UI. + print(exc) +else: + try: + print(response.output_text) + except Exception: + print(response) diff --git a/docs/versioned_docs/version-1.9.0/API-Reference/python-examples/api-openai-responses/continue-conversations-with-response-and-session-ids-2.py b/docs/versioned_docs/version-1.9.0/API-Reference/python-examples/api-openai-responses/continue-conversations-with-response-and-session-ids-2.py new file mode 100644 index 0000000000..336eb32ad2 --- /dev/null +++ b/docs/versioned_docs/version-1.9.0/API-Reference/python-examples/api-openai-responses/continue-conversations-with-response-and-session-ids-2.py @@ -0,0 +1,29 @@ +# Continuation requests use the same endpoint; add `previous_response_id` from a prior +# response's `id` field. The bootstrap flow is empty; use a Playground flow with ChatInput + +# ChatOutput for a full run. Same first message as continue-conversations-with-response-and-session-ids.py. + +import os + +import requests + +base = os.environ.get("LANGFLOW_URL") or os.environ.get("LANGFLOW_SERVER_URL", "") +flow_id = os.environ.get("FLOW_ID", "") +api_key = os.environ.get("LANGFLOW_API_KEY", "") + +url = f"{base}/api/v1/responses" + +headers = { + "x-api-key": api_key, + "Content-Type": "application/json", +} + +payload = { + "model": flow_id, + "input": "Hello, my name is Alice", + "stream": False, +} + +response = requests.post(url, headers=headers, json=payload, timeout=120) +response.raise_for_status() + +print(response.text) diff --git a/docs/versioned_docs/version-1.9.0/API-Reference/python-examples/api-openai-responses/continue-conversations-with-response-and-session-ids-3.py b/docs/versioned_docs/version-1.9.0/API-Reference/python-examples/api-openai-responses/continue-conversations-with-response-and-session-ids-3.py new file mode 100644 index 0000000000..88dacf14a4 --- /dev/null +++ b/docs/versioned_docs/version-1.9.0/API-Reference/python-examples/api-openai-responses/continue-conversations-with-response-and-session-ids-3.py @@ -0,0 +1,28 @@ +# Same pattern as continue-conversations-with-response-and-session-ids-2.py; you can pass +# `previous_response_id` from the prior turn (or a session id your app stores). + +import os + +import requests + +base = os.environ.get("LANGFLOW_URL") or os.environ.get("LANGFLOW_SERVER_URL", "") +flow_id = os.environ.get("FLOW_ID", "") +api_key = os.environ.get("LANGFLOW_API_KEY", "") + +url = f"{base}/api/v1/responses" + +headers = { + "x-api-key": api_key, + "Content-Type": "application/json", +} + +payload = { + "model": flow_id, + "input": "Hello, my name is Alice", + "stream": False, +} + +response = requests.post(url, headers=headers, json=payload, timeout=120) +response.raise_for_status() + +print(response.text) diff --git a/docs/versioned_docs/version-1.9.0/API-Reference/python-examples/api-openai-responses/continue-conversations-with-response-and-session-ids.py b/docs/versioned_docs/version-1.9.0/API-Reference/python-examples/api-openai-responses/continue-conversations-with-response-and-session-ids.py new file mode 100644 index 0000000000..e57f103f15 --- /dev/null +++ b/docs/versioned_docs/version-1.9.0/API-Reference/python-examples/api-openai-responses/continue-conversations-with-response-and-session-ids.py @@ -0,0 +1,25 @@ +import os + +import requests + +base = os.environ.get("LANGFLOW_URL") or os.environ.get("LANGFLOW_SERVER_URL", "") +flow_id = os.environ.get("FLOW_ID", "") +api_key = os.environ.get("LANGFLOW_API_KEY", "") + +url = f"{base}/api/v1/responses" + +headers = { + "x-api-key": api_key, + "Content-Type": "application/json", +} + +payload = { + "model": flow_id, + "input": "Hello, my name is Alice", + "stream": False, +} + +response = requests.post(url, headers=headers, json=payload, timeout=120) +response.raise_for_status() + +print(response.text) diff --git a/docs/versioned_docs/version-1.9.0/API-Reference/python-examples/api-openai-responses/example-request.py b/docs/versioned_docs/version-1.9.0/API-Reference/python-examples/api-openai-responses/example-request.py new file mode 100644 index 0000000000..f1ebea3260 --- /dev/null +++ b/docs/versioned_docs/version-1.9.0/API-Reference/python-examples/api-openai-responses/example-request.py @@ -0,0 +1,17 @@ +import os + +import requests + +url = f"{os.getenv('LANGFLOW_SERVER_URL', '')}/api/v1/responses" + +headers = { + "x-api-key": f"{os.getenv('LANGFLOW_API_KEY', '')}", + "Content-Type": "application/json", +} + +payload = {"model": "$YOUR_FLOW_ID", "input": "Hello, how are you?", "stream": False} + +response = requests.request("POST", url, headers=headers, json=payload) +response.raise_for_status() + +print(response.text) diff --git a/docs/versioned_docs/version-1.9.0/API-Reference/python-examples/api-openai-responses/example-streaming-request.py b/docs/versioned_docs/version-1.9.0/API-Reference/python-examples/api-openai-responses/example-streaming-request.py new file mode 100644 index 0000000000..b4565dd6ce --- /dev/null +++ b/docs/versioned_docs/version-1.9.0/API-Reference/python-examples/api-openai-responses/example-streaming-request.py @@ -0,0 +1,17 @@ +import os + +import requests + +url = f"{os.getenv('LANGFLOW_SERVER_URL', '')}/api/v1/responses" + +headers = { + "x-api-key": f"{os.getenv('LANGFLOW_API_KEY', '')}", + "Content-Type": "application/json", +} + +payload = {"model": "$FLOW_ID", "input": "Tell me a story about a robot", "stream": True} + +response = requests.request("POST", url, headers=headers, json=payload) +response.raise_for_status() + +print(response.text) diff --git a/docs/versioned_docs/version-1.9.0/API-Reference/python-examples/api-openai-responses/pass-global-variables-to-your-flows-in-headers.py b/docs/versioned_docs/version-1.9.0/API-Reference/python-examples/api-openai-responses/pass-global-variables-to-your-flows-in-headers.py new file mode 100644 index 0000000000..083e14c430 --- /dev/null +++ b/docs/versioned_docs/version-1.9.0/API-Reference/python-examples/api-openai-responses/pass-global-variables-to-your-flows-in-headers.py @@ -0,0 +1,20 @@ +import os + +import requests + +url = f"{os.getenv('LANGFLOW_SERVER_URL', '')}/api/v1/responses" + +headers = { + "x-api-key": f"{os.getenv('LANGFLOW_API_KEY', '')}", + "Content-Type": "application/json", + "X-LANGFLOW-GLOBAL-VAR-OPENAI_API_KEY": "sk-...", + "X-LANGFLOW-GLOBAL-VAR-USER_ID": "user123", + "X-LANGFLOW-GLOBAL-VAR-ENVIRONMENT": "production", +} + +payload = {"model": "your-flow-id", "input": "Hello"} + +response = requests.request("POST", url, headers=headers, json=payload) +response.raise_for_status() + +print(response.text) diff --git a/docs/versioned_docs/version-1.9.0/API-Reference/python-examples/api-openai-responses/retrieve-tool-call-results.py b/docs/versioned_docs/version-1.9.0/API-Reference/python-examples/api-openai-responses/retrieve-tool-call-results.py new file mode 100644 index 0000000000..feb5adf0dd --- /dev/null +++ b/docs/versioned_docs/version-1.9.0/API-Reference/python-examples/api-openai-responses/retrieve-tool-call-results.py @@ -0,0 +1,26 @@ +import os + +import requests + +base = os.environ.get("LANGFLOW_URL") or os.environ.get("LANGFLOW_SERVER_URL", "") +flow_id = os.environ.get("FLOW_ID", "") +api_key = os.environ.get("LANGFLOW_API_KEY", "") + +url = f"{base}/api/v1/responses" + +headers = { + "Content-Type": "application/json", + "x-api-key": api_key, +} + +payload = { + "model": flow_id, + "input": "Calculate 23 * 15 and show me the result", + "stream": False, + "include": ["tool_call.results"], +} + +response = requests.post(url, headers=headers, json=payload, timeout=120) +response.raise_for_status() + +print(response.text) diff --git a/docs/versioned_docs/version-1.9.0/API-Reference/python-examples/api-openai-responses/token-usage-tracking.py b/docs/versioned_docs/version-1.9.0/API-Reference/python-examples/api-openai-responses/token-usage-tracking.py new file mode 100644 index 0000000000..0d1e7c9e6c --- /dev/null +++ b/docs/versioned_docs/version-1.9.0/API-Reference/python-examples/api-openai-responses/token-usage-tracking.py @@ -0,0 +1,17 @@ +import os + +import requests + +url = f"{os.getenv('LANGFLOW_SERVER_URL', '')}/api/v1/responses" + +headers = { + "x-api-key": f"{os.getenv('LANGFLOW_API_KEY', '')}", + "Content-Type": "application/json", +} + +payload = {"model": "FLOW_ID", "input": "Explain quantum computing in simple terms", "stream": False} + +response = requests.request("POST", url, headers=headers, json=payload) +response.raise_for_status() + +print(response.text) diff --git a/docs/versioned_docs/version-1.9.0/API-Reference/python-examples/api-projects/create-project-2.py b/docs/versioned_docs/version-1.9.0/API-Reference/python-examples/api-projects/create-project-2.py new file mode 100644 index 0000000000..a2a4413ae3 --- /dev/null +++ b/docs/versioned_docs/version-1.9.0/API-Reference/python-examples/api-projects/create-project-2.py @@ -0,0 +1,23 @@ +import os + +import requests + +url = f"{os.getenv('LANGFLOW_URL', '')}/api/v1/projects/" + +headers = { + "accept": "application/json", + "Content-Type": "application/json", + "x-api-key": f"{os.getenv('LANGFLOW_API_KEY', '')}", +} + +payload = { + "name": "new_project_name", + "description": "string", + "components_list": ["3fa85f64-5717-4562-b3fc-2c963f66afa6"], + "flows_list": ["3fa85f64-5717-4562-b3fc-2c963f66afa6"], +} + +response = requests.request("POST", url, headers=headers, json=payload) +response.raise_for_status() + +print(response.text) diff --git a/docs/versioned_docs/version-1.9.0/API-Reference/python-examples/api-projects/create-project.py b/docs/versioned_docs/version-1.9.0/API-Reference/python-examples/api-projects/create-project.py new file mode 100644 index 0000000000..30d9661f0f --- /dev/null +++ b/docs/versioned_docs/version-1.9.0/API-Reference/python-examples/api-projects/create-project.py @@ -0,0 +1,17 @@ +import os + +import requests + +url = f"{os.getenv('LANGFLOW_URL', '')}/api/v1/projects/" + +headers = { + "Content-Type": "application/json", + "x-api-key": f"{os.getenv('LANGFLOW_API_KEY', '')}", +} + +payload = {"name": "new_project_name", "description": "string", "components_list": [], "flows_list": []} + +response = requests.request("POST", url, headers=headers, json=payload) +response.raise_for_status() + +print(response.text) diff --git a/docs/versioned_docs/version-1.9.0/API-Reference/python-examples/api-projects/delete-project.py b/docs/versioned_docs/version-1.9.0/API-Reference/python-examples/api-projects/delete-project.py new file mode 100644 index 0000000000..e0ee3bac13 --- /dev/null +++ b/docs/versioned_docs/version-1.9.0/API-Reference/python-examples/api-projects/delete-project.py @@ -0,0 +1,26 @@ +import os + +import requests + +base = os.environ.get("LANGFLOW_URL", "") +api_key = os.environ.get("LANGFLOW_API_KEY", "") + +headers = {"accept": "*/*", "Content-Type": "application/json", "x-api-key": api_key} + +create = requests.post( + f"{base}/api/v1/projects/", + headers=headers, + json={ + "name": "docs-example-delete-me", + "description": "Temporary project", + "components_list": [], + "flows_list": [], + }, + timeout=30, +) +create.raise_for_status() +project_id = create.json()["id"] + +delete = requests.delete(f"{base}/api/v1/projects/{project_id}", headers=headers, timeout=30) +delete.raise_for_status() +print(delete.text) diff --git a/docs/versioned_docs/version-1.9.0/API-Reference/python-examples/api-projects/export-a-project.py b/docs/versioned_docs/version-1.9.0/API-Reference/python-examples/api-projects/export-a-project.py new file mode 100644 index 0000000000..1fe7c65052 --- /dev/null +++ b/docs/versioned_docs/version-1.9.0/API-Reference/python-examples/api-projects/export-a-project.py @@ -0,0 +1,17 @@ +import os + +import requests + +url = f"{os.getenv('LANGFLOW_URL', '')}/api/v1/projects/download/{os.getenv('PROJECT_ID', '')}" + +headers = { + "accept": "application/json", + "x-api-key": f"{os.getenv('LANGFLOW_API_KEY', '')}", +} + +response = requests.request("GET", url, headers=headers) +response.raise_for_status() + +with open("langflow-project.zip", "wb") as f: + f.write(response.content) +print("Saved response to langflow-project.zip") diff --git a/docs/versioned_docs/version-1.9.0/API-Reference/python-examples/api-projects/import-a-project.py b/docs/versioned_docs/version-1.9.0/API-Reference/python-examples/api-projects/import-a-project.py new file mode 100644 index 0000000000..4e57f499bc --- /dev/null +++ b/docs/versioned_docs/version-1.9.0/API-Reference/python-examples/api-projects/import-a-project.py @@ -0,0 +1,19 @@ +import os +from pathlib import Path + +import requests + +base = os.environ.get("LANGFLOW_URL", "") +api_key = os.environ.get("LANGFLOW_API_KEY", "") + +fixtures = Path(__file__).resolve().parents[2] / "fixtures" +default_json = fixtures / "project-import.json" +import_path = Path(os.environ.get("PROJECT_IMPORT_JSON", str(default_json))) + +headers = {"accept": "application/json", "x-api-key": api_key} + +files = {"file": (import_path.name, import_path.read_bytes(), "application/json")} +response = requests.post(f"{base}/api/v1/projects/upload/", headers=headers, files=files, timeout=60) + +response.raise_for_status() +print(response.text) diff --git a/docs/versioned_docs/version-1.9.0/API-Reference/python-examples/api-projects/read-project.py b/docs/versioned_docs/version-1.9.0/API-Reference/python-examples/api-projects/read-project.py new file mode 100644 index 0000000000..eaff3ac7b5 --- /dev/null +++ b/docs/versioned_docs/version-1.9.0/API-Reference/python-examples/api-projects/read-project.py @@ -0,0 +1,15 @@ +import os + +import requests + +url = f"{os.getenv('LANGFLOW_URL', '')}/api/v1/projects/{os.getenv('PROJECT_ID', '')}" + +headers = { + "accept": "application/json", + "x-api-key": f"{os.getenv('LANGFLOW_API_KEY', '')}", +} + +response = requests.request("GET", url, headers=headers) +response.raise_for_status() + +print(response.text) diff --git a/docs/versioned_docs/version-1.9.0/API-Reference/python-examples/api-projects/read-projects.py b/docs/versioned_docs/version-1.9.0/API-Reference/python-examples/api-projects/read-projects.py new file mode 100644 index 0000000000..117274016e --- /dev/null +++ b/docs/versioned_docs/version-1.9.0/API-Reference/python-examples/api-projects/read-projects.py @@ -0,0 +1,15 @@ +import os + +import requests + +url = f"{os.getenv('LANGFLOW_URL', '')}/api/v1/projects/" + +headers = { + "accept": "application/json", + "x-api-key": f"{os.getenv('LANGFLOW_API_KEY', '')}", +} + +response = requests.request("GET", url, headers=headers) +response.raise_for_status() + +print(response.text) diff --git a/docs/versioned_docs/version-1.9.0/API-Reference/python-examples/api-projects/update-project.py b/docs/versioned_docs/version-1.9.0/API-Reference/python-examples/api-projects/update-project.py new file mode 100644 index 0000000000..46d41b1c21 --- /dev/null +++ b/docs/versioned_docs/version-1.9.0/API-Reference/python-examples/api-projects/update-project.py @@ -0,0 +1,19 @@ +import os +import uuid + +import requests + +base = os.environ.get("LANGFLOW_URL") or os.environ.get("LANGFLOW_SERVER_URL", "") +project_id = os.environ.get("PROJECT_ID", "") +api_key = os.environ.get("LANGFLOW_API_KEY", "") + +headers = {"accept": "application/json", "Content-Type": "application/json", "x-api-key": api_key} + +payload = { + "name": f"docs-example-renamed-project-{uuid.uuid4().hex[:8]}", + "description": "Updated via API docs Python example", +} + +response = requests.patch(f"{base}/api/v1/projects/{project_id}", headers=headers, json=payload, timeout=30) +response.raise_for_status() +print(response.text) diff --git a/docs/versioned_docs/version-1.9.0/API-Reference/python-examples/api-reference-api-examples/form-langflow-api-requests.py b/docs/versioned_docs/version-1.9.0/API-Reference/python-examples/api-reference-api-examples/form-langflow-api-requests.py new file mode 100644 index 0000000000..554748bdd8 --- /dev/null +++ b/docs/versioned_docs/version-1.9.0/API-Reference/python-examples/api-reference-api-examples/form-langflow-api-requests.py @@ -0,0 +1,24 @@ +import os + +import requests + +base = os.environ.get("LANGFLOW_URL") or os.environ.get("LANGFLOW_SERVER_URL", "") +flow_id = os.environ.get("FLOW_ID", "") +api_key = os.environ.get("LANGFLOW_API_KEY", "") + +url = f"{base}/api/v1/run/{flow_id}?stream=false" + +headers = { + "Content-Type": "application/json", + "x-api-key": api_key, +} + +payload = { + "input_value": "hello world!", + "output_type": "chat", + "input_type": "chat", +} + +response = requests.post(url, headers=headers, json=payload, timeout=60) +response.raise_for_status() +print(response.text) diff --git a/docs/versioned_docs/version-1.9.0/API-Reference/python-examples/api-reference-api-examples/get-all-components.py b/docs/versioned_docs/version-1.9.0/API-Reference/python-examples/api-reference-api-examples/get-all-components.py new file mode 100644 index 0000000000..f0f3f1a202 --- /dev/null +++ b/docs/versioned_docs/version-1.9.0/API-Reference/python-examples/api-reference-api-examples/get-all-components.py @@ -0,0 +1,15 @@ +import os + +import requests + +url = f"{os.getenv('LANGFLOW_SERVER_URL', '')}/api/v1/all" + +headers = { + "accept": "application/json", + "x-api-key": f"{os.getenv('LANGFLOW_API_KEY', '')}", +} + +response = requests.request("GET", url, headers=headers) +response.raise_for_status() + +print(response.text) diff --git a/docs/versioned_docs/version-1.9.0/API-Reference/python-examples/api-reference-api-examples/get-configuration.py b/docs/versioned_docs/version-1.9.0/API-Reference/python-examples/api-reference-api-examples/get-configuration.py new file mode 100644 index 0000000000..51c856abb3 --- /dev/null +++ b/docs/versioned_docs/version-1.9.0/API-Reference/python-examples/api-reference-api-examples/get-configuration.py @@ -0,0 +1,15 @@ +import os + +import requests + +url = f"{os.getenv('LANGFLOW_SERVER_URL', '')}/api/v1/config" + +headers = { + "accept": "application/json", + "x-api-key": f"{os.getenv('LANGFLOW_API_KEY', '')}", +} + +response = requests.request("GET", url, headers=headers) +response.raise_for_status() + +print(response.text) diff --git a/docs/versioned_docs/version-1.9.0/API-Reference/python-examples/api-reference-api-examples/get-version.py b/docs/versioned_docs/version-1.9.0/API-Reference/python-examples/api-reference-api-examples/get-version.py new file mode 100644 index 0000000000..81da3e568a --- /dev/null +++ b/docs/versioned_docs/version-1.9.0/API-Reference/python-examples/api-reference-api-examples/get-version.py @@ -0,0 +1,14 @@ +import os + +import requests + +url = f"{os.getenv('LANGFLOW_SERVER_URL', '')}/api/v1/version" + +headers = { + "accept": "application/json", +} + +response = requests.request("GET", url, headers=headers) +response.raise_for_status() + +print(response.text) diff --git a/docs/versioned_docs/version-1.9.0/API-Reference/python-examples/api-reference-api-examples/health-check.py b/docs/versioned_docs/version-1.9.0/API-Reference/python-examples/api-reference-api-examples/health-check.py new file mode 100644 index 0000000000..7deb1c7172 --- /dev/null +++ b/docs/versioned_docs/version-1.9.0/API-Reference/python-examples/api-reference-api-examples/health-check.py @@ -0,0 +1,14 @@ +import os + +import requests + +url = f"{os.getenv('LANGFLOW_SERVER_URL', '')}/health_check" + +headers = { + "accept": "application/json", +} + +response = requests.request("GET", url, headers=headers) +response.raise_for_status() + +print(response.text) diff --git a/docs/versioned_docs/version-1.9.0/API-Reference/python-examples/api-users/add-user.py b/docs/versioned_docs/version-1.9.0/API-Reference/python-examples/api-users/add-user.py new file mode 100644 index 0000000000..de7369d11c --- /dev/null +++ b/docs/versioned_docs/version-1.9.0/API-Reference/python-examples/api-users/add-user.py @@ -0,0 +1,18 @@ +import os +import uuid + +import requests + +base = os.environ.get("LANGFLOW_URL", "") +api_key = os.environ.get("LANGFLOW_API_KEY", "") + +headers = {"Content-Type": "application/json", "x-api-key": api_key} + +payload = { + "username": f"docsuser_{uuid.uuid4().hex[:12]}", + "password": "securepassword123", +} + +response = requests.post(f"{base}/api/v1/users/", headers=headers, json=payload, timeout=30) +response.raise_for_status() +print(response.text) diff --git a/docs/versioned_docs/version-1.9.0/API-Reference/python-examples/api-users/delete-user.py b/docs/versioned_docs/version-1.9.0/API-Reference/python-examples/api-users/delete-user.py new file mode 100644 index 0000000000..f81a966d51 --- /dev/null +++ b/docs/versioned_docs/version-1.9.0/API-Reference/python-examples/api-users/delete-user.py @@ -0,0 +1,22 @@ +import os +import uuid + +import requests + +base = os.environ.get("LANGFLOW_URL", "") +api_key = os.environ.get("LANGFLOW_API_KEY", "") + +headers = {"accept": "application/json", "Content-Type": "application/json", "x-api-key": api_key} + +create = requests.post( + f"{base}/api/v1/users/", + headers=headers, + json={"username": f"docsdel_{uuid.uuid4().hex[:12]}", "password": "securepassword123"}, + timeout=30, +) +create.raise_for_status() +user_id = create.json()["id"] + +delete = requests.delete(f"{base}/api/v1/users/{user_id}", headers=headers, timeout=30) +delete.raise_for_status() +print(delete.text) diff --git a/docs/versioned_docs/version-1.9.0/API-Reference/python-examples/api-users/get-current-user.py b/docs/versioned_docs/version-1.9.0/API-Reference/python-examples/api-users/get-current-user.py new file mode 100644 index 0000000000..43e3d6271a --- /dev/null +++ b/docs/versioned_docs/version-1.9.0/API-Reference/python-examples/api-users/get-current-user.py @@ -0,0 +1,15 @@ +import os + +import requests + +url = f"{os.getenv('LANGFLOW_URL', '')}/api/v1/users/whoami" + +headers = { + "accept": "application/json", + "x-api-key": f"{os.getenv('LANGFLOW_API_KEY', '')}", +} + +response = requests.request("GET", url, headers=headers) +response.raise_for_status() + +print(response.text) diff --git a/docs/versioned_docs/version-1.9.0/API-Reference/python-examples/api-users/list-all-users.py b/docs/versioned_docs/version-1.9.0/API-Reference/python-examples/api-users/list-all-users.py new file mode 100644 index 0000000000..ff34460d67 --- /dev/null +++ b/docs/versioned_docs/version-1.9.0/API-Reference/python-examples/api-users/list-all-users.py @@ -0,0 +1,15 @@ +import os + +import requests + +url = f"{os.getenv('LANGFLOW_URL', '')}/api/v1/users/?skip=0&limit=10" + +headers = { + "accept": "application/json", + "x-api-key": f"{os.getenv('LANGFLOW_API_KEY', '')}", +} + +response = requests.request("GET", url, headers=headers) +response.raise_for_status() + +print(response.text) diff --git a/docs/versioned_docs/version-1.9.0/API-Reference/python-examples/api-users/reset-password.py b/docs/versioned_docs/version-1.9.0/API-Reference/python-examples/api-users/reset-password.py new file mode 100644 index 0000000000..ce4211c666 --- /dev/null +++ b/docs/versioned_docs/version-1.9.0/API-Reference/python-examples/api-users/reset-password.py @@ -0,0 +1,24 @@ +import os + +import requests + +base = os.environ.get("LANGFLOW_URL", "") +api_key = os.environ.get("LANGFLOW_API_KEY", "") + +headers = {"Content-Type": "application/json", "x-api-key": api_key} + +who = requests.get(f"{base}/api/v1/users/whoami", headers=headers, timeout=30) +who.raise_for_status() +user_id = who.json()["id"] + +# Must differ from the current password (default superuser is often langflow/langflow). +payload = {"password": "DocsExampleResetPass2025!"} + +response = requests.patch( + f"{base}/api/v1/users/{user_id}/reset-password", + headers=headers, + json=payload, + timeout=30, +) +response.raise_for_status() +print(response.text) diff --git a/docs/versioned_docs/version-1.9.0/API-Reference/python-examples/api-users/update-user.py b/docs/versioned_docs/version-1.9.0/API-Reference/python-examples/api-users/update-user.py new file mode 100644 index 0000000000..13a1562789 --- /dev/null +++ b/docs/versioned_docs/version-1.9.0/API-Reference/python-examples/api-users/update-user.py @@ -0,0 +1,18 @@ +import os + +import requests + +base = os.environ.get("LANGFLOW_URL", "") +api_key = os.environ.get("LANGFLOW_API_KEY", "") + +headers = {"Content-Type": "application/json", "x-api-key": api_key} + +who = requests.get(f"{base}/api/v1/users/whoami", headers=headers, timeout=30) +who.raise_for_status() +user_id = who.json()["id"] + +payload = {"is_active": True} + +response = requests.patch(f"{base}/api/v1/users/{user_id}", headers=headers, json=payload, timeout=30) +response.raise_for_status() +print(response.text) diff --git a/docs/versioned_docs/version-1.9.0/API-Reference/python-examples/test-python-examples.sh b/docs/versioned_docs/version-1.9.0/API-Reference/python-examples/test-python-examples.sh new file mode 100644 index 0000000000..d572054bf7 --- /dev/null +++ b/docs/versioned_docs/version-1.9.0/API-Reference/python-examples/test-python-examples.sh @@ -0,0 +1,226 @@ +#!/usr/bin/env bash +set -euo pipefail + +SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)" +ROOT_DIR="$(cd "$SCRIPT_DIR/../../../.." && pwd)" +EXAMPLES_DIR="$SCRIPT_DIR" +TEST_SCRIPT_NAME="$(basename "${BASH_SOURCE[0]}")" + +MODE="syntax" + +load_repo_env() { + local env_file="$ROOT_DIR/.env" + if [[ -f "$env_file" ]]; then + set -a + # shellcheck source=/dev/null + source "$env_file" + set +a + fi +} + +print_help() { + cat <<'EOF' +Usage: + test-python-examples.sh [--execute] + +Modes: + (default) Syntax check only (py_compile) + --execute Execute examples after syntax checks + +EOF +} + +while [[ $# -gt 0 ]]; do + case "$1" in + --execute) + MODE="execute" + shift + ;; + --help|-h) + print_help + exit 0 + ;; + *) + echo "Unknown argument: $1" + print_help + exit 1 + ;; + esac +done + +PY_FILES=() +while IFS= read -r line; do + if [[ "$(basename "$line")" == "$TEST_SCRIPT_NAME" ]]; then + continue + fi + PY_FILES+=("$line") +done < <(uv run python - "$EXAMPLES_DIR" <<'PY' +import sys +from pathlib import Path + +root = Path(sys.argv[1]) +for p in sorted(root.rglob("*.py")): + print(p) +PY +) + +if [[ ${#PY_FILES[@]} -eq 0 ]]; then + echo "No .py examples found in $EXAMPLES_DIR" + exit 1 +fi + +PASS=0 +FAIL=0 +SKIP=0 +PY_TIMEOUT_SECONDS="${PY_TIMEOUT_SECONDS:-45}" + +echo "Testing ${#PY_FILES[@]} Python examples in '$MODE' mode..." +if [[ "$MODE" == "execute" ]]; then + load_repo_env +fi + +has_placeholder_file_inputs() { + uv run python - "$1" <<'PY' +import sys +text = open(sys.argv[1], encoding="utf-8").read() +needles = ("FILE_NAME", "PATH/TO/FILE", "") +print("yes" if any(n in text for n in needles) else "no") +PY +} + +has_missing_required_env() { + uv run python - "$1" <<'PY' +import os +import re +import sys + +text = open(sys.argv[1], encoding="utf-8").read() +vars_to_check = ["FLOW_ID", "PROJECT_ID", "FOLDER_ID", "SESSION_ID", "JOB_ID", "USER_ID"] + +for name in vars_to_check: + getenv_pat = rf"os\.getenv\(\s*['\"]{name}['\"]" + environ_pat = rf"os\.environ\.get\(\s*['\"]{name}['\"]" + if (re.search(getenv_pat, text) or re.search(environ_pat, text)) and not os.getenv(name): + print(name) + raise SystemExit(0) + +print("") +PY +} + +print_failure_logs() { + local out_file="$1" + local err_file="$2" + if [[ -s "$err_file" ]]; then + echo " stderr (last 12 lines):" + uv run python - "$err_file" <<'PY' +import sys +from pathlib import Path + +lines = Path(sys.argv[1]).read_text(encoding="utf-8", errors="replace").splitlines() +for line in lines[-12:]: + print(line) +PY + fi + if [[ -s "$out_file" ]]; then + echo " stdout (last 12 lines):" + uv run python - "$out_file" <<'PY' +import sys +from pathlib import Path + +lines = Path(sys.argv[1]).read_text(encoding="utf-8", errors="replace").splitlines() +for line in lines[-12:]: + print(line) +PY + fi +} + +for file in "${PY_FILES[@]}"; do + rel="${file#"$ROOT_DIR"/}" + + if ! uv run python -m py_compile "$file"; then + echo "FAIL $rel (py_compile)" + ((FAIL+=1)) + continue + fi + + if [[ "$MODE" == "execute" ]]; then + # api-openai-responses/* call Langflow's HTTP API (e.g. /api/v1/responses) with x-api-key; + # they do not require OPENAI_API_KEY in the environment (same as the JS examples). + + # Streaming / long-running examples: skip in local harness (hang, flaky, or need extra setup). + case "$(basename "$file")" in + build-flow-and-stream-events-2.py|build-flow-and-stream-events-3.py|stream-llm-token-responses.py|example-streaming-request.py|stream-logs.py) + echo "SKIP $rel (streaming/long-running; not run in local harness)" + ((SKIP+=1)) + continue + ;; + esac + + if [[ "$(basename "$file")" == "retrieve-logs-with-optional-parameters.py" ]]; then + echo "SKIP $rel (/logs endpoint not implemented in local server)" + ((SKIP+=1)) + continue + fi + + if [[ "$(basename "$file")" == "reset-password.py" ]]; then + echo "SKIP $rel (reset-password may return 500 in local SQLite runs; run manually if needed)" + ((SKIP+=1)) + continue + fi + + if [[ -z "${LANGFLOW_API_KEY:-}" || ( -z "${LANGFLOW_URL:-}" && -z "${LANGFLOW_SERVER_URL:-}" ) ]]; then + echo "SKIP $rel (set LANGFLOW_API_KEY and LANGFLOW_URL or LANGFLOW_SERVER_URL to execute)" + ((SKIP+=1)) + continue + fi + + if [[ "$(has_placeholder_file_inputs "$file")" == "yes" ]]; then + echo "SKIP $rel (placeholder file input values)" + ((SKIP+=1)) + continue + fi + + missing_env="$(has_missing_required_env "$file")" + if [[ -n "$missing_env" ]]; then + echo "SKIP $rel (missing required env: $missing_env)" + ((SKIP+=1)) + continue + fi + + if ! uv run python - "$file" "$PY_TIMEOUT_SECONDS" >/tmp/langflow-python-example.out 2>/tmp/langflow-python-example.err <<'PY' +import runpy +import signal +import sys + +script_path = sys.argv[1] +timeout_seconds = int(sys.argv[2]) + +def _handle_timeout(_signum, _frame): + raise TimeoutError(f"execution timed out after {timeout_seconds}s") + +signal.signal(signal.SIGALRM, _handle_timeout) +signal.alarm(timeout_seconds) +try: + runpy.run_path(script_path, run_name="__main__") +finally: + signal.alarm(0) +PY + then + echo "FAIL $rel (execution)" + print_failure_logs "/tmp/langflow-python-example.out" "/tmp/langflow-python-example.err" + ((FAIL+=1)) + continue + fi + fi + + echo "PASS $rel" + ((PASS+=1)) +done + +echo +echo "Summary: PASS=$PASS FAIL=$FAIL SKIP=$SKIP TOTAL=${#PY_FILES[@]}" + +if [[ $FAIL -gt 0 ]]; then + exit 1 +fi diff --git a/docs/versioned_docs/version-1.9.0/API-Reference/python-examples/workflows-api/example-asynchronous-request.py b/docs/versioned_docs/version-1.9.0/API-Reference/python-examples/workflows-api/example-asynchronous-request.py new file mode 100644 index 0000000000..d09613b756 --- /dev/null +++ b/docs/versioned_docs/version-1.9.0/API-Reference/python-examples/workflows-api/example-asynchronous-request.py @@ -0,0 +1,20 @@ +import os + +import requests + +base = os.environ.get("LANGFLOW_URL") or os.environ.get("LANGFLOW_SERVER_URL", "") +flow_id = os.environ.get("FLOW_ID", "") +api_key = os.environ.get("LANGFLOW_API_KEY", "") + +headers = {"Content-Type": "application/json", "x-api-key": api_key} + +payload = { + "flow_id": flow_id, + "background": True, + "stream": False, + "inputs": {}, +} + +response = requests.post(f"{base}/api/v2/workflows", headers=headers, json=payload, timeout=60) +response.raise_for_status() +print(response.text) diff --git a/docs/versioned_docs/version-1.9.0/API-Reference/python-examples/workflows-api/example-request-2.py b/docs/versioned_docs/version-1.9.0/API-Reference/python-examples/workflows-api/example-request-2.py new file mode 100644 index 0000000000..728729ad98 --- /dev/null +++ b/docs/versioned_docs/version-1.9.0/API-Reference/python-examples/workflows-api/example-request-2.py @@ -0,0 +1,26 @@ +import os + +import requests + +base = os.environ.get("LANGFLOW_URL") or os.environ.get("LANGFLOW_SERVER_URL", "") +flow_id = os.environ.get("FLOW_ID", "") +api_key = os.environ.get("LANGFLOW_API_KEY", "") + +headers = {"Content-Type": "application/json", "x-api-key": api_key} + +start = requests.post( + f"{base}/api/v2/workflows", + headers=headers, + json={"flow_id": flow_id, "background": True, "stream": False, "inputs": {}}, + timeout=60, +) +start.raise_for_status() +job_id = start.json()["job_id"] + +stop = requests.post( + f"{base}/api/v2/workflows/stop", + headers=headers, + json={"job_id": job_id}, + timeout=60, +) +print(stop.status_code, stop.text) diff --git a/docs/versioned_docs/version-1.9.0/API-Reference/python-examples/workflows-api/example-request.py b/docs/versioned_docs/version-1.9.0/API-Reference/python-examples/workflows-api/example-request.py new file mode 100644 index 0000000000..7d175afe06 --- /dev/null +++ b/docs/versioned_docs/version-1.9.0/API-Reference/python-examples/workflows-api/example-request.py @@ -0,0 +1,18 @@ +import os + +import requests + +base = os.environ.get("LANGFLOW_URL") or os.environ.get("LANGFLOW_SERVER_URL", "") +flow_id = os.environ.get("FLOW_ID", "") +api_key = os.environ.get("LANGFLOW_API_KEY", "") + +headers = {"Content-Type": "application/json", "x-api-key": api_key} + +start = requests.post( + f"{base}/api/v2/workflows", + headers=headers, + json={"flow_id": flow_id, "background": True, "stream": False, "inputs": {}}, + timeout=60, +) +start.raise_for_status() +print(start.text) diff --git a/docs/versioned_docs/version-1.9.0/API-Reference/python-examples/workflows-api/example-synchronous-request.py b/docs/versioned_docs/version-1.9.0/API-Reference/python-examples/workflows-api/example-synchronous-request.py new file mode 100644 index 0000000000..477ea27f9e --- /dev/null +++ b/docs/versioned_docs/version-1.9.0/API-Reference/python-examples/workflows-api/example-synchronous-request.py @@ -0,0 +1,20 @@ +import os + +import requests + +base = os.environ.get("LANGFLOW_URL") or os.environ.get("LANGFLOW_SERVER_URL", "") +flow_id = os.environ.get("FLOW_ID", "") +api_key = os.environ.get("LANGFLOW_API_KEY", "") + +headers = {"Content-Type": "application/json", "x-api-key": api_key} + +payload = { + "flow_id": flow_id, + "background": False, + "stream": False, + "inputs": {}, +} + +response = requests.post(f"{base}/api/v2/workflows", headers=headers, json=payload, timeout=120) +response.raise_for_status() +print(response.text) diff --git a/docs/versioned_docs/version-1.9.0/API-Reference/typescript-client.mdx b/docs/versioned_docs/version-1.9.0/API-Reference/typescript-client.mdx new file mode 100644 index 0000000000..695157a7ce --- /dev/null +++ b/docs/versioned_docs/version-1.9.0/API-Reference/typescript-client.mdx @@ -0,0 +1,389 @@ +--- +title: Langflow TypeScript client +slug: /typescript-client +--- + +import Tabs from '@theme/Tabs'; +import TabItem from '@theme/TabItem'; + +The Langflow TypeScript client allows your TypeScript applications to programmatically interact with the Langflow API. + +For the client code repository, see [langflow-client-ts](https://github.com/datastax/langflow-client-ts/). + +For the npm package, see [@datastax/langflow-client](https://www.npmjs.com/package/@datastax/langflow-client). + +## Install the Langflow TypeScript package + +To install the Langflow typescript client package, use one of the following commands: + + + + +```bash +npm install @datastax/langflow-client +``` + + + + +```bash +yarn add @datastax/langflow-client +``` + + + + +```bash +pnpm add @datastax/langflow-client +``` + + + + +## Initialize the Langflow TypeScript client + +1. Import the client into your code. + + ```tsx + import { LangflowClient } from "@datastax/langflow-client"; + ``` + +2. Initialize a `LangflowClient` object to interact with your server: + + ```tsx + const baseUrl = "BASE_URL"; + const apiKey = "API_KEY"; + const client = new LangflowClient({ baseUrl, apiKey }); + ``` + + Replace `BASE_URL` and `API_KEY` with values from your deployment. + The default Langflow base URL is `http://localhost:7860`. + To create an API key, see [API keys and authentication](/api-keys-and-authentication). + +## Connect to your server and get responses + +1. With your Langflow client initialized, test the connection by calling your Langflow server. + + The following example runs a flow (`runFlow`) by sending the flow ID and a chat input string: + + ```tsx + import { LangflowClient } from "@datastax/langflow-client"; + + const baseUrl = "http://localhost:7860"; + const client = new LangflowClient({ baseUrl }); + + async function runFlow() { + const flowId = "aa5a238b-02c0-4f03-bc5c-cc3a83335cdf"; + const flow = client.flow(flowId); + const input = "Is anyone there?"; + + const response = await flow.run(input); + console.log(response); + } + + runFlow().catch(console.error); + ``` + + Replace the following: + + * `baseUrl`: The URL of your Langflow server. + * `flowId`: The ID of the flow you want to run. + * `input`: The chat input message you want to send to trigger the flow. + This is only valid for flows with a **Chat Input** component. + +2. Review the result to confirm that the client connected to your Langflow server. + + The following example shows the response from a well-formed `runFlow` request that reached the Langflow server and successfully started the flow: + + ``` + FlowResponse { + sessionId: 'aa5a238b-02c0-4f03-bc5c-cc3a83335cdf', + outputs: [ { inputs: [Object], outputs: [Array] } ] + } + ``` + + In this case, the response includes a [`sessionID`](/session-id) that is a unique identifier for the client-server session and an `outputs` array that contains information about the flow run. + +3. Optional: If you want to get full response objects from the server, change `console.log` to stringify the returned JSON object: + + ```tsx + console.log(JSON.stringify(response, null, 2)); + ``` + + The exact structure of the returned `inputs` and `outputs` objects depends on the components and configuration of your flow. + +4. Optional: If you want the response to include only the chat message from the **Chat Output** component, change `console.log` to use the `chatOutputText` convenience function: + + ```tsx + console.log(response.chatOutputText()); + ``` + +## Use advanced TypeScript client features + +The TypeScript client can do more than just connect to your server and run a flow. + +This example builds on the quickstart with additional features for interacting with Langflow: + +1. Pass [tweaks](/concepts-publish#input-schema) as an object with the request. +Tweaks are programmatic run-time overrides for component settings. + + This example changes the LLM used by a language model component in a flow:: + + ```tsx + const tweaks = { model_name: "gpt-4o-mini" }; + ``` + +2. Pass a [session ID](/session-id) with the request to separate the conversation from other flow runs, and to be able to continue this conversation by calling the same session ID in the future: + + ```tsx + const session_id = "aa5a238b-02c0-4f03-bc5c-cc3a83335cdf"; + ``` + +3. Instead of calling `run` on the Flow object, call `stream` with the same arguments to get a streaming response: + + ```tsx + const response = await client.flow(flowId).stream(input); + + for await (const event of response) { + console.log(event); + } + ``` + + The response is a [`ReadableStream`](https://developer.mozilla.org/en-US/docs/Web/API/ReadableStream) of objects. + For more information on streaming Langflow responses, see the [`/run` endpoint](/api-flows-run#run-flow). + +4. Run the modified TypeScript application to run the flow with `tweaks`, `session_id`, and streaming: + + ```tsx + import { LangflowClient } from "@datastax/langflow-client"; + + const baseUrl = "http://localhost:7860"; + const client = new LangflowClient({ baseUrl }); + + async function runFlow() { + const flowId = "aa5a238b-02c0-4f03-bc5c-cc3a83335cdf"; + const input = "Is anyone there?"; + const tweaks = { model_name: "gpt-4o-mini" }; + const session_id = "test-session"; + + const response = await client.flow(flowId).stream(input, { + session_id, + tweaks, + }); + + for await (const event of response) { + console.log(event); + } + + } + runFlow().catch(console.error); + ``` + + Replace the following: + + * `baseUrl`: The URL of your Langflow server. + * `flowId`: The ID of the flow you want to run. + * `input`: The chat input message you want to send to trigger the flow, assuming the flow has a **Chat Input** component. + * `tweaks`: Any tweak modifiers to apply to the flow run. + This example changes the LLM used by a component in the flow. + * `session_id`: Pass a custom session ID. + If omitted or empty, the flow ID is the default session ID. + +
+ Result + + With streaming enabled, the response includes the flow metatadata and timestamped events for flow activity. + For example: + + ```text + { + event: 'add_message', + data: { + timestamp: '2025-05-23 15:52:48 UTC', + sender: 'User', + sender_name: 'User', + session_id: 'test-session', + text: 'Is anyone there?', + files: [], + error: false, + edit: false, + properties: { + text_color: '', + background_color: '', + edited: false, + source: [Object], + icon: '', + allow_markdown: false, + positive_feedback: null, + state: 'complete', + targets: [] + }, + category: 'message', + content_blocks: [], + id: '7f096715-3f2d-4d84-88d6-5e2f76bf3fbe', + flow_id: 'aa5a238b-02c0-4f03-bc5c-cc3a83335cdf', + duration: null + } + } + { + event: 'token', + data: { + chunk: 'Absolutely', + id: 'c5a99314-6b23-488b-84e2-038aa3e87fb5', + timestamp: '2025-05-23 15:52:48 UTC' + } + } + { + event: 'token', + data: { + chunk: ',', + id: 'c5a99314-6b23-488b-84e2-038aa3e87fb5', + timestamp: '2025-05-23 15:52:48 UTC' + } + } + { + event: 'token', + data: { + chunk: " I'm", + id: 'c5a99314-6b23-488b-84e2-038aa3e87fb5', + timestamp: '2025-05-23 15:52:48 UTC' + } + } + { + event: 'token', + data: { + chunk: ' here', + id: 'c5a99314-6b23-488b-84e2-038aa3e87fb5', + timestamp: '2025-05-23 15:52:48 UTC' + } + } + + // this response is abbreviated + + { + event: 'end', + data: { result: { session_id: 'test-session', outputs: [Array] } } + } + ``` + +
+ +## Retrieve Langflow logs with the TypeScript client + +To retrieve [Langflow logs](/logging), you must enable log retrieval on your Langflow server by including the following values in your Langflow `.env` file: + +```text +LANGFLOW_ENABLE_LOG_RETRIEVAL=True +LANGFLOW_LOG_RETRIEVER_BUFFER_SIZE=10000 +LANGFLOW_LOG_LEVEL=DEBUG +``` + +The following example script starts streaming logs in the background, and then runs a flow so you can monitor the flow run: + +```tsx +import { LangflowClient } from "@datastax/langflow-client"; + +const baseUrl = "http://localhost:7863"; +const flowId = "86f0bf45-0544-4e88-b0b1-8e622da7a7f0"; + +async function runFlow(client: LangflowClient) { + const input = "Is anyone there?"; + const response = await client.flow(flowId).run(input); + console.log('Flow response:', response); +} + +async function main() { + const client = new LangflowClient({ baseUrl: baseUrl }); + + // Start streaming logs + console.log('Starting log stream...'); + for await (const log of await client.logs.stream()) { + console.log('Log:', log); + } + + // Run the flow + await runFlow(client); + +} + +main().catch(console.error); +``` + +Replace the following: + +* `baseUrl`: The URL of your Langflow server. +* `flowId`: The ID of the flow you want to run. +* `input`: The chat input message you want to send to trigger the flow, assuming the flow has a **Chat Input** component. + +Logs begin streaming indefinitely, and the flow runs once. + +
+Result + +The following example result is truncated for readability, but you can follow the messages to see how the flow instantiates its components, configures its model, and processes the outputs. + +The `FlowResponse` object, at the end of the stream, is returned to the client with the flow result in the `outputs` array. + +```text +Starting log stream... +Log: Log { + timestamp: 2025-05-30T11:49:16.006Z, + message: '2025-05-30T07:49:16.006127-0400 DEBUG Instantiating ChatInput of type component\n' +} +Log: Log { + timestamp: 2025-05-30T11:49:16.029Z, + message: '2025-05-30T07:49:16.029957-0400 DEBUG Instantiating Prompt of type component\n' +} +Log: Log { + timestamp: 2025-05-30T11:49:16.049Z, + message: '2025-05-30T07:49:16.049520-0400 DEBUG Instantiating ChatOutput of type component\n' +} +Log: Log { + timestamp: 2025-05-30T11:49:16.069Z, + message: '2025-05-30T07:49:16.069359-0400 DEBUG Instantiating OpenAIModel of type component\n' +} +Log: Log { + timestamp: 2025-05-30T11:49:16.086Z, + message: "2025-05-30T07:49:16.086426-0400 DEBUG Running layer 0 with 2 tasks, ['ChatInput-xjucM', 'Prompt-I3pxU']\n" +} +Log: Log { + timestamp: 2025-05-30T11:49:16.101Z, + message: '2025-05-30T07:49:16.101766-0400 DEBUG Building Chat Input\n' +} +Log: Log { + timestamp: 2025-05-30T11:49:16.113Z, + message: '2025-05-30T07:49:16.113343-0400 DEBUG Building Prompt\n' +} +Log: Log { + timestamp: 2025-05-30T11:49:16.131Z, + message: '2025-05-30T07:49:16.131423-0400 DEBUG Logged vertex build: 6bd9fe9c-5eea-4f05-a96d-f6de9dc77e3c\n' +} +Log: Log { + timestamp: 2025-05-30T11:49:16.143Z, + message: '2025-05-30T07:49:16.143295-0400 DEBUG Logged vertex build: 39c68ec9-3859-4fff-9b14-80b3271f8fbf\n' +} +Log: Log { + timestamp: 2025-05-30T11:49:16.188Z, + message: "2025-05-30T07:49:16.188730-0400 DEBUG Running layer 1 with 1 tasks, ['OpenAIModel-RtlZm']\n" +} +Log: Log { + timestamp: 2025-05-30T11:49:16.201Z, + message: '2025-05-30T07:49:16.201946-0400 DEBUG Building OpenAI\n' +} +Log: Log { + timestamp: 2025-05-30T11:49:16.216Z, + message: '2025-05-30T07:49:16.216622-0400 INFO Model name: gpt-4.1-mini\n' +} +Flow response: FlowResponse { + sessionId: '86f0bf45-0544-4e88-b0b1-8e622da7a7f0', + outputs: [ { inputs: [Object], outputs: [Array] } ] +} +Log: Log { + timestamp: 2025-05-30T11:49:18.094Z, + message: `2025-05-30T07:49:18.094364-0400 DEBUG Vertex OpenAIModel-RtlZm, result: , object: {'text_output': "Hey there! I'm here and ready to help you build something awesome with AI. What are you thinking about creating today?"}\n` +} +``` + +
+ +For more information, see [Logs endpoints](/api-logs). \ No newline at end of file diff --git a/docs/versioned_docs/version-1.9.0/API-Reference/workflows-api.mdx b/docs/versioned_docs/version-1.9.0/API-Reference/workflows-api.mdx new file mode 100644 index 0000000000..60ffab4674 --- /dev/null +++ b/docs/versioned_docs/version-1.9.0/API-Reference/workflows-api.mdx @@ -0,0 +1,322 @@ +--- +title: Workflow API (Beta) +slug: /workflow-api +--- +import CodeSnippet from '@site/src/components/CodeSnippet'; +import exampleWorkflowsApiExampleSynchronousRequest from '!!raw-loader!@site/docs/API-Reference/curl-examples/workflows-api/example-synchronous-request.sh'; +import exampleWorkflowsApiExampleAsynchronousRequest from '!!raw-loader!@site/docs/API-Reference/curl-examples/workflows-api/example-asynchronous-request.sh'; +import exampleWorkflowsApiExampleRequest from '!!raw-loader!@site/docs/API-Reference/curl-examples/workflows-api/example-request.sh'; +import exampleWorkflowsApiExampleRequest2 from '!!raw-loader!@site/docs/API-Reference/curl-examples/workflows-api/example-request-2.sh'; +import examplePythonWorkflowsApiExampleSynchronousRequest from '!!raw-loader!@site/docs/API-Reference/python-examples/workflows-api/example-synchronous-request.py'; +import examplePythonWorkflowsApiExampleAsynchronousRequest from '!!raw-loader!@site/docs/API-Reference/python-examples/workflows-api/example-asynchronous-request.py'; +import examplePythonWorkflowsApiExampleRequest from '!!raw-loader!@site/docs/API-Reference/python-examples/workflows-api/example-request.py'; +import examplePythonWorkflowsApiExampleRequest2 from '!!raw-loader!@site/docs/API-Reference/python-examples/workflows-api/example-request-2.py'; +import exampleJavascriptWorkflowsApiExampleSynchronousRequest from '!!raw-loader!@site/docs/API-Reference/javascript-examples/workflows-api/example-synchronous-request.js'; +import exampleJavascriptWorkflowsApiExampleAsynchronousRequest from '!!raw-loader!@site/docs/API-Reference/javascript-examples/workflows-api/example-asynchronous-request.js'; +import exampleJavascriptWorkflowsApiExampleRequest from '!!raw-loader!@site/docs/API-Reference/javascript-examples/workflows-api/example-request.js'; +import exampleJavascriptWorkflowsApiExampleRequest2 from '!!raw-loader!@site/docs/API-Reference/javascript-examples/workflows-api/example-request-2.js'; + + + + +import Tabs from '@theme/Tabs'; +import TabItem from '@theme/TabItem'; +import PartialAPISetup from '@site/docs/_partial-api-setup.mdx'; + +:::warning Beta Feature +The Workflow API is currently in **Beta**. +The API endpoints and response formats may change in future releases. +::: + +The Workflow API provides programmatic access to execute Langflow workflows synchronously or asynchronously. +Synchronous requests receive complete results immediately upon completion. +Asynchronous requests are queued in the background and will run until complete, or a request is issued to the [Stop Workflow endpoint](#stop-workflow-endpoint). + +The Workflow API is part of the Langflow Developer v2 API and offers enhanced workflow execution capabilities compared to the v1 `/run` endpoint. + + + +## Execute workflows endpoint (synchronous or asynchronous) + +**Endpoint:** + +``` +POST /api/v2/workflows +``` + +**Description:** Execute a workflow synchronously and receive complete results immediately upon completion. +Set `background=false` to make the request synchronous. + +### Example synchronous request + +Execute a workflow synchronously and receive complete results immediately: + + + + + + + + + + + + + + + + + + + +### Example asynchronous request + +For long-running workflows, set `background=true` to get a `job_id` immediately, and then poll the status [using the GET endpoint](#get-workflow-status-endpoint) until the job is complete. + +To stop a job, send a POST request to the [Stop workflow endpoint](#stop-workflow-endpoint). + +:::tip +The asynchronous request contains `stream` parameter, but streaming is not yet supported. The parameter is included for future compatibility. +::: + +**Example request:** + + + + + + + + + + + + + + + + + + + +**Response:** + +```json +{ + "job_id": "job_id_1234567890", + "created_timestamp": "2025-01-15T10:30:00Z", + "status": "queued", + "errors": [] +} +``` + +### Request body + +| Field | Type | Required | Default | Description | +|-------|------|----------|---------|-------------| +| `flow_id` | `string` | Yes | - | The ID or endpoint name of the flow to execute. | +| `flow_version` | `string` | No | - | Optional version hash to pin to a specific flow version. | +| `background` | `boolean` | No | `false` | Must be `false` for synchronous execution. | +| `inputs` | `object` | No | `{}` | Inputs for the workflow execution. Uses component identifiers with dot notation (e.g., `ChatInput-abc.input_value`). See [Component identifiers and input structure](#component-identifiers-and-input-structure) for detailed information. | + +### Example response + +```json +{ + "flow_id": "flow_67ccd2be17f0819081ff3bb2cf6508e60bb6a6b452d3795b", + "job_id": "job_id_1234567890", + "object": "response", + "created_at": 1741476542, + "status": "completed", + "errors": [], + "inputs": { + "ChatInput-abc.input_type": "chat", + "ChatInput-abc.input_value": "what is 2+2", + "ChatInput-abc.session_id": "session-123" + }, + "outputs": { + "ChatOutput-xyz": { + "type": "message", + "component_id": "ChatOutput-xyz", + "status": "completed", + "content": "2 + 2 equals 4." + } + }, + "metadata": {} +} +``` + +### Response body + +The response includes an `outputs` field containing component-level results. Each output has a `type` field indicating the type of content: + +| Type | Description | Example | +|------|-------------|---------| +| `message` | Text message content. | Chat responses, summaries | +| `image` | Image URL or data. | Generated images, processed images | +| `sql` | SQL query results. | Database query outputs | +| `data` | Structured data. | JSON objects, arrays | +| `file` | File reference. | Generated documents, reports | + +## Get workflow status endpoint + +**Endpoint:** `GET /api/v2/workflows` + +**Description:** Retrieve the status and results of a workflow execution by job ID. + +### Example request + + + + + + + + + + + + + + + + + + + +### Query parameters + +| Parameter | Type | Required | Description | +|-----------|------|----------|-------------| +| `job_id` | `string` | Yes | The job ID returned from a workflow execution. | +| `stream` | `boolean` | No | If `true`, returns server-sent events stream. Default: `false`. | +| `sequence_id` | `integer` | No | Optional sequence ID to resume streaming from a specific point. | + +### Example response + +```json +{ + "flow_id": "flow_67ccd2be17f0819081ff3bb2cf6508e60bb6a6b452d3795b", + "job_id": "job_id_1234567890", + "object": "response", + "created_at": 1741476542, + "status": "completed", + "errors": [], + "outputs": { + "ChatOutput-xyz": { + "type": "message", + "component_id": "ChatOutput-xyz", + "status": "completed", + "content": "Processing complete..." + } + }, + "input": [ + { + "type": "text", + "data": "Input text prompt for the workflow execution", + "role": "User" + } + ], + "metadata": {} +} +``` + +### Response body + +The response includes a `status` field that indicates the current state of the workflow execution: + +| Status | Description | +|--------|-------------| +| `queued` | Job is queued and waiting to start. | +| `in_progress` | Job is currently executing. | +| `completed` | Job completed successfully. | +| `failed` | Job failed during execution. | +| `error` | Job encountered an error. | + +## Stop workflow endpoint + +**Endpoint:** `POST /api/v2/workflows/stop` + +**Description:** Stop a running workflow execution by job ID. + +### Example request + + + + + + + + + + + + + + + + + + + +### Request body + +| Field | Type | Required | Default | Description | +|-------|------|----------|---------|-------------| +| `job_id` | `string` | Yes | - | The job ID of the workflow to stop. | + +### Example response + +```json +{ + "job_id": "job_id_1234567890", + "message": "Job job_id_1234567890 cancelled successfully." +} +``` + +## Component identifiers and input structure + +The Workflows API uses component identifiers with dot notation to specify inputs for individual components in your workflow. This allows you to pass values to specific components and override component parameters. + +Component identifiers use the format `{component_id}.{parameter_name}`. +When making requests to the Workflows API, include component identifiers in the `inputs` object. +For example, this demonstrates targeting multiple components and their parameters in a single request. + +```json +{ + "flow_id": "your-flow-id", + "inputs": { + "ChatInput-abc.input_type": "chat", + "ChatInput-abc.input_value": "what is 2+2", + "ChatInput-abc.session_id": "session-123", + "OpenSearchComponent-xyz.opensearch_url": "https://opensearch:9200", + "LLMComponent-123.temperature": 0.7, + "LLMComponent-123.max_tokens": 100 + } +} +``` + +To find the component ID in the Langflow UI, open your flow in Langflow, click the component, and then click **Controls**. The component ID is at the top of the **Controls** pane. + +You can override any component's parameters. + +## Error handling + +The API uses standard HTTP status codes to indicate success or failure: + +| Status Code | Description | +|-------------|-------------| +| `200 OK` | Request successful. | +| `400 Bad Request` | Invalid request parameters. | +| `401 Unauthorized` | Invalid or missing API key. | +| `404 Not Found` | Flow not found or developer API disabled. | +| `500 Internal Server Error` | Server error during execution. | +| `501 Not Implemented` | Endpoint not yet implemented. | + +### Error response format + +```json +{ + "detail": "Error message describing what went wrong" +} +``` diff --git a/docs/versioned_docs/version-1.9.0/Agents/agents-tools.mdx b/docs/versioned_docs/version-1.9.0/Agents/agents-tools.mdx new file mode 100644 index 0000000000..5dc1897677 --- /dev/null +++ b/docs/versioned_docs/version-1.9.0/Agents/agents-tools.mdx @@ -0,0 +1,219 @@ +--- +title: Configure tools for agents +slug: /agents-tools +--- + +import Icon from "@site/src/components/icon"; + +By default, [Langflow agents](/agents) only include the functionality built-in to their base LLM. + +You can attach tools to agents to provide access to additional, targeted functionality. +For example, tools can be used to create domain-specific agents, such as a customer support agent that can access a company's knowledge base, a financial agent that can retrieve stock prices, or a math tutor agent that can use advanced math functions to solve complex equations. + +## Attach tools + +To attach a tool to an agent, you connect any component's **Tool** output to the **Agent** component's **Tools** input. + +Some components emit **Tool** output by default. +For all other components, you must enable **Tool Mode** in the [component's header menu](/concepts-components#component-menus). +Then, you can connect the tool to the agent. + +You can connect multiple tools to one agent, and each tool can have multiple actions (functions) that the agent can call. + +When you run your flow, the agent decides when to call on certain tools, if it determines that a tool can help it respond to the user's prompt. + +### Edit a tool's actions {#edit-a-tools-actions} + +When you attach components to an agent as tools, each tool can have multiple actions (functions) that the agent can call. +Available actions are listed in each tool component's **Actions** list. + +You can change each action's labels, descriptions, and availability to help the agent understand how to use the tool and prevent it from using irrelevant or undesired actions. + +:::tip +If an agent seems to be using a tool incorrectly, try editing the actions metadata to clarify the tool's purpose and disable unnecessary actions. + +You can also try using a **Prompt Template** component to pass additional instructions or examples to the agent. +::: + +To view and edit a tool's actions, click