API 示例
本页提供使用 Langflow API 管理 Langflow 的示例和实践。
可以在您的 Langflow 部署的 docs
端点查看和测试 Langflow API 的 OpenAPI 规范。例如,http://127.0.0.1:7860/docs
。
导出值
您可能会发现在终端中设置以下环境变量很有帮助。
本指南中的示例使用环境变量来表示这些值。
- 在终端中导出您的 Langflow URL。Langflow 默认从
http://127.0.0.1:7860
开始运行。
_10export LANGFLOW_URL="http://127.0.0.1:7860"
- 在终端中导出
flow-id
。flow-id
可以在发布窗格或流的 URL 中找到。
_10export FLOW_ID="359cd752-07ea-46f2-9d3b-a4407ef618da"
- 在终端中导出
project-id
。要找到您的项目 ID,请调用 Langflow /api/v1/projects/ 端点以获取项目列表。
- curl
- 结果
_10curl -X GET \_10"$LANGFLOW_URL/api/v1/projects/" \_10"$LANGFLOW_URL/api/v1/projects/" \_10-H "accept: application/json"
_10[_10 {_10"name": "My Projects",_10"description": "Manage your own projects. Download and upload projects.",_10"id": "1415de42-8f01-4f36-bf34-539f23e47466",_10"parent_id": null_10 }_10]
将 project-id
导出为环境变量。将 project-id
导出为环境变量。
_10export project_ID="1415de42-8f01-4f36-bf34-539f23e47466"
- 将 Langflow API 密钥导出为环境变量。要创建 Langflow API 密钥,请在 Langflow CLI 中运行以下命令。
- curl
- 结果
_10langflow api-key
_10API Key Created Successfully_10sk-...
将生成的 API 密钥导出为环境变量。
_10export LANGFLOW_API_KEY="sk-..."
基础
使用基础 Langflow API 运行您的流并检索配置信息。
获取所有组件
此操作返回包含所有 Langflow 组件的字典。
- curl
- 结果
_10curl -X GET \_10"$LANGFLOW_URL/api/v1/all" \_10-H "accept: application/json"
_10一个包含所有 Langflow 组件的字典。
运行流
按 ID 或名称执行指定的流。流以批处理方式执行,但 LLM 响应可以流式传输。
此示例运行一个指定 flow_id
的基本提示流,并将一个 JSON 对象作为输入值传递。
参数在请求体中传递。在此示例中,值是默认值。
- curl
- 结果
_11curl -X POST \_11"$LANGFLOW_URL/api/v1/run/$FLOW_ID" \_11-H "Content-Type: application/json" \_11-d '{_11"input_value": "Tell me about something interesting!",_11"session_id": "chat-123",_11"input_type": "chat",_11"output_type": "chat",_11"output_component": "",_11"tweaks": null_11 }'
_29{_29"session_id": "chat-123",_29"outputs": [{_29"inputs": {_29"input_value": "Tell me about something interesting!"_29 },_29"outputs": [{_29"results": {_29"message": {_29"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!",_29"sender": "Machine",_29"sender_name": "AI",_29"session_id": "chat-123",_29"timestamp": "2025-03-03T17:17:37+00:00",_29"flow_id": "d2bbd92b-187e-4c84-b2d4-5df365704201",_29"properties": {_29"source": {_29"id": "OpenAIModel-d1wOZ",_29"display_name": "OpenAI",_29"source": "gpt-4o-mini"_29 },_29"icon": "OpenAI"_29 },_29"component_id": "ChatOutput-ylMzN"_29 }_29 }_29 }]_29 }]_29}
要流式传输 LLM 令牌响应,请在请求中附加 ?stream=true
查询参数。LLM 聊天响应将以 token
事件的形式流回,直到 end
事件关闭连接。
- curl
- 结果
_10curl -X POST \_10"$LANGFLOW_URL/api/v1/run/$FLOW_ID?stream=true" \_10-H "accept: application/json" \_10-H "Content-Type: application/json" \_10-d '{_10"message": "Tell me something interesting!",_10"session_id": "chat-123"_10 }'
_19{"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"}}_19_19{"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"}}_19_19{"event": "token", "data": {"chunk": " Have", "id": "27b66789-e673-4c65-9e81-021752925161", "timestamp": "2025-03-03 17:20:18 UTC"}}_19_19{"event": "token", "data": {"chunk": " you", "id": "27b66789-e673-4c65-9e81-021752925161", "timestamp": "2025-03-03 17:20:18 UTC"}}_19_19{"event": "token", "data": {"chunk": " ever", "id": "27b66789-e673-4c65-9e81-021752925161", "timestamp": "2025-03-03 17:20:18 UTC"}}_19_19{"event": "token", "data": {"chunk": " heard", "id": "27b66789-e673-4c65-9e81-021752925161", "timestamp": "2025-03-03 17:20:18 UTC"}}_19_19{"event": "token", "data": {"chunk": " of", "id": "27b66789-e673-4c65-9e81-021752925161", "timestamp": "2025-03-03 17:20:18 UTC"}}_19_19{"event": "token", "data": {"chunk": " the", "id": "27b66789-e673-4c65-9e81-021752925161", "timestamp": "2025-03-03 17:20:18 UTC"}}_19_19{"event": "token", "data": {"chunk": " phenomenon", "id": "27b66789-e673-4c65-9e81-021752925161", "timestamp": "2025-03-03 17:20:18 UTC"}}_19_19{"event": "end", "data": {"result": {"session_id": "chat-123", "message": "Sure! Have you ever heard of the phenomenon known as \"bioluminescence\"?..."}}}
此结果已缩写,但说明了 end
事件何时完成 LLM 的令牌流式响应。
运行端点头和参数
参数可以通过三种方式传递给 /run
端点
- URL 路径:
flow_id
作为端点路径的一部分 - 查询字符串:URL 中的
stream
参数 - 请求体:包含其余参数的 JSON 对象
请求头
请求头 | 信息 | 示例 |
---|---|---|
Content-Type | 必需。指定 JSON 格式。 | "application/json" |
accept | 必需。指定响应格式。 | "application/json" |
x-api-key | 可选。仅在启用身份验证时需要。 | "sk-..." |
参数
参数 | 类型 | 信息 |
---|---|---|
flow_id | UUID/字符串 | 必需。URL 的一部分:/run/{flow_id} |
stream | 布尔值 | 可选。查询参数:/run/{flow_id}?stream=true |
input_value | 字符串 | 可选。JSON 请求体字段。主要输入文本/提示。默认值:null |
input_type | 字符串 | 可选。JSON 请求体字段。输入类型(“chat” 或 “text”)。默认值:"chat" |
output_type | 字符串 | 可选。JSON 请求体字段。输出类型(“chat”、“any”、“debug”)。默认值:"chat" |
output_component | 字符串 | 可选。JSON 请求体字段。输出的目标组件。默认值:"" |
tweaks | 对象 | 可选。JSON 请求体字段。组件调整。默认值:null |
session_id | 字符串 | 可选。JSON 请求体字段。会话上下文 ID。默认值:null |
请求示例
_17curl -X POST \_17"http://$LANGFLOW_URL/api/v1/run/$FLOW_ID?stream=true" \_17-H "Content-Type: application/json" \_17-H "accept: application/json" \_17-H "x-api-key: sk-..." \_17-d '{_17"input_value": "Tell me a story",_17"input_type": "chat",_17"output_type": "chat",_17"output_component": "chat_output",_17"session_id": "chat-123",_17"tweaks": {_17"component_id": {_17"parameter_name": "value"_17 }_17 }_17 }'
Webhook 运行流
Webhook 端点通过 HTTP POST 请求触发流执行。
将 Webhook 组件添加到工作区时,API 窗格中会新增一个 Webhook cURL 标签页,其中包含用于触发 Webhook 组件的 HTTP POST 请求,类似于此示例中的调用。
要在您的流中测试 Webhook 组件,请参阅Webhook 组件。
- curl
- 结果
_10curl -X POST \_10"$LANGFLOW_URL/api/v1/webhook/$FLOW_ID" \_10-H "Content-Type: application/json" \_10-d '{"data": "example-data"}'
_10{_10{"message":"Task started in the background","status":"in progress"}_10}
处理
此端点已弃用。请改用 /run
端点。
预测
此端点已弃用。请改用 /run
端点。
获取任务状态
获取任务的状态。
- curl
- 结果
_10curl -X GET \_10"$LANGFLOW_URL/api/v1/task/TASK_ID" \_10-H "accept: application/json"
_10{_10"status": "Task status",_10"result": "Task result if completed"_10}
创建上传文件(已弃用)
此端点已弃用。请改用 /file
端点。
获取版本
获取 Langflow API 的版本。
- curl
- 结果
_10curl -X GET \_10"$LANGFLOW_URL/api/v1/version" \_10-H "accept: application/json"
_10{_10"version": "1.1.1",_10"main_version": "1.1.1",_10"package": "Langflow"_10}
获取配置
检索 Langflow 配置信息。
- curl
- 结果
_10curl -X GET \_10"$LANGFLOW_URL/api/v1/config" \_10-H "accept: application/json"
_10{_10"feature_flags": {_10"mvp_components": false_10 },_10"frontend_timeout": 0,_10"auto_saving": true,_10"auto_saving_interval": 1000,_10"health_check_max_retries": 5,_10"max_file_size_upload": 100_10}
构建
使用 /build
端点构建顶点和流,并以流式事件响应执行这些流。
/build
端点为运行流提供了额外的配置。
要更简单地执行您的流,请改用/run
端点。
构建流
此端点旨在供前端使用,并未针对外部使用进行优化。要运行您的流,请改用/run
端点。
此端点构建并执行流,返回一个可用于流式传输执行事件的作业 ID。
- 向
/build/{flow_id}/flow
端点发送 POST 请求。
- curl
- 结果
_10curl -X POST \_10"$LANGFLOW_URL/api/v1/build/$FLOW_ID/flow" \_10-H "accept: application/json" \_10-H "Content-Type: application/json" \_10-d '{_10"inputs": {_10"input_value": "Tell me a story"_10 }_10 }'
_10{_10"job_id": "123e4567-e89b-12d3-a456-426614174000"_10}
- 从构建端点接收到作业 ID 后,使用
/build/{job_id}/events
端点流式传输执行结果
- curl
- 结果
_10curl -X GET \_10"$LANGFLOW_URL/api/v1/build/123e4567-e89b-12d3-a456-426614174000/events" \_10-H "accept: application/json"
_10{"event": "vertices_sorted", "data": {"ids": ["ChatInput-XtBLx"], "to_run": ["Prompt-x74Ze", "ChatOutput-ylMzN", "ChatInput-XtBLx", "OpenAIModel-d1wOZ"]}}_10_10{"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"}}_10_10// ... Additional events as the flow executes ..._10_10{"event": "end", "data": {}}
events 端点接受可选的 stream
查询参数,默认值为 true
。要禁用流式传输并一次性获取所有事件,请将 stream
设置为 false
。
_10curl -X GET \_10"$LANGFLOW_URL/api/v1/build/123e4567-e89b-12d3-a456-426614174000/events?stream=false" \_10-H "accept: application/json"
构建端点头和参数
请求头
请求头 | 信息 | 示例 |
---|---|---|
Content-Type | 必需。指定 JSON 格式。 | "application/json" |
accept | 必需。指定响应格式。 | "application/json" |
x-api-key | 可选。仅在启用身份验证时需要。 | "sk-..." |
/build/{flow_id}/flow
端点在其请求体中接受以下参数
参数
参数 | 类型 | 描述 |
---|---|---|
inputs | 对象 | 可选。流组件的输入值。 |
data | 对象 | 可选。用于覆盖存储配置的流数据。 |
files | array[字符串] | 可选。要使用的文件路径列表。 |
stop_component_id | 字符串 | 可选。执行应停止的组件 ID。 |
start_component_id | 字符串 | 可选。执行应开始的组件 ID。 |
log_builds | 布尔值 | 可选。控制构建日志记录。默认值:true 。 |
配置构建端点
/build
端点接受 start_component_id
和 stop_component_id
的可选值,以控制流运行的起点和终点。为组件设置 stop_component_id
会触发与在该组件上点击 运行 按钮相同的行为,即也会运行导致该组件的所有依赖组件。例如,要在 Open AI 模型组件处停止流执行,请运行以下命令
_10curl -X POST \_10"$LANGFLOW_URL/api/v1/build/$FLOW_ID/flow" \_10-H "accept: application/json" \_10-H "Content-Type: application/json" \_10-H "x-api-key: $LANGFLOW_API_KEY" \_10-d '{"stop_component_id": "OpenAIModel-Uksag"}'
/build
端点也直接接受 data
的输入,而不是使用 Langflow 数据库中存储的值。这对于运行流而无需通过 UI 传递自定义值非常有用。
- curl
- 结果
_14curl -X POST \_14"$LANGFLOW_URL/api/v1/build/$FLOW_ID/flow" \_14-H "accept: application/json" \_14-H "Content-Type: application/json" \_14-d '{_14"data": {_14"nodes": [],_14"edges": []_14 },_14"inputs": {_14"input_value": "Your custom input here",_14"session": "session_id"_14 }_14 }'
_10{ "job_id": "0bcc7f23-40b4-4bfa-9b8a-a44181fd1175" }
文件
使用 /files
端点在您的本地机器和 Langflow 之间添加或删除文件。
/files
端点有 /v1
和 /v2
版本。v2/files
版本相对于 /v1
提供了一些改进
- 在
v1
中,文件按flow_id
组织。在v2
中,文件按user_id
组织。这意味着文件基于用户所有权访问,并且不与特定流绑定。您可以将文件上传到 Langflow 一次,并在多个流中使用它。 - 在
v2
中,文件在 Langflow 数据库中进行跟踪,可以批量添加或删除,而不是逐个进行。 - 来自
/v2
端点的响应包含更具描述性的元数据。 v2
端点需要通过 API 密钥或 JWT 进行身份验证。
文件/V1 端点
使用 /files
端点在您的本地机器和 Langflow 之间添加或删除文件。
- 在
v1
中,文件按flow_id
组织。 - 在
v2
中,文件按user_id
组织并在 Langflow 数据库中进行跟踪,可以批量添加或删除,而不是逐个进行。
上传文件 (v1)
将文件上传到流的 v1/files/upload/<YOUR-FLOW-ID>
端点。将 FILE_NAME 替换为上传的文件名。
- curl
- 结果
_10curl -X POST \_10"$LANGFLOW_URL/api/v1/files/upload/$FLOW_ID" \_10-H "accept: application/json" \_10-H "Content-Type: multipart/form-data" \_10-F "file=@FILE_NAME.txt"
_10{_10"flowId": "92f9a4c5-cfc8-4656-ae63-1f0881163c28",_10"file_path": "92f9a4c5-cfc8-4656-ae63-1f0881163c28/2024-12-30_15-19-43_your_file.txt"_10}
上传图像文件 (v1)
将图像文件发送到 Langflow API 进行 AI 分析。
默认文件大小限制为 100 MB。要配置此值,请更改 LANGFLOW_MAX_FILE_SIZE_UPLOAD
环境变量。有关更多信息,请参阅支持的环境变量。
- 要通过 API 将图像发送到您的流,请将图像文件 POST 到流的
v1/files/upload/<YOUR-FLOW-ID>
端点。将 FILE_NAME 替换为上传的文件名。
_10curl -X POST "$LANGFLOW_URL/api/v1/files/upload/a430cc57-06bb-4c11-be39-d3d4de68d2c4" \_10-H "Content-Type: multipart/form-data" \_10-F "file=@FILE_NAME.png"
API 返回图像文件路径,格式为 "file_path":"<YOUR-FLOW-ID>/<TIMESTAMP>_<FILE-NAME>"}
。
_10{_10"flowId": "a430cc57-06bb-4c11-be39-d3d4de68d2c4",_10"file_path": "a430cc57-06bb-4c11-be39-d3d4de68d2c4/2024-11-27_14-47-50_image-file.png"_10}
- 将图像文件 POST 到基本提示流的 Chat Input 组件。将文件路径值作为输入传递到 Langflow curl 调用的 Tweaks 部分。要找到您的 Chat Input 组件 ID,请使用
_12curl -X POST \_12"$LANGFLOW_URL/api/v1/run/a430cc57-06bb-4c11-be39-d3d4de68d2c4?stream=false" \_12-H 'Content-Type: application/json'\_12-d '{_12"output_type": "chat",_12"input_type": "chat",_12"tweaks": {_12"ChatInput-b67sL": {_12"files": "a430cc57-06bb-4c11-be39-d3d4de68d2c4/2024-11-27_14-47-50_image-file.png",_12"input_value": "what do you see?"_12 }_12}}'
您的聊天机器人会描述您发送的图像文件。
_10"text": "This flowchart appears to represent a complex system for processing financial inquiries using various AI agents and tools. Here's a breakdown of its components and how they might work together..."
列出文件 (v1)
列出与特定流关联的所有文件。
- curl
- 结果
_10curl -X GET \_10"$LANGFLOW_URL/api/v1/files/list/$FLOW_ID" \_10-H "accept: application/json"
_10{_10"files": ["2024-12-30_15-19-43_your_file.txt"]_10}
下载文件 (v1)
从流中下载特定文件。
- curl
- 结果
_10curl -X GET \_10"$LANGFLOW_URL/api/v1/files/download/$FLOW_ID/2024-12-30_15-19-43_your_file.txt" \_10-H "accept: application/json" \_10--output downloaded_file.txt
_10文件内容已下载到 downloaded_file.txt
删除文件 (v1)
从流中删除特定文件。
- curl
- 结果
_10curl -X DELETE \_10"$LANGFLOW_URL/api/v1/files/delete/$FLOW_ID/2024-12-30_15-19-43_your_file.txt" \_10-H "accept: application/json"
_10{_10"message": "File 2024-12-30_15-19-43_your_file.txt deleted successfully"_10}
文件/V2 端点
在 v2
中,文件按 user_id
组织并在 Langflow 数据库中进行跟踪,可以批量添加或删除,而不是逐个进行。v2
端点需要通过 API 密钥或 JWT 进行身份验证。要创建 Langflow API 密钥并将其导出为环境变量,请参阅导出值。
上传文件 (v2)
将文件上传到您的用户帐户。该文件可用于多个流。
文件以上传格式为 USER_ID/FILE_ID.FILE_EXTENSION
,例如 6f17a73e-97d7-4519-a8d9-8e4c0be411bb/c7b22c4c-d5e0-4ec9-af97-5d85b7657a34.txt
。将 FILE_NAME.EXTENSION 替换为上传的文件名及其扩展名。
- curl
- 结果
_10curl -X POST \_10"$LANGFLOW_URL/api/v2/files" \_10-H "accept: application/json" \_10-H "Content-Type: multipart/form-data" \_10-H "x-api-key: $LANGFLOW_API_KEY" \_10-F "file=@FILE_NAME.EXTENSION"
_10{_10"id": "c7b22c4c-d5e0-4ec9-af97-5d85b7657a34",_10"name": "FILE_NAME.EXTENSION",_10"path": "6f17a73e-97d7-4519-a8d9-8e4c0be411bb/c7b22c4c-d5e0-4ec9-af97-5d85b7657a34.txt",_10"size": 1234,_10"provider": null_10}
将文件发送到您的流 (v2)
使用文件组件将文件发送到您的流进行分析。
默认文件大小限制为 100 MB。要配置此值,请更改 LANGFLOW_MAX_FILE_SIZE_UPLOAD
环境变量。有关更多信息,请参阅支持的环境变量。
- 要通过 API 将图像发送到您的流,请将图像文件 POST 到
/api/v2/files
端点。将 FILE_NAME 替换为上传的文件名。
_10curl -X POST "$LANGFLOW_URL/api/v2/files" \_10-H "Content-Type: multipart/form-data" \_10-H "x-api-key: $LANGFLOW_API_KEY" \_10-F "file=@FILE_NAME.png"
文件以上传格式为 USER_ID/FILE_ID.FILE_EXTENSION
,API 返回上传文件的元数据
_10{_10"id": "5f829bc4-ac1e-4a80-b1d1-fedc03cd5b6e",_10"name": "FILE_NAME",_10"path": "232f54ba-dd54-4760-977e-ed637f83e785/5f829bc4-ac1e-4a80-b1d1-fedc03cd5b6e.png",_10"size": 84408,_10"provider": null_10}
- 要在您的流中使用此文件,请添加一个文件组件将文件加载到流中。
- 要将文件加载到您的流中,请将其发送到 File 组件。
_16curl --request POST \_16--url '$LANGFLOW_URL/api/v1/run/$FLOW_ID' \_16--header 'Content-Type: application/json' \_16--header 'x-api-key: $LANGFLOW_API_KEY' \_16--data '{_16"input_value": "what do you see?",_16"output_type": "chat",_16"input_type": "text",_16"tweaks": {_16"File-t2Ngc": {_16"path": [_16"232f54ba-dd54-4760-977e-ed637f83e785/5f829bc4-ac1e-4a80-b1d1-fedc03cd5b6e.png"_16 ]_16 }_16 }_16}'
列出文件 (v2)
列出与您的用户帐户关联的所有文件。
- curl
- 结果
_10curl -X GET \_10"$LANGFLOW_URL/api/v2/files" \_10-H "accept: application/json" \_10-H "x-api-key: $LANGFLOW_API_KEY"
_10[_10 {_10"id": "c7b22c4c-d5e0-4ec9-af97-5d85b7657a34",_10"name": "your_file",_10"path": "6f17a73e-97d7-4519-a8d9-8e4c0be411bb/c7b22c4c-d5e0-4ec9-af97-5d85b7657a34.txt",_10"size": 1234,_10"provider": null_10 }_10]
下载文件 (v2)
按其 ID 和文件扩展名下载特定文件。
您必须在 --output
值中指定您期望的文件类型。
- curl
- 结果
_10curl -X GET \_10"$LANGFLOW_URL/api/v2/files/c7b22c4c-d5e0-4ec9-af97-5d85b7657a34" \_10-H "accept: application/json" \_10-H "x-api-key: $LANGFLOW_API_KEY" \_10--output downloaded_file.txt
_10文件内容已下载到 downloaded_file.txt
编辑文件名 (v2)
更改文件名。
- curl
- 结果
_10curl -X PUT \_10"$LANGFLOW_URL/api/v2/files/$FILE_ID?name=new_file_name" \_10-H "accept: application/json" \_10-H "x-api-key: $LANGFLOW_API_KEY"
_10{_10"id": "76543e40-f388-4cb3-b0ee-a1e870aca3d3",_10"name": "new_file_name",_10"path": "6f17a73e-97d7-4519-a8d9-8e4c0be411bb/76543e40-f388-4cb3-b0ee-a1e870aca3d3.png",_10"size": 2728251,_10"provider": null_10}
删除文件 (v2)
按其 ID 删除特定文件。
- curl
- 结果
_10curl -X DELETE \_10"$LANGFLOW_URL/api/v2/files/$FILE_ID" \_10-H "accept: application/json" \_10-H "x-api-key: $LANGFLOW_API_KEY"
_10{_10"message": "File deleted successfully"_10}
删除所有文件 (v2)
删除与您的用户帐户关联的所有文件。
- curl
- 结果
_10curl -X DELETE \_10"$LANGFLOW_URL/api/v2/files" \_10-H "accept: application/json" \_10-H "x-api-key: $LANGFLOW_API_KEY"
_10{_10"message": "All files deleted successfully"_10}
流
使用 /flows
端点创建、读取、更新和删除流。
创建流
创建一个新流。
- curl
- 结果
_19curl -X POST \_19"$LANGFLOW_URL/api/v1/flows/" \_19-H "accept: application/json" \_19-H "Content-Type: application/json" \_19-d '{_19"name": "string2",_19"description": "string",_19"icon": "string",_19"icon_bg_color": "#FF0000",_19"gradient": "string",_19"data": {},_19"is_component": false,_19"updated_at": "2024-12-30T15:48:01.519Z",_19"webhook": false,_19"endpoint_name": "string",_19"tags": [_19"string"_19 ]_19}'
_17{_17"name": "string2",_17"description": "string",_17"icon": "string",_17"icon_bg_color": "#FF0000",_17"gradient": "string",_17"data": {},_17"is_component": false,_17"updated_at": "2025-02-04T21:07:36+00:00",_17"webhook": false,_17"endpoint_name": "string",_17"tags": ["string"],_17"locked": false,_17"id": "e8d81c37-714b-49ae-ba82-e61141f020ee",_17"user_id": "f58396d4-a387-4bb8-b749-f40825c3d9f3",_17"project_id": "1415de42-8f01-4f36-bf34-539f23e47466"_17}
读取流
检索支持分页的流列表。
- curl
- 结果
_10curl -X GET \_10"$LANGFLOW_URL/api/v1/flows/?remove_example_flows=false&components_only=false&get_all=true&header_flows=false&page=1&size=50" \_10-H "accept: application/json"
_10包含流列表的 JSON 对象。
要仅检索特定项目中的流,请在查询字符串中传递 project_id
。
- curl
- 结果
_10curl -X GET \_10"$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" \_10-H "accept: application/json"
_10包含流列表的 JSON 对象。
读取流
按其 ID 读取特定流。
- curl
- 结果
_10curl -X GET \_10"$LANGFLOW_URL/api/v1/flows/$FLOW_ID" \_10-H "accept: application/json"
_12{_12"name": "Basic Prompting",_12"description": "Perform basic prompting with an OpenAI model.",_12"icon": "Braces",_12"icon_bg_color": null,_12"gradient": "2",_12"data": {_12"nodes": [_12 ..._12 ]_12 }_12}
更新流
按其 ID 更新现有流。
此示例将 endpoint_name
的值从随机 UUID 更改为 my_new_endpoint_name
。
- curl
- 结果
_13curl -X PATCH \_13"$LANGFLOW_URL/api/v1/flows/$FLOW_ID" \_13-H "accept: application/json" \_13-H "Content-Type: application/json" \_13-d '{_13"name": "string",_13"description": "string",_13"data": {},_13"project_id": "3fa85f64-5717-4562-b3fc-2c963f66afa6",_13"project_id": "3fa85f64-5717-4562-b3fc-2c963f66afa6",_13"endpoint_name": "my_new_endpoint_name",_13"locked": true_13}'
_18{_18"name": "string",_18"description": "string",_18"icon": "Braces",_18"icon_bg_color": null,_18"gradient": "2",_18"data": {},_18"is_component": false,_18"updated_at": "2024-12-30T18:30:22+00:00",_18"webhook": false,_18"endpoint_name": "my_new_endpoint_name",_18"tags": null,_18"locked": true,_18"id": "01ce083d-748b-4b8d-97b6-33adbb6a528a",_18"user_id": "f58396d4-a387-4bb8-b749-f40825c3d9f3",_18"project_id": "3fa85f64-5717-4562-b3fc-2c963f66afa6"_18"project_id": "3fa85f64-5717-4562-b3fc-2c963f66afa6"_18}
删除流
按其 ID 删除特定流。
- curl
- 结果
_10curl -X DELETE \_10"$LANGFLOW_URL/api/v1/flows/$FLOW_ID" \_10-H "accept: application/json"
_10{_10"message": "Flow deleted successfully"_10}
创建多个流
创建多个新流。
- curl
- 结果
_46curl -X POST \_46"$LANGFLOW_URL/api/v1/flows/batch/" \_46-H "accept: application/json" \_46-H "Content-Type: application/json" \_46-d '{_46"flows": [_46 {_46"name": "string",_46"description": "string",_46"icon": "string",_46"icon_bg_color": "string",_46"gradient": "string",_46"data": {},_46"is_component": false,_46"updated_at": "2024-12-30T18:36:02.737Z",_46"webhook": false,_46"endpoint_name": "string",_46"tags": [_46"string"_46 ],_46"locked": false,_46"user_id": "3fa85f64-5717-4562-b3fc-2c963f66afa6",_46"project_id": "3fa85f64-5717-4562-b3fc-2c963f66afa6"_46"project_id": "3fa85f64-5717-4562-b3fc-2c963f66afa6"_46 },_46 {_46"name": "string",_46"description": "string",_46"icon": "string",_46"icon_bg_color": "string",_46"gradient": "string",_46"data": {},_46"is_component": false,_46"updated_at": "2024-12-30T18:36:02.737Z",_46"webhook": false,_46"endpoint_name": "string",_46"tags": [_46"string"_46 ],_46"locked": false,_46"user_id": "3fa85f64-5717-4562-b3fc-2c963f66afa6",_46"project_id": "3fa85f64-5717-4562-b3fc-2c963f66afa6"_46"project_id": "3fa85f64-5717-4562-b3fc-2c963f66afa6"_46 }_46 ]_46}'
_10[_10 {_10// FlowRead objects_10 }_10]
上传流
从文件上传流。
此示例上传一个名为 agent-with-astra-db-tool.json
的本地文件。
- curl
- 结果
_10curl -X POST \_10"$LANGFLOW_URL/api/v1/flows/upload/?project_id=$project_ID" \_10-H "accept: application/json" \_10-H "Content-Type: multipart/form-data" \_10-F "file=@agent-with-astra-db-tool.json;type=application/json"
_11[_11 {_11"name": "agent-with-astra-db-tool",_11"description": "",_11"icon": null,_11"icon_bg_color": null,_11"gradient": null,_11"data": {}_11 ..._11 }_11]
要指定流的目标项目,请包含查询参数 project_id
。目标 project_id
在上传流之前必须已存在。调用/api/v1/projects/ 端点以获取可用项目列表。要指定流的目标项目,请包含查询参数 project_id
。目标 project_id
在上传流之前必须已存在。调用/api/v1/projects/ 端点以获取可用项目列表。
_10curl -X POST \_10"$LANGFLOW_URL/api/v1/flows/upload/?project_id=$project_ID" \_10-H "accept: application/json" \_10-H "Content-Type: multipart/form-data" \_10-F "file=@agent-with-astra-db-tool.json;type=application/json"
下载所有流
将所有流下载为 ZIP 文件。
此端点下载一个 ZIP 文件,其中包含命令体中列出的所有 flow-id
值的流。
- curl
- 结果
_10curl -X POST \_10"$LANGFLOW_URL/api/v1/flows/download/" \_10-H "accept: application/json" \_10-H "Content-Type: application/json" \_10-d '[_10"e1e40c77-0541-41a9-88ab-ddb3419398b5",_10"92f9a4c5-cfc8-4656-ae63-1f0881163c28"_10]' \_10--output langflow-flows.zip
_10% Total % Received % Xferd Average Speed Time Time Time Current_10Dload Upload Total Spent Left Speed_10100 76437 0 76353 100 84 4516k 5088 --:--:-- --:--:-- --:--:-- 4665k
读取基本示例
检索基本示例流的列表。
- curl
- 结果
_10curl -X GET \_10"$LANGFLOW_URL/api/v1/flows/basic_examples/" \_10-H "accept: application/json"
_10示例流的列表。
项目
项目
使用 /projects
端点创建、读取、更新和删除项目。
项目存储您的流和组件。
读取项目
获取 Langflow 项目列表。
- curl
- 结果
_10curl -X GET \_10"$LANGFLOW_URL/api/v1/projects/" \_10"$LANGFLOW_URL/api/v1/projects/" \_10-H "accept: application/json"
_10[_10 {_10"name": "My Projects",_10"description": "Manage your own projects. Download and upload projects.",_10"id": "1415de42-8f01-4f36-bf34-539f23e47466",_10"parent_id": null_10 }_10]
创建项目
创建项目
创建一个新项目。创建一个新项目。
- curl
- 结果
_12curl -X POST \_12"$LANGFLOW_URL/api/v1/projects/" \_12"$LANGFLOW_URL/api/v1/projects/" \_12-H "accept: application/json" \_12-H "Content-Type: application/json" \_12-d '{_12"name": "new_project_name",_12"name": "new_project_name",_12"description": "string",_12"components_list": [],_12"flows_list": []_12}'
_10{_10"name": "new_project_name",_10"name": "new_project_name",_10"description": "string",_10"id": "b408ddb9-6266-4431-9be8-e04a62758331",_10"parent_id": null_10}
要在项目创建时添加流和组件,请从/api/v1/store/components 和/api/v1/flows/read 端点检索 components_list
和 flows_list
的值,并将它们添加到请求体中。要在项目创建时添加流和组件,请从/api/v1/store/components 和/api/v1/flows/read 端点检索 components_list
和 flows_list
的值,并将它们添加到请求体中。
将流添加到项目会将其从先前位置移动。流不会被复制。将流添加到项目会将其从先前位置移动。流不会被复制。
_16curl -X POST \_16"$LANGFLOW_URL/api/v1/projects/" \_16"$LANGFLOW_URL/api/v1/projects/" \_16-H "accept: application/json" \_16-H "Content-Type: application/json" \_16-d '{_16"name": "new_project_name",_16"name": "new_project_name",_16"description": "string",_16"components_list": [_16"3fa85f64-5717-4562-b3fc-2c963f66afa6"_16 ],_16"flows_list": [_16"3fa85f64-5717-4562-b3fc-2c963f66afa6"_16 ]_16}'
读取项目
读取项目
检索特定项目的详细信息。检索特定项目的详细信息。
要查找项目的 UUID,请调用读取项目端点。要查找项目的 UUID,请调用读取项目端点。
- curl
- 结果
_10curl -X GET \_10"$LANGFLOW_URL/api/v1/projects/$project_ID" \_10-H "accept: application/json"
_10[_10 {_10"name": "My Projects",_10"description": "Manage your own projects. Download and upload projects.",_10"id": "3fa85f64-5717-4562-b3fc-2c963f66afa6",_10"parent_id": null_10 }_10]
更新项目
更新项目
使用 PATCH
请求更新特定项目的信息。使用 PATCH
请求更新特定项目的信息。
每个 PATCH 请求都会用您发送的值更新项目。每个 PATCH 请求都会用您发送的值更新项目。仅更新您请求中包含的字段。即使值未更改,如果您多次发送相同的值,更新仍会处理。
- curl
- 结果
_16curl -X PATCH \_16"$LANGFLOW_URL/api/v1/projects/b408ddb9-6266-4431-9be8-e04a62758331" \_16"$LANGFLOW_URL/api/v1/projects/b408ddb9-6266-4431-9be8-e04a62758331" \_16-H "accept: application/json" \_16-H "Content-Type: application/json" \_16-d '{_16"name": "string",_16"description": "string",_16"parent_id": "3fa85f64-5717-4562-b3fc-2c963f66afa6",_16"components": [_16"3fa85f64-5717-4562-b3fc-2c963f66afa6"_16 ],_16"flows": [_16"3fa85f64-5717-4562-b3fc-2c963f66afa6"_16 ]_16}'
_10{_10"name": "string",_10"description": "string",_10"id": "b408ddb9-6266-4431-9be8-e04a62758331",_10"parent_id": null_10}
删除项目
删除项目
删除特定项目。删除特定项目。
- curl
- 结果
_10curl -X DELETE \_10"$LANGFLOW_URL/api/v1/projects/$project_ID" \_10-H "accept: */*"
_10204 No Content
下载项目
下载项目
将项目中的所有流下载为 zip 文件。将项目中的所有流下载为 zip 文件。
--output
标志是可选的。
- curl
- 结果
_10curl -X GET \_10"$LANGFLOW_URL/api/v1/projects/download/b408ddb9-6266-4431-9be8-e04a62758331" \_10"$LANGFLOW_URL/api/v1/projects/download/b408ddb9-6266-4431-9be8-e04a62758331" \_10-H "accept: application/json" \_10--output langflow-project.zip_10--output langflow-project.zip
_10项目内容。_10项目内容。
上传项目
上传项目
将项目上传到 Langflow。将项目上传到 Langflow。
- curl
- 结果
_10curl -X POST \_10"$LANGFLOW_URL/api/v1/projects/upload/" \_10"$LANGFLOW_URL/api/v1/projects/upload/" \_10-H "accept: application/json" \_10-H "Content-Type: multipart/form-data" \_10-F "file=@20241230_135006_langflow_flows.zip;type=application/zip"
_10项目内容已上传到 Langflow。_10项目内容已上传到 Langflow。
日志
检索 Langflow 流的日志。
此端点要求在您的 Langflow 应用程序中启用日志检索。
要启用日志检索,请在您的 .env
文件中包含这些值
_10LANGFLOW_ENABLE_LOG_RETRIEVAL=true_10LANGFLOW_LOG_RETRIEVER_BUFFER_SIZE=10000_10LANGFLOW_LOG_LEVEL=DEBUG
要使日志检索正常工作,LANGFLOW_LOG_RETRIEVER_BUFFER_SIZE
必须大于 0。默认值为 10000
。
使用此 .env
启动 Langflow
_10uv run langflow run --env-file .env
流式传输日志
使用 Server-Sent Events (SSE) 实时流式传输日志。
- curl
- 结果
_10curl -X GET \_10"$LANGFLOW_URL/logs-stream" \_10-H "accept: text/event-stream"
_17keepalive_17_17{"1736355791151": "2025-01-08T12:03:11.151218-0500 DEBUG Building Chat Input\n"}_17_17{"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"}_17_17{"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"}_17_17{"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"}_17_17{"1736355791513": "2025-01-08T12:03:11.513097-0500 DEBUG Logged vertex build: 729ff2f8-6b01-48c8-9ad0-3743c2af9e8a\n"}_17_17{"1736355791834": "2025-01-08T12:03:11.834982-0500 DEBUG Telemetry data sent successfully.\n"}_17_17{"1736355791941": "2025-01-08T12:03:11.941840-0500 DEBUG Telemetry data sent successfully.\n"}_17_17keepalive
使用可选参数检索日志
使用可选查询参数检索日志。
lines_before
:时间戳或最后一条日志之前的日志数量。lines_after
:时间戳之后的日志数量。timestamp
:开始获取日志的时间戳。
所有三个参数的默认值均为 0
。使用这些值时,端点将返回最后 10 行日志。
- curl
- 结果
_10curl -X GET \_10"$LANGFLOW_URL/logs?lines_before=0&lines_after=0×tamp=0" \_10-H "accept: application/json"
_12{_12"1736354770500": "2025-01-08T11:46:10.500363-0500 DEBUG Creating starter project Document Q&A\n",_12"1736354770511": "2025-01-08T11:46:10.511146-0500 DEBUG Creating starter project Image Sentiment Analysis\n",_12"1736354770521": "2025-01-08T11:46:10.521018-0500 DEBUG Creating starter project SEO Keyword Generator\n",_12"1736354770532": "2025-01-08T11:46:10.532677-0500 DEBUG Creating starter project Sequential Tasks Agents\n",_12"1736354770544": "2025-01-08T11:46:10.544010-0500 DEBUG Creating starter project Custom Component Generator\n",_12"1736354770555": "2025-01-08T11:46:10.555513-0500 DEBUG Creating starter project Prompt Chaining\n",_12"1736354770588": "2025-01-08T11:46:10.588105-0500 DEBUG Create service ServiceType.CHAT_SERVICE\n",_12"1736354771021": "2025-01-08T11:46:11.021817-0500 DEBUG Telemetry data sent successfully.\n",_12"1736354775619": "2025-01-08T11:46:15.619545-0500 DEBUG Create service ServiceType.STORE_SERVICE\n",_12"1736354775699": "2025-01-08T11:46:15.699661-0500 DEBUG File 046-rocket.svg retrieved successfully from flow /Users/mendon.kissling/Library/Caches/langflow/profile_pictures/Space.\n"_12}
监控
使用 /monitor
端点监控和修改 Langflow 组件之间传递的消息、顶点构建和事务。
获取顶点构建
检索特定流的顶点构建。
- curl
- 结果
_10curl -X GET \_10"$LANGFLOW_URL/api/v1/monitor/builds?flow_id=$FLOW_ID" \_10-H "accept: application/json"
_357{_357"vertex_builds": {_357"ChatInput-NCmix": [_357 {_357"data": {_357"results": {_357"message": {_357"text_key": "text",_357"data": {_357"timestamp": "2024-12-23 19:10:57",_357"sender": "User",_357"sender_name": "User",_357"session_id": "01ce083d-748b-4b8d-97b6-33adbb6a528a",_357"text": "Hello",_357"files": [],_357"error": "False",_357"edit": "False",_357"properties": {_357"text_color": "",_357"background_color": "",_357"edited": "False",_357"source": {_357"id": "None",_357"display_name": "None",_357"source": "None"_357 },_357"icon": "",_357"allow_markdown": "False",_357"positive_feedback": "None",_357"state": "complete",_357"targets": []_357 },_357"category": "message",_357"content_blocks": [],_357"id": "c95bed34-f906-4aa6-84e4-68553f6db772",_357"flow_id": "01ce083d-748b-4b8d-97b6-33adbb6a528a"_357 },_357"default_value": "",_357"text": "Hello",_357"sender": "User",_357"sender_name": "User",_357"files": [],_357"session_id": "01ce083d-748b-4b8d-97b6-33adbb6a528a",_357"timestamp": "2024-12-23 19:10:57+00:00",_357"flow_id": "01ce083d-748b-4b8d-97b6-33adbb6a528a",_357"error": "False",_357"edit": "False",_357"properties": {_357"text_color": "",_357"background_color": "",_357"edited": "False",_357"source": {_357"id": "None",_357"display_name": "None",_357"source": "None"_357 },_357"icon": "",_357"allow_markdown": "False",_357"positive_feedback": "None",_357"state": "complete",_357"targets": []_357 },_357"category": "message",_357"content_blocks": []_357 }_357 },_357"outputs": {_357"message": {_357"message": {_357"timestamp": "2024-12-23T19:10:57",_357"sender": "User",_357"sender_name": "User",_357"session_id": "01ce083d-748b-4b8d-97b6-33adbb6a528a",_357"text": "Hello",_357"files": [],_357"error": false,_357"edit": false,_357"properties": {_357"text_color": "",_357"background_color": "",_357"edited": false,_357"source": {_357"id": null,_357"display_name": null,_357"source": null_357 },_357"icon": "",_357"allow_markdown": false,_357"positive_feedback": null,_357"state": "complete",_357"targets": []_357 },_357"category": "message",_357"content_blocks": [],_357"id": "c95bed34-f906-4aa6-84e4-68553f6db772",_357"flow_id": "01ce083d-748b-4b8d-97b6-33adbb6a528a"_357 },_357"type": "object"_357 }_357 },_357"logs": { "message": [] },_357"message": {_357"message": "Hello",_357"sender": "User",_357"sender_name": "User",_357"files": [],_357"type": "object"_357 },_357"artifacts": {_357"message": "Hello",_357"sender": "User",_357"sender_name": "User",_357"files": [],_357"type": "object"_357 },_357"timedelta": 0.015060124918818474,_357"duration": "15 ms",_357"used_frozen_result": false_357 },_357"artifacts": {_357"message": "Hello",_357"sender": "User",_357"sender_name": "User",_357"files": [],_357"type": "object"_357 },_357"params": "- Files: []\n Message: Hello\n Sender: User\n Sender Name: User\n Type: object\n",_357"valid": true,_357"build_id": "40aa200e-74db-4651-b698-f80301d2b26b",_357"id": "ChatInput-NCmix",_357"timestamp": "2024-12-23T19:10:58.772766Z",_357"flow_id": "01ce083d-748b-4b8d-97b6-33adbb6a528a"_357 }_357 ],_357"Prompt-BEn9c": [_357 {_357"data": {_357"results": {},_357"outputs": {_357"prompt": {_357"message": "Answer the user as if you were a GenAI expert, enthusiastic about helping them get started building something fresh.",_357"type": "text"_357 }_357 },_357"logs": { "prompt": [] },_357"message": {_357"prompt": {_357"repr": "Answer the user as if you were a GenAI expert, enthusiastic about helping them get started building something fresh.",_357"raw": "Answer the user as if you were a GenAI expert, enthusiastic about helping them get started building something fresh.",_357"type": "text"_357 }_357 },_357"artifacts": {_357"prompt": {_357"repr": "Answer the user as if you were a GenAI expert, enthusiastic about helping them get started building something fresh.",_357"raw": "Answer the user as if you were a GenAI expert, enthusiastic about helping them get started building something fresh.",_357"type": "text"_357 }_357 },_357"timedelta": 0.0057758750626817346,_357"duration": "6 ms",_357"used_frozen_result": false_357 },_357"artifacts": {_357"prompt": {_357"repr": "Answer the user as if you were a GenAI expert, enthusiastic about helping them get started building something fresh.",_357"raw": "Answer the user as if you were a GenAI expert, enthusiastic about helping them get started building something fresh.",_357"type": "text"_357 }_357 },_357"params": "None",_357"valid": true,_357"build_id": "39bbbfde-97fd-42a5-a9ed-d42a5c5d532b",_357"id": "Prompt-BEn9c",_357"timestamp": "2024-12-23T19:10:58.781019Z",_357"flow_id": "01ce083d-748b-4b8d-97b6-33adbb6a528a"_357 }_357 ],_357"OpenAIModel-7AjrN": [_357 {_357"data": {_357"results": {},_357"outputs": {_357"text_output": {_357"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!",_357"type": "text"_357 },_357"model_output": { "message": "", "type": "unknown" }_357 },_357"logs": { "text_output": [] },_357"message": {_357"text_output": {_357"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!",_357"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!",_357"type": "text"_357 }_357 },_357"artifacts": {_357"text_output": {_357"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!",_357"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!",_357"type": "text"_357 }_357 },_357"timedelta": 1.034765167045407,_357"duration": "1.03 seconds",_357"used_frozen_result": false_357 },_357"artifacts": {_357"text_output": {_357"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!",_357"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!",_357"type": "text"_357 }_357 },_357"params": "None",_357"valid": true,_357"build_id": "4f0ae730-a266-4d35-b89f-7b825c620a0f",_357"id": "OpenAIModel-7AjrN",_357"timestamp": "2024-12-23T19:10:58.790484Z",_357"flow_id": "01ce083d-748b-4b8d-97b6-33adbb6a528a"_357 }_357 ],_357"ChatOutput-sfUhT": [_357 {_357"data": {_357"results": {_357"message": {_357"text_key": "text",_357"data": {_357"timestamp": "2024-12-23 19:10:58",_357"sender": "Machine",_357"sender_name": "AI",_357"session_id": "01ce083d-748b-4b8d-97b6-33adbb6a528a",_357"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!",_357"files": [],_357"error": "False",_357"edit": "False",_357"properties": {_357"text_color": "",_357"background_color": "",_357"edited": "False",_357"source": {_357"id": "OpenAIModel-7AjrN",_357"display_name": "OpenAI",_357"source": "gpt-4o-mini"_357 },_357"icon": "OpenAI",_357"allow_markdown": "False",_357"positive_feedback": "None",_357"state": "complete",_357"targets": []_357 },_357"category": "message",_357"content_blocks": [],_357"id": "5688356d-9f30-40ca-9907-79a7a2fc16fd",_357"flow_id": "01ce083d-748b-4b8d-97b6-33adbb6a528a"_357 },_357"default_value": "",_357"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!",_357"sender": "Machine",_357"sender_name": "AI",_357"files": [],_357"session_id": "01ce083d-748b-4b8d-97b6-33adbb6a528a",_357"timestamp": "2024-12-23 19:10:58+00:00",_357"flow_id": "01ce083d-748b-4b8d-97b6-33adbb6a528a",_357"error": "False",_357"edit": "False",_357"properties": {_357"text_color": "",_357"background_color": "",_357"edited": "False",_357"source": {_357"id": "OpenAIModel-7AjrN",_357"display_name": "OpenAI",_357"source": "gpt-4o-mini"_357 },_357"icon": "OpenAI",_357"allow_markdown": "False",_357"positive_feedback": "None",_357"state": "complete",_357"targets": []_357 },_357"category": "message",_357"content_blocks": []_357 }_357 },_357"outputs": {_357"message": {_357"message": {_357"timestamp": "2024-12-23T19:10:58",_357"sender": "Machine",_357"sender_name": "AI",_357"session_id": "01ce083d-748b-4b8d-97b6-33adbb6a528a",_357"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!",_357"files": [],_357"error": false,_357"edit": false,_357"properties": {_357"text_color": "",_357"background_color": "",_357"edited": false,_357"source": {_357"id": "OpenAIModel-7AjrN",_357"display_name": "OpenAI",_357"source": "gpt-4o-mini"_357 },_357"icon": "OpenAI",_357"allow_markdown": false,_357"positive_feedback": null,_357"state": "complete",_357"targets": []_357 },_357"category": "message",_357"content_blocks": [],_357"id": "5688356d-9f30-40ca-9907-79a7a2fc16fd",_357"flow_id": "01ce083d-748b-4b8d-97b6-33adbb6a528a"_357 },_357"type": "object"_357 }_357 },_357"logs": { "message": [] },_357"message": {_357"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!",_357"sender": "Machine",_357"sender_name": "AI",_357"files": [],_357"type": "object"_357 },_357"artifacts": {_357"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!",_357"sender": "Machine",_357"sender_name": "AI",_357"files": [],_357"type": "object"_357 },_357"timedelta": 0.017838125000707805,_357"duration": "18 ms",_357"used_frozen_result": false_357 },_357"artifacts": {_357"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!",_357"sender": "Machine",_357"sender_name": "AI",_357"files": [],_357"type": "object"_357 },_357"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",_357"valid": true,_357"build_id": "1e8b908b-aba7-403b-9e9b-eca92bb78668",_357"id": "ChatOutput-sfUhT",_357"timestamp": "2024-12-23T19:10:58.813268Z",_357"flow_id": "01ce083d-748b-4b8d-97b6-33adbb6a528a"_357 }_357 ]_357 }_357}
删除顶点构建
删除特定流的顶点构建。
- curl
- 结果
_10curl -X DELETE \_10"$LANGFLOW_URL/api/v1/monitor/builds?flow_id=$FLOW_ID" \_10-H "accept: */*"
_10204 No Content
获取消息
使用可选过滤器检索消息。
- curl
- 结果
_10curl -X GET \_10"$LANGFLOW_URL/api/v1/monitor/messages" \_10-H "accept: application/json"
_10所有消息列表。
您可以按 flow_id
、session_id
、sender
和 sender_name
过滤消息。结果可以使用 order_by
查询字符串进行排序。
此示例检索给定聊天会话(session_id
)中由 Machine
和 AI
发送的消息,并按时间戳对消息进行排序。
- curl
- 结果
_10curl -X GET \_10"$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" \_10-H "accept: application/json"
_30[_30 {_30"id": "1c1d6134-9b8b-4079-931c-84dcaddf19ba",_30"flow_id": "01ce083d-748b-4b8d-97b6-33adbb6a528a",_30"timestamp": "2024-12-23 19:20:11 UTC",_30"sender": "Machine",_30"sender_name": "AI",_30"session_id": "01ce083d-748b-4b8d-97b6-33adbb6a528a",_30"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!",_30"files": "[]",_30"edit": false,_30"properties": {_30"text_color": "",_30"background_color": "",_30"edited": false,_30"source": {_30"id": "OpenAIModel-7AjrN",_30"display_name": "OpenAI",_30"source": "gpt-4o-mini"_30 },_30"icon": "OpenAI",_30"allow_markdown": false,_30"positive_feedback": null,_30"state": "complete",_30"targets": []_30 },_30"category": "message",_30"content_blocks": []_30 }_30]
删除消息
按其 ID 删除特定消息。
此示例删除在之前的获取消息示例中检索到的消息。
- curl
- 结果
_10curl -v -X DELETE \_10"$LANGFLOW_URL/api/v1/monitor/messages" \_10-H "accept: */*" \_10-H "Content-Type: application/json" \_10-d '["MESSAGE_ID_1", "MESSAGE_ID_2"]'
_10204 No Content
更新消息
按其 ID 更新特定消息。
此示例更新 ID 为 3ab66cc6-c048-48f8-ab07-570f5af7b160
的消息的 text
值。
- curl
- 结果
_10curl -X PUT \_10"$LANGFLOW_URL/api/v1/monitor/messages/3ab66cc6-c048-48f8-ab07-570f5af7b160" \_10-H "accept: application/json" \_10-H "Content-Type: application/json" \_10-d '{_10"text": "testing 1234"_10}'
_25{_25"timestamp": "2024-12-23T18:49:06",_25"sender": "string",_25"sender_name": "string",_25"session_id": "01ce083d-748b-4b8d-97b6-33adbb6a528a",_25"text": "testing 1234",_25"files": ["string"],_25"error": true,_25"edit": true,_25"properties": {_25"text_color": "string",_25"background_color": "string",_25"edited": false,_25"source": { "id": "string", "display_name": "string", "source": "string" },_25"icon": "string",_25"allow_markdown": false,_25"positive_feedback": true,_25"state": "complete",_25"targets": []_25 },_25"category": "message",_25"content_blocks": [],_25"id": "3ab66cc6-c048-48f8-ab07-570f5af7b160",_25"flow_id": "01ce083d-748b-4b8d-97b6-33adbb6a528a"_25}
更新会话 ID
更新消息的会话 ID。
此示例将会话 ID 01ce083d-748b-4b8d-97b6-33adbb6a528a
的值更新为 different_session_id
。
- curl
- 结果
_10curl -X PATCH \_10"$LANGFLOW_URL/api/v1/monitor/messages/session/01ce083d-748b-4b8d-97b6-33adbb6a528a?new_session_id=different_session_id" \_10-H "accept: application/json"
_30[_30 {_30"id": "8dd7f064-e63a-4773-b472-ca0475249dfd",_30"flow_id": "01ce083d-748b-4b8d-97b6-33adbb6a528a",_30"timestamp": "2024-12-23 18:49:55 UTC",_30"sender": "User",_30"sender_name": "User",_30"session_id": "different_session_id",_30"text": "message",_30"files": "[]",_30"edit": false,_30"properties": {_30"text_color": "",_30"background_color": "",_30"edited": false,_30"source": {_30"id": null,_30"display_name": null,_30"source": null_30 },_30"icon": "",_30"allow_markdown": false,_30"positive_feedback": null,_30"state": "complete",_30"targets": []_30 },_30"category": "message",_30"content_blocks": []_30 }_30]
按会话删除消息
删除特定会话的所有消息。
- curl
- 结果
_10curl -X DELETE \_10"$LANGFLOW_URL/api/v1/monitor/messages/session/different_session_id_2" \_10-H "accept: */*"
_10HTTP/1.1 204 No Content
获取事务
检索特定流的所有事务(组件之间的交互)。
- curl
- 结果
_10curl -X GET \_10"$LANGFLOW_URL/api/v1/monitor/transactions?flow_id=$FLOW_ID&page=1&size=50" \_10-H "accept: application/json"
_19{_19"items": [_19 {_19"timestamp": "2024-12-23T20:05:01.061Z",_19"vertex_id": "string",_19"target_id": "string",_19"inputs": {},_19"outputs": {},_19"status": "string",_19"error": "string",_19"flow_id": "3fa85f64-5717-4562-b3fc-2c963f66afa6",_19"id": "3fa85f64-5717-4562-b3fc-2c963f66afa6"_19 }_19 ],_19"total": 0,_19"page": 1,_19"size": 1,_19"pages": 0_19}