### Troubleshooting and Setup Commands
Source: https://github.com/langgenius/dify/blob/main/scripts/stress-test/README.md
Commands for installing dependencies, running setup scripts, and managing permissions.
```bash
# Dependencies are installed automatically, but if needed:
uv --project api add --dev locust sseclient-py
```
```bash
# Run setup
python scripts/stress-test/setup_all.py
```
```bash
python scripts/stress-test/setup/mock_openai_server.py
```
```bash
chmod +x run_benchmark.sh
```
--------------------------------
### Run Setup Script
Source: https://github.com/langgenius/dify/blob/main/api/README.md
Execute the setup script to copy environment files and install dependencies. This is the recommended first step for setting up the Dify backend.
```bash
./dev/setup
```
--------------------------------
### GET /console/api/setup
Source: https://github.com/langgenius/dify/blob/main/api/openapi/markdown/console-openapi.md
Retrieves the system setup status. This endpoint is unauthenticated and designed for first-time bootstrap to query setup progress before any login flow.
```APIDOC
## GET /console/api/setup
### Description
Get system setup status.
NOTE: This endpoint is unauthenticated by design.
During first-time bootstrap there is no admin account yet, so frontend initialization must be
able to query setup progress before any login flow exists.
Only bootstrap-safe status information should be returned by this endpoint.
### Method
GET
### Endpoint
/console/api/setup
### Responses
#### Success Response (200)
- **application/json**: SetupStatusResponse
```
--------------------------------
### Run Full E2E Reset and Install
Source: https://github.com/langgenius/dify/blob/main/e2e/AGENTS.md
Perform a full reset, fresh install, and run authenticated scenarios. This command starts the required middleware and dependencies automatically.
```bash
pnpm -C e2e e2e:full
```
--------------------------------
### Basic Docker Compose Deployment
Source: https://github.com/langgenius/dify/blob/main/docker/README.md
Copy the example environment file and start the Dify services using Docker Compose.
```bash
cp .env.example .env
docker compose up -d
```
--------------------------------
### Copy and Edit Environment File
Source: https://github.com/langgenius/dify/blob/main/cli/test/e2e/README.md
Copies the example environment file for end-to-end tests and instructs to edit it with real credentials. This is the initial setup step for running tests.
```bash
cp cli/test/e2e/.env.e2e.example cli/.env.e2e
# edit cli/.env.e2e with real credentials
```
--------------------------------
### Get Application WebApp Settings Request
Source: https://github.com/langgenius/dify/blob/main/web/app/components/develop/template/template.en.mdx
Example of how to make a GET request to retrieve WebApp settings. Requires an API key for authorization.
```bash
curl -X GET '${props.appDetail.api_base_url}/site' \
-H 'Authorization: Bearer {api_key}'
```
--------------------------------
### Start Dify with Docker Compose
Source: https://github.com/langgenius/dify/blob/main/README.md
Use these commands to set up and run Dify locally. Ensure Docker and Docker Compose are installed. After running, access the dashboard at http://localhost/install.
```bash
cd dify
cd docker
cp .env.example .env
docker compose up -d
```
--------------------------------
### Start Dify Agent Server (Development with Uvicorn)
Source: https://github.com/langgenius/dify/blob/main/dify-agent/docs/dify-agent/get-started/index.md
This command provides an equivalent development setup using uvicorn directly, with hot-reloading enabled. Ensure to configure your .env file for ServerSettings.
```bash
uv run --extra server uvicorn dify_agent.server.app:app \
--host 127.0.0.1 \
--port 8000 \
--reload
```
--------------------------------
### Start Services and Check Metadata
Source: https://github.com/langgenius/dify/blob/main/docs/weaviate/WEAVIATE_MIGRATION_GUIDE/README.md
Start the services and wait for them to become available. Then, check the Weaviate metadata using curl.
```bash
docker compose up -d
sleep 30
curl http://localhost:8080/v1/meta
```
--------------------------------
### Start Storybook Server
Source: https://github.com/langgenius/dify/blob/main/web/README.md
Starts the Storybook server for UI component development. Access it via http://localhost:6006.
```bash
pnpm -C web storybook
```
--------------------------------
### Start Production Server
Source: https://github.com/langgenius/dify/blob/main/web/README.md
Starts the production server after the application has been built. You can specify a custom port and host.
```bash
pnpm -C web run start
```
```bash
pnpm -C web run start --port=3001 --host=0.0.0.0
```
--------------------------------
### Install Dify Node.js SDK
Source: https://github.com/langgenius/dify/blob/main/sdks/nodejs-client/README.md
Install the SDK using npm. This command downloads and installs the dify-client package into your project.
```bash
npm install dify-client
```
--------------------------------
### Run Stress Test Setup
Source: https://github.com/langgenius/dify/blob/main/scripts/stress-test/README.md
Executes the complete setup script for the stress testing environment.
```bash
# Run the complete setup
python scripts/stress-test/setup_all.py
```
--------------------------------
### Start Mock OpenAI Server
Source: https://github.com/langgenius/dify/blob/main/scripts/stress-test/README.md
Starts the mock server required for simulating OpenAI responses during tests.
```bash
python scripts/stress-test/setup/mock_openai_server.py
```
--------------------------------
### POST /installed-apps
Source: https://github.com/langgenius/dify/blob/main/api/openapi/markdown/console-openapi.md
Installs a new application. Requires a payload containing the necessary details for installation.
```APIDOC
## POST /installed-apps
### Description
Install a new application.
### Method
POST
### Endpoint
/installed-apps
### Parameters
#### Request Body
- **application/json**: InstalledAppCreatePayload - Required
### Responses
#### Success Response (200)
- **application/json**: SimpleMessageResponse
```
--------------------------------
### Install Backend Test Dependencies
Source: https://github.com/langgenius/dify/blob/main/api/README.md
Installs development dependencies for the backend and testing environment using uv. Ensure you are in the 'api' directory before running.
```bash
cd api
uv sync --group dev
```
--------------------------------
### Get Application Basic Information Response
Source: https://github.com/langgenius/dify/blob/main/web/app/components/develop/template/template.en.mdx
Example JSON response when requesting application basic information. It includes fields like name, description, tags, mode, and author_name.
```json
{
"name": "My App",
"description": "This is my app.",
"tags": [
"tag1",
"tag2"
],
"mode": "chat",
"author_name": "Dify"
}
```
--------------------------------
### Install Dependencies
Source: https://github.com/langgenius/dify/blob/main/web/README.md
Installs project dependencies using pnpm. Ensure you run this from the repository root.
```bash
pnpm install
```
--------------------------------
### Start Web Service
Source: https://github.com/langgenius/dify/blob/main/api/README.md
Starts the Dify frontend web service. JavaScript dependencies are managed through the repository root workspace.
```bash
./dev/start-web
```
--------------------------------
### Installing Dify Agent Skills (with Options)
Source: https://github.com/langgenius/dify/blob/main/cli/README.md
Install a skill to detected agents, restrict installation to a subset of agents, or force installation into a specific directory.
```sh
difyctl skills install --yes
```
```sh
difyctl skills install --agent claude-code[,cursor]
```
```sh
difyctl skills install
```
--------------------------------
### Install Dev Proxy
Source: https://github.com/langgenius/dify/blob/main/packages/dev-proxy/README.md
Install the dev-proxy package as a development dependency.
```bash
pnpm add -D @langgenius/dev-proxy
```
--------------------------------
### Install Playwright Browsers
Source: https://github.com/langgenius/dify/blob/main/e2e/AGENTS.md
Install Playwright browsers and perform initial checks for the E2E test package. Run these commands from the repository root.
```bash
pnpm install
pnpm -C e2e e2e:install
pnpm -C e2e check
```
--------------------------------
### POST /workspaces/current/plugin/install/github
Source: https://github.com/langgenius/dify/blob/main/api/openapi/markdown/console-openapi.md
Installs a plugin from a GitHub repository. This endpoint requires a request body containing the necessary information for GitHub installation.
```APIDOC
## POST /workspaces/current/plugin/install/github
### Description
Installs a plugin from a GitHub repository.
### Method
POST
### Endpoint
/workspaces/current/plugin/install/github
#### Request Body
- **application/json**: [ParserGithubInstall](#parsergithubinstall) - Required
#### Responses
##### Success Response (200)
- **application/json**: [PluginDaemonOperationResponse](#plugindaemonoperationresponse)
```
--------------------------------
### POST /workspaces/current/plugin/install/pkg
Source: https://github.com/langgenius/dify/blob/main/api/openapi/markdown/console-openapi.md
Installs a plugin from a package. This endpoint requires a request body specifying the plugin identifiers to be installed.
```APIDOC
## POST /workspaces/current/plugin/install/pkg
### Description
Installs a plugin from a package.
### Method
POST
### Endpoint
/workspaces/current/plugin/install/pkg
#### Request Body
- **application/json**: [ParserPluginIdentifiers](#parserpluginidentifiers) - Required
#### Responses
##### Success Response (200)
- **application/json**: [PluginDaemonOperationResponse](#plugindaemonoperationresponse)
```
--------------------------------
### POST /console/api/setup
Source: https://github.com/langgenius/dify/blob/main/api/openapi/markdown/console-openapi.md
Initializes the Dify system setup by creating an admin account. This endpoint is unauthenticated for first-time bootstrap and restricted by deployment mode and init-password validation.
```APIDOC
## POST /console/api/setup
### Description
Initialize system setup with admin account.
NOTE: This endpoint is unauthenticated by design for first-time bootstrap.
Access is restricted by deployment mode (`SELF_HOSTED`), one-time setup guards,
and init-password validation rather than user session authentication.
### Method
POST
### Endpoint
/console/api/setup
### Request Body
- **application/json**: SetupRequestPayload
### Responses
#### Success Response (201)
- **application/json**: SetupResponse
```
--------------------------------
### Run Dify Agent Client Example
Source: https://github.com/langgenius/dify/blob/main/dify-agent/docs/dify-agent/get-started/index.md
Execute the Dify Agent client example script from the dify-agent directory. Ensure your server-side .env is configured correctly.
```bash
uv run python ./run_dify_agent_client.py
```
--------------------------------
### Get Suggested Messages Request
Source: https://github.com/langgenius/dify/blob/main/web/app/components/develop/template/template_advanced_chat.en.mdx
Example of a GET request to retrieve suggested messages for a given message ID. Requires an API key and user identifier.
```shell
curl --location --request GET 'https://your-api-base-url/messages/{message_id}/suggested?user=abc-123' \
--header 'Authorization: Bearer ENTER-YOUR-SECRET-KEY' \
--header 'Content-Type: application/json'
```
--------------------------------
### GET /installed-apps/{installed_app_id}/parameters
Source: https://github.com/langgenius/dify/blob/main/api/openapi/markdown/console-openapi.md
Retrieves the parameters for a specific installed app.
```APIDOC
## GET /installed-apps/{installed_app_id}/parameters
### Description
Retrieves the parameters for a specific installed app.
### Method
GET
### Endpoint
/installed-apps/{installed_app_id}/parameters
#### Path Parameters
- **installed_app_id** (string (uuid)) - Required -
### Responses
#### Success Response (200)
- **application/json**: [Parameters](#parameters)
```
--------------------------------
### GET /installed-apps/{installed_app_id}/meta
Source: https://github.com/langgenius/dify/blob/main/api/openapi/markdown/console-openapi.md
Retrieves metadata for a specific installed app.
```APIDOC
## GET /installed-apps/{installed_app_id}/meta
### Description
Retrieves metadata for a specific installed app.
### Method
GET
### Endpoint
/installed-apps/{installed_app_id}/meta
#### Path Parameters
- **installed_app_id** (string (uuid)) - Required -
### Responses
#### Success Response (200)
- **application/json**: [ExploreAppMetaResponse](#exploreappmetaresponse)
```
--------------------------------
### Get Conversation History Messages Request
Source: https://github.com/langgenius/dify/blob/main/web/app/components/develop/template/template_advanced_chat.en.mdx
Example of a GET request to fetch historical chat messages for a specific conversation. Includes parameters for user, conversation ID, and pagination.
```shell
curl -X GET 'https://your-api-base-url/messages?user=abc-123&conversation_id={conversation_id}'
--header 'Authorization: Bearer {api_key}'
```
--------------------------------
### GET /installed-apps
Source: https://github.com/langgenius/dify/blob/main/api/openapi/markdown/console-openapi.md
Retrieves a list of installed applications, with an option to filter by App ID.
```APIDOC
## GET /installed-apps
### Description
Get a list of installed applications.
### Method
GET
### Endpoint
/installed-apps
### Parameters
#### Query Parameters
- **app_id** (string) - Optional - App ID to filter by
### Responses
#### Success Response (200)
- **application/json**: InstalledAppListResponse
```
--------------------------------
### Run Development Server
Source: https://github.com/langgenius/dify/blob/main/web/README.md
Starts the Next.js development server. Use `dev:vinext` for an enhanced experience with vinext, or `dev:proxy` to enable a development proxy server.
```bash
pnpm -C web run dev
```
```bash
pnpm -C web run dev:vinext
```
```bash
pnpm -C web run dev:proxy
```
--------------------------------
### GET /workspaces/current/plugin/list
Source: https://github.com/langgenius/dify/blob/main/api/openapi/markdown/console-openapi.md
Retrieves a list of installed plugins within the current workspace. Supports pagination.
```APIDOC
## GET /workspaces/current/plugin/list
### Description
Retrieves a list of installed plugins within the current workspace. Supports pagination.
### Method
GET
### Endpoint
/workspaces/current/plugin/list
### Parameters
#### Query Parameters
- **page** (integer) - Optional - Page number. Default: 1
- **page_size** (integer) - Optional - Page size (1-256). Default: 256
### Responses
#### Success Response (200)
- **application/json**: PluginListResponse
```
--------------------------------
### GET /installed-apps/{installed_app_id}/saved-messages
Source: https://github.com/langgenius/dify/blob/main/api/openapi/markdown/console-openapi.md
Retrieves a list of saved messages for a given installed app. Supports pagination.
```APIDOC
## GET /installed-apps/{installed_app_id}/saved-messages
### Description
Retrieves a list of saved messages for a given installed app. Supports pagination.
### Method
GET
### Endpoint
/installed-apps/{installed_app_id}/saved-messages
#### Query Parameters
- **last_id** (string) - Optional -
- **limit** (integer) - Optional - Default: 20
#### Path Parameters
- **installed_app_id** (string (uuid)) - Required -
### Responses
#### Success Response (200)
- **application/json**: [SavedMessageInfiniteScrollPagination](#savedmessageinfinitescrollpagination)
```
--------------------------------
### Running a Command with Mocked Dependencies
Source: https://github.com/langgenius/dify/blob/main/cli/ARD.md
Demonstrates how to execute a command, `runGetApp`, with mocked HTTP clients and I/O streams for testing purposes. The output is then asserted for correctness.
```typescript
const io = bufferStreams()
const result = await runGetApp(
{ format: 'json', appId: 'app-1' },
{ bundle, http: mockHttp, io, appsFactory: () => fakeClient },
)
expect(JSON.parse(result).data).toHaveLength(1)
```
--------------------------------
### GET /installed-apps/{installed_app_id}/conversations
Source: https://github.com/langgenius/dify/blob/main/api/openapi/markdown/console-openapi.md
Retrieves a list of conversations for a specific installed application, with options for pagination and filtering.
```APIDOC
## GET /installed-apps/{installed_app_id}/conversations
### Description
Retrieves a list of conversations for a specific installed application, with options for pagination and filtering.
### Method
GET
### Endpoint
/installed-apps/{installed_app_id}/conversations
#### Parameters
##### Path Parameters
- **installed_app_id** (string (uuid)) - Required -
##### Query Parameters
- **last_id** (string) - Optional -
- **limit** (integer) - Optional - Default: 20
- **pinned** (boolean) - Optional -
#### Responses
##### Success Response (200)
- **application/json**: ConversationInfiniteScrollPagination
```
--------------------------------
### GET /installed-apps/{installed_app_id}/messages/{message_id}/suggested-questions
Source: https://github.com/langgenius/dify/blob/main/api/openapi/markdown/console-openapi.md
Retrieves suggested questions related to a specific message from an installed app.
```APIDOC
## GET /installed-apps/{installed_app_id}/messages/{message_id}/suggested-questions
### Description
Retrieves suggested questions related to a specific message from an installed app.
### Method
GET
### Endpoint
/installed-apps/{installed_app_id}/messages/{message_id}/suggested-questions
#### Path Parameters
- **installed_app_id** (string (uuid)) - Required -
- **message_id** (string (uuid)) - Required -
### Responses
#### Success Response (200)
- **application/json**: [SuggestedQuestionsResponse](#suggestedquestionsresponse)
```
--------------------------------
### Install Dify using Docker Compose
Source: https://github.com/langgenius/dify/blob/main/docs/tlh/README.md
Quickly set up Dify by running the provided docker-compose.yml file. Ensure Docker and Docker Compose are installed beforehand.
```bash
cd docker
cp .env.example .env
docker compose up -d
```
--------------------------------
### Streaming Workflow Events
Source: https://github.com/langgenius/dify/blob/main/web/app/components/develop/template/template_workflow.en.mdx
This example shows Server-Sent Events (SSE) for a workflow, including start, node progression, and completion.
```streaming
data: {"event": "workflow_started", "task_id": "5ad4cb98-f0c7-4085-b384-88c403be6290", "workflow_run_id": "5ad498-f0c7-4085-b384-88cbe6290", "data": {"id": "5ad498-f0c7-4085-b384-88cbe6290", "workflow_id": "dfjasklfjdslag", "created_at": 1679586595}}
data: {"event": "node_started", "task_id": "5ad4cb98-f0c7-4085-b384-88c403be6290", "workflow_run_id": "5ad498-f0c7-4085-b384-88cbe6290", "data": {"id": "5ad498-f0c7-4085-b384-88cbe6290", "node_id": "dfjasklfjdslag", "node_type": "start", "title": "Start", "index": 0, "predecessor_node_id": "fdljewklfklgejlglsd", "inputs": {}, "created_at": 1679586595}}
data: {"event": "node_finished", "task_id": "5ad4cb98-f0c7-4085-b384-88c403be6290", "workflow_run_id": "5ad498-f0c7-4085-b384-88cbe6290", "data": {"id": "5ad498-f0c7-4085-b384-88cbe6290", "node_id": "dfjasklfjdslag", "node_type": "start", "title": "Start", "index": 0, "predecessor_node_id": "fdljewklfklgejlglsd", "inputs": {}, "outputs": {}, "status": "succeeded", "elapsed_time": 0.324, "execution_metadata": {"total_tokens": 63127864, "total_price": 2.378, "currency": "USD"}, "created_at": 1679586595}}
data: {"event": "workflow_finished", "task_id": "5ad4cb98-f0c7-4085-b384-88c403be6290", "workflow_run_id": "5ad498-f0c7-4085-b384-88cbe6290", "data": {"id": "5ad498-f0c7-4085-b384-88cbe6290", "workflow_id": "dfjasklfjdslag", "outputs": {}, "status": "succeeded", "elapsed_time": 0.324, "total_tokens": 63127864, "total_steps": "1", "created_at": 1679586595, "finished_at": 1679976595}}
data: {"event": "tts_message", "conversation_id": "23dd85f3-1a41-4ea0-b7a9-062734ccfaf9", "message_id": "a8bdc41c-13b2-4c18-bfd9-054b9803038c", "created_at": 1721205487, "task_id": "3bf8a0bb-e73b-4690-9e66-4e429bad8ee7", "audio": "qqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqq"}
data: {"event": "tts_message_end", "conversation_id": "23dd85f3-1a41-4ea0-b7a9-062734ccfaf9", "message_id": "a8bdc41c-13b2-4c18-bfd9-054b9803038c", "created_at": 1721205487, "task_id": "3bf8a0bb-e73b-4690-9e66-4e429bad8ee7", "audio": ""}
```
--------------------------------
### Agenton Basics Example
Source: https://github.com/langgenius/dify/blob/main/dify-agent/docs/agenton/examples/index.md
Demonstrates the basic usage of Agenton. This snippet is located at /examples/agenton/agenton_examples/basics.py.
```python
from langgraph.graph import StateGraph, END
from typing import TypedDict, Annotated
import operator
class State(TypedDict):
# State definition for the graph
input: str
output: Annotated[str, operator.add]
def add(state: State) -> State:
# Function to add input to output
return {"output": state["input"]}
def multiply(state: State) -> State:
# Function to multiply input to output
return {"output": state["input"]}
workflow = StateGraph(State)
workflow.add_node("add", add)
workflow.add_node("multiply", multiply)
workflow.set_entry_point("add")
workflow.add_edge("add", "multiply")
workflow.add_edge("multiply", "add")
app = workflow.compile()
inputs = {"input": "hello world"}
# Run the graph for 5 steps
for s in app.stream(inputs, {
```
```python
from langgraph.graph import StateGraph, END
from typing import TypedDict, Annotated
import operator
class State(TypedDict):
# State definition for the graph
input: str
output: Annotated[str, operator.add]
def add(state: State) -> State:
# Function to add input to output
return {"output": state["input"]}
def multiply(state: State) -> State:
# Function to multiply input to output
return {"output": state["input"]}
workflow = StateGraph(State)
workflow.add_node("add", add)
workflow.add_node("multiply", multiply)
workflow.set_entry_point("add")
workflow.add_edge("add", "multiply")
workflow.add_edge("multiply", "add")
app = workflow.compile()
inputs = {"input": "hello world"}
# Run the graph for 5 steps
for s in app.stream(inputs, {"recursion_limit": 5}):
print(s)
```
--------------------------------
### Starting Mock Server for Fixtures
Source: https://github.com/langgenius/dify/blob/main/cli/ARD.md
Shows how to import and start an isolated instance of the `dify-mock` server for testing, specifying a scenario. The mock server should be stopped after the test.
```typescript
import { startMock } from '../../../test/fixtures/dify-mock/server.js'
const mock = await startMock({ scenario: 'happy' })
// ... test against mock.url ...
await mock.stop()
```
--------------------------------
### GET /installed-apps/{installed_app_id}/messages
Source: https://github.com/langgenius/dify/blob/main/api/openapi/markdown/console-openapi.md
Retrieves a list of messages for a given installed app. Supports pagination and filtering by conversation ID.
```APIDOC
## GET /installed-apps/{installed_app_id}/messages
### Description
Retrieves a list of messages for a given installed app. Supports pagination and filtering by conversation ID.
### Method
GET
### Endpoint
/installed-apps/{installed_app_id}/messages
#### Query Parameters
- **conversation_id** (string) - Required - Conversation ID.
- **first_id** (string) - Optional - The ID of the first chat record on the current page. Omit this value to fetch the latest messages; for subsequent pages, use the first message ID from the current list to fetch older messages.
- **limit** (integer) - Optional - Number of chat history messages to return per request. Default: 20
#### Path Parameters
- **installed_app_id** (string (uuid)) - Required -
### Responses
#### Success Response (200)
- **application/json**: [MessageInfiniteScrollPagination](#messageinfinitescrollpagination)
```
--------------------------------
### GET /rag/pipelines/{pipeline_id}/workflows/default-workflow-block-configs
Source: https://github.com/langgenius/dify/blob/main/api/openapi/markdown/console-openapi.md
Retrieves the default block configuration for a pipeline. This is useful for understanding the default setup of workflow blocks.
```APIDOC
## GET /rag/pipelines/{pipeline_id}/workflows/default-workflow-block-configs
### Description
Get default block config
### Method
GET
### Endpoint
/rag/pipelines/{pipeline_id}/workflows/default-workflow-block-configs
### Parameters
#### Path Parameters
- **pipeline_id** (string (uuid)) - Required -
### Responses
#### Success Response (200)
Default block configs retrieved successfully. Schema: application/json: [DefaultBlockConfigsResponse](#defaultblockconfigsresponse)
```
--------------------------------
### Launch legacy server
Source: https://github.com/langgenius/dify/blob/main/docker/certbot/README.md
Start containers without the Certbot profile to use existing local SSL files.
```shell
docker compose up -d
```
--------------------------------
### Get Conversations Request Example
Source: https://github.com/langgenius/dify/blob/main/web/app/components/develop/template/template_advanced_chat.en.mdx
This cURL command demonstrates how to retrieve a list of conversations for a specific user, with options for pagination and sorting.
```bash
curl -X GET 'https://api.example.com/conversations?user=abc-123&last_id=&limit=20' \
--header 'Authorization: Bearer {api_key}'
```
--------------------------------
### GET /installed-apps/{installed_app_id}/messages/{message_id}/more-like-this
Source: https://github.com/langgenius/dify/blob/main/api/openapi/markdown/console-openapi.md
Retrieves similar messages or responses based on a given message ID from an installed app.
```APIDOC
## GET /installed-apps/{installed_app_id}/messages/{message_id}/more-like-this
### Description
Retrieves similar messages or responses based on a given message ID from an installed app.
### Method
GET
### Endpoint
/installed-apps/{installed_app_id}/messages/{message_id}/more-like-this
#### Query Parameters
- **response_mode** (string) - Required - Available values: "blocking", "streaming"
#### Path Parameters
- **installed_app_id** (string (uuid)) - Required -
- **message_id** (string (uuid)) - Required -
### Responses
#### Success Response (200)
- **application/json**: [GeneratedAppResponse](#generatedappresponse)
```
--------------------------------
### Test Scenarios
Source: https://github.com/langgenius/dify/blob/main/scripts/stress-test/README.md
Configuration examples for different load levels.
```yaml
concurrency: 10
iterations: 100
```
```yaml
concurrency: 100
iterations: 1000
```
```yaml
concurrency: 500
iterations: 5000
```
```yaml
concurrency: 1000
iterations: 10000
```
--------------------------------
### GET /apps/{app_id}/statistics/daily-end-users
Source: https://github.com/langgenius/dify/blob/main/api/openapi/markdown/console-openapi.md
Retrieves the daily terminal/end-user statistics for a given application. Optional start and end dates can be provided to filter the statistics.
```APIDOC
## GET /apps/{app_id}/statistics/daily-end-users
### Description
Get daily terminal/end-user statistics for an application.
### Method
GET
### Endpoint
/apps/{app_id}/statistics/daily-end-users
### Parameters
#### Path Parameters
- **app_id** (string (uuid)) - Required - Application ID
#### Query Parameters
- **end** (string) - Optional - End date (YYYY-MM-DD HH:MM)
- **start** (string) - Optional - Start date (YYYY-MM-MM HH:MM)
### Responses
#### Success Response (200)
- **application/json**: [DailyTerminalStatisticResponse](#dailyterminalstatisticresponse)
```
--------------------------------
### Example .env File for Dify Agent Configuration
Source: https://github.com/langgenius/dify/blob/main/dify-agent/docs/dify-agent/guide/index.md
This example .env file demonstrates how to configure various Dify Agent server settings, including Redis connection, plugin daemon URLs, and security keys. Adjust values according to your environment.
```env
DIFY_AGENT_REDIS_URL=redis://localhost:6379/0
DIFY_AGENT_REDIS_PREFIX=dify-agent-dev
DIFY_AGENT_SHUTDOWN_GRACE_SECONDS=30
DIFY_AGENT_RUN_RETENTION_SECONDS=259200
DIFY_AGENT_PLUGIN_DAEMON_URL=http://localhost:5002
DIFY_AGENT_PLUGIN_DAEMON_API_KEY=replace-with-daemon-key
DIFY_AGENT_SHELLCTL_ENTRYPOINT=http://127.0.0.1:5004
DIFY_AGENT_SHELLCTL_AUTH_TOKEN=replace-with-shellctl-token
# Generate with: python -c 'import base64, secrets; print(base64.urlsafe_b64encode(secrets.token_bytes(32)).rstrip(b"=").decode())'
DIFY_AGENT_STUB_URL=https://agent.example.com/agent-stub
DIFY_AGENT_SERVER_SECRET_KEY=replace-with-base64url-32-byte-secret
```
--------------------------------
### GET /apps/{app_id}/statistics/daily-conversations
Source: https://github.com/langgenius/dify/blob/main/api/openapi/markdown/console-openapi.md
Retrieves the daily conversation statistics for a given application. Optional start and end dates can be provided to filter the statistics.
```APIDOC
## GET /apps/{app_id}/statistics/daily-conversations
### Description
Get daily conversation statistics for an application.
### Method
GET
### Endpoint
/apps/{app_id}/statistics/daily-conversations
### Parameters
#### Path Parameters
- **app_id** (string (uuid)) - Required - Application ID
#### Query Parameters
- **end** (string) - Optional - End date (YYYY-MM-DD HH:MM)
- **start** (string) - Optional - Start date (YYYY-MM-DD HH:MM)
### Responses
#### Success Response (200)
- **application/json**: [DailyConversationStatisticResponse](#dailyconversationstatisticresponse)
```
--------------------------------
### GET /apps/{app_id}/statistics/average-session-interactions
Source: https://github.com/langgenius/dify/blob/main/api/openapi/markdown/console-openapi.md
Retrieves the average session interaction statistics for a given application. Optional start and end dates can be provided to filter the statistics.
```APIDOC
## GET /apps/{app_id}/statistics/average-session-interactions
### Description
Get average session interaction statistics for an application.
### Method
GET
### Endpoint
/apps/{app_id}/statistics/average-session-interactions
### Parameters
#### Path Parameters
- **app_id** (string (uuid)) - Required - Application ID
#### Query Parameters
- **end** (string) - Optional - End date (YYYY-MM-DD HH:MM)
- **start** (string) - Optional - Start date (YYYY-MM-DD HH:MM)
### Responses
#### Success Response (200)
- **application/json**: [AverageSessionInteractionStatisticResponse](#averagesessioninteractionstatisticresponse)
```
--------------------------------
### Configure Environment Variables
Source: https://github.com/langgenius/dify/blob/main/web/README.md
Copies the example environment file to a local file for customization. Modify the copied file to set necessary environment variables for the frontend.
```bash
cp web/.env.example web/.env.local
```
--------------------------------
### GET /apps/{app_id}/statistics/average-response-time
Source: https://github.com/langgenius/dify/blob/main/api/openapi/markdown/console-openapi.md
Retrieves the average response time statistics for a given application. Optional start and end dates can be provided to filter the statistics.
```APIDOC
## GET /apps/{app_id}/statistics/average-response-time
### Description
Get average response time statistics for an application.
### Method
GET
### Endpoint
/apps/{app_id}/statistics/average-response-time
### Parameters
#### Path Parameters
- **app_id** (string (uuid)) - Required - Application ID
#### Query Parameters
- **end** (string) - Optional - End date (YYYY-MM-DD HH:MM)
- **start** (string) - Optional - Start date (YYYY-MM-DD HH:MM)
### Responses
#### Success Response (200)
- **application/json**: [AverageResponseTimeStatisticResponse](#averageresponsetimestatisticresponse)
```
--------------------------------
### Get Application Parameters Information
Source: https://github.com/langgenius/dify/blob/main/web/app/components/develop/template/template_workflow.en.mdx
Obtains information about application features, input parameter names, types, and default values. This is used at the start of entering the page.
```APIDOC
## GET /parameters
### Description
Obtains information about application features, input parameter names, types, and default values. This is used at the start of entering the page.
### Method
GET
### Endpoint
/parameters
### Response
#### Success Response (200)
- `user_input_form` (array[object]) User input form configuration
- `text-input` (object) Text input control
- `label` (string) Variable display label name
- `variable` (string) Variable ID
- `required` (bool) Whether it is required
- `default` (string) Default value
- `paragraph` (object) Paragraph text input control
- `label` (string) Variable display label name
- `variable` (string) Variable ID
- `required` (bool) Whether it is required
- `default` (string) Default value
- `select` (object) Dropdown control
- `label` (string) Variable display label name
- `variable` (string) Variable ID
- `required` (bool) Whether it is required
- `default` (string) Default value
- `options` (array[string]) Option values
- `file_upload` (object) File upload configuration
- `document` (object) Document settings
Currently only supports document types: `txt`, `md`, `markdown`, `pdf`, `html`, `xlsx`, `xls`, `docx`, `csv`, `eml`, `msg`, `pptx`, `ppt`, `xml`, `epub`.
- `enabled` (bool) Whether it is enabled
- `number_limits` (int) Document number limit, default is 3
- `transfer_methods` (array[string]) List of transfer methods: `remote_url`, `local_file`. Must choose one.
- `image` (object) Image settings
Currently only supports image types: `png`, `jpg`, `jpeg`, `webp`, `gif`.
- `enabled` (bool) Whether it is enabled
- `number_limits` (int) Image number limit, default is 3
- `transfer_methods` (array[string]) List of transfer methods: `remote_url`, `local_file`. Must choose one.
- `audio` (object) Audio settings
Currently only supports audio types: `mp3`, `m4a`, `wav`, `webm`, `amr`.
- `enabled` (bool) Whether it is enabled
- `number_limits` (int) Audio number limit, default is 3
- `transfer_methods` (array[string]) List of transfer methods: `remote_url`, `local_file`. Must choose one.
- `video` (object) Video settings
Currently only supports video types: `mp4`, `mov`, `mpeg`, `mpga`.
- `enabled` (bool) Whether it is enabled
- `number_limits` (int) Video number limit, default is 3
- `transfer_methods` (array[string]) List of transfer methods: `remote_url`, `local_file`. Must choose one.
- `custom` (object) Custom settings
- `enabled` (bool) Whether it is enabled
- `number_limits` (int) Custom number limit, default is 3
- `transfer_methods` (array[string]) List of transfer methods: `remote_url`, `local_file`. Must choose one.
- `system_parameters` (object) System parameters
- `file_size_limit` (int) Document upload size limit (MB)
- `image_file_size_limit` (int) Image file upload size limit (MB)
- `audio_file_size_limit` (int) Audio file upload size limit (MB)
- `video_file_size_limit` (int) Video file upload size limit (MB)
### Request Example
```bash
curl -X GET '/parameters'
```
```
--------------------------------
### Default Local Startup Command
Source: https://github.com/langgenius/dify/blob/main/dify-agent/docs/dify-agent/guide/index.md
Use this command to start the Dify Agent server locally with uvicorn and FastAPI. Ensure Redis is running beforehand.
```bash
uv run --project dify-agent uvicorn dify_agent.server.app:app --reload
```
--------------------------------
### GET /installed-apps/{installed_app_id}/messages/{message_id}/more-like-this
Source: https://github.com/langgenius/dify/blob/main/packages/contracts/non-json-openapi-responses.md
Retrieves messages similar to a given message for an installed app. Supports streaming responses via `response_mode=streaming`.
```APIDOC
## GET /installed-apps/{installed_app_id}/messages/{message_id}/more-like-this
### Description
Retrieves messages similar to a given message for an installed app. Supports streaming responses via `response_mode=streaming`.
### Method
GET
### Endpoint
`/installed-apps/{installed_app_id}/messages/{message_id}/more-like-this`
### Parameters
#### Path Parameters
- **installed_app_id** (string) - Required - The ID of the installed application.
- **message_id** (string) - Required - The ID of the message to find similar messages for.
#### Query Parameters
- **response_mode** (string) - Optional - Set to `streaming` for streaming responses.
### Response
#### Success Response (200)
- **GeneratedAppResponse** (object) - The schema for the generated application response.
#### Response Example
(Schema details not provided in source)
```
--------------------------------
### GET /workspaces/current/trigger-provider/{provider}/oauth/client
Source: https://github.com/langgenius/dify/blob/main/api/openapi/markdown/console-openapi.md
Retrieves the OAuth client configuration for a given trigger provider. This endpoint is used to fetch the details of the OAuth client setup.
```APIDOC
## GET /workspaces/current/trigger-provider/{provider}/oauth/client
### Description
Get OAuth client configuration for a provider
### Method
GET
### Endpoint
/workspaces/current/trigger-provider/{provider}/oauth/client
#### Path Parameters
- **provider** (string) - Required -
#### Responses
#### Success Response (200)
- **application/json**: [TriggerOAuthClientResponse](#triggeroauthclientresponse)
```
--------------------------------
### POST /datasets/init
Source: https://github.com/langgenius/dify/blob/main/api/openapi/markdown/console-openapi.md
Initializes a new dataset with provided documents and configuration. This is the starting point for creating and setting up a dataset.
```APIDOC
## POST /datasets/init
### Description
Initializes a dataset with documents.
### Method
POST
### Endpoint
/datasets/init
#### Request Body
- **application/json**: [KnowledgeConfig](#knowledgeconfig) - Required
#### Responses
##### Success Response (201)
- **application/json**: [DatasetAndDocumentResponse](#datasetanddocumentresponse)
##### Error Response (400)
- Description: Invalid request parameters
```
--------------------------------
### Get Suggested Messages
Source: https://github.com/langgenius/dify/blob/main/web/app/components/develop/template/template_advanced_chat.en.mdx
Retrieves suggested responses for a given message ID. This can be useful for providing users with quick reply options or guiding the conversation flow.
```APIDOC
## GET /messages/{message_id}/suggested
### Description
Retrieves suggested responses for a given message ID.
### Method
GET
### Endpoint
/messages/{message_id}/suggested
### Parameters
#### Query Parameters
- **user** (string) - Required - User identifier, used to define the identity of the end-user for retrieval and statistics. Should be uniquely defined by the developer within the application.
### Request Example
```bash
curl --location --request GET 'YOUR_API_BASE_URL/messages/{message_id}/suggested?user=abc-123' \
--header 'Authorization: Bearer ENTER-YOUR-SECRET-KEY' \
--header 'Content-Type: application/json'
```
### Response
#### Success Response (200)
- **data** (array[string]) - List of suggested responses.
#### Response Example
```json
{
"result": "success",
"data": [
"a",
"b",
"c"
]
}
```
```
--------------------------------
### GET /workspaces/current/trigger-provider/{provider}/subscriptions/oauth/authorize
Source: https://github.com/langgenius/dify/blob/main/api/openapi/markdown/console-openapi.md
Initiate OAuth authorization flow for a trigger provider. This endpoint starts the process for authorizing access to a trigger provider via OAuth.
```APIDOC
## GET /workspaces/current/trigger-provider/{provider}/subscriptions/oauth/authorize
### Description
Initiate OAuth authorization flow for a trigger provider.
### Method
GET
### Endpoint
/workspaces/current/trigger-provider/{provider}/subscriptions/oauth/authorize
#### Path Parameters
- **provider** (string) - Required -
#### Success Response (200)
- **application/json**: TriggerOAuthAuthorizeResponse - Authorization URL retrieved successfully
```
--------------------------------
### Start Middleware Stack
Source: https://github.com/langgenius/dify/blob/main/e2e/AGENTS.md
Starts the full middleware stack required for E2E testing, including PostgreSQL, Redis, Weaviate, Sandbox, SSRF proxy, and Plugin daemon.
```bash
pnpm -C e2e e2e:middleware:up
```
--------------------------------
### Get Application WebApp Settings Response
Source: https://github.com/langgenius/dify/blob/main/web/app/components/develop/template/template.en.mdx
Example JSON response for the WebApp settings. Includes details like app title, theme, icon, and privacy policy.
```json
{
"title": "My App",
"chat_color_theme": "#ff4a4a",
"chat_color_theme_inverted": false,
"icon_type": "emoji",
"icon": "😄",
"icon_background": "#FFEAD5",
"icon_url": null,
"description": "This is my app.",
"copyright": "all rights reserved",
"privacy_policy": "",
"custom_disclaimer": "All generated by AI",
"default_language": "en-US",
"show_workflow_steps": false,
"use_icon_as_answer_icon": false,
}
```
--------------------------------
### Initialize and use Dify PHP SDK
Source: https://github.com/langgenius/dify/blob/main/sdks/php-client/README.md
Demonstrates client initialization and common API operations including chat, completion, vision support, and file management.
```php
create_completion_message(array("query" => "Who are you?"), "blocking", "user_id");
// Create a chat client
$chatClient = new ChatClient($apiKey);
$response = $chatClient->create_chat_message(array(), "Who are you?", "user_id", "blocking", $conversation_id);
$fileForVision = [
[
"type" => "image",
"transfer_method" => "remote_url",
"url" => "your_image_url"
]
];
// $fileForVision = [
// [
// "type" => "image",
// "transfer_method" => "local_file",
// "url" => "your_file_id"
// ]
// ];
// Create a completion client with vision model like gpt-4-vision
$response = $completionClient->create_completion_message(array("query" => "Describe this image."), "blocking", "user_id", $fileForVision);
// Create a chat client with vision model like gpt-4-vision
$response = $chatClient->create_chat_message(array(), "Describe this image.", "user_id", "blocking", $conversation_id, $fileForVision);
// File Upload
$fileForUpload = [
[
'tmp_name' => '/path/to/file/filename.jpg',
'name' => 'filename.jpg'
]
];
$response = $difyClient->file_upload("user_id", $fileForUpload);
$result = json_decode($response->getBody(), true);
echo 'upload_file_id: ' . $result['id'];
// Fetch application parameters
$response = $difyClient->get_application_parameters("user_id");
// Provide feedback for a message
$response = $difyClient->message_feedback($message_id, $rating, "user_id");
// Other available methods:
// - get_conversation_messages()
// - get_conversations()
// - rename_conversation()
```
--------------------------------
### Get workflow daily terminals statistics
Source: https://github.com/langgenius/dify/blob/main/api/openapi/markdown/console-openapi.md
Retrieves daily statistics for workflow terminals within a specified date range. Optional start and end date parameters can be provided.
```APIDOC
## GET /apps/{app_id}/workflow/statistics/daily-terminals
### Description
Get workflow daily terminals statistics.
### Method
GET
### Endpoint
/apps/{app_id}/workflow/statistics/daily-terminals
#### Path Parameters
- **app_id** (string (uuid)) - Required - Application ID
#### Query Parameters
- **end** (string) - Optional - End date and time (YYYY-MM-DD HH:MM)
- **start** (string) - Optional - Start date and time (YYYY-MM-DD HH:MM)
### Response
#### Success Response (200)
- **application/json** - WorkflowDailyTerminalsStatisticResponse
```
--------------------------------
### Start Backend Service
Source: https://github.com/langgenius/dify/blob/main/api/README.md
Starts the Dify backend service, which includes running necessary database migrations. This command should be run after the middleware services are active.
```bash
./dev/start-api
```
--------------------------------
### Initialize Certbot containers
Source: https://github.com/langgenius/dify/blob/main/docker/certbot/README.md
Commands to prune networks and start the Certbot profile.
```shell
docker network prune
docker compose --profile certbot up --force-recreate -d
```
--------------------------------
### Get workflow daily runs statistics
Source: https://github.com/langgenius/dify/blob/main/api/openapi/markdown/console-openapi.md
Retrieves daily statistics for workflow runs within a specified date range. Optional start and end date parameters can be provided.
```APIDOC
## GET /apps/{app_id}/workflow/statistics/daily-conversations
### Description
Get workflow daily runs statistics.
### Method
GET
### Endpoint
/apps/{app_id}/workflow/statistics/daily-conversations
#### Path Parameters
- **app_id** (string (uuid)) - Required - Application ID
#### Query Parameters
- **end** (string) - Optional - End date and time (YYYY-MM-DD HH:MM)
- **start** (string) - Optional - Start date and time (YYYY-MM-DD HH:MM)
### Response
#### Success Response (200)
- **application/json** - WorkflowDailyRunsStatisticResponse
```
--------------------------------
### PluginInstallationsResponse
Source: https://github.com/langgenius/dify/blob/main/api/openapi/markdown/console-openapi.md
Response containing information about installed plugins.
```APIDOC
## PluginInstallationsResponse
### Description
Provides a list of installed plugins.
### Fields
* **plugins** - Required - Description not specified.
```
--------------------------------
### Start Middleware Services
Source: https://github.com/langgenius/dify/blob/main/api/README.md
Initiates the middleware services, including PostgreSQL, Redis, and Weaviate, using Docker Compose. Ensure these services are running before starting the backend.
```bash
./dev/start-docker-compose
```
--------------------------------
### GET /trial-apps/{app_id}/messages/{message_id}/suggested-questions
Source: https://github.com/langgenius/dify/blob/main/api/openapi/markdown/console-openapi.md
Fetches suggested questions related to a specific message within a trial application. Useful for guiding user interaction or follow-up.
```APIDOC
## GET /trial-apps/{app_id}/messages/{message_id}/suggested-questions
### Description
Fetches suggested questions for a given message.
### Method
GET
### Endpoint
/trial-apps/{app_id}/messages/{message_id}/suggested-questions
#### Path Parameters
- **app_id** (string (uuid)) - Required - The ID of the application.
- **message_id** (string (uuid)) - Required - The ID of the message.
#### Responses
#### Success Response (200)
- **application/json**: [SuggestedQuestionsResponse](#suggestedquestionsresponse)
```
--------------------------------
### POST /installed-apps/{installed_app_id}/workflows/run
Source: https://github.com/langgenius/dify/blob/main/api/openapi/markdown/console-openapi.md
Runs a workflow for a given installed application.
```APIDOC
## POST /installed-apps/{installed_app_id}/workflows/run
### Description
Run workflow
### Method
POST
### Endpoint
/installed-apps/{installed_app_id}/workflows/run
### Parameters
#### Path Parameters
- **installed_app_id** (string (uuid)) - Required -
#### Request Body
- **application/json**: [WorkflowRunPayload](#workflowrunpayload) - Required
### Response
#### Success Response (200)
- **application/json**: [GeneratedAppResponse](#generatedappresponse)
```