### GET /console/api/setup Source: https://github.com/langgenius/dify/blob/main/api/openapi/markdown/console-openapi.md Get system setup status. ```APIDOC ## GET /console/api/setup ### Description Get system setup status. This endpoint is unauthenticated by design. ### Method GET ### Endpoint /console/api/setup ### Response #### Success Response (200) - **setup_at** (string) - Setup completion time (ISO format) - **step** (string) - Setup step status (finished, not_started) ``` -------------------------------- ### 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 ``` -------------------------------- ### Build and Start Production Server Source: https://github.com/langgenius/dify/blob/main/web/README.md Build the application for production and start the server. ```bash pnpm -C web run build ``` ```bash pnpm -C web run start ``` -------------------------------- ### 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}' ``` -------------------------------- ### Command Path Examples Source: https://github.com/langgenius/dify/blob/main/cli/ARD.md Examples of valid command directory paths. ```text get/app/, auth/devices/revoke/, describe/app/. ``` -------------------------------- ### Install the development proxy Source: https://github.com/langgenius/dify/blob/main/packages/dev-proxy/README.md Install the package as a development dependency. ```bash pnpm add -D @langgenius/dev-proxy ``` -------------------------------- ### File Preview 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 preview or download a previously uploaded file. ```bash curl -X GET '${props.appDetail.api_base_url}/files/72fa9618-8f89-4a37-9b33-7e1178a24a67/preview' \ --header 'Authorization: Bearer {api_key}' ``` -------------------------------- ### Install Dependencies Source: https://github.com/langgenius/dify/blob/main/web/README.md Install project dependencies from the repository root. ```bash pnpm install ``` -------------------------------- ### GET /installed-apps Source: https://github.com/langgenius/dify/blob/main/api/openapi/markdown/console-openapi.md Retrieve a list of installed applications. ```APIDOC ## [GET] /installed-apps ### Description Retrieve a list of installed applications. ### Method GET ### Endpoint /installed-apps ### Parameters #### Query Parameters - **app_id** (string) - Optional - App ID to filter by - **cursor** (string) - Optional - Opaque cursor returned by the previous page - **limit** (integer) - Optional - Number of installed apps to return (Default: 20) - **name** (string) - Optional - App name to search for ``` -------------------------------- ### GET /console/api/init Source: https://github.com/langgenius/dify/blob/main/api/openapi/markdown/console-openapi.md Get initialization validation status. ```APIDOC ## GET /console/api/init ### Description Get initialization validation status. ### Method GET ### Endpoint /console/api/init ### Response #### Success Response (200) - **status** (string) - Initialization status (finished, not_started) ``` -------------------------------- ### 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 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 ``` -------------------------------- ### Integrate agent guide into command class Source: https://github.com/langgenius/dify/blob/main/cli/src/commands/AGENTS.md Import the guide string and override the agentGuide method in the command class to display it in help output. ```ts import { agentGuide } from './guide.js' export default class MyCmd extends DifyCommand { override agentGuide(): string { return agentGuide } } ``` -------------------------------- ### Install difyctl on Windows Source: https://github.com/langgenius/dify/blob/main/cli/README.md Installs the CLI on Windows using PowerShell. Environment variables are set via the $env prefix. ```powershell $env:DIFYCTL_R2_BASE=''; irm https://raw.githubusercontent.com/langgenius/dify/main/cli/scripts/install-r2.ps1 | iex ``` -------------------------------- ### 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 ``` -------------------------------- ### Install Dify Agent dependencies Source: https://github.com/langgenius/dify/blob/main/dify-agent/docs/dify-agent/get-started/index.md Install all extras and dependency groups from the repository root. ```bash cd dify-agent uv sync --all-extras --all-groups ``` -------------------------------- ### Installing Agent Skills Source: https://github.com/langgenius/dify/blob/main/cli/README.md Commands to manage the installation of agent skills into local development environments. ```sh difyctl skills install difyctl skills install --yes difyctl skills install --stdout difyctl version ``` -------------------------------- ### Install Dify Node.js SDK Source: https://github.com/langgenius/dify/blob/main/sdks/nodejs-client/README.md Use npm to install the package in your project. ```bash npm install dify-client ``` -------------------------------- ### POST /console/api/setup Source: https://github.com/langgenius/dify/blob/main/api/openapi/markdown/console-openapi.md Initialize system setup with admin account. ```APIDOC ## POST /console/api/setup ### Description Initialize system setup with admin account. This endpoint is unauthenticated by design for first-time bootstrap. ### Method POST ### Endpoint /console/api/setup ### Request Body - **email** (string) - Required - Admin email address - **language** (string) - Optional - Admin language - **name** (string) - Required - Admin name (max 30 characters) - **password** (string) - Required - Admin password ### Response #### Success Response (201) - **result** (string) - Setup result ``` -------------------------------- ### Paused Streaming Response Example Source: https://github.com/langgenius/dify/blob/main/web/app/components/develop/template/template_advanced_chat.en.mdx Example of an SSE stream showing workflow start, node start, and node finish events during a paused state. ```streaming event: ping data: { "event": "workflow_started", "workflow_run_id": "a4959eb4-c852-4e0c-ac7a-348233f7f345", "task_id": "0399c5c2-181b-4493-a78e-1421914e8a25", "data": { "id": "a4959eb4-c852-4e0c-ac7a-348233f7f345", "workflow_id": "e46514f1-c008-41ff-94b0-4f33d4b97d36", "inputs": { "sys.files": [], "sys.user_id": "abc-123", "sys.app_id": "d1074979-f67e-4114-8691-e35878df9a89", "sys.workflow_id": "e46514f1-c008-41ff-94b0-4f33d4b97d36", "sys.workflow_run_id": "a4959eb4-c852-4e0c-ac7a-348233f7f345" }, "created_at": 1776129228, "reason": "initial" } } data: { "event": "node_started", "workflow_run_id": "a4959eb4-c852-4e0c-ac7a-348233f7f345", "task_id": "0399c5c2-181b-4493-a78e-1421914e8a25", "data": { "id": "7d9bb041-5ecb-497f-a674-d8706eed0ab1", "node_id": "1775717266623", "node_type": "start", "title": "User Input", "index": 1, "predecessor_node_id": null, "inputs": null, "inputs_truncated": false, "created_at": 1776129228, "extras": {}, "iteration_id": null, "loop_id": null, "agent_strategy": null } } data: { "event": "node_finished", "workflow_run_id": "a4959eb4-c852-4e0c-ac7a-348233f7f345", "task_id": "0399c5c2-181b-4493-a78e-1421914e8a25", "data": { "id": "7d9bb041-5ecb-497f-a674-d8706eed0ab1", "node_id": "1775717266623", "node_type": "start", "title": "User Input", "index": 1, "predecessor_node_id": null, "inputs": { "sys.files": [], "sys.user_id": "abc-123", "sys.app_id": "d1074979-f67e-4114-8691-e35878df9a89", "sys.workflow_id": "e46514f1-c008-41ff-94b0-4f33d4b97d36", "sys.workflow_run_id": "a4959eb4-c852-4e0c-ac7a-348233f7f345", "sys.timestamp": 1776129228 }, "inputs_truncated": false, "process_data": {}, "process_data_truncated": false, "outputs": { "sys.files": [], "sys.user_id": "abc-123", "sys.app_id": "d1074979-f67e-4114-8691-e35878df9a89", "sys.workflow_id": "e46514f1-c008-41ff-94b0-4f33d4b97d36", "sys.workflow_run_id": "a4959eb4-c852-4e0c-ac7a-348233f7f345", "sys.timestamp": 1776129228 }, "outputs_truncated": false, "status": "succeeded", "error": null, "elapsed_time": 0.000097, "execution_metadata": null, "created_at": 1776129228, "finished_at": 1776129228, "files": [], "iteration_id": null, "loop_id": null } } ``` -------------------------------- ### GET /installed-apps/{installed_app_id} Source: https://github.com/langgenius/dify/blob/main/api/openapi/markdown/console-openapi.md Get details of an installed application. ```APIDOC ## [GET] /installed-apps/{installed_app_id} ### Description Get details of an installed application. ### Method GET ### Endpoint /installed-apps/{installed_app_id} ### Parameters #### Path Parameters - **installed_app_id** (string) - Required ``` -------------------------------- ### GET /workspaces/current/plugin/list Source: https://github.com/langgenius/dify/blob/main/api/openapi/markdown/console-openapi.md Lists installed plugins with pagination. ```APIDOC ## GET /workspaces/current/plugin/list ### Description Retrieves a paginated list of installed plugins. ### 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) ### Response #### Success Response (200) - **application/json** (PluginListResponse) - Success ``` -------------------------------- ### Build the Project Source: https://github.com/langgenius/dify/blob/main/dify-agent-runtime/README.md Compile the Go binaries into the bin/ directory. ```bash make build ``` -------------------------------- ### Run Development Server Source: https://github.com/langgenius/dify/blob/main/web/README.md Start the development server using standard or proxy configurations. ```bash pnpm -C web run dev # or if you are using vinext which provides a better development experience pnpm -C web run dev:vinext # (optional) start the dev proxy server so that you can use online API in development # edit web/dev-proxy.config.ts to choose proxy paths # edit web/.env.local to override DEV_PROXY_TARGET, DEV_PROXY_ENTERPRISE_TARGET, DEV_PROXY_HOST, or DEV_PROXY_PORT pnpm -C web run dev:proxy ``` -------------------------------- ### Start Server with Custom Host and Port Source: https://github.com/langgenius/dify/blob/main/web/README.md Launch the production server on a specific host and port. ```bash pnpm -C web run start --port=3001 --host=0.0.0.0 ``` -------------------------------- ### Workflow Event Stream Examples Source: https://github.com/langgenius/dify/blob/main/web/app/components/develop/template/template_workflow.en.mdx Examples of server-sent events emitted during workflow execution, including node start, node finish, and workflow completion. ```json data: {"event":"node_started","workflow_run_id":"5d7ef348-e1c1-4f6d-bb9b-62cc2fb2ef3c","task_id":"1784c3dd-20eb-4919-bd5d-a8d800b74ada","data":{"id":"e88dec7e-aa2c-41f7-8d73-032b749e23f5","node_id":"1775717354177","node_type":"end","title":"Output","index":1,"predecessor_node_id":null,"inputs":null,"inputs_truncated":false,"created_at":1776087877,"extras":{},"iteration_id":null,"loop_id":null,"agent_strategy":null}} ``` ```json data: {"event":"node_finished","workflow_run_id":"5d7ef348-e1c1-4f6d-bb9b-62cc2fb2ef3c","task_id":"1784c3dd-20eb-4919-bd5d-a8d800b74ada","data":{"id":"e88dec7e-aa2c-41f7-8d73-032b749e23f5","node_id":"1775717354177","node_type":"end","title":"Output","index":1,"predecessor_node_id":null,"inputs":{"output":"field 1 filled!"},"inputs_truncated":false,"process_data":{},"process_data_truncated":false,"outputs":{"output":"field 1 filled!"},"outputs_truncated":false,"status":"succeeded","error":null,"elapsed_time":0.00003,"execution_metadata":null,"created_at":1776087877,"finished_at":1776087877,"files":[],"iteration_id":null,"loop_id":null}} ``` ```json data: {"event":"workflow_finished","workflow_run_id":"5d7ef348-e1c1-4f6d-bb9b-62cc2fb2ef3c","task_id":"1784c3dd-20eb-4919-bd5d-a8d800b74ada","data":{"id":"5d7ef348-e1c1-4f6d-bb9b-62cc2fb2ef3c","workflow_id":"e46514f1-c008-41ff-94b0-4f33d4b97d36","status":"succeeded","outputs":{"output":"field 1 filled!"},"error":null,"elapsed_time":0.364935,"total_tokens":0,"total_steps":5,"created_by":{"id":"7932d34c-dcf4-4fba-b770-f2a9de88c0a0","user":"abc-123"},"created_at":1776087877,"finished_at":1776087877,"exceptions_count":0,"files":[]}} ``` -------------------------------- ### Paused Streaming Response Example Source: https://github.com/langgenius/dify/blob/main/web/app/components/develop/template/template_workflow.en.mdx Example of a streaming response sequence including workflow start, node execution, and a human input requirement event. ```streaming event: ping data: { "event": "workflow_started", "workflow_run_id": "a4959eb4-c852-4e0c-ac7a-348233f7f345", "task_id": "0399c5c2-181b-4493-a78e-1421914e8a25", "data": { "id": "a4959eb4-c852-4e0c-ac7a-348233f7f345", "workflow_id": "e46514f1-c008-41ff-94b0-4f33d4b97d36", "inputs": { "sys.files": [], "sys.user_id": "abc-123", "sys.app_id": "d1074979-f67e-4114-8691-e35878df9a89", "sys.workflow_id": "e46514f1-c008-41ff-94b0-4f33d4b97d36", "sys.workflow_run_id": "a4959eb4-c852-4e0c-ac7a-348233f7f345" }, "created_at": 1776129228, "reason": "initial" } } data: { "event": "node_started", "workflow_run_id": "a4959eb4-c852-4e0c-ac7a-348233f7f345", "task_id": "0399c5c2-181b-4493-a78e-1421914e8a25", "data": { "id": "7d9bb041-5ecb-497f-a674-d8706eed0ab1", "node_id": "1775717266623", "node_type": "start", "title": "User Input", "index": 1, "predecessor_node_id": null, "inputs": null, "inputs_truncated": false, "created_at": 1776129228, "extras": {}, "iteration_id": null, "loop_id": null, "agent_strategy": null } } data: { "event": "node_finished", "workflow_run_id": "a4959eb4-c852-4e0c-ac7a-348233f7f345", "task_id": "0399c5c2-181b-4493-a78e-1421914e8a25", "data": { "id": "7d9bb041-5ecb-497f-a674-d8706eed0ab1", "node_id": "1775717266623", "node_type": "start", "title": "User Input", "index": 1, "predecessor_node_id": null, "inputs": { "sys.files": [], "sys.user_id": "abc-123", "sys.app_id": "d1074979-f67e-4114-8691-e35878df9a89", "sys.workflow_id": "e46514f1-c008-41ff-94b0-4f33d4b97d36", "sys.workflow_run_id": "a4959eb4-c852-4e0c-ac7a-348233f7f345", "sys.timestamp": 1776129228 }, "inputs_truncated": false, "process_data": {}, "process_data_truncated": false, "outputs": { "sys.files": [], "sys.user_id": "abc-123", "sys.app_id": "d1074979-f67e-4114-8691-e35878df9a89", "sys.workflow_id": "e46514f1-c008-41ff-94b0-4f33d4b97d36", "sys.workflow_run_id": "a4959eb4-c852-4e0c-ac7a-348233f7f345", "sys.timestamp": 1776129228 }, "outputs_truncated": false, "status": "succeeded", "error": null, "elapsed_time": 0.000097, "execution_metadata": null, "created_at": 1776129228, "finished_at": 1776129228, "files": [], "iteration_id": null, "loop_id": null } } data: { "event": "node_started", "workflow_run_id": "a4959eb4-c852-4e0c-ac7a-348233f7f345", "task_id": "0399c5c2-181b-4493-a78e-1421914e8a25", "data": { "id": "c09ff568-1d55-4f0d-9a07-512bcbfeb289", "node_id": "1775717346519", "node_type": "human-input", "title": "Human Input", "index": 1, "predecessor_node_id": null, "inputs": null, "inputs_truncated": false, "created_at": 1776129228, "extras": {}, "iteration_id": null, "loop_id": null, "agent_strategy": null } } data: { "event": "human_input_required", "workflow_run_id": "a4959eb4-c852-4e0c-ac7a-348233f7f345", "task_id": "0399c5c2-181b-4493-a78e-1421914e8a25", "data": { "form_id": "019d898d-3d80-7105-b920-9899ead4ff3e", "node_id": "1775717346519", "node_title": "Human Input", "form_content": "this is form 1:\n{{#$output.some_field#}}\n", "inputs": [ { "type": "paragraph", "output_variable_name": "some_field", "default": { "type": "variable", "selector": [ "sys", "workflow_run_id" ], "value": "" } } ], "actions": [ { "id": "approve", "title": "YES", "button_style": "default" }, { "id": "reject", "title": "NO", "button_style": "default" } ], "display_in_ui": true, "form_token": "0Tb1nXYe4hzQUD706nHB4y", "resolved_default_values": { "some_field": "a4959eb4-c852-4e0c-ac7a-348233f7f345" }, "expiration_time": 1776388428 } } ``` -------------------------------- ### Initialize E2E Environment Variables Source: https://github.com/langgenius/dify/blob/main/cli/test/e2e/README.md Copy the provided example environment file to the required location before populating it with credentials. ```bash cp cli/test/e2e/.env.e2e.example cli/.env.e2e # edit cli/.env.e2e with real credentials ``` -------------------------------- ### Start Storybook Source: https://github.com/langgenius/dify/blob/main/web/README.md Launch the Storybook server for UI component development. ```bash pnpm -C web storybook ``` -------------------------------- ### Dify CLI Quickstart Commands Source: https://github.com/langgenius/dify/blob/main/cli/README.md Commonly used commands for authentication, listing apps, and executing app workflows. ```sh difyctl auth login # opens browser; paste the device code shown difyctl get app # list apps in default workspace difyctl describe app # inspect parameters difyctl run app "hello" # run, blocking difyctl run app "hello" -o json | jq .answer # JSON output difyctl run app --input name=world --input topic=cats # workflow inputs ``` -------------------------------- ### GET /workspaces/current/plugin/installed-ids Source: https://github.com/langgenius/dify/blob/main/api/openapi/markdown/console-openapi.md Retrieves the IDs of installed plugins filtered by category. ```APIDOC ## GET /workspaces/current/plugin/installed-ids ### Description Fetches a list of installed plugin IDs based on the specified category. ### Method GET ### Endpoint /workspaces/current/plugin/installed-ids ### Parameters #### Query Parameters - **category** (string) - Required - Plugin category to include (agent-strategy, datasource, extension, model, tool, trigger) ### Response #### Success Response (200) - **application/json** (PluginInstalledIdsResponse) - Success ``` -------------------------------- ### GET /installed-apps/{installed_app_id}/meta Source: https://github.com/langgenius/dify/blob/main/api/openapi/markdown/console-openapi.md Retrieve metadata for an installed application. ```APIDOC ## [GET] /installed-apps/{installed_app_id}/meta ### Description Retrieve metadata for an installed application. ### Method GET ### Endpoint /installed-apps/{installed_app_id}/meta ### Parameters #### Path Parameters - **installed_app_id** (string) - Required ### Response #### Success Response (200) - **ExploreAppMetaResponse** (object) - Success ``` -------------------------------- ### Start Required Services Source: https://github.com/langgenius/dify/blob/main/scripts/stress-test/README.md Launch the Dify API and the mock OpenAI server required for testing. ```bash # Start Dify API with Gunicorn (production mode) cd api uv run gunicorn --bind 0.0.0.0:5001 --workers 4 --worker-class gevent app:app # Start Mock OpenAI server python scripts/stress-test/setup/mock_openai_server.py ``` -------------------------------- ### GET /installed-apps/{installed_app_id}/parameters Source: https://github.com/langgenius/dify/blob/main/api/openapi/markdown/console-openapi.md Retrieve configuration parameters for an installed application. ```APIDOC ## [GET] /installed-apps/{installed_app_id}/parameters ### Description Retrieve configuration parameters for an installed application. ### Method GET ### Endpoint /installed-apps/{installed_app_id}/parameters ### Parameters #### Path Parameters - **installed_app_id** (string) - Required ### Response #### Success Response (200) - **Parameters** (object) - Success ``` -------------------------------- ### 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 an installed application. ```APIDOC ## [GET] /installed-apps/{installed_app_id}/conversations ### Description Fetches a paginated list of conversations associated with the installed application. ### Method GET ### Endpoint /installed-apps/{installed_app_id}/conversations ### Parameters #### Path Parameters - **installed_app_id** (string) - Required - The UUID of the installed application. #### Query Parameters - **last_id** (string) - Optional - ID of the last item for pagination. - **limit** (integer) - Optional - Number of items to return (default: 20). - **pinned** (boolean) - Optional - Filter by pinned status. ``` -------------------------------- ### POST /installed-apps Source: https://github.com/langgenius/dify/blob/main/api/openapi/markdown/console-openapi.md Create a new installed application. ```APIDOC ## [POST] /installed-apps ### Description Create a new installed application. ### Method POST ### Endpoint /installed-apps ### Request Body - **application/json** (InstalledAppCreatePayload) - Required ``` -------------------------------- ### Initialize Stress Test Environment Source: https://github.com/langgenius/dify/blob/main/scripts/stress-test/README.md Run the setup script to resolve API key configuration issues. ```bash # Run setup python scripts/stress-test/setup_all.py ``` -------------------------------- ### GET /installed-apps/{installed_app_id}/saved-messages Source: https://github.com/langgenius/dify/blob/main/api/openapi/markdown/console-openapi.md Retrieve a list of saved messages for an installed application. ```APIDOC ## [GET] /installed-apps/{installed_app_id}/saved-messages ### Description Retrieve a list of saved messages for an installed application. ### Method GET ### Endpoint /installed-apps/{installed_app_id}/saved-messages ### Parameters #### Path Parameters - **installed_app_id** (string) - Required #### Query Parameters - **last_id** (string) - Optional - **limit** (integer) - Optional - Default: 20 ### Response #### Success Response (200) - **SavedMessageInfiniteScrollPagination** (object) - Success ``` -------------------------------- ### Start Mock OpenAI Server Source: https://github.com/langgenius/dify/blob/main/scripts/stress-test/README.md Launches the mock OpenAI server required for testing LLM integration. ```bash python scripts/stress-test/setup/mock_openai_server.py ``` -------------------------------- ### POST /workspaces/current/plugin/install/marketplace Source: https://github.com/langgenius/dify/blob/main/api/openapi/markdown/console-openapi.md Installs a plugin from the marketplace. ```APIDOC ## POST /workspaces/current/plugin/install/marketplace ### Description Initiates the installation of a plugin from the marketplace. ### Method POST ### Endpoint /workspaces/current/plugin/install/marketplace ### Request Body - **body** (ParserPluginIdentifiers) - Required - Plugin identifiers for marketplace installation. ### Response #### Success Response (200) - **task** (PluginInstallTaskStartResponse) - Installation task start response. ``` -------------------------------- ### 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 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, } ``` -------------------------------- ### 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) ``` -------------------------------- ### 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 ``` -------------------------------- ### Dify API Prepared Wikipedia Tool Example Source: https://github.com/langgenius/dify/blob/main/dify-agent/docs/dify-agent/user-manual/plugin-tool-layer/index.md This snippet demonstrates the setup for exposing a Wikipedia tool from a plugin to the model. It imports necessary components for defining tool configurations and execution layers. ```python from dify_agent.layers.execution_context import DIFY_EXECUTION_CONTEXT_LAYER_TYPE_ID, DifyExecutionContextLayerConfig from dify_agent.layers.dify_plugin import ( DIFY_PLUGIN_TOOLS_LAYER_TYPE_ID, DifyPluginToolConfig, DifyPluginToolParameter, DifyPluginToolsLayerConfig, ) from dify_agent.protocol import RunComposition, RunLayerSpec # Dify API side: resolve the selected tool into the API-side Tool runtime first, # for example with ToolManager.get_agent_tool_runtime(...). Then adapt its # effective ToolParameter objects at the protocol boundary. Dify Agent accepts # both ToolParameter attribute objects and ToolParameter.model_dump(mode="json") ``` -------------------------------- ### GET /workspaces/current/permission Source: https://github.com/langgenius/dify/blob/main/api/openapi/markdown/console-openapi.md Get workspace permission settings. ```APIDOC ## GET /workspaces/current/permission ### Description Returns permission flags that control workspace features like member invitations and owner transfer. ### Method GET ### Endpoint /workspaces/current/permission ### Response #### Success Response (200) - **permissions** (WorkspacePermissionResponse) - Workspace permission settings. ``` -------------------------------- ### GET /datasets/retrieval-setting Source: https://github.com/langgenius/dify/blob/main/api/openapi/markdown/console-openapi.md Get dataset retrieval settings. ```APIDOC ## GET /datasets/retrieval-setting ### Description Get dataset retrieval settings. ### Method GET ### Endpoint /datasets/retrieval-setting ### Response #### Success Response (200) - **application/json** (RetrievalSettingResponse) - Retrieval settings retrieved successfully ``` -------------------------------- ### POST /account/init Source: https://github.com/langgenius/dify/blob/main/api/openapi/markdown/console-openapi.md Initializes the account. ```APIDOC ## POST /account/init ### Description Initializes the account. ### Method POST ### Endpoint /account/init ### Parameters #### Request Body - **AccountInitPayload** (object) - Required ### Response #### Success Response (200) - **application/json** - SimpleResultResponse ``` -------------------------------- ### GET /datasets/{dataset_id} Source: https://github.com/langgenius/dify/blob/main/api/openapi/markdown/console-openapi.md Get details of a specific dataset. ```APIDOC ## GET /datasets/{dataset_id} ### Description Get dataset details. ### Method GET ### Endpoint /datasets/{dataset_id} ### Parameters #### Path Parameters - **dataset_id** (string) - Required - Dataset ID ### Response #### Success Response (200) - **application/json** (DatasetDetailWithPartialMembersResponse) - Dataset retrieved successfully ``` -------------------------------- ### Deploy Middleware Services Source: https://github.com/langgenius/dify/blob/main/docker/README.md Start essential middleware services like databases and caches using the middleware-specific configuration file. ```bash docker compose --env-file middleware.env -f docker-compose.middleware.yaml -p dify up -d ``` -------------------------------- ### GET /datasets/process-rule Source: https://github.com/langgenius/dify/blob/main/api/openapi/markdown/console-openapi.md Get dataset document processing rules. ```APIDOC ## GET /datasets/process-rule ### Description Get dataset document processing rules. ### Method GET ### Endpoint /datasets/process-rule ### Parameters #### Query Parameters - **document_id** (string) - Optional - Document ID ### Response #### Success Response (200) - **application/json** (ProcessRuleResponse) - Process rules retrieved successfully ``` -------------------------------- ### Start Dify Agent Server Source: https://github.com/langgenius/dify/blob/main/dify-agent/docs/dify-agent/get-started/index.md Commands to launch the server for production or development environments. ```bash make serve ``` ```bash make dev ``` -------------------------------- ### [GET] /apps/{app_id}/workflow/comments Source: https://github.com/langgenius/dify/blob/main/api/openapi/markdown/console-openapi.md Get all comments for a workflow. ```APIDOC ## [GET] /apps/{app_id}/workflow/comments ### Description Get all comments for a workflow. ### Method GET ### Endpoint /apps/{app_id}/workflow/comments ### Parameters #### Path Parameters - **app_id** (string) - Required - Application ID ### Response #### Success Response (200) - **WorkflowCommentBasicList** (object) - Comments retrieved successfully ``` -------------------------------- ### [GET] /apps/starred Source: https://github.com/langgenius/dify/blob/main/api/openapi/markdown/console-openapi.md Get applications starred by the current account. ```APIDOC ## [GET] /apps/starred ### Method GET ### Endpoint /apps/starred ### Parameters #### Query Parameters - **creator_ids** ([string]) - Optional - Filter by creator account IDs - **is_created_by_me** (boolean) - Optional - Filter by creator - **limit** (integer) - Optional - Page size (1-100). Default: 20 - **mode** (string) - Optional - App mode filter. Default: all - **name** (string) - Optional - Filter by app name - **page** (integer) - Optional - Page number (1-99999). Default: 1 - **sort_by** (string) - Optional - Sort apps. Default: last_modified ### Response #### Success Response (200) - **application/json** (AppPagination) - Success ``` -------------------------------- ### Initialize and Use Dify Clients Source: https://github.com/langgenius/dify/blob/main/sdks/nodejs-client/README.md Demonstrates initializing various clients and performing common operations like chat, completion, workflow execution, and knowledge base management. ```js import { DifyClient, ChatClient, CompletionClient, WorkflowClient, KnowledgeBaseClient, WorkspaceClient, } from 'dify-client' const API_KEY = 'your-app-api-key' const DATASET_API_KEY = 'your-dataset-api-key' const user = 'random-user-id' const query = 'Please tell me a short story in 10 words or less.' const chatClient = new ChatClient(API_KEY) const completionClient = new CompletionClient(API_KEY) const workflowClient = new WorkflowClient(API_KEY) const kbClient = new KnowledgeBaseClient(DATASET_API_KEY) const workspaceClient = new WorkspaceClient(DATASET_API_KEY) const client = new DifyClient(API_KEY) // App core await client.getApplicationParameters(user) await client.messageFeedback('message-id', 'like', user) // Completion (blocking) await completionClient.createCompletionMessage({ inputs: { query }, user, response_mode: 'blocking', }) // Chat (streaming) const stream = await chatClient.createChatMessage({ inputs: {}, query, user, response_mode: 'streaming', }) for await (const event of stream) { console.log(event.event, event.data) } // Chatflow (advanced chat via workflow_id) await chatClient.createChatMessage({ inputs: {}, query, user, workflow_id: 'workflow-id', response_mode: 'blocking', }) // Workflow run (blocking or streaming) await workflowClient.run({ inputs: { query }, user, response_mode: 'blocking', }) // Knowledge base (dataset token required) await kbClient.listDatasets({ page: 1, limit: 20 }) await kbClient.createDataset({ name: 'KB', indexing_technique: 'economy' }) // RAG pipeline (may require service API route registration) const pipelineStream = await kbClient.runPipeline('dataset-id', { inputs: {}, datasource_type: 'online_document', datasource_info_list: [], start_node_id: 'start-node-id', is_published: true, response_mode: 'streaming', }) for await (const event of pipelineStream) { console.log(event.data) } // Workspace models (dataset token required) await workspaceClient.getModelsByType('text-embedding') ``` -------------------------------- ### GET /api-based-extension Source: https://github.com/langgenius/dify/blob/main/api/openapi/markdown/console-openapi.md Get all API-based extensions for the current tenant. ```APIDOC ## [GET] /api-based-extension ### Description Get all API-based extensions for current tenant. ### Method GET ### Endpoint /api-based-extension ### Response #### Success Response (200) - **APIBasedExtensionListResponse** (object) - Success ``` -------------------------------- ### Define an agent guide string Source: https://github.com/langgenius/dify/blob/main/cli/src/commands/AGENTS.md Create a guide.ts file exporting a plain string to provide workflow and error recovery instructions. ```ts export const agentGuide = ` WORKFLOW 1. ... ERROR RECOVERY ... ` ``` -------------------------------- ### 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] /workspaces/current/trigger-provider/{provider}/info Source: https://github.com/langgenius/dify/blob/main/api/openapi/markdown/console-openapi.md Get info for a trigger provider. ```APIDOC ## [GET] /workspaces/current/trigger-provider/{provider}/info ### Description Get info for a trigger provider. ### Method GET ### Endpoint /workspaces/current/trigger-provider/{provider}/info ### Parameters #### Path Parameters - **provider** (string) - Required ``` -------------------------------- ### 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. ```APIDOC ## POST /workspaces/current/plugin/install/github ### Description Initiates the installation of a plugin from a GitHub source. ### Method POST ### Endpoint /workspaces/current/plugin/install/github ### Request Body - **body** (ParserGithubInstall) - Required - GitHub installation details. ### Response #### Success Response (200) - **task** (PluginInstallTaskStartResponse) - Installation task start response. ``` -------------------------------- ### GET /workspaces/current/agent-provider/{provider_name} Source: https://github.com/langgenius/dify/blob/main/api/openapi/markdown/console-openapi.md Get specific agent provider details. ```APIDOC ## GET /workspaces/current/agent-provider/{provider_name} ### Description Get specific agent provider details. ### Method GET ### Endpoint /workspaces/current/agent-provider/{provider_name} ### Parameters #### Path Parameters - **provider_name** (string) - Required - Agent provider name ### Response #### Success Response (200) - **application/json** (AgentProviderResponse) - Success ``` -------------------------------- ### Run Proxy Command Source: https://github.com/langgenius/dify/blob/main/packages/dev-proxy/README.md Command to start the proxy with a specific configuration and environment file. ```bash dev-proxy --config ./dev-proxy.config.ts --env-file ./.env.local ``` -------------------------------- ### GET /workflow/{workflow_run_id}/pause-details Source: https://github.com/langgenius/dify/blob/main/api/openapi/markdown/console-openapi.md Get workflow pause details. ```APIDOC ## GET /workflow/{workflow_run_id}/pause-details ### Description Get workflow pause details. Returns information about why and where the workflow is paused. ### Method GET ### Endpoint /workflow/{workflow_run_id}/pause-details ### Parameters #### Path Parameters - **workflow_run_id** (string) - Required - Workflow run ID ### Response #### Success Response (200) - **application/json** (WorkflowPauseDetailsResponse) - Workflow pause details retrieved successfully #### Error Response (404) - Workflow run not found ``` -------------------------------- ### GET /datasets/{dataset_id}/indexing-status Source: https://github.com/langgenius/dify/blob/main/api/openapi/markdown/console-openapi.md Get the indexing status of a dataset. ```APIDOC ## GET /datasets/{dataset_id}/indexing-status ### Description Get dataset indexing status. ### Method GET ### Endpoint /datasets/{dataset_id}/indexing-status ### Parameters #### Path Parameters - **dataset_id** (string) - Required - Dataset ID ``` -------------------------------- ### Configure Environment Variables Source: https://github.com/langgenius/dify/blob/main/web/README.md Initialize the local environment configuration file. ```bash cp web/.env.example web/.env.local ``` -------------------------------- ### GET /datasets/{dataset_id}/auto-disable-logs Source: https://github.com/langgenius/dify/blob/main/api/openapi/markdown/console-openapi.md Get auto-disable logs for a dataset. ```APIDOC ## GET /datasets/{dataset_id}/auto-disable-logs ### Description Get dataset auto disable logs. ### Method GET ### Endpoint /datasets/{dataset_id}/auto-disable-logs ### Parameters #### Path Parameters - **dataset_id** (string) - Required - Dataset ID ### Response #### Success Response (200) - **application/json** (AutoDisableLogsResponse) - Auto disable logs retrieved successfully ``` -------------------------------- ### [POST] /apps Source: https://github.com/langgenius/dify/blob/main/api/openapi/markdown/console-openapi.md Create a new application. ```APIDOC ## [POST] /apps ### Description Create a new application. ### Method POST ### Endpoint /apps ### Request Body - **application/json** (CreateAppPayload) - Required ### Response #### Success Response (201) - **application/json** (AppDetailWithSite) - App created successfully #### Error Responses - 400 - Invalid request parameters - 403 - Insufficient permissions ``` -------------------------------- ### GET /code-based-extension Source: https://github.com/langgenius/dify/blob/main/api/openapi/markdown/console-openapi.md Get code-based extension data by module name. ```APIDOC ## [GET] /code-based-extension ### Description Get code-based extension data by module name. ### Method GET ### Endpoint /code-based-extension ### Parameters #### Query Parameters - **module** (string) - Required - The module name. ### Response #### Success Response (200) - **CodeBasedExtensionResponse** (object) - Success ```