API pane
The API pane presents code templates for integrating your flow into external applications.

cURL​
-The cURL tab displays sample code for posting a query to your flow. Modify the input_value to change your input message. Copy the code and run it to post a query to your flow and get the result.
Python API​
-The Python API tab displays code to interact with your flow using the Python HTTP requests library.
To use the requests library:
-
+
- curl
- Python API
- JS API
- Python code
- Copy and paste the code into a Python script.
- Run the script and pass your message with it. -
- Copy and paste the code into a JavaScript file. +
- Run the script with any necessary arguments for your flow: +
-
In your Workspace, click Settings, and then select Export.
@@ -49,19 +43,12 @@
-
-
Copy and paste the code from the API tab into a Python script file. -It will look like this:
+Copy and paste the code from the API tab into a Python script file.
- - Run the script: -
-
+
Run the script:
+
+
The cURL tab displays sample code for posting a query to your flow. Modify the input_value to change your input message. Copy the code and run it to post a query to your flow and get the result.
The Python API tab displays code to interact with your flow using the Python HTTP requests library.
To use the requests library:
_10python3 python-api-script.py --message="tell me about something interesting"
Python code​
-The Python Code tab displays code to interact with your flow's .json file using the Langflow runtime.
To use your code in a Python application using the Langflow runtime, you have to first download your flow’s JSON file.
--
+
_10python3 python-test-script.py --message="tell me about something interesting"
The JavaScript API tab displays code to interact with your flow in JavaScript.
-
+
_10node test-script.js "tell me about something interesting"
The response content depends on your flow. Make sure the endpoint returns a successful response.
The Python Code tab displays code to interact with your flow's .json file using the Langflow runtime.
To use your code in a Python application using the Langflow runtime, you have to first download your flow’s JSON file.
Download the flow to your local machine. Make sure the flow path in the script matches the flow’s location on your machine.
_14from langflow.load import run_flow_from_json_14TWEAKS = {_14 "ChatInput-kKhri": {},_14 "Prompt-KDSi5": {},_14 "ChatOutput-Vr3Q7": {},_14 "OpenAIModel-4xYtx": {}_14}_14_14result = run_flow_from_json(flow="./basic-prompting-local.json",_14 input_value="tell me about something interesting",_14 fallback_to_env_vars=True, # False by default_14 tweaks=TWEAKS)_14_14print(result)
-
-
_10python3 python-api-script.py
Tweaks​
-The Tweaks tab displays the available parameters for your flow. Modifying the parameters changes the code parameters across all windows. For example, changing the Chat Input component's input_value will change that value across all API calls.
Send image files to your flow with the API​
-For information on sending files to the Langflow API, see API examples.
+
_10python python-test-script.py
Chat Widget​
The Chat Widget HTML tab displays code that can be inserted in the <body> of your HTML to interact with your flow.
The Langflow Chat Widget is a powerful web component that enables communication with a Langflow project. This widget allows for a chat interface embedding, allowing the integration of Langflow into web applications effortlessly.
@@ -96,9 +83,13 @@ It will look like this:Use the widget API to customize your Chat Widget:
Props with the type JSON need to be passed as stringified JSONs, with the format {"key":"value"}.
| Prop | Type | Required | Description |
|---|---|---|---|
| bot_message_style | JSON | No | Applies custom formatting to bot messages. |
| chat_input_field | String | Yes | Defines the type of the input field for chat messages. |
| chat_inputs | JSON | Yes | Determines the chat input elements and their respective values. |
| chat_output_key | String | No | Specifies which output to display if multiple outputs are available. |
| chat_position | String | No | Positions the chat window on the screen (options include: top-left, top-center, top-right, center-left, center-right, bottom-right, bottom-center, bottom-left). |
| chat_trigger_style | JSON | No | Styles the chat trigger button. |
| chat_window_style | JSON | No | Customizes the overall appearance of the chat window. |
| error_message_style | JSON | No | Sets the format for error messages within the chat window. |
| flow_id | String | Yes | Identifies the flow that the component is associated with. |
| height | Number | No | Sets the height of the chat window in pixels. |
| host_url | String | Yes | Specifies the URL of the host for chat component communication. |
| input_container_style | JSON | No | Applies styling to the container where chat messages are entered. |
| input_style | JSON | No | Sets the style for the chat input field. |
| online | Boolean | No | Toggles the online status of the chat component. |
| online_message | String | No | Sets a custom message to display when the chat component is online. |
| placeholder | String | No | Sets the placeholder text for the chat input field. |
| placeholder_sending | String | No | Sets the placeholder text to display while a message is being sent. |
| send_button_style | JSON | No | Sets the style for the send button in the chat window. |
| send_icon_style | JSON | No | Sets the style for the send icon in the chat window. |
| tweaks | JSON | No | Applies additional custom adjustments for the associated flow. |
| user_message_style | JSON | No | Determines the formatting for user messages in the chat window. |
| width | Number | No | Sets the width of the chat window in pixels. |
| window_title | String | No | Sets the title displayed in the chat window's header or title bar. |
Tweaks​
+The Tweaks tab displays the available parameters for your flow. Modifying the parameters changes the code parameters across all windows. For example, changing the Chat Input component's input_value will change that value across all API calls.
Send image files to your flow with the API​
+For information on sending files to the Langflow API, see API examples.
Webhook cURL​
When a Webhook component is added to the workspace, a new Webhook cURL tab becomes available in the API pane that contains an HTTP POST request for triggering the webhook component. For example:
_10curl -X POST \_10 "http://127.0.0.1:7860/api/v1/webhook/**YOUR_FLOW_ID**" \_10 -H 'Content-Type: application/json'\_10 -d '{"any": "data"}'
To test the Webhook component in your flow, see the Webhook component.