mirror of
https://github.com/langflow-ai/langflow.git
synced 2026-07-24 00:03:32 +08:00
* version-1.9.0-docs * [autofix.ci] apply automated fixes * [autofix.ci] apply automated fixes (attempt 2/3) --------- Co-authored-by: autofix-ci[bot] <114827586+autofix-ci[bot]@users.noreply.github.com>
57 lines
2.2 KiB
Plaintext
57 lines
2.2 KiB
Plaintext
## Prerequisites
|
|
|
|
Before using the API, you need:
|
|
|
|
* [Install and start Langflow](/get-started-installation) with the developer API enabled
|
|
|
|
The Workflows API endpoints require the `developer_api_enabled` setting to be enabled. If this setting is disabled, these endpoints will return a 404 Not Found error.
|
|
|
|
To enable the developer API endpoint, do the following:
|
|
1. In the Langflow `.env` file, set the environment variable to `true`:
|
|
```
|
|
LANGFLOW_DEVELOPER_API_ENABLED=true
|
|
```
|
|
2. Start your Langflow server with the `.env` file enabled:
|
|
```
|
|
uv run langflow run --env-file .env
|
|
```
|
|
|
|
For more information about configuring environment variables, see [Environment variables](/environment-variables).
|
|
* [Create a Langflow API key](/api-keys-and-authentication)
|
|
* [Create a flow](/concepts-flows) that you want to execute
|
|
* [Get the flow ID](/concepts-publish#api-access) or endpoint name of the flow you want to execute
|
|
|
|
### Set environment variables
|
|
|
|
All code examples in this documentation assume you have set the following environment variables:
|
|
|
|
**Python:**
|
|
```python
|
|
import os
|
|
|
|
LANGFLOW_SERVER_URL = os.getenv("LANGFLOW_SERVER_URL")
|
|
LANGFLOW_API_KEY = os.getenv("LANGFLOW_API_KEY")
|
|
```
|
|
|
|
**TypeScript/JavaScript:**
|
|
```typescript
|
|
const LANGFLOW_SERVER_URL = process.env.LANGFLOW_SERVER_URL;
|
|
const LANGFLOW_API_KEY = process.env.LANGFLOW_API_KEY;
|
|
```
|
|
|
|
Set these environment variables before running the examples, or replace the variable references in the code examples with your actual Langflow server URL and API key.
|
|
|
|
The default `LANGFLOW_SERVER_URL` for a local Langflow deployment is `http://localhost:7860`.
|
|
For remote deployments, the domain is set by your hosting service, such as `https://UUID.ngrok.app`.
|
|
|
|
### Authentication and headers
|
|
|
|
All Workflows API requests require authentication using a Langflow API key. The API key is passed in the `x-api-key` header.
|
|
|
|
For more information, see [Create a Langflow API key](/api-keys-and-authentication).
|
|
|
|
| Header | Description | Example |
|
|
|--------|-------------|---------|
|
|
| `Content-Type` | Specifies the JSON format. | `application/json` |
|
|
| `x-api-key` | Your Langflow API key. | `sk-...` |
|
|
| `accept` | Optional. Specifies the response format. | `application/json` | |