mirror of
https://github.com/hanzoai/flow.git
synced 2026-10-17 01:29:18 +00:00
* langflow-webhook-auth-enable
* add-not-contains-filter-operator
* does-not-contains-operator
* less-redundant-explanation
* docs: add jq and path selection to data operations (#10083)
add-jq-and-path-to-data-operations
* smart transform historical names
* change back to smart transform
* jq expression capitalization/package name
* small edit for clarity of not contains operator
* read/write file component name changes
* docs: add smart router component (#10097)
* init
* add-to-release-notes
* remove-dynamic-output-as-parameter
* Apply suggestion from @aimurphy
Co-authored-by: April I. Murphy <[email protected]>
* Apply suggestion from @aimurphy
Co-authored-by: April I. Murphy <[email protected]>
* Apply suggestion from @aimurphy
Co-authored-by: April I. Murphy <[email protected]>
* Apply suggestion from @aimurphy
Co-authored-by: April I. Murphy <[email protected]>
---------
Co-authored-by: April I. Murphy <[email protected]>
* docs: screenshot audit (#10166)
* remove-unused
* agent-examples
* main-ui-screenshots
* components-screenshots
* combine-web-search-components
* simple-agent-flow-in-playground
* round-screenshots
* my-projects
* combine-data-components
* docs: component paths updates for lfx (#10130)
* contributing-bundles-path
* api-monitor-example
* concepts-components-page
* contribute-components-path
* Apply suggestion from @aimurphy
Co-authored-by: April I. Murphy <[email protected]>
---------
Co-authored-by: April I. Murphy <[email protected]>
* docs: auto-add projects as MCP servers (#10096)
* add-mcp-auto-auth-as-default-behavior
* Apply suggestion from @aimurphy
Co-authored-by: April I. Murphy <[email protected]>
* Apply suggestion from @aimurphy
Co-authored-by: April I. Murphy <[email protected]>
---------
Co-authored-by: April I. Murphy <[email protected]>
Co-authored-by: Edwin Jose <[email protected]>
* docs: amazon bedrock converse (#10289)
* use-bedrock-converse
* Apply suggestion from @aimurphy
Co-authored-by: April I. Murphy <[email protected]>
* Update docs/docs/Components/bundles-amazon.mdx
---------
Co-authored-by: April I. Murphy <[email protected]>
* docs 1.7 release: add mock data component (#10288)
* add-component-and-release-note
* Apply suggestion from @aimurphy
Co-authored-by: April I. Murphy <[email protected]>
---------
Co-authored-by: April I. Murphy <[email protected]>
* docs: update custom component docs (#10323)
* add-partial
* update-lfx-component-paths
* move-partial
* completed-quickstart
* clean up intro
* try-docker-with-custom-mount
* up-to-typed-annotations
* typed-annotations
* dynamic-fields
* end-of-file
* bundles-naming
* chore: update component index
---------
Co-authored-by: Hanzo Dev <[email protected]>
* docs: add cometapi back for 1.7 release (#10445)
* add-comet-bundle-back-for-1.7
* add-comet-to-release-notes
* docs: add back docling remote vlm for release 1.7 (#10489)
* add-back-docling-vlm-content
* add-release-note
* docs: ALTK component (#10511)
* broken-anchor
* sidebar-and-page
* add-release-note
* add-context-on-output
* docs: SSRF warning (#10573)
* add-ssrf-protection-env-var
* api-request-component
* Update docs/docs/Components/components-data.mdx
* Apply suggestions from code review
Co-authored-by: April I. Murphy <[email protected]>
* move-note-to-table
* release-note
---------
Co-authored-by: April I. Murphy <[email protected]>
* docs: dynamic create data component (#10517)
* add-dynamic-create-data-component-and-release-note
* Apply suggestions from code review
Co-authored-by: April I. Murphy <[email protected]>
* clarify-message-types
---------
Co-authored-by: April I. Murphy <[email protected]>
* docs: cuga component bundle (#10589)
* initlal-content
* cuga-specific-component-connections
* cleanup
* use-the-same-name
* add-lite-mode-remove-api-flag-and-mode
* Apply suggestions from code review
Co-authored-by: April I. Murphy <[email protected]>
* public-or-private-internet
* agent-doesnt-check-urls
* peer-review
---------
Co-authored-by: April I. Murphy <[email protected]>
* docs: remove docling vlm component from 1.7 release branch (#10630)
remove-vlm-component
* docs: rename component categories and make all components single pages (#10648)
* docs: OpenAPI spec version upgraded from 1.6.5 to 1.6.8 (#10627)
Co-authored-by: github-merge-queue <[email protected]>
Co-authored-by: Mendon Kissling <[email protected]>
* up to models and agents
* sidebars
* fix-broken-links
* chore: Fix indentation on bundles-docling.mdx (#10640)
* sidebars
* redo-intros
* link-to-models
* data-components
* files-components-no-kb
* io-components
* helper-utility-components
* llm-ops-components
* logic-components
* processing-pages
* sidebars
* combine-legacy-components-into-one-page
* update-links
* remove-overview-pages-and-redirect
* make-mcp-tools-page
* Apply suggestions from code review
Co-authored-by: April I. Murphy <[email protected]>
* no-cap
---------
Co-authored-by: Hanzo Dev <[email protected]>
Co-authored-by: github-merge-queue <[email protected]>
Co-authored-by: April I. Murphy <[email protected]>
* docs: combined web search component (#10664)
* combine-pages
* remove-rss-and-news-search-and-update-links
* remove-vlm-link
* leave-old-release-note-but-remove-link
* docs: add altk reflection component (#10660)
* add-new-component
* differentiate-components
* docs: mcp streamable http client (#10621)
* release note
* mcp-client-changes
* update-astra-example
* icons-and-copy
* order-of-names
* docs: add cuga decomposition strategy as advanced parameter (#10672)
* update-component-link
* init
* add-decomp-as-advanced-param
* [autofix.ci] apply automated fixes
* [autofix.ci] apply automated fixes (attempt 2/3)
* [autofix.ci] apply automated fixes (attempt 3/3)
* Apply suggestions from code review
Co-authored-by: April I. Murphy <[email protected]>
* update-component-index
* [autofix.ci] apply automated fixes
* [autofix.ci] apply automated fixes (attempt 2/3)
* [autofix.ci] apply automated fixes (attempt 3/3)
---------
Co-authored-by: Hanzo Dev <[email protected]>
Co-authored-by: April I. Murphy <[email protected]>
* docs: datastax bundles page (#10686)
* init
* Apply suggestions from code review
Co-authored-by: April I. Murphy <[email protected]>
---------
Co-authored-by: April I. Murphy <[email protected]>
* docs: llm router changed to llm selector (#10663)
* update-component-name
* previous-name-and-release-note
* [autofix.ci] apply automated fixes
* [autofix.ci] apply automated fixes (attempt 2/3)
* [autofix.ci] apply automated fixes (attempt 3/3)
* docs: log alembic to stdout (#10711)
* docs-alembic-log-env-var
* cleanup
* remove-legacy-component-link
* docs: configure s3 for file storage backend (#10678)
* configure-file-storage-s3
* Apply suggestions from code review
Co-authored-by: April I. Murphy <[email protected]>
* Apply suggestions from code review
Co-authored-by: April I. Murphy <[email protected]>
* clarify-s3-credentials
* add-storage-tags-and-cleanup-creds-seciton
* role-link-name
* fix-parse-error
---------
Co-authored-by: April I. Murphy <[email protected]>
* docs: allow rest tweaks to mcp tools component (#10833)
* typo
* tweak-mcp-tools-component
* Apply suggestions from code review
Co-authored-by: April I. Murphy <[email protected]>
---------
Co-authored-by: April I. Murphy <[email protected]>
* add-release-note
* docs: use mustache templates in prompts (#11262)
* mustache-templating
* syntax
* release-note
* peer-review
* docs: smart transform supports Message type (#11306)
* component-supports-message-type
* Apply suggestions from code review
Co-authored-by: April I. Murphy <[email protected]>
* peer-review
---------
Co-authored-by: April I. Murphy <[email protected]>
* docs: modular dependency imports for langflow-base (#11250)
* modular-base-dependencies
* syntax-and-clarification
* release-note
* Apply suggestions from code review
Co-authored-by: April I. Murphy <[email protected]>
* [autofix.ci] apply automated fixes
* clarify-base-and-langflow
* component-index
* delete-component-index
* [autofix.ci] apply automated fixes
* set-agentic-experience
* potential-breaking-changes
* not-audio-package
* cleanup-and-syntax
* Apply suggestions from code review
Co-authored-by: April I. Murphy <[email protected]>
---------
Co-authored-by: April I. Murphy <[email protected]>
Co-authored-by: Hanzo Dev <[email protected]>
* docs: symmetric and asymmetric JWT (#11159)
* initial-content
* cleanup
* Apply suggestions from code review
Co-authored-by: April I. Murphy <[email protected]>
* [autofix.ci] apply automated fixes
* docs-peer-review
* [autofix.ci] apply automated fixes
---------
Co-authored-by: April I. Murphy <[email protected]>
Co-authored-by: Hanzo Dev <[email protected]>
* docs: add markdown output to url component (#11336)
* add-markdown-output-format
* raw-content
* Apply suggestions from code review
* docs: Add global variable support for MCP server headers (#11397)
* add-global-var-in-mcp-headers
* revert-curl-syntax-change
* remove-duplicate-tab
* Apply suggestions from code review
Co-authored-by: April I. Murphy <[email protected]>
* remove-code-block
* add-release-note
---------
Co-authored-by: April I. Murphy <[email protected]>
* Update docs/docs/Develop/install-custom-dependencies.mdx
* Update docs/docs/Develop/jwt-authentication.mdx
* docs: global model provider feature (#11231)
* initial-changes-to-model-providers
* add-icon-for-model-partial
* syntax
* adding-custom-language-model
* release-note
* Apply suggestions from code review
Co-authored-by: April I. Murphy <[email protected]>
* peer-review
* use-anthropic-model-with-agent
* [autofix.ci] apply automated fixes
* design-changes
---------
Co-authored-by: April I. Murphy <[email protected]>
Co-authored-by: Hanzo Dev <[email protected]>
* mustache-limitations
* release-note-for-jwt
* docs: playground refactor and screenshots (#11639)
* screenshots
* new-playground-and-icon
* release-note
* Apply suggestions from code review
Co-authored-by: April I. Murphy <[email protected]>
---------
Co-authored-by: April I. Murphy <[email protected]>
* docs: component inspection panel (#11675)
* docs-component-inspection-panel
* cleanup
* docs: add tool shortlisting and remove web_apps from CUGA component (#11669)
docs-add-shortlist-tools-and-remove-webapps-parameters
* fix-details-tab-error
* docs: workflow API draft build (#11323)
* delete-unused-yaml-file
* initial-content
* add-python-and-ts-to-example-requests
* separate-pages
* test-spec-presentation
* hide-async-and-make-workflows-plural
* fix-broken-link
* add-changes-to-async
* use-workflow-spec-from-sdk-build
* make-setup-partial
* add-fetch-script-for-openapi-spec
* update-workflows-spec
* remove-stream-for-now
* remove-reconnect-to-stream
* consolidate-pages
* remove-force-boolean
* [autofix.ci] apply automated fixes
* docs: add guardrails component (#11674)
* docs-add-guardrails-component
* cleanup
* example-and-heuristic-check
* Apply suggestions from code review
Co-authored-by: April I. Murphy <[email protected]>
* [autofix.ci] apply automated fixes
* add-note-about-llm
* add-release-note
---------
Co-authored-by: April I. Murphy <[email protected]>
Co-authored-by: Hanzo Dev <[email protected]>
* docs: pass env var to run command and endpoint as header (#11447)
* pass-env-var-to-lfx
* add-env-var-passing-to-run-endpoint
* add-python-and-js-commands
* docs: responses api token usage tracking (#11564)
* initlal-content
* add-release-note
* changes-for-accessing-advanced-parameters
* [autofix.ci] apply automated fixes
* [autofix.ci] apply automated fixes (attempt 2/3)
* small-playground-changes
* [autofix.ci] apply automated fixes
* Revert "docs: OpenAPI spec content updated without version change (#11787)"
This reverts commit e2f1d8db4c.
* [autofix.ci] apply automated fixes
* docs: add LiteLLM proxy bundle (#11867)
* docs-add-litellm-proxy-component
* Update docs/docs/Components/bundles-lite-llm.mdx
* docs: 1.8 changes from QA (#11998)
* remove-rightside-playground
* tutorials
* image-size-update
* component-release-notes
* Apply suggestions from code review
Co-authored-by: April I. Murphy <[email protected]>
---------
Co-authored-by: April I. Murphy <[email protected]>
* docs: pass API keys to args and not env (#11997)
* remove-rightside-playground
* tutorials
* image-size-update
* docs-troubleshoot-mcp-proxy-header-keys
* Apply suggestions from code review
Co-authored-by: April I. Murphy <[email protected]>
---------
Co-authored-by: April I. Murphy <[email protected]>
* docs: knowledge bases (#11924)
* docs-add-back-kb-content
* update-with-release-candidate-branch
* fix-linking-error
* remove-advanced-flag
* Apply suggestions from code review
Co-authored-by: April I. Murphy <[email protected]>
* add-release-note
---------
Co-authored-by: April I. Murphy <[email protected]>
* docs: traces v0 (#12014)
* env-var-release-note-and-sidebars
* traces-and-database
* traces-ui-and-api-retrieval
* cleanup
* space
* move-section
* move-what-traces-capture-section
* docs: remove kb ingestion and rename kb retrieval (#12065)
remove-knowledge-ingestion-and-rename-knowledge-retrieval
* docs: add link to secret key rotation script (#12072)
* add-link-to-secret-key-rotation
* Apply suggestions from code review
Co-authored-by: April I. Murphy <[email protected]>
---------
Co-authored-by: April I. Murphy <[email protected]>
* docs: openlayer follow-on (#12073)
* add-openlayer-to-sidebars-and-release-notes
* Update docs/docs/Support/release-notes.mdx
---------
Co-authored-by: April M <[email protected]>
Co-authored-by: Edwin Jose <[email protected]>
Co-authored-by: Hanzo Dev <[email protected]>
Co-authored-by: Hanzo Dev <[email protected]>
Co-authored-by: github-merge-queue <[email protected]>
Co-authored-by: Hanzo Dev <[email protected]>
532 lines
17 KiB
Plaintext
532 lines
17 KiB
Plaintext
---
|
|
title: Flow trigger endpoints
|
|
slug: /api-flows-run
|
|
---
|
|
|
|
import Tabs from '@theme/Tabs';
|
|
import TabItem from '@theme/TabItem';
|
|
|
|
Use the `/run` and `/webhook` endpoints to run flows.
|
|
|
|
To create, read, update, and delete flows, see [Flow management endpoints](/api-flows).
|
|
|
|
## Run flow
|
|
|
|
:::tip
|
|
Langflow automatically generates Python, JavaScript, and curl code snippets for the `/v1/run/$FLOW_ID` endpoint for all flows.
|
|
For more information, see [Generate API code snippets](/concepts-publish#generate-api-code-snippets).
|
|
:::
|
|
|
|
Execute a specified flow by ID or name.
|
|
Flow IDs can be found on the code snippets on the [**API access** pane](/concepts-publish#api-access) or in a flow's URL.
|
|
|
|
The following example runs the **Basic Prompting** template flow with flow parameters passed in the request body.
|
|
This flow requires a chat input string (`input_value`), and uses default values for all other parameters.
|
|
|
|
<Tabs>
|
|
<TabItem value="Python" label="Python" default>
|
|
|
|
```python
|
|
import requests
|
|
|
|
url = "http://LANGFLOW_SERVER_URL/api/v1/run/FLOW_ID"
|
|
|
|
# Request payload
|
|
payload = {
|
|
"input_value": "Tell me about something interesting!",
|
|
"session_id": "chat-123",
|
|
"input_type": "chat",
|
|
"output_type": "chat",
|
|
"output_component": ""
|
|
}
|
|
|
|
# Request headers
|
|
headers = {
|
|
"Content-Type": "application/json",
|
|
"x-api-key": "LANGFLOW_API_KEY"
|
|
}
|
|
|
|
try:
|
|
response = requests.post(url, json=payload, headers=headers)
|
|
response.raise_for_status()
|
|
print(response.json())
|
|
except requests.exceptions.RequestException as e:
|
|
print(f"Error making API request: {e}")
|
|
```
|
|
|
|
</TabItem>
|
|
<TabItem value="JavaScript" label="JavaScript">
|
|
|
|
```js
|
|
const payload = {
|
|
input_value: "Tell me about something interesting!",
|
|
session_id: "chat-123",
|
|
input_type: "chat",
|
|
output_type: "chat",
|
|
output_component: ""
|
|
};
|
|
|
|
const options = {
|
|
method: 'POST',
|
|
headers: {
|
|
'Content-Type': 'application/json',
|
|
'x-api-key': 'LANGFLOW_API_KEY'
|
|
},
|
|
body: JSON.stringify(payload)
|
|
};
|
|
|
|
fetch('http://LANGFLOW_SERVER_URL/api/v1/run/FLOW_ID', options)
|
|
.then(response => response.json())
|
|
.then(data => console.log(data))
|
|
.catch(err => console.error(err));
|
|
```
|
|
|
|
</TabItem>
|
|
<TabItem value="curl" label="curl">
|
|
|
|
```bash
|
|
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": ""
|
|
}'
|
|
```
|
|
|
|
</TabItem>
|
|
</Tabs>
|
|
|
|
The response from `/v1/run/$FLOW_ID` includes metadata, inputs, and outputs for the run.
|
|
|
|
<details>
|
|
<summary>Result</summary>
|
|
|
|
The following example illustrates a response from a Basic Prompting flow:
|
|
|
|
```json
|
|
{
|
|
"session_id": "chat-123",
|
|
"outputs": [{
|
|
"inputs": {
|
|
"input_value": "Tell me about something interesting!"
|
|
},
|
|
"outputs": [{
|
|
"results": {
|
|
"message": {
|
|
"text": "Sure! Have you ever heard of the phenomenon known as \"bioluminescence\"? It's a fascinating natural occurrence where living organisms produce and emit light. This ability is found in various species, including certain types of jellyfish, fireflies, and deep-sea creatures like anglerfish.\n\nBioluminescence occurs through a chemical reaction in which a light-emitting molecule called luciferin reacts with oxygen, catalyzed by an enzyme called luciferase. The result is a beautiful glow that can serve various purposes, such as attracting mates, deterring predators, or luring prey.\n\nOne of the most stunning displays of bioluminescence can be seen in the ocean, where certain plankton emit light when disturbed, creating a mesmerizing blue glow in the water. This phenomenon is often referred to as \"sea sparkle\" and can be seen in coastal areas around the world.\n\nBioluminescence not only captivates our imagination but also has practical applications in science and medicine, including the development of biosensors and imaging techniques. It's a remarkable example of nature's creativity and complexity!",
|
|
"sender": "Machine",
|
|
"sender_name": "AI",
|
|
"session_id": "chat-123",
|
|
"timestamp": "2025-03-03T17:17:37+00:00",
|
|
"flow_id": "d2bbd92b-187e-4c84-b2d4-5df365704201",
|
|
"properties": {
|
|
"source": {
|
|
"id": "OpenAIModel-d1wOZ",
|
|
"display_name": "OpenAI",
|
|
"source": "gpt-4o-mini"
|
|
},
|
|
"icon": "OpenAI"
|
|
},
|
|
"component_id": "ChatOutput-ylMzN"
|
|
}
|
|
}
|
|
}]
|
|
}]
|
|
}
|
|
```
|
|
</details>
|
|
|
|
If you are parsing the response in an application, you most likely need to extract the relevant content from the response, rather than pass the entire response back to the user.
|
|
For an example of a script that extracts data from a Langflow API response, see the [Quickstart](/get-started-quickstart).
|
|
|
|
### Stream LLM token responses
|
|
|
|
With `/v1/run/$FLOW_ID`, the flow is executed as a batch with optional LLM token response streaming.
|
|
|
|
To stream LLM token responses, append the `?stream=true` query parameter to the request:
|
|
|
|
<Tabs>
|
|
<TabItem value="Python" label="Python" default>
|
|
|
|
```python
|
|
import requests
|
|
|
|
url = "http://LANGFLOW_SERVER_URL/api/v1/run/FLOW_ID?stream=true"
|
|
|
|
# Request payload
|
|
payload = {
|
|
"message": "Tell me something interesting!",
|
|
"session_id": "chat-123"
|
|
}
|
|
|
|
# Request headers
|
|
headers = {
|
|
"accept": "application/json",
|
|
"Content-Type": "application/json",
|
|
"x-api-key": "LANGFLOW_API_KEY"
|
|
}
|
|
|
|
try:
|
|
response = requests.post(url, json=payload, headers=headers, stream=True)
|
|
response.raise_for_status()
|
|
|
|
# Process streaming response
|
|
for line in response.iter_lines():
|
|
if line:
|
|
print(line.decode('utf-8'))
|
|
except requests.exceptions.RequestException as e:
|
|
print(f"Error making API request: {e}")
|
|
```
|
|
|
|
</TabItem>
|
|
<TabItem value="JavaScript" label="JavaScript">
|
|
|
|
```js
|
|
const payload = {
|
|
message: "Tell me something interesting!",
|
|
session_id: "chat-123"
|
|
};
|
|
|
|
const options = {
|
|
method: 'POST',
|
|
headers: {
|
|
'accept': 'application/json',
|
|
'Content-Type': 'application/json',
|
|
'x-api-key': 'LANGFLOW_API_KEY'
|
|
},
|
|
body: JSON.stringify(payload)
|
|
};
|
|
|
|
fetch('http://LANGFLOW_SERVER_URL/api/v1/run/FLOW_ID?stream=true', options)
|
|
.then(async response => {
|
|
const reader = response.body?.getReader();
|
|
const decoder = new TextDecoder();
|
|
|
|
if (reader) {
|
|
while (true) {
|
|
const { done, value } = await reader.read();
|
|
if (done) break;
|
|
console.log(decoder.decode(value));
|
|
}
|
|
}
|
|
})
|
|
.catch(err => console.error(err));
|
|
```
|
|
|
|
</TabItem>
|
|
<TabItem value="curl" label="curl">
|
|
|
|
```bash
|
|
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"
|
|
}'
|
|
```
|
|
|
|
</TabItem>
|
|
</Tabs>
|
|
|
|
LLM chat responses are streamed back as `token` events, culminating in a final `end` event that closes the connection.
|
|
|
|
<details>
|
|
<summary>Result</summary>
|
|
|
|
The following example is truncated to illustrate a series of `token` events as well as the final `end` event that closes the LLM's token streaming response:
|
|
|
|
```text
|
|
{"event": "add_message", "data": {"timestamp": "2025-03-03T17:20:18", "sender": "User", "sender_name": "User", "session_id": "chat-123", "text": "Tell me about something interesting!", "files": [], "error": false, "edit": false, "properties": {"text_color": "", "background_color": "", "edited": false, "source": {"id": null, "display_name": null, "source": null}, "icon": "", "allow_markdown": false, "positive_feedback": null, "state": "complete", "targets": []}, "category": "message", "content_blocks": [], "id": "0103a21b-ebf7-4c02-9d72-017fb297f812", "flow_id": "d2bbd92b-187e-4c84-b2d4-5df365704201"}}
|
|
|
|
{"event": "add_message", "data": {"timestamp": "2025-03-03T17:20:18", "sender": "Machine", "sender_name": "AI", "session_id": "chat-123", "text": "", "files": [], "error": false, "edit": false, "properties": {"text_color": "", "background_color": "", "edited": false, "source": {"id": "OpenAIModel-d1wOZ", "display_name": "OpenAI", "source": "gpt-4o-mini"}, "icon": "OpenAI", "allow_markdown": false, "positive_feedback": null, "state": "complete", "targets": []}, "category": "message", "content_blocks": [], "id": "27b66789-e673-4c65-9e81-021752925161", "flow_id": "d2bbd92b-187e-4c84-b2d4-5df365704201"}}
|
|
|
|
{"event": "token", "data": {"chunk": " Have", "id": "27b66789-e673-4c65-9e81-021752925161", "timestamp": "2025-03-03 17:20:18 UTC"}}
|
|
|
|
{"event": "token", "data": {"chunk": " you", "id": "27b66789-e673-4c65-9e81-021752925161", "timestamp": "2025-03-03 17:20:18 UTC"}}
|
|
|
|
{"event": "token", "data": {"chunk": " ever", "id": "27b66789-e673-4c65-9e81-021752925161", "timestamp": "2025-03-03 17:20:18 UTC"}}
|
|
|
|
{"event": "token", "data": {"chunk": " heard", "id": "27b66789-e673-4c65-9e81-021752925161", "timestamp": "2025-03-03 17:20:18 UTC"}}
|
|
|
|
{"event": "token", "data": {"chunk": " of", "id": "27b66789-e673-4c65-9e81-021752925161", "timestamp": "2025-03-03 17:20:18 UTC"}}
|
|
|
|
{"event": "token", "data": {"chunk": " the", "id": "27b66789-e673-4c65-9e81-021752925161", "timestamp": "2025-03-03 17:20:18 UTC"}}
|
|
|
|
{"event": "token", "data": {"chunk": " phenomenon", "id": "27b66789-e673-4c65-9e81-021752925161", "timestamp": "2025-03-03 17:20:18 UTC"}}
|
|
|
|
{"event": "end", "data": {"result": {"session_id": "chat-123", "message": "Sure! Have you ever heard of the phenomenon known as \"bioluminescence\"?..."}}}
|
|
```
|
|
|
|
</details>
|
|
|
|
### Run endpoint headers
|
|
|
|
| Header | Info | Example |
|
|
|--------|------|---------|
|
|
| Content-Type | Required. Specifies the JSON format. | "application/json" |
|
|
| accept | Optional. Specifies the response format. Defaults to JSON if not specified. | "application/json" |
|
|
| x-api-key | Required. Your Langflow API key for authentication. Can be passed as a header or query parameter. | "sk-..." |
|
|
| `X-LANGFLOW-GLOBAL-VAR-*` | Optional. Pass global variables to the flow. Variable names are automatically converted to uppercase. These variables take precedence over OS environment variables and are only available during this specific request execution. | `"X-LANGFLOW-GLOBAL-VAR-API_KEY: sk-..."` |
|
|
|
|
### Run endpoint parameters
|
|
|
|
| Parameter | Type | Info |
|
|
|-----------|------|------|
|
|
| flow_id | UUID/string | Required. Part of URL: `/run/$FLOW_ID` |
|
|
| stream | Boolean | Optional. Query parameter: `/run/$FLOW_ID?stream=true` |
|
|
| input_value | string | Optional. JSON body field. Main input text/prompt. Default: `null` |
|
|
| input_type | string | Optional. JSON body field. Input type ("chat" or "text"). Default: `"chat"` |
|
|
| output_type | string | Optional. JSON body field. Output type ("chat", "any", "debug"). Default: `"chat"` |
|
|
| output_component | string | Optional. JSON body field. Target component for output. Default: `""` |
|
|
| tweaks | object | Optional. JSON body field. Component adjustments. Default: `null` |
|
|
| session_id | string | Optional. JSON body field. Conversation context ID. See [Session ID](/session-id). Default: `null` |
|
|
|
|
### Request example with all headers and parameters
|
|
|
|
<Tabs>
|
|
<TabItem value="Python" label="Python" default>
|
|
|
|
```python
|
|
import requests
|
|
|
|
url = "http://LANGFLOW_SERVER_URL/api/v1/run/FLOW_ID?stream=true"
|
|
|
|
# Request payload with tweaks
|
|
payload = {
|
|
"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"
|
|
}
|
|
}
|
|
}
|
|
|
|
# Request headers
|
|
headers = {
|
|
"Content-Type": "application/json",
|
|
"accept": "application/json",
|
|
"x-api-key": "LANGFLOW_API_KEY"
|
|
}
|
|
|
|
try:
|
|
response = requests.post(url, json=payload, headers=headers, stream=True)
|
|
response.raise_for_status()
|
|
|
|
# Process streaming response
|
|
for line in response.iter_lines():
|
|
if line:
|
|
print(line.decode('utf-8'))
|
|
except requests.exceptions.RequestException as e:
|
|
print(f"Error making API request: {e}")
|
|
```
|
|
|
|
</TabItem>
|
|
<TabItem value="JavaScript" label="JavaScript">
|
|
|
|
```js
|
|
const payload = {
|
|
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"
|
|
}
|
|
}
|
|
};
|
|
|
|
const options = {
|
|
method: 'POST',
|
|
headers: {
|
|
'Content-Type': 'application/json',
|
|
'accept': 'application/json',
|
|
'x-api-key': 'LANGFLOW_API_KEY'
|
|
},
|
|
body: JSON.stringify(payload)
|
|
};
|
|
|
|
fetch('http://LANGFLOW_SERVER_URL/api/v1/run/FLOW_ID?stream=true', options)
|
|
.then(async response => {
|
|
const reader = response.body?.getReader();
|
|
const decoder = new TextDecoder();
|
|
|
|
if (reader) {
|
|
while (true) {
|
|
const { done, value } = await reader.read();
|
|
if (done) break;
|
|
console.log(decoder.decode(value));
|
|
}
|
|
}
|
|
})
|
|
.catch(err => console.error(err));
|
|
```
|
|
|
|
</TabItem>
|
|
<TabItem value="curl" label="curl">
|
|
|
|
```bash
|
|
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"
|
|
}
|
|
}
|
|
}'
|
|
```
|
|
|
|
</TabItem>
|
|
</Tabs>
|
|
|
|
### Pass global variables in request headers {#pass-global-variables-in-headers}
|
|
|
|
You can pass global variables to your flow using HTTP headers with the format `X-LANGFLOW-GLOBAL-VAR-{VARIABLE_NAME}`.
|
|
|
|
Variables passed in headers take precedence over OS environment variables. If a variable is provided in both a header and an environment variable, the header value is used. Variables are only available during this specific request execution and aren't persisted.
|
|
|
|
Variable names are automatically converted to uppercase. For example, `X-LANGFLOW-GLOBAL-VAR-api-key` becomes `API_KEY` in your flow.
|
|
|
|
You don't need to create these variables in Langflow's Global Variables section first. Pass any variable name using this header format.
|
|
|
|
<Tabs>
|
|
<TabItem value="Python" label="Python" default>
|
|
|
|
```python
|
|
import requests
|
|
|
|
url = "http://LANGFLOW_SERVER_URL/api/v1/run/FLOW_ID"
|
|
|
|
# Request payload
|
|
payload = {
|
|
"input_value": "Tell me about something interesting!",
|
|
"input_type": "chat",
|
|
"output_type": "chat"
|
|
}
|
|
|
|
# Request headers with global variables
|
|
headers = {
|
|
"Content-Type": "application/json",
|
|
"x-api-key": "LANGFLOW_API_KEY",
|
|
"X-LANGFLOW-GLOBAL-VAR-OPENAI_API_KEY": "sk-...",
|
|
"X-LANGFLOW-GLOBAL-VAR-USER_ID": "user123",
|
|
"X-LANGFLOW-GLOBAL-VAR-ENVIRONMENT": "production"
|
|
}
|
|
|
|
try:
|
|
response = requests.post(url, json=payload, headers=headers)
|
|
response.raise_for_status()
|
|
print(response.json())
|
|
except requests.exceptions.RequestException as e:
|
|
print(f"Error making API request: {e}")
|
|
```
|
|
|
|
</TabItem>
|
|
<TabItem value="JavaScript" label="JavaScript">
|
|
|
|
```js
|
|
const payload = {
|
|
input_value: "Tell me about something interesting!",
|
|
input_type: "chat",
|
|
output_type: "chat"
|
|
};
|
|
|
|
const options = {
|
|
method: 'POST',
|
|
headers: {
|
|
'Content-Type': 'application/json',
|
|
'x-api-key': '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(payload)
|
|
};
|
|
|
|
fetch('http://LANGFLOW_SERVER_URL/api/v1/run/FLOW_ID', options)
|
|
.then(response => response.json())
|
|
.then(data => console.log(data))
|
|
.catch(err => console.error(err));
|
|
```
|
|
|
|
</TabItem>
|
|
<TabItem value="curl" label="curl">
|
|
|
|
```bash
|
|
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"
|
|
}'
|
|
```
|
|
|
|
</TabItem>
|
|
</Tabs>
|
|
|
|
If your flow components reference variables that aren't provided in headers or your Langflow database, the flow fails by default. To avoid this, you can set `LANGFLOW_FALLBACK_TO_ENV_VAR=True` in your `.env` file, which allows the flow to use values from OS environment variables if they aren't otherwise specified.
|
|
|
|
|
|
## Webhook run flow
|
|
|
|
Use the `/webhook` endpoint to start a flow by sending an HTTP `POST` request.
|
|
|
|
:::tip
|
|
After you add a [**Webhook** component](/webhook) to a flow, open the [**API access** pane](/concepts-publish), and then click the **Webhook curl** tab to get an automatically generated `POST /webhook` request for your flow.
|
|
For more information, see [Trigger flows with webhooks](/webhook).
|
|
:::
|
|
|
|
```bash
|
|
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"}'
|
|
```
|
|
|
|
<details>
|
|
<summary>Result</summary>
|
|
|
|
```json
|
|
{
|
|
"message": "Task started in the background",
|
|
"status": "in progress"
|
|
}
|
|
```
|
|
|
|
</details>
|
|
|
|
## Deprecated flow trigger endpoints
|
|
|
|
The following endpoints are deprecated and replaced by the `/run` endpoint:
|
|
|
|
* `/process`
|
|
* `/predict` |