From aacc0e0874be0fe95ce5473f50e854ec4212a8eb Mon Sep 17 00:00:00 2001 From: Mendon Kissling <59585235+mendonk@users.noreply.github.com> Date: Tue, 24 Jun 2025 17:38:16 -0400 Subject: [PATCH 01/28] add-api-key-header-to-examples --- docs/docs/Components/components-data.md | 3 +- docs/docs/Components/components-io.md | 3 ++ docs/docs/Components/components-processing.md | 4 ++ docs/docs/Concepts/concepts-playground.md | 2 + .../Configuration/configuration-api-keys.md | 22 +++++--- docs/docs/Develop/session-id.md | 1 + docs/docs/Develop/webhook.md | 1 + .../Get-Started/get-started-quickstart.md | 53 +++++++++++++++---- 8 files changed, 70 insertions(+), 19 deletions(-) diff --git a/docs/docs/Components/components-data.md b/docs/docs/Components/components-data.md index 5b2e612614b0..e12fc644d7c8 100644 --- a/docs/docs/Components/components-data.md +++ b/docs/docs/Components/components-data.md @@ -269,7 +269,8 @@ When a **Webhook** component is added to the workspace, a new **Webhook cURL** t ```bash curl -X POST \ "http://localhost:7860/api/v1/webhook/**YOUR_FLOW_ID**" \ - -H 'Content-Type: application/json'\ + -H 'Content-Type: application/json' \ + -H 'x-api-key: LANGFLOW_API_KEY' \ -d '{"any": "data"}' ``` diff --git a/docs/docs/Components/components-io.md b/docs/docs/Components/components-io.md index 37066983292a..96ad783f0ad0 100644 --- a/docs/docs/Components/components-io.md +++ b/docs/docs/Components/components-io.md @@ -213,6 +213,7 @@ It looks similar to this: curl --request POST \ --url 'http://localhost:7860/api/v1/run/51eed711-4530-4fdc-9bce-5db4351cc73a?stream=false' \ --header 'Content-Type: application/json' \ + --header 'x-api-key: LANGFLOW_API_KEY' \ --data '{ "input_value": "What's the recommended way to install Docker on Mac M1?", "output_type": "chat", @@ -228,6 +229,7 @@ Note the `output_type` and `input_type` parameters that are passed with the mess curl --request POST \ --url 'http://localhost:7860/api/v1/run/51eed711-4530-4fdc-9bce-5db4351cc73a?stream=false' \ --header 'Content-Type: application/json' \ + --header 'x-api-key: LANGFLOW_API_KEY' \ --data '{ "input_value": "Whats the recommended way to install Docker on Mac M1", "session_id": "docker-question-on-m1", @@ -248,6 +250,7 @@ For example, disabling storing messages from the **Chat Input** component adds a curl --request POST \ --url 'http://localhost:7860/api/v1/run/51eed711-4530-4fdc-9bce-5db4351cc73a?stream=false' \ --header 'Content-Type: application/json' \ + --header 'x-api-key: LANGFLOW_API_KEY' \ --data '{ "input_value": "Text to input to the flow", "output_type": "chat", diff --git a/docs/docs/Components/components-processing.md b/docs/docs/Components/components-processing.md index a3ef0c8aa2e2..49acc440600e 100644 --- a/docs/docs/Components/components-processing.md +++ b/docs/docs/Components/components-processing.md @@ -114,6 +114,7 @@ Replace `YOUR_FLOW_ID` with your flow ID. ```bash curl -X POST "http://localhost:7860/api/v1/webhook/YOUR_FLOW_ID" \ -H 'Content-Type: application/json' \ +-H 'x-api-key: LANGFLOW_API_KEY' \ -d '{ "id": 1, "name": "Leanne Graham", @@ -207,6 +208,7 @@ This example uses the default Langflow server address. ```text curl -X POST "http://localhost:7860/api/v1/webhook/YOUR_FLOW_ID" \ -H 'Content-Type: application/json' \ +-H 'x-api-key: LANGFLOW_API_KEY' \ -d '{ "text": "Alex Cruz - Employee Profile", "data": { @@ -229,6 +231,7 @@ The **Data to DataFrame** component converts the webhook request into a `DataFra ```text curl -X POST "http://localhost:7860/api/v1/webhook/YOUR_FLOW_ID" \ -H 'Content-Type: application/json' \ +-H 'x-api-key: LANGFLOW_API_KEY' \ -d '{ "text": "Kalani Smith - Employee Profile", "data": { @@ -414,6 +417,7 @@ This example uses the default Langflow server address. ```text curl -X POST "http://localhost:7860/api/v1/webhook/YOUR_FLOW_ID" \ -H 'Content-Type: application/json' \ +-H 'x-api-key: LANGFLOW_API_KEY' \ -d '{ "Name": ["Alex Cruz", "Kalani Smith", "Noam Johnson"], "Role": ["Developer", "Designer", "Manager"], diff --git a/docs/docs/Concepts/concepts-playground.md b/docs/docs/Concepts/concepts-playground.md index c06e075d8b67..d46bf501d0ea 100644 --- a/docs/docs/Concepts/concepts-playground.md +++ b/docs/docs/Concepts/concepts-playground.md @@ -45,6 +45,7 @@ To post a message to a flow with a specific Session ID with curl, enter the foll ```bash curl -X POST "http://localhost:7860/api/v1/run/$FLOW_ID" \ -H 'Content-Type: application/json' \ + -H 'x-api-key: LANGFLOW_API_KEY' \ -d '{ "session_id": "custom_session_123", "input_value": "message", @@ -78,6 +79,7 @@ This example sends a base64-encoded image to the Playground using curl: ```bash curl -X POST "http://localhost:7860/api/v1/run/$FLOW_ID" \ -H 'Content-Type: application/json' \ +-H 'x-api-key: LANGFLOW_API_KEY' \ -d '{ "session_id": "custom_session_123", "input_value": "What is in this image?", diff --git a/docs/docs/Configuration/configuration-api-keys.md b/docs/docs/Configuration/configuration-api-keys.md index 50a43be05359..40cc1f6858da 100644 --- a/docs/docs/Configuration/configuration-api-keys.md +++ b/docs/docs/Configuration/configuration-api-keys.md @@ -16,16 +16,25 @@ Generate a user-specific token to use with Langflow. ### Generate an API key with the Langflow UI 1. Click your user icon, and then select **Settings**. -2. Click **Langflow API**, and then click **Add New**. -3. Name your key, and then click **Create Secret Key**. +2. Click **Langflow API Keys**, and then click **Add New**. +3. Name your key, and then click **Create API Key**. 4. Copy the API key and store it in a secure location. ### Generate an API key with the Langflow CLI +This command only works if `AUTO_LOGIN` is set to `FALSE` and the user is a superuser. + +For example, if you're serving your flow with `--backend-only=true`, you don't have a way to create an API key within the UI. + +``` +LANGFLOW_AUTO_LOGIN=False +LANGFLOW_SUPERUSER=admin +LANGFLOW_SUPERUSER_PASSWORD=password +``` + ```shell -langflow api-key -# or -python -m langflow api-key +uv run langflow api-key + ╭─────────────────────────────────────────────────────────────────────╮ │ API Key Created Successfully: │ │ │ @@ -36,7 +45,6 @@ python -m langflow api-key │ │ │ The API key has been copied to your clipboard. Cmd + V to paste it. │ ╰────────────────────────────── - ``` ## Authenticate requests with the Langflow API key @@ -53,7 +61,7 @@ To use the API key when making API requests, include the API key in the HTTP hea curl -X POST \ "http://localhost:7860/api/v1/run/FLOW_ID?stream=false" \ -H 'Content-Type: application/json' \ - -H 'x-api-key: API_KEY' \ + -H 'x-api-key: LANGFLOW_API_KEY' \ -d '{"inputs": {"text":""}, "tweaks": {}}' ``` diff --git a/docs/docs/Develop/session-id.md b/docs/docs/Develop/session-id.md index 850c52831a09..1c226e91a1b2 100644 --- a/docs/docs/Develop/session-id.md +++ b/docs/docs/Develop/session-id.md @@ -21,6 +21,7 @@ If you set a custom session ID in a payload, all downstream components use the u curl --request POST \ --url 'http://localhost:7860/api/v1/run/$FLOW_ID' \ --header 'Content-Type: application/json' \ + --header 'x-api-key: LANGFLOW_API_KEY' \ --data '{ "input_value": "Hello", "output_type": "chat", diff --git a/docs/docs/Develop/webhook.md b/docs/docs/Develop/webhook.md index 7e0264ebd869..cb116f49ec97 100644 --- a/docs/docs/Develop/webhook.md +++ b/docs/docs/Develop/webhook.md @@ -34,6 +34,7 @@ Replace **FLOW_ID** with your flow's ID, which can be found on the [Publish pane ```bash curl -X POST "http://localhost:7860/api/v1/webhook/YOUR_FLOW_ID" \ -H 'Content-Type: application/json' \ + -H 'x-api-key: LANGFLOW_API_KEY' \ -d '{"id": "12345", "name": "alex", "email": "alex@email.com"}' ``` diff --git a/docs/docs/Get-Started/get-started-quickstart.md b/docs/docs/Get-Started/get-started-quickstart.md index 0f9d76250bfd..ba49c8ee846f 100644 --- a/docs/docs/Get-Started/get-started-quickstart.md +++ b/docs/docs/Get-Started/get-started-quickstart.md @@ -13,6 +13,30 @@ Get started with Langflow by loading a template flow, running it, and then servi - [A running Langflow instance](/get-started-installation) - [An OpenAI API key](https://platform.openai.com/api-keys) +- [A Langflow API key](/configuration-api-keys) + +
+Need help creating an API key? + +To generate a user-specific token to use with Langflow, do the following. + +1. Open the Langflow UI, click your user icon, and then select **Settings**. +2. Click **Langflow API Keys**, and then click **Add New**. +3. Name your key, and then click **Create API Key**. +4. Copy the API key and store it in a secure location. +5. Include your `LANGFLOW_API_KEY` in requests like this: + ``` + curl --request POST \ + --url 'http://localhost:7860/api/v1/run/0901b40b-9212-41cb-87c6-ac66a427913c?stream=false' \ + --header 'Content-Type: application/json' \ + --header 'x-api-key: LANGFLOW_API_KEY' \ + --data '{ + "output_type": "chat", + "input_type": "chat", + "input_value": "Hello" + }' + ``` +
## Run the Simple Agent template flow @@ -88,7 +112,8 @@ Langflow provides code snippets to help you get started with the Langflow API. # Request headers headers = { - "Content-Type": "application/json" + "Content-Type": "application/json", + "x-api-key: LANGFLOW_API_KEY" } try: @@ -119,7 +144,8 @@ Langflow provides code snippets to help you get started with the Langflow API. const options = { method: 'POST', headers: { - 'Content-Type': 'application/json' + 'Content-Type': 'application/json', + 'x-api-key: LANGFLOW_API_KEY' }, body: JSON.stringify(payload) }; @@ -136,13 +162,14 @@ Langflow provides code snippets to help you get started with the Langflow API. ```text curl --request POST \ - --url 'http://LANGFLOW_SERVER_ADDRESS/api/v1/run/FLOW_ID?stream=false' \ - --header 'Content-Type: application/json' \ - --data '{ - "output_type": "chat", - "input_type": "chat", - "input_value": "hello world!" - }' + --url 'http://localhost:7860/api/v1/run/0901b40b-9212-41cb-87c6-ac66a427913c?stream=false' \ + --header 'Content-Type: application/json' \ + --header 'x-api-key: LANGFLOW_API_KEY' \ + --data '{ + "output_type": "chat", + "input_type": "chat", + "input_value": "Hello" + }' # A 200 response confirms the call succeeded. ``` @@ -353,7 +380,10 @@ This script runs a question-and-answer chat in your terminal and stores the Agen "input_value": question, } - headers = {"Content-Type": "application/json"} + headers = { + "Content-Type": "application/json", + "x-api-key: LANGFLOW_API_KEY" + } try: response = requests.post(url, json=payload, headers=headers) @@ -426,7 +456,8 @@ This script runs a question-and-answer chat in your terminal and stores the Agen const options = { method: 'POST', headers: { - 'Content-Type': 'application/json' + 'Content-Type': 'application/json', + 'x-api-key: LANGFLOW_API_KEY' }, body: JSON.stringify(payload) }; From 07d073f9865b92e030db749bb17b11b54db0baa4 Mon Sep 17 00:00:00 2001 From: Mendon Kissling <59585235+mendonk@users.noreply.github.com> Date: Tue, 24 Jun 2025 18:17:43 -0400 Subject: [PATCH 02/28] api-examples-add-keys --- docs/docs/API-Reference/api-build.md | 8 +++++-- docs/docs/API-Reference/api-files.md | 16 +++++++++---- docs/docs/API-Reference/api-flows-run.md | 5 +++- docs/docs/API-Reference/api-flows.md | 20 ++++++++++++---- docs/docs/API-Reference/api-logs.md | 6 +++-- docs/docs/API-Reference/api-monitor.md | 23 +++++++++++++------ docs/docs/API-Reference/api-projects.md | 14 ++++++++--- .../api-reference-api-examples.md | 11 +++++---- docs/docs/API-Reference/api-users.md | 1 + 9 files changed, 75 insertions(+), 29 deletions(-) diff --git a/docs/docs/API-Reference/api-build.md b/docs/docs/API-Reference/api-build.md index f977348dce73..b1f3a86416c4 100644 --- a/docs/docs/API-Reference/api-build.md +++ b/docs/docs/API-Reference/api-build.md @@ -32,6 +32,7 @@ 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" @@ -59,7 +60,8 @@ curl -X POST \ ```text curl -X GET \ "$LANGFLOW_URL/api/v1/build/123e4567-e89b-12d3-a456-426614174000/events" \ - -H "accept: application/json" + -H "accept: application/json" \ + -H "x-api-key: $LANGFLOW_API_KEY" ``` @@ -84,7 +86,8 @@ To disable streaming and get all events at once, set `stream` to `false`. ```text curl -X GET \ "$LANGFLOW_URL/api/v1/build/123e4567-e89b-12d3-a456-426614174000/events?stream=false" \ - -H "accept: application/json" + -H "accept: application/json" \ + -H "x-api-key: $LANGFLOW_API_KEY" ``` ## Build headers @@ -136,6 +139,7 @@ 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": [], diff --git a/docs/docs/API-Reference/api-files.md b/docs/docs/API-Reference/api-files.md index 0b22a01e929a..703d6479fd38 100644 --- a/docs/docs/API-Reference/api-files.md +++ b/docs/docs/API-Reference/api-files.md @@ -43,6 +43,7 @@ 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=@FILE_NAME.txt" ``` @@ -72,6 +73,7 @@ For more information, see [Supported environment variables](/environment-variabl ```bash curl -X POST "$LANGFLOW_URL/api/v1/files/upload/a430cc57-06bb-4c11-be39-d3d4de68d2c4" \ -H "Content-Type: multipart/form-data" \ + -H "x-api-key: $LANGFLOW_API_KEY" \ -F "file=@FILE_NAME.png" ``` @@ -92,7 +94,8 @@ The API returns the image file path in the format `"file_path":"/< ```bash curl -X POST \ "$LANGFLOW_URL/api/v1/run/a430cc57-06bb-4c11-be39-d3d4de68d2c4?stream=false" \ - -H 'Content-Type: application/json'\ + -H 'Content-Type: application/json' \ + -H "x-api-key: $LANGFLOW_API_KEY" \ -d '{ "output_type": "chat", "input_type": "chat", @@ -120,7 +123,8 @@ List all files associated with a specific flow. ```bash curl -X GET \ "$LANGFLOW_URL/api/v1/files/list/$FLOW_ID" \ - -H "accept: application/json" + -H "accept: application/json" \ + -H "x-api-key: $LANGFLOW_API_KEY" ``` @@ -146,6 +150,7 @@ Download a specific file from a flow. 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 ``` @@ -169,7 +174,8 @@ Delete a specific file from a flow. ```bash 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 "accept: application/json" \ + -H "x-api-key: $LANGFLOW_API_KEY" ``` @@ -201,7 +207,8 @@ To retrieve your current `user_id`, call the `/whoami` endpoint. ```bash curl -X GET \ "$LANGFLOW_URL/api/v1/users/whoami" \ - -H "accept: application/json" + -H "accept: application/json" \ + -H "x-api-key: $LANGFLOW_API_KEY" ``` Result: @@ -280,6 +287,7 @@ In this example, the file uploaded to `/v2/files` is included with the `/v1/run` 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", diff --git a/docs/docs/API-Reference/api-flows-run.md b/docs/docs/API-Reference/api-flows-run.md index 463f3c3fb46d..5ff6e4525328 100644 --- a/docs/docs/API-Reference/api-flows-run.md +++ b/docs/docs/API-Reference/api-flows-run.md @@ -27,6 +27,7 @@ The parameters are passed in the request body. In this example, the values are t curl -X POST \ "$LANGFLOW_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", @@ -87,6 +88,7 @@ curl -X POST \ "$LANGFLOW_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" @@ -151,7 +153,7 @@ curl -X POST \ "http://$LANGFLOW_URL/api/v1/run/$FLOW_ID?stream=true" \ -H "Content-Type: application/json" \ -H "accept: application/json" \ - -H "x-api-key: sk-..." \ + -H "x-api-key: $LANGFLOW_API_KEY" \ -d '{ "input_value": "Tell me a story", "input_type": "chat", @@ -178,6 +180,7 @@ After you add a **Webhook** component to a flow, open the [**API access** pane]( curl -X POST \ "$LANGFLOW_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/docs/API-Reference/api-flows.md b/docs/docs/API-Reference/api-flows.md index 15e99eea7839..b98b6733d25e 100644 --- a/docs/docs/API-Reference/api-flows.md +++ b/docs/docs/API-Reference/api-flows.md @@ -22,6 +22,7 @@ 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", @@ -74,6 +75,7 @@ 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": [ { @@ -126,7 +128,8 @@ Retrieves a specific flow by its ID. ```bash curl -X GET \ "$LANGFLOW_URL/api/v1/flows/$FLOW_ID" \ - -H "accept: application/json" + -H "accept: application/json" \ + -H "x-api-key: $LANGFLOW_API_KEY" ``` @@ -160,7 +163,8 @@ Retrieve all flows with pagination: ```bash 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 "accept: application/json" \ + -H "x-api-key: $LANGFLOW_API_KEY" ``` To retrieve flows from a specific project, use the `project_id` query parameter: @@ -168,7 +172,8 @@ To retrieve flows from a specific project, use the `project_id` query parameter: ```bash 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 "accept: application/json" \ + -H "x-api-key: $LANGFLOW_API_KEY" ``` ## Read sample flows @@ -178,7 +183,8 @@ Retrieves a list of sample flows: ```bash curl -X GET \ "$LANGFLOW_URL/api/v1/flows/basic_examples/" \ - -H "accept: application/json" + -H "accept: application/json" \ + -H "x-api-key: $LANGFLOW_API_KEY" ``` ## Update flow @@ -195,6 +201,7 @@ 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", @@ -241,7 +248,8 @@ Deletes a specific flow by its ID. ```bash curl -X DELETE \ "$LANGFLOW_URL/api/v1/flows/$FLOW_ID" \ - -H "accept: application/json" + -H "accept: application/json" \ + -H "x-api-key: $LANGFLOW_API_KEY" ``` @@ -271,6 +279,7 @@ 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" @@ -307,6 +316,7 @@ curl -X POST \ "$LANGFLOW_URL/api/v1/flows/upload/?project_id=$PROJECT_ID" \ -H "accept: application/json" \ -H "Content-Type: multipart/form-data" \ + -H "x-api-key: $LANGFLOW_API_KEY" \ -F "file=@agent-with-astra-db-tool.json;type=application/json" ``` diff --git a/docs/docs/API-Reference/api-logs.md b/docs/docs/API-Reference/api-logs.md index 07fb960a687b..b7b543549c5c 100644 --- a/docs/docs/API-Reference/api-logs.md +++ b/docs/docs/API-Reference/api-logs.md @@ -38,7 +38,8 @@ Stream logs in real-time using Server Sent Events (SSE). ```bash curl -X GET \ "$LANGFLOW_URL/logs-stream" \ - -H "accept: text/event-stream" + -H "accept: text/event-stream" \ + -H "x-api-key: $LANGFLOW_API_KEY" ``` @@ -84,7 +85,8 @@ With default values, the endpoint returns the last 10 lines of logs. ```bash curl -X GET \ "$LANGFLOW_URL/logs?lines_before=0&lines_after=0×tamp=0" \ - -H "accept: application/json" + -H "accept: application/json" \ + -H "x-api-key: $LANGFLOW_API_KEY" ``` diff --git a/docs/docs/API-Reference/api-monitor.md b/docs/docs/API-Reference/api-monitor.md index d7bc135b37ca..b76379bab2d4 100644 --- a/docs/docs/API-Reference/api-monitor.md +++ b/docs/docs/API-Reference/api-monitor.md @@ -18,7 +18,8 @@ Retrieve Vertex builds for a specific flow. ```bash curl -X GET \ "$LANGFLOW_URL/api/v1/monitor/builds?flow_id=$FLOW_ID" \ - -H "accept: application/json" + -H "accept: application/json" \ + -H "x-api-key: $LANGFLOW_API_KEY" ``` @@ -397,7 +398,8 @@ Delete Vertex builds for a specific flow. ```bash curl -X DELETE \ "$LANGFLOW_URL/api/v1/monitor/builds?flow_id=$FLOW_ID" \ - -H "accept: */*" + -H "accept: */*" \ + -H "x-api-key: $LANGFLOW_API_KEY" ``` @@ -417,7 +419,8 @@ Retrieve a list of all messages: ```bash curl -X GET \ "$LANGFLOW_URL/api/v1/monitor/messages" \ - -H "accept: application/json" + -H "accept: application/json" \ + -H "x-api-key: $LANGFLOW_API_KEY" ``` To filter messages, use the `flow_id`, `session_id`, `sender`, and `sender_name` query parameters. @@ -432,7 +435,8 @@ This example retrieves messages sent by `Machine` and `AI` in a given chat sessi ```bash 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 "accept: application/json" \ + -H "x-api-key: $LANGFLOW_API_KEY" ``` @@ -488,6 +492,7 @@ 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"]' ``` @@ -515,6 +520,7 @@ 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" }' @@ -566,7 +572,8 @@ This example updates the `session_ID` value `01ce083d-748b-4b8d-97b6-33adbb6a528 ```bash 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 "accept: application/json" \ + -H "x-api-key: $LANGFLOW_API_KEY" ``` @@ -618,7 +625,8 @@ Delete all messages for a specific session. ```bash curl -X DELETE \ "$LANGFLOW_URL/api/v1/monitor/messages/session/different_session_id_2" \ - -H "accept: */*" + -H "accept: */*" \ + -H "x-api-key: $LANGFLOW_API_KEY" ``` @@ -641,7 +649,8 @@ Retrieve all transactions, which are interactions between components, for a spec ```bash curl -X GET \ "$LANGFLOW_URL/api/v1/monitor/transactions?flow_id=$FLOW_ID&page=1&size=50" \ - -H "accept: application/json" + -H "accept: application/json" \ + -H "x-api-key: $LANGFLOW_API_KEY" ``` diff --git a/docs/docs/API-Reference/api-projects.md b/docs/docs/API-Reference/api-projects.md index 7269322ff34f..3dfecb330d22 100644 --- a/docs/docs/API-Reference/api-projects.md +++ b/docs/docs/API-Reference/api-projects.md @@ -20,7 +20,8 @@ Get a list of Langflow projects, including project IDs, names, and descriptions. ```bash curl -X GET \ "$LANGFLOW_URL/api/v1/projects/" \ - -H "accept: application/json" + -H "accept: application/json" \ + -H "x-api-key: $LANGFLOW_API_KEY" ``` @@ -51,6 +52,7 @@ Create a new project. curl -X POST \ "$LANGFLOW_URL/api/v1/projects/" \ -H "Content-Type: application/json" \ + -H "x-api-key: $LANGFLOW_API_KEY" \ -d '{ "name": "new_project_name", "description": "string", @@ -83,6 +85,7 @@ curl -X POST \ "$LANGFLOW_URL/api/v1/projects/" \ -H "accept: application/json" \ -H "Content-Type: application/json" \ + -H "x-api-key: $LANGFLOW_API_KEY" \ -d '{ "name": "new_project_name", "description": "string", @@ -107,7 +110,8 @@ To find the UUID of your project, call the [read projects](#read-projects) endpo ```bash curl -X GET \ "$LANGFLOW_URL/api/v1/projects/$PROJECT_ID" \ - -H "accept: application/json" + -H "accept: application/json" \ + -H "x-api-key: $LANGFLOW_API_KEY" ``` @@ -142,6 +146,7 @@ If you send the same values multiple times, the update is still processed, even curl -X PATCH \ "$LANGFLOW_URL/api/v1/projects/b408ddb9-6266-4431-9be8-e04a62758331" \ -H "accept: application/json" \ + -H "x-api-key: $LANGFLOW_API_KEY" \ -d '{ "name": "string", "description": "string", @@ -180,7 +185,8 @@ Delete a specific project. ```bash curl -X DELETE \ "$LANGFLOW_URL/api/v1/projects/$PROJECT_ID" \ - -H "accept: */*" + -H "accept: */*" \ + -H "x-api-key: $LANGFLOW_API_KEY" ``` @@ -203,6 +209,7 @@ The `--output` flag is optional. curl -X GET \ "$LANGFLOW_URL/api/v1/projects/download/b408ddb9-6266-4431-9be8-e04a62758331" \ -H "accept: application/json" \ + -H "x-api-key: $LANGFLOW_API_KEY" \ --output langflow-project.zip ``` @@ -215,5 +222,6 @@ curl -X POST \ "$LANGFLOW_URL/api/v1/projects/upload/" \ -H "accept: application/json" \ -H "Content-Type: multipart/form-data" \ + -H "x-api-key: $LANGFLOW_API_KEY" \ -F "file=@20241230_135006_langflow_flows.zip;type=application/zip" ``` \ No newline at end of file diff --git a/docs/docs/API-Reference/api-reference-api-examples.md b/docs/docs/API-Reference/api-reference-api-examples.md index 53180d424ee1..216f5830e7d7 100644 --- a/docs/docs/API-Reference/api-reference-api-examples.md +++ b/docs/docs/API-Reference/api-reference-api-examples.md @@ -84,7 +84,7 @@ For example: export LANGFLOW_URL="http://localhost:7860" export FLOW_ID="359cd752-07ea-46f2-9d3b-a4407ef618da" export PROJECT_ID="1415de42-8f01-4f36-bf34-539f23e47466" -export API_KEY="sk-..." +export LANGFLOW_API_KEY="sk-..." ``` :::tip @@ -145,14 +145,15 @@ curl -X GET \ ``` -### Get all components +### Get current user -Returns a dictionary of all Langflow components: +Returns a user object. ```bash curl -X GET \ - "$LANGFLOW_URL/api/v1/all" \ - -H "accept: application/json" + "$LANGFLOW_URL/api/v1/users/whoami" \ + -H "accept: application/json" \ + -H "x-api-key: $LANGFLOW_API_KEY" ``` ## Next steps diff --git a/docs/docs/API-Reference/api-users.md b/docs/docs/API-Reference/api-users.md index d35b8d7a3c7d..ee4a364e979e 100644 --- a/docs/docs/API-Reference/api-users.md +++ b/docs/docs/API-Reference/api-users.md @@ -24,6 +24,7 @@ This creates a new UUID for the user's `id`, which is mapped to `user_id` in the curl -X POST \ "$LANGFLOW_URL/api/v1/users/" \ -H "Content-Type: application/json" \ + -H "x-api-key: $LANGFLOW_API_KEY" \ -d '{ "username": "newuser2", "password": "securepassword123" From bc20ed6d841a0eb9156c3d5d6e113445873fb1d5 Mon Sep 17 00:00:00 2001 From: Mendon Kissling <59585235+mendonk@users.noreply.github.com> Date: Wed, 25 Jun 2025 12:03:08 -0400 Subject: [PATCH 03/28] auth-login-behavior-changes --- .../Configuration/configuration-api-keys.md | 73 +++++++++++++------ 1 file changed, 49 insertions(+), 24 deletions(-) diff --git a/docs/docs/Configuration/configuration-api-keys.md b/docs/docs/Configuration/configuration-api-keys.md index 40cc1f6858da..c9100d85e3c8 100644 --- a/docs/docs/Configuration/configuration-api-keys.md +++ b/docs/docs/Configuration/configuration-api-keys.md @@ -7,7 +7,13 @@ import Tabs from '@theme/Tabs'; import TabItem from '@theme/TabItem'; import Icon from "@site/src/components/icon"; -Langflow provides an API key functionality that allows users to access their individual components and flows without traditional login authentication. +Langflow provides an API key functionality that allows users to access their individual components and flows. + +## Auto-login and API key authentication + +Prior to Langflow v1.5, when `AUTO_LOGIN` was enabled (`AUTO_LOGIN=true`), Langflow automatically logged users in as a superuser without requiring authentication. + +As of Langflow v1.5, when `AUTO_LOGIN` is enabled, `AUTO_LOGIN` requires a valid API key. ## Generate a Langflow API key @@ -22,30 +28,49 @@ Generate a user-specific token to use with Langflow. ### Generate an API key with the Langflow CLI -This command only works if `AUTO_LOGIN` is set to `FALSE` and the user is a superuser. +If you're serving your flow with `--backend-only=true`, you don't have a way to create an API key within the UI. -For example, if you're serving your flow with `--backend-only=true`, you don't have a way to create an API key within the UI. +To create API keys with the Langflow CLI, `AUTO_LOGIN` must be set to `FALSE` and you must be logged in as a superuser. -``` -LANGFLOW_AUTO_LOGIN=False -LANGFLOW_SUPERUSER=admin -LANGFLOW_SUPERUSER_PASSWORD=password -``` +To create an API key for a user from the CLI, do the following: -```shell -uv run langflow api-key - -╭─────────────────────────────────────────────────────────────────────╮ -│ API Key Created Successfully: │ -│ │ -│ sk-O0elzoWID1izAH8RUKrnnvyyMwIzHi2Wk-uXWoNJ2Ro │ -│ │ -│ This is the only time the API key will be displayed. │ -│ Make sure to store it in a secure location. │ -│ │ -│ The API key has been copied to your clipboard. Cmd + V to paste it. │ -╰────────────────────────────── -``` +1. In your `.env` file, set `AUTO_LOGIN=FALSE`, and set superuser credentials for your server. + + ```text + LANGFLOW_AUTO_LOGIN=False + LANGFLOW_SUPERUSER=administrator + LANGFLOW_SUPERUSER_PASSWORD=securepassword + ``` + +2. To confirm your superuser status, check that `is_superuser` is `true` in the response from the [users/whoami](/api-users#get-current-user) endpoint. + + ```bash + curl -X GET \ + "$LANGFLOW_URL/api/v1/users/whoami" \ + -H "accept: application/json" \ + -H "x-api-key: $LANGFLOW_API_KEY" + ``` + + Result: + ```json + { + "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-29T15:06:56.157860", + "last_login_at": "2025-05-29T15:06:56.157016", + } + ``` + +2. To create an API key, run: + + ```shell + uv run langflow api-key + ``` ## Authenticate requests with the Langflow API key @@ -59,7 +84,7 @@ To use the API key when making API requests, include the API key in the HTTP hea ```shell curl -X POST \ - "http://localhost:7860/api/v1/run/FLOW_ID?stream=false" \ + "http://LANGFLOW_SERVER_ADDRESS/api/v1/run/FLOW_ID?stream=false" \ -H 'Content-Type: application/json' \ -H 'x-api-key: LANGFLOW_API_KEY' \ -d '{"inputs": {"text":""}, "tweaks": {}}' @@ -71,7 +96,7 @@ To pass the API key as a query parameter: ```shell curl -X POST \ - "http://localhost:7860/api/v1/run/FLOW_ID?x-api-key=API_KEY?stream=false" \ + "http://LANGFLOW_SERVER_ADDRESS/api/v1/run/FLOW_ID?x-api-key=LANGFLOW_API_KEY?stream=false" \ -H 'Content-Type: application/json' \ -d '{"inputs": {"text":""}, "tweaks": {}}' ``` From 14370657e1f21cc06472edfdeffaf4e8a6f9a8d9 Mon Sep 17 00:00:00 2001 From: Mendon Kissling <59585235+mendonk@users.noreply.github.com> Date: Wed, 25 Jun 2025 12:13:18 -0400 Subject: [PATCH 04/28] no-all-endpoint --- docs/docs/API-Reference/api-projects.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/docs/API-Reference/api-projects.md b/docs/docs/API-Reference/api-projects.md index 3dfecb330d22..b4f5d60462b8 100644 --- a/docs/docs/API-Reference/api-projects.md +++ b/docs/docs/API-Reference/api-projects.md @@ -76,7 +76,7 @@ curl -X POST \ -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. +To add flows and components at project creation, retrieve the `components_list` and `flows_list` values from the [/flows/read](/api-flows#read-flows) endpoint and add them to the request body. Adding a flow to a project moves the flow from its previous location. The flow is not copied. From 1bf8157d1cec7665c9a3c9df70ad8644ff2697b8 Mon Sep 17 00:00:00 2001 From: Mendon Kissling <59585235+mendonk@users.noreply.github.com> Date: Wed, 25 Jun 2025 12:23:17 -0400 Subject: [PATCH 05/28] syntax --- docs/docs/Configuration/configuration-api-keys.md | 2 +- docs/docs/Get-Started/get-started-quickstart.md | 8 ++++---- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/docs/docs/Configuration/configuration-api-keys.md b/docs/docs/Configuration/configuration-api-keys.md index c9100d85e3c8..bcc63670ceef 100644 --- a/docs/docs/Configuration/configuration-api-keys.md +++ b/docs/docs/Configuration/configuration-api-keys.md @@ -96,7 +96,7 @@ To pass the API key as a query parameter: ```shell curl -X POST \ - "http://LANGFLOW_SERVER_ADDRESS/api/v1/run/FLOW_ID?x-api-key=LANGFLOW_API_KEY?stream=false" \ + "http://LANGFLOW_SERVER_ADDRESS/api/v1/run/FLOW_ID?x-api-key=LANGFLOW_API_KEY" \ -H 'Content-Type: application/json' \ -d '{"inputs": {"text":""}, "tweaks": {}}' ``` diff --git a/docs/docs/Get-Started/get-started-quickstart.md b/docs/docs/Get-Started/get-started-quickstart.md index ba49c8ee846f..8fc061df044d 100644 --- a/docs/docs/Get-Started/get-started-quickstart.md +++ b/docs/docs/Get-Started/get-started-quickstart.md @@ -113,7 +113,7 @@ Langflow provides code snippets to help you get started with the Langflow API. # Request headers headers = { "Content-Type": "application/json", - "x-api-key: LANGFLOW_API_KEY" + "x-api-key": "LANGFLOW_API_KEY" } try: @@ -145,7 +145,7 @@ Langflow provides code snippets to help you get started with the Langflow API. method: 'POST', headers: { 'Content-Type': 'application/json', - 'x-api-key: LANGFLOW_API_KEY' + 'x-api-key': 'LANGFLOW_API_KEY' }, body: JSON.stringify(payload) }; @@ -382,7 +382,7 @@ This script runs a question-and-answer chat in your terminal and stores the Agen headers = { "Content-Type": "application/json", - "x-api-key: LANGFLOW_API_KEY" + "x-api-key": "LANGFLOW_API_KEY" } try: @@ -457,7 +457,7 @@ This script runs a question-and-answer chat in your terminal and stores the Agen method: 'POST', headers: { 'Content-Type': 'application/json', - 'x-api-key: LANGFLOW_API_KEY' + 'x-api-key': 'LANGFLOW_API_KEY' }, body: JSON.stringify(payload) }; From b87389dcf8df080f846a46594779e795f7114072 Mon Sep 17 00:00:00 2001 From: Mendon Kissling <59585235+mendonk@users.noreply.github.com> Date: Wed, 25 Jun 2025 12:36:53 -0400 Subject: [PATCH 06/28] text --- docs/docs/Get-Started/get-started-quickstart.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/docs/Get-Started/get-started-quickstart.md b/docs/docs/Get-Started/get-started-quickstart.md index 8fc061df044d..996cef15178a 100644 --- a/docs/docs/Get-Started/get-started-quickstart.md +++ b/docs/docs/Get-Started/get-started-quickstart.md @@ -25,7 +25,7 @@ To generate a user-specific token to use with Langflow, do the following. 3. Name your key, and then click **Create API Key**. 4. Copy the API key and store it in a secure location. 5. Include your `LANGFLOW_API_KEY` in requests like this: - ``` + ```text curl --request POST \ --url 'http://localhost:7860/api/v1/run/0901b40b-9212-41cb-87c6-ac66a427913c?stream=false' \ --header 'Content-Type: application/json' \ From 5c480985ae452c15ae1873191f766b76ca162b26 Mon Sep 17 00:00:00 2001 From: Mendon Kissling <59585235+mendonk@users.noreply.github.com> Date: Wed, 25 Jun 2025 12:47:19 -0400 Subject: [PATCH 07/28] cleanup --- docs/docs/Get-Started/get-started-quickstart.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/docs/docs/Get-Started/get-started-quickstart.md b/docs/docs/Get-Started/get-started-quickstart.md index 996cef15178a..1e8d41197d64 100644 --- a/docs/docs/Get-Started/get-started-quickstart.md +++ b/docs/docs/Get-Started/get-started-quickstart.md @@ -27,7 +27,7 @@ To generate a user-specific token to use with Langflow, do the following. 5. Include your `LANGFLOW_API_KEY` in requests like this: ```text curl --request POST \ - --url 'http://localhost:7860/api/v1/run/0901b40b-9212-41cb-87c6-ac66a427913c?stream=false' \ + --url 'http://LANGFLOW_SERVER_ADDRESS/api/v1/run/FLOW_ID' \ --header 'Content-Type: application/json' \ --header 'x-api-key: LANGFLOW_API_KEY' \ --data '{ @@ -162,7 +162,7 @@ Langflow provides code snippets to help you get started with the Langflow API. ```text curl --request POST \ - --url 'http://localhost:7860/api/v1/run/0901b40b-9212-41cb-87c6-ac66a427913c?stream=false' \ + --url 'http://LANGFLOW_SERVER_ADDRESS/api/v1/run/FLOW_ID' \ --header 'Content-Type: application/json' \ --header 'x-api-key: LANGFLOW_API_KEY' \ --data '{ From 488b0ecb63c127488fa16100a7351bd42902cc51 Mon Sep 17 00:00:00 2001 From: Mendon Kissling <59585235+mendonk@users.noreply.github.com> Date: Thu, 26 Jun 2025 09:02:53 -0400 Subject: [PATCH 08/28] notice-for-mcp --- docs/docs/Configuration/configuration-api-keys.md | 5 +++-- docs/docs/Configuration/configuration-authentication.md | 5 +++++ docs/docs/Configuration/configuration-cli.md | 2 +- docs/docs/Configuration/environment-variables.md | 2 +- 4 files changed, 10 insertions(+), 4 deletions(-) diff --git a/docs/docs/Configuration/configuration-api-keys.md b/docs/docs/Configuration/configuration-api-keys.md index bcc63670ceef..95d0816a8410 100644 --- a/docs/docs/Configuration/configuration-api-keys.md +++ b/docs/docs/Configuration/configuration-api-keys.md @@ -11,9 +11,10 @@ Langflow provides an API key functionality that allows users to access their ind ## Auto-login and API key authentication -Prior to Langflow v1.5, when `AUTO_LOGIN` was enabled (`AUTO_LOGIN=true`), Langflow automatically logged users in as a superuser without requiring authentication. +Prior to Langflow v1.5, when `AUTO_LOGIN` was enabled with `AUTO_LOGIN=true`, Langflow automatically logged users in as a superuser without requiring authentication, and API requests could be made without a Langflow API key. -As of Langflow v1.5, when `AUTO_LOGIN` is enabled, `AUTO_LOGIN` requires a valid API key. +As of Langflow v1.5, all API requests require a Langflow API key, even when `AUTO_LOGIN` is enabled. +The MCP-related endpoints will continue to require no authentication when `AUTO_LOGIN=true`. ## Generate a Langflow API key diff --git a/docs/docs/Configuration/configuration-authentication.md b/docs/docs/Configuration/configuration-authentication.md index 2f404d150dcb..f3ec39fe8bd6 100644 --- a/docs/docs/Configuration/configuration-authentication.md +++ b/docs/docs/Configuration/configuration-authentication.md @@ -24,6 +24,11 @@ You can copy the contents of this file into your own `.env` file and replace the ### LANGFLOW_AUTO_LOGIN +:::important +As of Langflow v1.5, all API requests require a Langflow API key, even when `AUTO_LOGIN` is enabled. +The MCP-related endpoints will continue to require no authentication when `AUTO_LOGIN=true`. +::: + When `True`, Langflow automatically logs users in with username `langflow` and password `langflow` without requiring user authentication. To disable automatic login and enforce user authentication, set this value to `False` in your `.env` file. By default, this variable is set to `True`. diff --git a/docs/docs/Configuration/configuration-cli.md b/docs/docs/Configuration/configuration-cli.md index 517dce8fc3f5..16ce23d0c409 100644 --- a/docs/docs/Configuration/configuration-cli.md +++ b/docs/docs/Configuration/configuration-cli.md @@ -33,7 +33,7 @@ python -m langflow [OPTIONS] ### langflow api-key -Create an API key for the default superuser if the `LANGFLOW_AUTO_LOGIN` environment variable is set to `true`. +To create API keys with the Langflow CLI, `AUTO_LOGIN` must be set to `FALSE` and you must be logged in as a superuser. ```bash langflow api-key [OPTIONS] diff --git a/docs/docs/Configuration/environment-variables.md b/docs/docs/Configuration/environment-variables.md index a3387ba48423..97eb7d2b6ad8 100644 --- a/docs/docs/Configuration/environment-variables.md +++ b/docs/docs/Configuration/environment-variables.md @@ -179,7 +179,7 @@ The following table lists the environment variables supported by Langflow. | Variable | Format | Default | Description | |----------|--------|---------|-------------| | DO_NOT_TRACK | Boolean | `false` | If this option is enabled, Langflow does not track telemetry. | -| LANGFLOW_AUTO_LOGIN | Boolean | `true` | Enable automatic login for Langflow. Set to `false` to disable automatic login and require the login form to log into the Langflow UI. Setting to `false` requires [`LANGFLOW_SUPERUSER`](#LANGFLOW_SUPERUSER) and [`LANGFLOW_SUPERUSER_PASSWORD`](environment-variables.md#LANGFLOW_SUPERUSER_PASSWORD) to be set. | +| LANGFLOW_AUTO_LOGIN | Boolean | `true` | Enable automatic login for Langflow. Set to `false` to disable automatic login and require the login form to log into the Langflow UI. Setting to `false` requires [`LANGFLOW_SUPERUSER`](#LANGFLOW_SUPERUSER) and [`LANGFLOW_SUPERUSER_PASSWORD`](environment-variables.md#LANGFLOW_SUPERUSER_PASSWORD) to be set. Langflow API requests require API keys as of Langflow v1.5. | | LANGFLOW_AUTO_SAVING | Boolean | `true` | Enable flow auto-saving.
See [`--auto-saving` option](./configuration-cli.md#run-auto-saving). | | LANGFLOW_AUTO_SAVING_INTERVAL | Integer | `1000` | Set the interval for flow auto-saving in milliseconds.
See [`--auto-saving-interval` option](./configuration-cli.md#run-auto-saving-interval). | | LANGFLOW_BACKEND_ONLY | Boolean | `false` | Only run Langflow's backend server (no frontend).
See [`--backend-only` option](./configuration-cli.md#run-backend-only). | From a3d07606a86ee9e4e6c34596fcc681098b5e9c58 Mon Sep 17 00:00:00 2001 From: Mendon Kissling <59585235+mendonk@users.noreply.github.com> Date: Fri, 27 Jun 2025 13:23:48 -0400 Subject: [PATCH 09/28] include-instructions-for-exporting-key --- docs/docs/Concepts/concepts-publish.md | 30 +++++++++++++++++++ .../Get-Started/get-started-quickstart.md | 5 ++++ 2 files changed, 35 insertions(+) diff --git a/docs/docs/Concepts/concepts-publish.md b/docs/docs/Concepts/concepts-publish.md index 6394e961a462..19f2f4186387 100644 --- a/docs/docs/Concepts/concepts-publish.md +++ b/docs/docs/Concepts/concepts-publish.md @@ -12,6 +12,36 @@ Langflow provides several ways to publish and integrate your flows into external The **API access** pane presents code templates for integrating your flow into external applications. +As of Langflow v1.5, all API requests require a `LANGFLOW_API_KEY`, even if `AUTO_LOGIN` is set to `True`. + +
+Need help creating an API key? + +To generate a user-specific token to use with Langflow, do the following. + +1. Open the Langflow UI, click your user icon, and then select **Settings**. +2. Click **Langflow API Keys**, and then click **Add New**. +3. Name your key, and then click **Create API Key**. +4. Copy the API key and store it in a secure location. +5. Include your `LANGFLOW_API_KEY` in requests like this: + ```text + curl --request POST \ + --url 'http://LANGFLOW_SERVER_ADDRESS/api/v1/run/FLOW_ID' \ + --header 'Content-Type: application/json' \ + --header 'x-api-key: LANGFLOW_API_KEY' \ + --data '{ + "output_type": "chat", + "input_type": "chat", + "input_value": "Hello" + }' + ``` +6. Alternatively, the API pane's code snippets include a script to detect your local `LANGFLOW_API_KEY`. +To set this variable in your terminal: +```bash +export LANGFLOW_API_KEY="sk..." +``` +
+ ![](/img/api-pane.png) diff --git a/docs/docs/Get-Started/get-started-quickstart.md b/docs/docs/Get-Started/get-started-quickstart.md index 6ed9fc7f254d..db43ca4388a5 100644 --- a/docs/docs/Get-Started/get-started-quickstart.md +++ b/docs/docs/Get-Started/get-started-quickstart.md @@ -36,6 +36,11 @@ To generate a user-specific token to use with Langflow, do the following. "input_value": "Hello" }' ``` +6. Alternatively, the API pane's code snippets include a script to detect your local `LANGFLOW_API_KEY`. +Set this variable in your terminal so you can copy and paste the commands. + ```bash + export LANGFLOW_API_KEY="sk..." + ``` ## Run the Simple Agent template flow From 7cdfceb61642e6529014eeec1460a20ffeb46ddb Mon Sep 17 00:00:00 2001 From: Mendon Kissling <59585235+mendonk@users.noreply.github.com> Date: Tue, 1 Jul 2025 09:49:40 -0400 Subject: [PATCH 10/28] Apply suggestions from code review Co-authored-by: April I. Murphy <36110273+aimurphy@users.noreply.github.com> --- docs/docs/Concepts/concepts-publish.md | 4 ++-- docs/docs/Get-Started/get-started-quickstart.md | 13 +++++++------ 2 files changed, 9 insertions(+), 8 deletions(-) diff --git a/docs/docs/Concepts/concepts-publish.md b/docs/docs/Concepts/concepts-publish.md index 19f2f4186387..3f98c386d1c0 100644 --- a/docs/docs/Concepts/concepts-publish.md +++ b/docs/docs/Concepts/concepts-publish.md @@ -12,7 +12,7 @@ Langflow provides several ways to publish and integrate your flows into external The **API access** pane presents code templates for integrating your flow into external applications. -As of Langflow v1.5, all API requests require a `LANGFLOW_API_KEY`, even if `AUTO_LOGIN` is set to `True`. +As of Langflow version 1.5, all API requests require authentication with a Langflow API key, even if `AUTO_LOGIN` is set to `True`.
Need help creating an API key? @@ -23,7 +23,7 @@ To generate a user-specific token to use with Langflow, do the following. 2. Click **Langflow API Keys**, and then click **Add New**. 3. Name your key, and then click **Create API Key**. 4. Copy the API key and store it in a secure location. -5. Include your `LANGFLOW_API_KEY` in requests like this: +5. Use your Langflow API key in your API requests. For example: ```text curl --request POST \ --url 'http://LANGFLOW_SERVER_ADDRESS/api/v1/run/FLOW_ID' \ diff --git a/docs/docs/Get-Started/get-started-quickstart.md b/docs/docs/Get-Started/get-started-quickstart.md index db43ca4388a5..bba1df225fec 100644 --- a/docs/docs/Get-Started/get-started-quickstart.md +++ b/docs/docs/Get-Started/get-started-quickstart.md @@ -13,14 +13,15 @@ Get started with Langflow by loading a template flow, running it, and then servi - [A running Langflow instance](/get-started-installation) - [An OpenAI API key](https://platform.openai.com/api-keys) -- [A Langflow API key](/configuration-api-keys) -
-Need help creating an API key? -To generate a user-specific token to use with Langflow, do the following. +## Create a Langflow API key -1. Open the Langflow UI, click your user icon, and then select **Settings**. +A [Langflow API key](/configuration-api-keys) is a user-specific token you can use with Langflow. + +To create a Langflow API key, do the following: + +1. In Langflow, click your user icon, and then select **Settings**. 2. Click **Langflow API Keys**, and then click **Add New**. 3. Name your key, and then click **Create API Key**. 4. Copy the API key and store it in a secure location. @@ -41,7 +42,7 @@ Set this variable in your terminal so you can copy and paste the commands. ```bash export LANGFLOW_API_KEY="sk..." ``` -
+ ## Run the Simple Agent template flow From d68a0e1826aff4dd69e338f11de73d2cb5426b10 Mon Sep 17 00:00:00 2001 From: Mendon Kissling <59585235+mendonk@users.noreply.github.com> Date: Tue, 1 Jul 2025 09:55:40 -0400 Subject: [PATCH 11/28] chat-io-double-quotes --- docs/docs/Components/components-io.md | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/docs/docs/Components/components-io.md b/docs/docs/Components/components-io.md index 5a0a996d02f0..b0431156b20b 100644 --- a/docs/docs/Components/components-io.md +++ b/docs/docs/Components/components-io.md @@ -211,9 +211,9 @@ To send the same example messages programmatically to your Langflow server, do t It looks similar to this: ```text curl --request POST \ - --url 'http://localhost:7860/api/v1/run/51eed711-4530-4fdc-9bce-5db4351cc73a?stream=false' \ - --header 'Content-Type: application/json' \ - --header 'x-api-key: LANGFLOW_API_KEY' \ + --url "http://LANGFLOW_SERVER_ADDRESS/api/v1/run/FLOW_ID" \ + --header "Content-Type: application/json" \ + --header "x-api-key: LANGFLOW_API_KEY" \ --data '{ "input_value": "What's the recommended way to install Docker on Mac M1?", "output_type": "chat", @@ -227,9 +227,9 @@ Note the `output_type` and `input_type` parameters that are passed with the mess 4. Add a custom `session_id` to the message's `data` object. ```text curl --request POST \ - --url 'http://localhost:7860/api/v1/run/51eed711-4530-4fdc-9bce-5db4351cc73a?stream=false' \ - --header 'Content-Type: application/json' \ - --header 'x-api-key: LANGFLOW_API_KEY' \ + --url "http://LANGFLOW_SERVER_ADDRESS/api/v1/run/FLOW_ID" \ + --header "Content-Type: application/json" \ + --header "x-api-key: LANGFLOW_API_KEY" \ --data '{ "input_value": "Whats the recommended way to install Docker on Mac M1", "session_id": "docker-question-on-m1", @@ -244,13 +244,13 @@ Your request is answered. 6. Navigate to the **Playground**. A new chat session called `docker-question-on-m1` has appeared, using your unique `session_id`. 7. To modify additional parameters with **Tweaks** for your **Chat Input** and **Chat Output** components, click **Publish**, and then click **API access**. -8. Click **Tweaks** to modify parameters in the component's `data` object. +8. Click **Input schema** to modify parameters in the component's `data` object. For example, disabling storing messages from the **Chat Input** component adds a **Tweak** to your command: ```text curl --request POST \ - --url 'http://localhost:7860/api/v1/run/51eed711-4530-4fdc-9bce-5db4351cc73a?stream=false' \ - --header 'Content-Type: application/json' \ - --header 'x-api-key: LANGFLOW_API_KEY' \ + --url "http://LANGFLOW_SERVER_ADDRESS/api/v1/run/FLOW_ID" \ + --header "Content-Type: application/json" \ + --header "x-api-key: LANGFLOW_API_KEY" \ --data '{ "input_value": "Text to input to the flow", "output_type": "chat", From 85d407402131770eefa209d4f463000af2e0def4 Mon Sep 17 00:00:00 2001 From: Mendon Kissling <59585235+mendonk@users.noreply.github.com> Date: Tue, 1 Jul 2025 12:18:48 -0400 Subject: [PATCH 12/28] auth-page-docs-review --- docs/docs/Concepts/concepts-playground.md | 10 ++--- docs/docs/Concepts/concepts-publish.md | 10 ++--- .../Configuration/configuration-api-keys.md | 37 +++++++++++++++---- .../configuration-authentication.md | 11 +++++- .../Configuration/environment-variables.md | 2 +- 5 files changed, 49 insertions(+), 21 deletions(-) diff --git a/docs/docs/Concepts/concepts-playground.md b/docs/docs/Concepts/concepts-playground.md index 4ae2c13edd6b..098c1451f976 100644 --- a/docs/docs/Concepts/concepts-playground.md +++ b/docs/docs/Concepts/concepts-playground.md @@ -43,9 +43,9 @@ To have more than one session in a single flow, pass a specific session ID to a To post a message to a flow with a specific Session ID with curl, enter the following command: ```bash - curl -X POST "http://localhost:7860/api/v1/run/$FLOW_ID" \ - -H 'Content-Type: application/json' \ - -H 'x-api-key: LANGFLOW_API_KEY' \ + curl -X POST "http://LANGFLOW_SERVER_ADDRESS/api/v1/run/FLOW_ID" \ + -H "Content-Type: application/json" \ + -H "x-api-key: LANGFLOW_API_KEY" \ -d '{ "session_id": "custom_session_123", "input_value": "message", @@ -78,8 +78,8 @@ This example sends a base64-encoded image to the Playground using curl: ```bash curl -X POST "http://localhost:7860/api/v1/run/$FLOW_ID" \ --H 'Content-Type: application/json' \ --H 'x-api-key: LANGFLOW_API_KEY' \ +-H "Content-Type: application/json" \ +-H "x-api-key: LANGFLOW_API_KEY" \ -d '{ "session_id": "custom_session_123", "input_value": "What is in this image?", diff --git a/docs/docs/Concepts/concepts-publish.md b/docs/docs/Concepts/concepts-publish.md index 3f98c386d1c0..8265b687bc4a 100644 --- a/docs/docs/Concepts/concepts-publish.md +++ b/docs/docs/Concepts/concepts-publish.md @@ -17,7 +17,7 @@ As of Langflow version 1.5, all API requests require authentication with a Langf
Need help creating an API key? -To generate a user-specific token to use with Langflow, do the following. +To generate an API key to use with Langflow, do the following. 1. Open the Langflow UI, click your user icon, and then select **Settings**. 2. Click **Langflow API Keys**, and then click **Add New**. @@ -26,16 +26,16 @@ To generate a user-specific token to use with Langflow, do the following. 5. Use your Langflow API key in your API requests. For example: ```text curl --request POST \ - --url 'http://LANGFLOW_SERVER_ADDRESS/api/v1/run/FLOW_ID' \ - --header 'Content-Type: application/json' \ - --header 'x-api-key: LANGFLOW_API_KEY' \ + --url "http://LANGFLOW_SERVER_ADDRESS/api/v1/run/FLOW_ID" \ + --header "Content-Type: application/json" \ + --header "x-api-key: LANGFLOW_API_KEY" \ --data '{ "output_type": "chat", "input_type": "chat", "input_value": "Hello" }' ``` -6. Alternatively, the API pane's code snippets include a script to detect your local `LANGFLOW_API_KEY`. +Alternatively, the API pane's code snippets include a script to detect your local `LANGFLOW_API_KEY`. To set this variable in your terminal: ```bash export LANGFLOW_API_KEY="sk..." diff --git a/docs/docs/Configuration/configuration-api-keys.md b/docs/docs/Configuration/configuration-api-keys.md index 95d0816a8410..da761cf6f0ac 100644 --- a/docs/docs/Configuration/configuration-api-keys.md +++ b/docs/docs/Configuration/configuration-api-keys.md @@ -7,29 +7,42 @@ import Tabs from '@theme/Tabs'; import TabItem from '@theme/TabItem'; import Icon from "@site/src/components/icon"; -Langflow provides an API key functionality that allows users to access their individual components and flows. +You can use Langflow API keys to interact with Langflow programmatically. -## Auto-login and API key authentication +The API key has the same permissions and access as you do when logged in through the web interface. This means your API key can only access your own flows, components, and data, and cannot access other users' resources. +The API key represents the user who created them. If you create your key as a superuser, you will have superuser privileges and can manage other users, but will do so with your API key. + +
+Auto-login and API key authentication Prior to Langflow v1.5, when `AUTO_LOGIN` was enabled with `AUTO_LOGIN=true`, Langflow automatically logged users in as a superuser without requiring authentication, and API requests could be made without a Langflow API key. As of Langflow v1.5, all API requests require a Langflow API key, even when `AUTO_LOGIN` is enabled. + +The only exceptions are the MCP endpoints at `/v1/mcp`, `/v1/mcp-projects`, and `/v2/mcp`. The MCP-related endpoints will continue to require no authentication when `AUTO_LOGIN=true`. +
+ ## Generate a Langflow API key -Generate a user-specific token to use with Langflow. +You can generate a Langflow API key with the UI, or the CLI. + +The UI-generated key is appropriate for most cases. The CLI key is needed when your Langflow server is running in `--backend-only` mode. -### Generate an API key with the Langflow UI + + 1. Click your user icon, and then select **Settings**. 2. Click **Langflow API Keys**, and then click **Add New**. 3. Name your key, and then click **Create API Key**. 4. Copy the API key and store it in a secure location. -### Generate an API key with the Langflow CLI + -If you're serving your flow with `--backend-only=true`, you don't have a way to create an API key within the UI. + + + If you're serving your flow with `--backend-only=true`, you don't have a way to create an API key within the UI. To create API keys with the Langflow CLI, `AUTO_LOGIN` must be set to `FALSE` and you must be logged in as a superuser. @@ -73,13 +86,18 @@ To create an API key for a user from the CLI, do the following: uv run langflow api-key ``` + + + + ## Authenticate requests with the Langflow API key Include your API key in API requests to authenticate requests to Langflow. API keys allow access only to the flows and components of the specific user to whom the key was issued. -### Include the API key in the HTTP header + + To use the API key when making API requests, include the API key in the HTTP header: @@ -91,7 +109,8 @@ curl -X POST \ -d '{"inputs": {"text":""}, "tweaks": {}}' ``` -### Include the API key as a query parameter + + To pass the API key as a query parameter: @@ -101,6 +120,8 @@ curl -X POST \ -H 'Content-Type: application/json' \ -d '{"inputs": {"text":""}, "tweaks": {}}' ``` + + ## Generate a Langflow secret key diff --git a/docs/docs/Configuration/configuration-authentication.md b/docs/docs/Configuration/configuration-authentication.md index f3ec39fe8bd6..f40a61a81767 100644 --- a/docs/docs/Configuration/configuration-authentication.md +++ b/docs/docs/Configuration/configuration-authentication.md @@ -24,10 +24,17 @@ You can copy the contents of this file into your own `.env` file and replace the ### LANGFLOW_AUTO_LOGIN -:::important +
+Auto-login and API key authentication + +Prior to Langflow v1.5, when `AUTO_LOGIN` was enabled with `AUTO_LOGIN=true`, Langflow automatically logged users in as a superuser without requiring authentication, and API requests could be made without a Langflow API key. + As of Langflow v1.5, all API requests require a Langflow API key, even when `AUTO_LOGIN` is enabled. + +The only exceptions are the MCP endpoints at `/v1/mcp`, `/v1/mcp-projects`, and `/v2/mcp`. The MCP-related endpoints will continue to require no authentication when `AUTO_LOGIN=true`. -::: + +
When `True`, Langflow automatically logs users in with username `langflow` and password `langflow` without requiring user authentication. To disable automatic login and enforce user authentication, set this value to `False` in your `.env` file. diff --git a/docs/docs/Configuration/environment-variables.md b/docs/docs/Configuration/environment-variables.md index 97eb7d2b6ad8..9934f75eecbc 100644 --- a/docs/docs/Configuration/environment-variables.md +++ b/docs/docs/Configuration/environment-variables.md @@ -179,7 +179,7 @@ The following table lists the environment variables supported by Langflow. | Variable | Format | Default | Description | |----------|--------|---------|-------------| | DO_NOT_TRACK | Boolean | `false` | If this option is enabled, Langflow does not track telemetry. | -| LANGFLOW_AUTO_LOGIN | Boolean | `true` | Enable automatic login for Langflow. Set to `false` to disable automatic login and require the login form to log into the Langflow UI. Setting to `false` requires [`LANGFLOW_SUPERUSER`](#LANGFLOW_SUPERUSER) and [`LANGFLOW_SUPERUSER_PASSWORD`](environment-variables.md#LANGFLOW_SUPERUSER_PASSWORD) to be set. Langflow API requests require API keys as of Langflow v1.5. | +| LANGFLOW_AUTO_LOGIN | Boolean | `true` | Enable automatic login for Langflow. Set to `false` to disable automatic login and require the login form to log into the Langflow UI. Setting to `false` requires [`LANGFLOW_SUPERUSER`](#LANGFLOW_SUPERUSER) and [`LANGFLOW_SUPERUSER_PASSWORD`](environment-variables.md#LANGFLOW_SUPERUSER_PASSWORD) to be set. For more information, see [Authentication](/configuration-authentication). | | LANGFLOW_AUTO_SAVING | Boolean | `true` | Enable flow auto-saving.
See [`--auto-saving` option](./configuration-cli.md#run-auto-saving). | | LANGFLOW_AUTO_SAVING_INTERVAL | Integer | `1000` | Set the interval for flow auto-saving in milliseconds.
See [`--auto-saving-interval` option](./configuration-cli.md#run-auto-saving-interval). | | LANGFLOW_BACKEND_ONLY | Boolean | `false` | Only run Langflow's backend server (no frontend).
See [`--backend-only` option](./configuration-cli.md#run-backend-only). | From 61d1cf3286c496087db84f893d1e122238a2dbca Mon Sep 17 00:00:00 2001 From: Mendon Kissling <59585235+mendonk@users.noreply.github.com> Date: Tue, 1 Jul 2025 12:34:55 -0400 Subject: [PATCH 13/28] docs-review --- docs/docs/API-Reference/api-projects.md | 2 +- docs/docs/API-Reference/api-reference-api-examples.md | 8 ++++---- docs/docs/Develop/session-id.md | 6 +++--- 3 files changed, 8 insertions(+), 8 deletions(-) diff --git a/docs/docs/API-Reference/api-projects.md b/docs/docs/API-Reference/api-projects.md index b4f5d60462b8..3dfecb330d22 100644 --- a/docs/docs/API-Reference/api-projects.md +++ b/docs/docs/API-Reference/api-projects.md @@ -76,7 +76,7 @@ curl -X POST \ -To add flows and components at project creation, retrieve the `components_list` and `flows_list` values from the [/flows/read](/api-flows#read-flows) endpoint and add them to the request body. +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 is not copied. diff --git a/docs/docs/API-Reference/api-reference-api-examples.md b/docs/docs/API-Reference/api-reference-api-examples.md index 216f5830e7d7..dd2761ef522e 100644 --- a/docs/docs/API-Reference/api-reference-api-examples.md +++ b/docs/docs/API-Reference/api-reference-api-examples.md @@ -96,7 +96,7 @@ export LANGFLOW_API_KEY="sk-..." Once you have your Langflow server URL, try calling these endpoints that return Langflow metadata. -If authentication is required, include an `x-api-key` header or query parameter with a valid [Langflow API key](/configuration-api-keys), such as `-H 'x-api-key: $API_KEY'`. +If authentication is required, include an `x-api-key` header or query parameter with a valid [Langflow API key](/configuration-api-keys), such as `-H "x-api-key: $API_KEY"`. ### Get version @@ -145,13 +145,13 @@ curl -X GET \ ```
-### Get current user +### Get all components -Returns a user object. +Returns a dictionary of all Langflow components: ```bash curl -X GET \ - "$LANGFLOW_URL/api/v1/users/whoami" \ + "$LANGFLOW_URL/api/v1/all" \ -H "accept: application/json" \ -H "x-api-key: $LANGFLOW_API_KEY" ``` diff --git a/docs/docs/Develop/session-id.md b/docs/docs/Develop/session-id.md index 1c226e91a1b2..bdf394f6a666 100644 --- a/docs/docs/Develop/session-id.md +++ b/docs/docs/Develop/session-id.md @@ -19,9 +19,9 @@ If you set a custom session ID in a payload, all downstream components use the u ``` curl --request POST \ - --url 'http://localhost:7860/api/v1/run/$FLOW_ID' \ - --header 'Content-Type: application/json' \ - --header 'x-api-key: LANGFLOW_API_KEY' \ + --url "http://localhost:7860/api/v1/run/$FLOW_ID" \ + --header "Content-Type: application/json" \ + --header "x-api-key: LANGFLOW_API_KEY" \ --data '{ "input_value": "Hello", "output_type": "chat", From 8056bf8cb5897c94328d42f891188731a03017ac Mon Sep 17 00:00:00 2001 From: Mendon Kissling <59585235+mendonk@users.noreply.github.com> Date: Tue, 1 Jul 2025 12:44:53 -0400 Subject: [PATCH 14/28] update-api-overview-page-docs-review --- .../API-Reference/api-reference-api-examples.md | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-) diff --git a/docs/docs/API-Reference/api-reference-api-examples.md b/docs/docs/API-Reference/api-reference-api-examples.md index dd2761ef522e..131b8973c915 100644 --- a/docs/docs/API-Reference/api-reference-api-examples.md +++ b/docs/docs/API-Reference/api-reference-api-examples.md @@ -48,12 +48,21 @@ The Langflow port number is set in the `LANGFLOW_PORT` [environment variable](/e ### Authentication -Your [Langflow deployment's authentication settings](/configuration-authentication) determine whether Langflow API requests require explicit authentication with a Langflow API key. +
+Auto-login and API key authentication -If explicit authentication is required, you must provide a valid Langflow API key in either an `x-api-key` header or query parameter. -For more information, see [API keys](/configuration-api-keys). +Prior to Langflow v1.5, when `AUTO_LOGIN` was enabled with `AUTO_LOGIN=true`, Langflow automatically logged users in as a superuser without requiring authentication, and API requests could be made without a Langflow API key. + +As of Langflow v1.5, all API requests require a Langflow API key, even when `AUTO_LOGIN` is enabled. + +The only exceptions are the MCP endpoints at `/v1/mcp`, `/v1/mcp-projects`, and `/v2/mcp`. +The MCP-related endpoints will continue to require no authentication when `AUTO_LOGIN=true`. -Because authentication isn't always required, Langflow API examples in the Langflow documentation often omit authentication. +For more information, see [Authentication](/configuration-authentication). +
+ +You must provide a valid Langflow API key in either an `x-api-key` header or query parameter. +For more information, see [API keys](/configuration-api-keys). ### Methods, paths, and parameters From ec9f8c07dd85e7a88f3c49f3281844ba71ba3cb4 Mon Sep 17 00:00:00 2001 From: Mendon Kissling <59585235+mendonk@users.noreply.github.com> Date: Thu, 3 Jul 2025 07:37:32 -0400 Subject: [PATCH 15/28] docs-and-eng-review --- .../api-reference-api-examples.md | 16 +++++++----- docs/docs/Components/components-io.md | 7 ++--- docs/docs/Components/components-processing.md | 11 ++++---- docs/docs/Concepts/concepts-playground.md | 8 +++--- docs/docs/Concepts/concepts-publish.md | 26 ++----------------- .../Configuration/configuration-api-keys.md | 17 ++++++------ .../configuration-authentication.md | 7 ++--- 7 files changed, 37 insertions(+), 55 deletions(-) diff --git a/docs/docs/API-Reference/api-reference-api-examples.md b/docs/docs/API-Reference/api-reference-api-examples.md index 131b8973c915..f16abb1745d0 100644 --- a/docs/docs/API-Reference/api-reference-api-examples.md +++ b/docs/docs/API-Reference/api-reference-api-examples.md @@ -50,18 +50,20 @@ The Langflow port number is set in the `LANGFLOW_PORT` [environment variable](/e
Auto-login and API key authentication - Prior to Langflow v1.5, when `AUTO_LOGIN` was enabled with `AUTO_LOGIN=true`, Langflow automatically logged users in as a superuser without requiring authentication, and API requests could be made without a Langflow API key. +If you set `SKIP_AUTH_AUTO_LOGIN=true`, authentication will be skipped entirely, and API requests will not require a Langflow API key, regardless of the `AUTO_LOGIN` setting. + +
+ As of Langflow v1.5, all API requests require a Langflow API key, even when `AUTO_LOGIN` is enabled. The only exceptions are the MCP endpoints at `/v1/mcp`, `/v1/mcp-projects`, and `/v2/mcp`. The MCP-related endpoints will continue to require no authentication when `AUTO_LOGIN=true`. For more information, see [Authentication](/configuration-authentication). -
-You must provide a valid Langflow API key in either an `x-api-key` header or query parameter. +You must provide a valid Langflow API key in either an `x-api-key` header or a query parameter. For more information, see [API keys](/configuration-api-keys). ### Methods, paths, and parameters @@ -105,8 +107,6 @@ export LANGFLOW_API_KEY="sk-..." Once you have your Langflow server URL, try calling these endpoints that return Langflow metadata. -If authentication is required, include an `x-api-key` header or query parameter with a valid [Langflow API key](/configuration-api-keys), such as `-H "x-api-key: $API_KEY"`. - ### Get version Returns the current Langflow API version: @@ -114,7 +114,8 @@ Returns the current Langflow API version: ```bash curl -X GET \ "$LANGFLOW_URL/api/v1/version" \ - -H "accept: application/json" + -H "accept: application/json" \ + -H "x-api-key: $LANGFLOW_API_KEY" ```
@@ -135,7 +136,8 @@ Returns configuration details for your Langflow deployment: ```bash curl -X GET \ "$LANGFLOW_URL/api/v1/config" \ - -H "accept: application/json" + -H "accept: application/json" \ + -H "x-api-key: $LANGFLOW_API_KEY" ```
diff --git a/docs/docs/Components/components-io.md b/docs/docs/Components/components-io.md index b0431156b20b..c17eb9b8b032 100644 --- a/docs/docs/Components/components-io.md +++ b/docs/docs/Components/components-io.md @@ -206,9 +206,10 @@ Optionally, to view the outputs of each component in the flow, click -Need help creating an API key? - -To generate an API key to use with Langflow, do the following. - -1. Open the Langflow UI, click your user icon, and then select **Settings**. -2. Click **Langflow API Keys**, and then click **Add New**. -3. Name your key, and then click **Create API Key**. -4. Copy the API key and store it in a secure location. -5. Use your Langflow API key in your API requests. For example: - ```text - curl --request POST \ - --url "http://LANGFLOW_SERVER_ADDRESS/api/v1/run/FLOW_ID" \ - --header "Content-Type: application/json" \ - --header "x-api-key: LANGFLOW_API_KEY" \ - --data '{ - "output_type": "chat", - "input_type": "chat", - "input_value": "Hello" - }' - ``` +For more information, see [API keys](/configuration-api-keys). Alternatively, the API pane's code snippets include a script to detect your local `LANGFLOW_API_KEY`. To set this variable in your terminal: ```bash export LANGFLOW_API_KEY="sk..." ``` -
-![](/img/api-pane.png) +![API pane](/img/api-pane.png) diff --git a/docs/docs/Configuration/configuration-api-keys.md b/docs/docs/Configuration/configuration-api-keys.md index da761cf6f0ac..6ba1cf6fdf3e 100644 --- a/docs/docs/Configuration/configuration-api-keys.md +++ b/docs/docs/Configuration/configuration-api-keys.md @@ -9,26 +9,27 @@ import Icon from "@site/src/components/icon"; You can use Langflow API keys to interact with Langflow programmatically. -The API key has the same permissions and access as you do when logged in through the web interface. This means your API key can only access your own flows, components, and data, and cannot access other users' resources. +The API key has the same permissions and access as you do when you launch Langflow. This means your API key can only access your own flows, components, and data. You cannot access other users' resources with your own Langflow API keys. The API key represents the user who created them. If you create your key as a superuser, you will have superuser privileges and can manage other users, but will do so with your API key. -
+
Auto-login and API key authentication - Prior to Langflow v1.5, when `AUTO_LOGIN` was enabled with `AUTO_LOGIN=true`, Langflow automatically logged users in as a superuser without requiring authentication, and API requests could be made without a Langflow API key. +If you set `SKIP_AUTH_AUTO_LOGIN=true`, authentication will be skipped entirely, and API requests will not require a Langflow API key, regardless of the `AUTO_LOGIN` setting. + +
+ As of Langflow v1.5, all API requests require a Langflow API key, even when `AUTO_LOGIN` is enabled. The only exceptions are the MCP endpoints at `/v1/mcp`, `/v1/mcp-projects`, and `/v2/mcp`. The MCP-related endpoints will continue to require no authentication when `AUTO_LOGIN=true`. -
- ## Generate a Langflow API key -You can generate a Langflow API key with the UI, or the CLI. +You can generate a Langflow API key with the UI or the CLI. -The UI-generated key is appropriate for most cases. The CLI key is needed when your Langflow server is running in `--backend-only` mode. +The UI-generated key is appropriate for most cases. The CLI-generated key is needed when your Langflow server is running in `--backend-only` mode. @@ -42,7 +43,7 @@ The UI-generated key is appropriate for most cases. The CLI key is needed when y - If you're serving your flow with `--backend-only=true`, you don't have a way to create an API key within the UI. + If you're serving your flow with `--backend-only=true`, you can't create API keys in the UI. To create API keys with the Langflow CLI, `AUTO_LOGIN` must be set to `FALSE` and you must be logged in as a superuser. diff --git a/docs/docs/Configuration/configuration-authentication.md b/docs/docs/Configuration/configuration-authentication.md index f40a61a81767..2d4190813069 100644 --- a/docs/docs/Configuration/configuration-authentication.md +++ b/docs/docs/Configuration/configuration-authentication.md @@ -29,16 +29,17 @@ You can copy the contents of this file into your own `.env` file and replace the Prior to Langflow v1.5, when `AUTO_LOGIN` was enabled with `AUTO_LOGIN=true`, Langflow automatically logged users in as a superuser without requiring authentication, and API requests could be made without a Langflow API key. +If you set `SKIP_AUTH_AUTO_LOGIN=true`, authentication will be skipped entirely, and API requests will not require a Langflow API key, regardless of the `AUTO_LOGIN` setting. + +
+ As of Langflow v1.5, all API requests require a Langflow API key, even when `AUTO_LOGIN` is enabled. The only exceptions are the MCP endpoints at `/v1/mcp`, `/v1/mcp-projects`, and `/v2/mcp`. The MCP-related endpoints will continue to require no authentication when `AUTO_LOGIN=true`. - - When `True`, Langflow automatically logs users in with username `langflow` and password `langflow` without requiring user authentication. To disable automatic login and enforce user authentication, set this value to `False` in your `.env` file. -By default, this variable is set to `True`. Langflow **does not** allow users to have simultaneous or shared access to flows. If `AUTO_LOGIN` is enabled and user management is disabled (`LANGFLOW_NEW_USER_IS_ACTIVE=true`), users can access the same environment, but it is not password protected. If two users access the same flow, Langflow saves only the work of the last user to save. From d119761d7e5b99b6d5aa152f0eb8e5a29cd54660 Mon Sep 17 00:00:00 2001 From: Mendon Kissling <59585235+mendonk@users.noreply.github.com> Date: Thu, 3 Jul 2025 07:43:47 -0400 Subject: [PATCH 16/28] details-title --- docs/docs/Configuration/configuration-api-keys.md | 11 +++++++---- .../Configuration/configuration-authentication.md | 3 +-- 2 files changed, 8 insertions(+), 6 deletions(-) diff --git a/docs/docs/Configuration/configuration-api-keys.md b/docs/docs/Configuration/configuration-api-keys.md index 6ba1cf6fdf3e..7a92a22f5499 100644 --- a/docs/docs/Configuration/configuration-api-keys.md +++ b/docs/docs/Configuration/configuration-api-keys.md @@ -13,7 +13,7 @@ The API key has the same permissions and access as you do when you launch Langfl The API key represents the user who created them. If you create your key as a superuser, you will have superuser privileges and can manage other users, but will do so with your API key.
-Auto-login and API key authentication +Auto-login and API key authentication in earlier Langflow versions Prior to Langflow v1.5, when `AUTO_LOGIN` was enabled with `AUTO_LOGIN=true`, Langflow automatically logged users in as a superuser without requiring authentication, and API requests could be made without a Langflow API key. If you set `SKIP_AUTH_AUTO_LOGIN=true`, authentication will be skipped entirely, and API requests will not require a Langflow API key, regardless of the `AUTO_LOGIN` setting. @@ -66,7 +66,9 @@ To create an API key for a user from the CLI, do the following: -H "x-api-key: $LANGFLOW_API_KEY" ``` - Result: +
+ Result + ```json { "id": "07e5b864-e367-4f52-b647-a48035ae7e5e", @@ -81,13 +83,14 @@ To create an API key for a user from the CLI, do the following: } ``` -2. To create an API key, run: +
+ +2. Create an API key: ```shell uv run langflow api-key ``` - diff --git a/docs/docs/Configuration/configuration-authentication.md b/docs/docs/Configuration/configuration-authentication.md index 2d4190813069..9b7dc5addafd 100644 --- a/docs/docs/Configuration/configuration-authentication.md +++ b/docs/docs/Configuration/configuration-authentication.md @@ -25,8 +25,7 @@ You can copy the contents of this file into your own `.env` file and replace the ### LANGFLOW_AUTO_LOGIN
-Auto-login and API key authentication - +Auto-login and API key authentication in earlier Langflow versions Prior to Langflow v1.5, when `AUTO_LOGIN` was enabled with `AUTO_LOGIN=true`, Langflow automatically logged users in as a superuser without requiring authentication, and API requests could be made without a Langflow API key. If you set `SKIP_AUTH_AUTO_LOGIN=true`, authentication will be skipped entirely, and API requests will not require a Langflow API key, regardless of the `AUTO_LOGIN` setting. From 348ad92f0dee23f238d158832633398bf0dbcd9c Mon Sep 17 00:00:00 2001 From: Mendon Kissling <59585235+mendonk@users.noreply.github.com> Date: Thu, 3 Jul 2025 08:09:38 -0400 Subject: [PATCH 17/28] Apply suggestions from code review Co-authored-by: April I. Murphy <36110273+aimurphy@users.noreply.github.com> --- docs/docs/Configuration/configuration-api-keys.md | 2 +- .../Configuration/configuration-authentication.md | 13 +++++++------ docs/docs/Develop/session-id.md | 2 +- 3 files changed, 9 insertions(+), 8 deletions(-) diff --git a/docs/docs/Configuration/configuration-api-keys.md b/docs/docs/Configuration/configuration-api-keys.md index 7a92a22f5499..b9867e0b5bdf 100644 --- a/docs/docs/Configuration/configuration-api-keys.md +++ b/docs/docs/Configuration/configuration-api-keys.md @@ -57,7 +57,7 @@ To create an API key for a user from the CLI, do the following: LANGFLOW_SUPERUSER_PASSWORD=securepassword ``` -2. To confirm your superuser status, check that `is_superuser` is `true` in the response from the [users/whoami](/api-users#get-current-user) endpoint. +2. To confirm your superuser status, call [`GET /users/whoami`](/api-users#get-current-user), and then check that the response contains `"is_superuser": true`: ```bash curl -X GET \ diff --git a/docs/docs/Configuration/configuration-authentication.md b/docs/docs/Configuration/configuration-authentication.md index 9b7dc5addafd..95aa7130307d 100644 --- a/docs/docs/Configuration/configuration-authentication.md +++ b/docs/docs/Configuration/configuration-authentication.md @@ -24,18 +24,19 @@ You can copy the contents of this file into your own `.env` file and replace the ### LANGFLOW_AUTO_LOGIN -
+In Langflow versions 1.5 and later, most API requests require a Langflow API key, even when `AUTO_LOGIN=true`. + +The only exceptions are the MCP endpoints: `/v1/mcp`, `/v1/mcp-projects`, and `/v2/mcp`. +These endpoints don't require authentication, regardless of the `AUTO_LOGIN` setting. + +
Auto-login and API key authentication in earlier Langflow versions -Prior to Langflow v1.5, when `AUTO_LOGIN` was enabled with `AUTO_LOGIN=true`, Langflow automatically logged users in as a superuser without requiring authentication, and API requests could be made without a Langflow API key. +If you are running a Langflow version earlier than 1.5, if `AUTO_LOGIN=true`, Langflow automatically logs users in as a superuser without requiring authentication, and API requests can be made without a Langflow API key. If you set `SKIP_AUTH_AUTO_LOGIN=true`, authentication will be skipped entirely, and API requests will not require a Langflow API key, regardless of the `AUTO_LOGIN` setting.
-As of Langflow v1.5, all API requests require a Langflow API key, even when `AUTO_LOGIN` is enabled. - -The only exceptions are the MCP endpoints at `/v1/mcp`, `/v1/mcp-projects`, and `/v2/mcp`. -The MCP-related endpoints will continue to require no authentication when `AUTO_LOGIN=true`. When `True`, Langflow automatically logs users in with username `langflow` and password `langflow` without requiring user authentication. To disable automatic login and enforce user authentication, set this value to `False` in your `.env` file. diff --git a/docs/docs/Develop/session-id.md b/docs/docs/Develop/session-id.md index bdf394f6a666..dd7253e6f9ee 100644 --- a/docs/docs/Develop/session-id.md +++ b/docs/docs/Develop/session-id.md @@ -21,7 +21,7 @@ If you set a custom session ID in a payload, all downstream components use the u curl --request POST \ --url "http://localhost:7860/api/v1/run/$FLOW_ID" \ --header "Content-Type: application/json" \ - --header "x-api-key: LANGFLOW_API_KEY" \ + --header "x-api-key: $LANGFLOW_API_KEY" \ --data '{ "input_value": "Hello", "output_type": "chat", From 4494b75442833bc655dcc44d9ac88deccde9b0a4 Mon Sep 17 00:00:00 2001 From: Mendon Kissling <59585235+mendonk@users.noreply.github.com> Date: Thu, 3 Jul 2025 08:18:19 -0400 Subject: [PATCH 18/28] Apply suggestions from code review Co-authored-by: April I. Murphy <36110273+aimurphy@users.noreply.github.com> --- docs/docs/Configuration/configuration-api-keys.md | 1 - docs/docs/Develop/webhook.md | 6 +++--- docs/docs/Get-Started/get-started-quickstart.md | 2 +- 3 files changed, 4 insertions(+), 5 deletions(-) diff --git a/docs/docs/Configuration/configuration-api-keys.md b/docs/docs/Configuration/configuration-api-keys.md index b9867e0b5bdf..84d3a35628fa 100644 --- a/docs/docs/Configuration/configuration-api-keys.md +++ b/docs/docs/Configuration/configuration-api-keys.md @@ -90,7 +90,6 @@ To create an API key for a user from the CLI, do the following: ```shell uv run langflow api-key ``` - diff --git a/docs/docs/Develop/webhook.md b/docs/docs/Develop/webhook.md index 3764a3420f7c..1001815ba316 100644 --- a/docs/docs/Develop/webhook.md +++ b/docs/docs/Develop/webhook.md @@ -32,9 +32,9 @@ To connect the **Webhook** to a **Parser** component to view and parse your data This example uses `id`, `name`, and `email` strings. Replace **FLOW_ID** with your flow's ID, which can be found on the [Publish pane](/concepts-publish) or in the flow's URL. ```bash - curl -X POST "http://localhost:7860/api/v1/webhook/YOUR_FLOW_ID" \ - -H 'Content-Type: application/json' \ - -H 'x-api-key: LANGFLOW_API_KEY' \ + curl -X POST "http://localhost:7860/api/v1/webhook/$FLOW_ID" \ + -H "Content-Type: application/json" \ + -H "x-api-key: $LANGFLOW_API_KEY" \ -d '{"id": "12345", "name": "alex", "email": "alex@email.com"}' ``` diff --git a/docs/docs/Get-Started/get-started-quickstart.md b/docs/docs/Get-Started/get-started-quickstart.md index bba1df225fec..6f2227e29c43 100644 --- a/docs/docs/Get-Started/get-started-quickstart.md +++ b/docs/docs/Get-Started/get-started-quickstart.md @@ -119,7 +119,7 @@ Langflow provides code snippets to help you get started with the Langflow API. # Request headers headers = { "Content-Type": "application/json", - "x-api-key": "LANGFLOW_API_KEY" + "x-api-key": "$LANGFLOW_API_KEY" } try: From df2e99daef1ebbc914a16c68c3af39523fa26305 Mon Sep 17 00:00:00 2001 From: Mendon Kissling <59585235+mendonk@users.noreply.github.com> Date: Thu, 3 Jul 2025 09:11:48 -0400 Subject: [PATCH 19/28] docs-review --- docs/docs/Components/components-data.md | 5 +++-- docs/docs/Develop/session-id.md | 4 ++-- docs/docs/Get-Started/get-started-quickstart.md | 14 +++++++------- 3 files changed, 12 insertions(+), 11 deletions(-) diff --git a/docs/docs/Components/components-data.md b/docs/docs/Components/components-data.md index 9d863d9e0347..08f823638ed8 100644 --- a/docs/docs/Components/components-data.md +++ b/docs/docs/Components/components-data.md @@ -265,14 +265,15 @@ This component defines a webhook trigger that runs a flow when it receives an HT If the input is not valid JSON, the component wraps it in a `payload` object so that it can be processed and still trigger the flow. The component does not require an API key. 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: +Replace `LANGFLOW_SERVER_ADDRESS`, `FLOW_ID`, and `LANGFLOW_API_KEY` with the values from your Langflow deployment. ```bash curl -X POST \ - "http://localhost:7860/api/v1/webhook/**YOUR_FLOW_ID**" \ + "http://LANGFLOW_SERVER_ADDRESS/api/v1/webhook/FLOW_ID" \ -H 'Content-Type: application/json' \ -H 'x-api-key: LANGFLOW_API_KEY' \ -d '{"any": "data"}' - ``` +``` To test the webhook component: diff --git a/docs/docs/Develop/session-id.md b/docs/docs/Develop/session-id.md index bdf394f6a666..c044f0366598 100644 --- a/docs/docs/Develop/session-id.md +++ b/docs/docs/Develop/session-id.md @@ -16,10 +16,10 @@ This differentiation between users per session is helpful in managing client/ser Custom session IDs can be set as part of the payload in API calls, or as advanced settings in individual components. The API session ID value takes precedence. If no session ID is specified, the flow ID is assigned. If you set a custom session ID in a payload, all downstream components use the upstream component's session ID value. - +Replace `LANGFLOW_SERVER_ADDRESS`, `FLOW_ID`, and `LANGFLOW_API_KEY` with the values from your Langflow deployment. ``` curl --request POST \ - --url "http://localhost:7860/api/v1/run/$FLOW_ID" \ + --url "http://LANGFLOW_SERVER_ADDRESS/api/v1/run/FLOW_ID" \ --header "Content-Type: application/json" \ --header "x-api-key: LANGFLOW_API_KEY" \ --data '{ diff --git a/docs/docs/Get-Started/get-started-quickstart.md b/docs/docs/Get-Started/get-started-quickstart.md index bba1df225fec..93a4ecd86a8e 100644 --- a/docs/docs/Get-Started/get-started-quickstart.md +++ b/docs/docs/Get-Started/get-started-quickstart.md @@ -13,7 +13,7 @@ Get started with Langflow by loading a template flow, running it, and then servi - [A running Langflow instance](/get-started-installation) - [An OpenAI API key](https://platform.openai.com/api-keys) - +- [A Langflow API key](/configuration-api-keys) ## Create a Langflow API key @@ -22,7 +22,7 @@ A [Langflow API key](/configuration-api-keys) is a user-specific token you can u To create a Langflow API key, do the following: 1. In Langflow, click your user icon, and then select **Settings**. -2. Click **Langflow API Keys**, and then click **Add New**. +2. Click **Langflow API Keys**, and then click