### Navigate to Web Directory Source: https://docs.dify.ai/en/self-host/advanced-deployments/local-source-code Change the current directory to the 'web' folder to start the web service setup. ```bash cd web ``` -------------------------------- ### Get Suggested Questions Example Source: https://docs.dify.ai/api-reference/chats/get-next-suggested-questions This example demonstrates a successful response when retrieving suggested questions for a message. It includes the message ID and a user identifier as query parameters. ```yaml openapi: 3.0.1 info: title: Chat App API description: >- Chat applications support session persistence, allowing previous chat history to be used as context for responses. This can be applicable for chatbot, customer service AI, etc. version: 1.0.0 servers: - url: '{api_base_url}' description: >- The base URL for the Chat App API. Replace {api_base_url} with the actual API base URL provided for your application. variables: api_base_url: default: https://api.dify.ai/v1 description: Actual base URL of the API security: - ApiKeyAuth: [] tags: - name: Chats description: Operations related to chat messages and interactions. - name: Files description: File upload and preview operations. - name: End Users description: Operations related to end user information. - name: Feedback description: User feedback operations. - name: Conversations description: Operations related to managing conversations. - name: TTS description: Text-to-Speech and Speech-to-Text operations. - name: Applications description: Operations to retrieve application settings and information. - name: Annotations description: Operations related to managing annotations for direct replies. paths: /messages/{message_id}/suggested: get: tags: - Chats summary: Get Next Suggested Questions description: Get next questions suggestions for the current message. operationId: getSuggestedQuestions parameters: - name: message_id in: path required: true description: Message ID. schema: type: string - name: user in: query required: true description: User identifier. schema: type: string responses: '200': description: Successfully retrieved suggested questions. content: application/json: schema: $ref: '#/components/schemas/SuggestedQuestionsResponse' examples: suggestedQuestions: summary: Response Example value: !include ../../api-reference/openapi_chat.json '400': description: |- - `not_chat_app` : App mode does not match the API route. - `bad_request` : Suggested questions feature is disabled. content: application/json: examples: not_chat_app: summary: not_chat_app value: status: 400 code: not_chat_app message: Please check if your app mode matches the right API route. bad_request: summary: bad_request value: status: 400 code: bad_request message: Suggested Questions Is Disabled. '404': description: '`not_found` : Message does not exist.' content: application/json: examples: message_not_exists: summary: not_found value: status: 404 code: not_found message: Message Not Exists. '500': description: '`internal_server_error` : Internal server error.' content: application/json: examples: internal_server_error: summary: internal_server_error value: status: 500 code: internal_server_error message: Internal server error. components: schemas: SuggestedQuestionsResponse: type: object properties: result: type: string description: Result status. data: type: array items: type: string description: List of suggested questions. securitySchemes: ApiKeyAuth: type: http scheme: bearer bearerFormat: API_KEY description: >- API Key authentication. For all API requests, include your API Key in the `Authorization` HTTP Header, prefixed with `Bearer `. Example: `Authorization: Bearer {API_KEY}`. **Strongly recommend storing your API Key on the server-side, not shared or stored on the client-side, to avoid possible API-Key leakage that can lead to serious consequences.** ``` -------------------------------- ### Web Service Startup Output Source: https://docs.dify.ai/en/self-host/advanced-deployments/local-source-code Example of the expected output when the Dify web service starts successfully, showing the local and network URLs. ```text ▲ Next.js 15 - Local: http://localhost:3000 - Network: http://0.0.0.0:3000 ✓ Starting... ✓ Ready in 73ms ``` -------------------------------- ### Initialize a New Dify Plugin Source: https://docs.dify.ai/en/develop-plugin/dev-guides-and-walkthroughs/cheatsheet Use this command to start a new plugin project. It will guide you through the initial configuration prompts. ```bash ./dify plugin init ``` -------------------------------- ### Dify Container Status Output Example Source: https://docs.dify.ai/en/self-host/quick-start/docker-compose Example output showing the status of Dify containers after starting with Docker Compose. Indicates successful startup and health status. ```text [+] Running 13/13 ✔ Network docker_ssrf_proxy_network Created 10.0s ✔ Network docker_default Created 0.1s ✔ Container docker-sandbox-1 Started 0.3s ✔ Container docker-db_postgres-1 Healthy 2.8s ✔ Container docker-web-1 Started 0.3s ✔ Container docker-redis-1 Started 0.3s ✔ Container docker-ssrf_proxy-1 Started 0.4s ✔ Container docker-weaviate-1 Started 0.3s ✔ Container docker-worker_beat-1 Started 3.2s ✔ Container docker-api-1 Started 3.2s ✔ Container docker-worker-1 Started 3.2s ✔ Container docker-plugin_daemon-1 Started 3.2s ✔ Container docker-nginx-1 Started 3.4s ``` -------------------------------- ### Workflow Started and Streaming Response Example Source: https://docs.dify.ai/api-reference/workflows/run-workflow This example demonstrates a typical workflow execution in streaming mode, showing events from workflow start to text chunk generation and final completion. It's useful for understanding real-time data flow during workflow execution. ```json data: {"event": "workflow_started", "task_id": "c3800678-a077-43df-a102-53f23ed20b88", "workflow_run_id": "fb47b2e6-5e43-4f90-be01-d5c5a088d156", "data": {"id": "fb47b2e6-5e43-4f90-be01-d5c5a088d156", "workflow_id": "7c3e33d4-2a8b-4e5f-9b1a-d3c6e8f12345", "inputs": {"query": "Translate this"}, "created_at": 1705407629, "reason": "initial"}} data: {"event": "node_started", "task_id": "c3800678-a077-43df-a102-53f23ed20b88", "workflow_run_id": "fb47b2e6-5e43-4f90-be01-d5c5a088d156", "data": {"id": "node_exec_1", "node_id": "node_1", "node_type": "llm", "title": "LLM Node", "index": 1, "created_at": 1705407629}} data: {"event": "text_chunk", "task_id": "c3800678-a077-43df-a102-53f23ed20b88", "workflow_run_id": "fb47b2e6-5e43-4f90-be01-d5c5a088d156", "data": {"text": "Bonjour", "from_variable_selector": ["node_1", "text"]}} data: {"event": "workflow_finished", "task_id": "c3800678-a077-43df-a102-53f23ed20b88", "workflow_run_id": "fb47b2e6-5e43-4f90-be01-d5c5a088d156", "data": {"id": "fb47b2e6-5e43-4f90-be01-d5c5a088d156", "workflow_id": "7c3e33d4-2a8b-4e5f-9b1a-d3c6e8f12345", "status": "succeeded", "outputs": {"result": "Bonjour le monde"}, "elapsed_time": 1.23, "total_tokens": 150, "total_steps": 3, "created_at": 1705407629, "finished_at": 1705407630}} ``` -------------------------------- ### Copy Example Environment File Source: https://docs.dify.ai/en/develop-plugin/dev-guides-and-walkthroughs/develop-flomo-plugin Copies the example environment file to .env for local configuration. ```bash cp .env.example .env ``` -------------------------------- ### Self-Hosted Dify Sandbox Setup Source: https://docs.dify.ai/en/use-dify/nodes/code Starts the sandbox service for secure code execution in a self-hosted Dify installation. Requires Docker. ```bash docker-compose -f docker-compose.middleware.yaml up -d ``` -------------------------------- ### Install Dependencies and Run Plugin Source: https://docs.dify.ai/en/develop-plugin/dev-guides-and-walkthroughs/develop-flomo-plugin Installs project dependencies and runs the plugin in debug mode. ```bash pip install -r requirements.txt python -m main ``` -------------------------------- ### WEAVIATE_GRPC_ENDPOINT Examples Source: https://docs.dify.ai/en/self-host/troubleshooting/weaviate-v4-migration Examples of how to configure the WEAVIATE_GRPC_ENDPOINT environment variable for different deployment scenarios. Do not include protocol prefixes. ```bash # Docker Compose (internal network) WEAVIATE_GRPC_ENDPOINT=weaviate:50051 ``` ```bash # External server (insecure) WEAVIATE_GRPC_ENDPOINT=192.168.1.100:50051 ``` ```bash # External server with custom port WEAVIATE_GRPC_ENDPOINT=weaviate.example.com:9090 ``` ```bash # Weaviate Cloud (secure/TLS on port 443) WEAVIATE_GRPC_ENDPOINT=your-instance.weaviate.cloud:443 ``` -------------------------------- ### Clone Example Repository and Configure Wrangler Source: https://docs.dify.ai/en/use-dify/workspace/api-extension/cloudflare-worker Clone the example GitHub repository for Dify API extensions and copy the example wrangler.toml file. Modify the `name` and `compatibility_date` in `wrangler.toml`. ```bash git clone https://github.com/crazywoola/dify-extension-workers.git cp wrangler.toml.example wrangler.toml ``` ```toml name = "dify-extension-example" compatibility_date = "2023-01-01" [vars] TOKEN = "bananaiscool" ``` -------------------------------- ### File Not Found Error Example Source: https://docs.dify.ai/api-reference/files/download-file This example shows the JSON response when the requested file cannot be found. ```json { "status": 404, "code": "file_not_found", "message": "The requested file was not found." } ``` -------------------------------- ### Install Dependencies with uv Source: https://docs.dify.ai/en/self-host/advanced-deployments/local-source-code Install project dependencies, including development dependencies, using the uv package manager. ```bash uv sync --dev ``` -------------------------------- ### Configure Plugin Project Details Source: https://docs.dify.ai/en/develop-plugin/getting-started/cli Example of interactive prompts for setting up a new Dify plugin, including name, author, description, and language support. ```bash Edit profile of the plugin Plugin name (press Enter to next step): hello-world Author (press Enter to next step): langgenius Description (press Enter to next step): hello world example Repository URL (Optional) (press Enter to next step): Repository URL (Optional) Enable multilingual README: [✔] English is required by default Languages to generate: English: [✔] (required) → 简体中文 (Simplified Chinese): [✔] 日本語 (Japanese): [✘] Português (Portuguese - Brazil): [✘] Controls: ↑/↓ Navigate • Space/Tab Toggle selection • Enter Next step ``` -------------------------------- ### Complete Weaviate Configuration Example Source: https://docs.dify.ai/en/self-host/troubleshooting/weaviate-v4-migration An example of a complete .env file configuration for Weaviate, including HTTP endpoint, authentication, gRPC settings, and batch import parameters. ```bash # docker/.env or environment configuration VECTOR_STORE=weaviate # HTTP Endpoint (required) WEAVIATE_ENDPOINT=http://weaviate:8080 # Authentication (if enabled on your Weaviate instance) WEAVIATE_API_KEY=your-secret-api-key # gRPC Configuration (recommended for performance) WEAVIATE_GRPC_ENABLED=true WEAVIATE_GRPC_ENDPOINT=weaviate:50051 # Batch Import Settings WEAVIATE_BATCH_SIZE=100 ``` -------------------------------- ### Install Specific Older Version of Dify Source: https://docs.dify.ai/en/self-host/quick-start/faqs Clone the Dify repository and specify a particular branch to install an older version. The rest of the setup follows the standard procedure. ```bash git clone https://github.com/langgenius/dify.git --branch 0.15.3 ``` -------------------------------- ### Navigate to Plugin Directory Source: https://docs.dify.ai/en/develop-plugin/getting-started/cli After initialization, change into the newly created plugin's directory. ```bash cd hello-world ``` -------------------------------- ### Human Input Pause Example Source: https://docs.dify.ai/api-reference/workflows/run-workflow-by-id This example demonstrates the sequence of events when a human input task pauses a workflow, including the initial start, the requirement for human input, and the subsequent pause. ```json data: {"event": "workflow_started", "task_id": "c3800678-a077-43df-a102-53f23ed20b88", "workflow_run_id": "fb47b2e6-5e43-4f90-be01-d5c5a088d156", "data": {"id": "fb47b2e6-5e43-4f90-be01-d5c5a088d156", "workflow_id": "7c3e33d4-2a8b-4e5f-9b1a-d3c6e8f12345", "inputs": {"draft": "Hello"}, "created_at": 1705407629, "reason": "initial"}} data: {"event": "human_input_required", "task_id": "c3800678-a077-43df-a102-53f23ed20b88", "workflow_run_id": "fb47b2e6-5e43-4f90-be01-d5c5a088d156", "data": {"form_id": "a1b2c3d4-e5f6-7890-abcd-ef1234567890", "form_token": "tok_abc123", "node_id": "approval_node", "node_title": "Approval", "form_content": "Please review the draft.", "inputs": [{"type": "text_input", "output_variable_name": "comment", "default": null}], "actions": [{"id": "approve", "title": "Approve", "button_style": "primary"}], "display_in_ui": false, "resolved_default_values": {"comment": ""}, "expiration_time": 1705494029}} data: {"event": "workflow_paused", "task_id": "c3800678-a077-43df-a102-53f23ed20b88", "workflow_run_id": "fb47b2e6-5e43-4f90-be01-d5c5a088d156", "data": {"workflow_run_id": "fb47b2e6-5e43-4f90-be01-d5c5a088d156", "status": "paused", "created_at": 1705407629, "elapsed_time": 0.5}} ``` -------------------------------- ### Example WebApp Settings Response Source: https://docs.dify.ai/api-reference/applications/get-app-webapp-settings This example shows a successful response for retrieving WebApp settings, including title, theme, icon, description, and copyright information. ```json { "title": "My Chat App", "chat_color_theme": "#4A90D9", "chat_color_theme_inverted": false, "icon_type": "emoji", "icon": "🤖", "icon_background": "#FFFFFF", "icon_url": null, "description": "A helpful customer service chatbot.", "copyright": "2025 Dify", "privacy_policy": "https://example.com/privacy", "custom_disclaimer": "", "default_language": "en-US", "show_workflow_steps": false, "use_icon_as_answer_icon": true } ``` -------------------------------- ### OpenAPI Specification for Get App Info Source: https://docs.dify.ai/api-reference/applications/get-app-info This OpenAPI 3.0.1 specification defines the GET /info endpoint for retrieving application details. It includes request parameters, response schemas, and an example response. ```yaml openapi: 3.0.1 info: title: Completion App API description: >- The text generation application offers non-session support and is ideal for translation, article writing, summarization AI, and more. version: 1.0.0 servers: - url: '{api_base_url}' description: >- The base URL for the Completion App API. Replace {api_base_url} with the actual API base URL provided for your application. variables: api_base_url: default: https://api.dify.ai/v1 description: Actual base URL of the API security: - ApiKeyAuth: [] tags: - name: Completions description: Operations related to text generation and completion. - name: Files description: Operations related to file management. - name: End Users description: Operations related to end user information. - name: Feedback description: Operations related to user feedback. - name: TTS description: Operations related to Text-to-Speech and Speech-to-Text. - name: Applications description: Operations to retrieve application settings and information. paths: /info: get: tags: - Applications summary: Get App Info description: >- Retrieve basic information about this application, including name, description, tags, and mode. operationId: getAppInfo responses: '200': description: Basic information of the application. content: application/json: schema: $ref: '#/components/schemas/AppInfoResponse' examples: appInfo: summary: Response Example value: name: My Completion App description: A helpful customer service chatbot. tags: - customer-service - chatbot mode: completion author_name: Dify Team components: schemas: AppInfoResponse: type: object properties: name: type: string description: Application name. description: type: string description: Application description. tags: type: array items: type: string description: Application tags. mode: type: string description: >- Application mode. `completion` for text generation apps, `chat` for basic chat apps, `agent-chat` for agent-based apps, `advanced-chat` for chatflow apps, `workflow` for workflow apps. author_name: type: string description: Name of the application author. securitySchemes: ApiKeyAuth: type: http scheme: bearer bearerFormat: API_KEY description: >- API Key authentication. For all API requests, include your API Key in the `Authorization` HTTP Header, prefixed with `Bearer `. Example: `Authorization: Bearer {API_KEY}`. **Strongly recommend storing your API Key on the server-side, not shared or stored on the client-side, to avoid possible API-Key leakage that can lead to serious consequences.** ``` -------------------------------- ### Get Built-in Metadata Fields OpenAPI Specification Source: https://docs.dify.ai/api-reference/metadata/get-built-in-metadata-fields This OpenAPI specification defines the GET endpoint for retrieving built-in metadata fields. It includes request parameters, response schema, and an example of a successful response. ```yaml openapi: 3.0.1 info: title: Knowledge API description: >- API for managing knowledge bases, documents, chunks, metadata, and tags, including creation, retrieval, and configuration. **Note:** A single Knowledge Base API key has permission to operate on all visible knowledge bases under the same account. Please pay attention to data security. version: 1.0.0 servers: - url: '{apiBaseUrl}' description: The base URL for the Knowledge API. variables: apiBaseUrl: default: https://api.dify.ai/v1 description: Actual base URL of the API security: - ApiKeyAuth: [] tags: - name: Knowledge Bases description: >- Operations for managing knowledge bases, including creation, configuration, and retrieval. - name: Documents description: >- Operations for creating, updating, and managing documents within a knowledge base. - name: Chunks description: Operations for managing document chunks and child chunks. - name: Metadata description: >- Operations for managing knowledge base metadata fields and document metadata values. - name: Tags description: Operations for managing knowledge base tags and tag bindings. - name: Models description: Operations for retrieving available models. - name: Knowledge Pipeline description: >- Operations for managing and running knowledge pipelines, including datasource plugins and pipeline execution. paths: /datasets/{dataset_id}/metadata/built-in: get: tags: - Metadata summary: Get Built-in Metadata Fields description: >- Returns the list of built-in metadata fields provided by the system (e.g., document type, source URL). operationId: getBuiltInMetadataFields parameters: - name: dataset_id in: path required: true schema: type: string format: uuid description: Knowledge base ID. responses: '200': description: Built-in metadata fields. content: application/json: schema: type: object properties: fields: type: array description: List of system-provided metadata fields. items: type: object properties: name: type: string description: >- Built-in field identifier. `document_name` for the document title, `uploader` for the creator, `upload_date` for creation time, `last_update_date` for last modification time, `source` for the document origin. type: type: string description: >- Field data type. `string` for text values, `time` for date/time values. examples: success: summary: Response Example value: fields: - name: document_name type: string - name: uploader type: string - name: upload_date type: time - name: last_update_date type: time - name: source type: string components: securitySchemes: ApiKeyAuth: type: http scheme: bearer bearerFormat: API_KEY description: >- API Key authentication. For all API requests, include your API Key in the `Authorization` HTTP Header, prefixed with `Bearer `. Example: `Authorization: Bearer {API_KEY}`. **Strongly recommend storing your API Key on the server-side, not shared or stored on the client-side, to avoid possible API-Key leakage that can lead to serious consequences.** ``` -------------------------------- ### Start Dify with Docker Compose Source: https://docs.dify.ai/en/use-dify/tutorials/twitter-chatflow Navigate to the Dify docker directory, copy the environment file, and start Dify using Docker Compose. ```bash cd dify/docker cp .env.example .env docker compose up -d ``` -------------------------------- ### Get App WebApp Settings OpenAPI Specification Source: https://docs.dify.ai/api-reference/applications/get-app-webapp-settings This OpenAPI 3.0.1 specification defines the GET /site endpoint for retrieving WebApp settings. It includes details on request parameters, response schemas, and example responses for both success and error cases. ```yaml openapi: 3.0.1 info: title: Completion App API description: >- The text generation application offers non-session support and is ideal for translation, article writing, summarization AI, and more. version: 1.0.0 servers: - url: '{api_base_url}' description: >- The base URL for the Completion App API. Replace {api_base_url} with the actual API base URL provided for your application. variables: api_base_url: default: https://api.dify.ai/v1 description: Actual base URL of the API security: - ApiKeyAuth: [] tags: - name: Completions description: Operations related to text generation and completion. - name: Files description: Operations related to file management. - name: End Users description: Operations related to end user information. - name: Feedback description: Operations related to user feedback. - name: TTS description: Operations related to Text-to-Speech and Speech-to-Text. - name: Applications description: Operations to retrieve application settings and information. paths: /site: get: tags: - Applications summary: Get App WebApp Settings description: >- Retrieve the WebApp settings of this application, including site configuration, theme, and customization options. operationId: getWebAppSettings responses: '200': description: WebApp settings of the application. content: application/json: schema: $ref: '#/components/schemas/WebAppSettingsResponse' examples: webAppSettings: summary: Response Example value: title: My Chat App chat_color_theme: '#4A90D9' chat_color_theme_inverted: false icon_type: emoji icon: 🤖 icon_background: '#FFFFFF' icon_url: null description: A helpful customer service chatbot. copyright: 2025 Dify privacy_policy: https://example.com/privacy custom_disclaimer: '' default_language: en-US show_workflow_steps: false use_icon_as_answer_icon: true '403': description: >- `forbidden` : Site not found for this application or the workspace has been archived. content: application/json: examples: forbidden: summary: forbidden value: status: 403 code: forbidden message: Forbidden. components: schemas: WebAppSettingsResponse: type: object properties: title: type: string description: WebApp title. chat_color_theme: type: string description: Chat color theme. chat_color_theme_inverted: type: boolean description: Whether the chat color theme is inverted. icon_type: type: string description: >- Type of icon used. `emoji` for emoji icons, `image` for uploaded image icons. icon: type: string description: Icon content (emoji or image ID). icon_background: type: string description: Icon background color. icon_url: type: string format: url nullable: true description: URL of the icon image. description: type: string description: WebApp description. copyright: type: string description: Copyright text. privacy_policy: type: string description: Privacy policy URL. custom_disclaimer: type: string description: Custom disclaimer text. default_language: type: string description: Default language code. show_workflow_steps: type: boolean description: Whether to show workflow steps. use_icon_as_answer_icon: type: boolean description: Whether to use the app icon as the answer icon. securitySchemes: ApiKeyAuth: type: http scheme: bearer bearerFormat: API_KEY description: >- API Key authentication. For all API requests, include your API Key in the `Authorization` HTTP Header, prefixed with `Bearer `. Example: `Authorization: Bearer {API_KEY}`. **Strongly recommend storing your API Key on the server-side, not shared or stored on the client-side, to avoid possible API-Key leakage that can lead to serious consequences.** ``` -------------------------------- ### Create Plugin Entrypoint Source: https://docs.dify.ai/en/develop-plugin/dev-guides-and-walkthroughs/develop-md-exporter Sets up the main entrypoint for the Dify plugin by initializing `PluginRunner` with the created Word and PDF export tools. No credential providers are needed for this plugin. ```python from dify_plugin import PluginRunner from tools.word_export import WordExportTool from tools.pdf_export import PDFExportTool plugin = PluginRunner( tools=[ WordExportTool(), PDFExportTool(), ], providers=[] # No credential providers needed ) ``` -------------------------------- ### Get Annotation Reply Job Status Source: https://docs.dify.ai/api-reference/annotations/get-annotation-reply-job-status Retrieves the status of an asynchronous annotation reply configuration job started by Configure Annotation Reply. ```APIDOC ## Get Annotation Reply Job Status ### Description Retrieves the status of an asynchronous annotation reply configuration job. ### Method GET ### Endpoint /api/v1/annotations/annotation-reply/job-status ### Query Parameters - **job_id** (string) - Required - The ID of the annotation reply job. ``` -------------------------------- ### Get Annotation Reply Job Status Source: https://docs.dify.ai/api-reference/annotations/get-annotation-reply-job-status Retrieves the status of an asynchronous annotation reply configuration job started by the Configure Annotation Reply API. ```APIDOC ## GET /apps/annotation-reply/{action}/status/{job_id} ### Description Retrieves the status of an asynchronous annotation reply configuration job started by [Configure Annotation Reply](/api-reference/annotations/configure-annotation-reply). ### Method GET ### Endpoint /apps/annotation-reply/{action}/status/{job_id} ### Parameters #### Path Parameters - **action** (string) - Required - Action type, must match the [Configure Annotation Reply](/api-reference/annotations/configure-annotation-reply) call. Must be one of: `enable`, `disable`. - **job_id** (string) - Required - Job ID returned by [Configure Annotation Reply](/api-reference/annotations/configure-annotation-reply). ### Response #### Success Response (200) - **job_id** (string) - Job ID from the [Configure Annotation Reply](/api-reference/annotations/configure-annotation-reply) call. - **job_status** (string) - Current job status. `waiting` for queued, `processing` for in progress, `completed` when finished, `error` if failed. - **error_msg** (string) - Error message describing why the job failed. Empty string when `job_status` is not `error`. #### Response Example ```json { "job_id": "a1b2c3d4-5678-90ab-cdef-1234567890ab", "job_status": "completed", "error_msg": "" } ``` #### Error Response (400) - **status** (integer) - HTTP status code, e.g., 400. - **code** (string) - Error code, e.g., `invalid_param`. - **message** (string) - Error message, e.g., The job does not exist. #### Error Response Example ```json { "status": 400, "code": "invalid_param", "message": "The job does not exist." } ``` ``` -------------------------------- ### Initialize Git and Push Plugin Source Source: https://docs.dify.ai/en/develop-plugin/publishing/marketplace-listing/release-to-individual-github-repo Initialize a Git repository in your plugin project directory, add all files, commit them, set the main branch, add the remote origin, and push the code to GitHub. ```bash cd your_plugin_project git init git add . git commit -m "initial commit" git branch -M main git remote add origin https://github.com//.git git push -u origin main ``` -------------------------------- ### Initialize Ngrok and Add Authentication Token Source: https://docs.dify.ai/en/use-dify/workspace/api-extension/api-extension Unzip the Ngrok executable and add your authentication token for configuration. This is a necessary step before starting the tunneling service. ```shell unzip /path/to/ngrok.zip ./ngrok config add-authtoken your-token ``` -------------------------------- ### Workflow Streaming Response Example Source: https://docs.dify.ai/api-reference/chatflows/send-chat-message Illustrates parsing a streaming response that includes workflow lifecycle events such as workflow start, node progression, and message completion. ```text data: {"event": "workflow_started", "task_id": "task123", "workflow_run_id": "wfr_abc123", "message_id": "msg123", "conversation_id": "conv123", "data": {"id": "wfr_abc123", "workflow_id": "wf_def456", "inputs": {"city": "San Francisco"}, "created_at": 1705395332}} data: {"event": "node_started", "task_id": "task123", "workflow_run_id": "wfr_abc123", "message_id": "msg123", "conversation_id": "conv123", "data": {"id": "ne_001", "node_id": "node_llm_1", "node_type": "llm", "title": "LLM", "index": 1, "created_at": 1705395332}} data: {"event": "message", "task_id": "task123", "message_id": "msg123", "conversation_id": "conv123", "answer": " I", "created_at": 1705395333} data: {"event": "node_finished", "task_id": "task123", "workflow_run_id": "wfr_abc123", "message_id": "msg123", "conversation_id": "conv123", "data": {"id": "ne_001", "node_id": "node_llm_1", "node_type": "llm", "title": "LLM", "index": 1, "status": "succeeded", "elapsed_time": 1.5, "created_at": 1705395332, "finished_at": 1705395334}} data: {"event": "message_end", "task_id": "task123", "message_id": "msg123"} ``` -------------------------------- ### Get End User by ID (OpenAPI) Source: https://docs.dify.ai/api-reference/终端用户/获取终端用户信息 This OpenAPI specification defines the endpoint for retrieving end-user information. It includes parameters, response schemas, and examples for successful retrieval and not found scenarios. ```yaml openapi: 3.0.1 info: title: 工作流应用 API description: 工作流应用提供无会话支持,适用于翻译、文章写作、摘要 AI 等场景。 version: 1.0.0 servers: - url: '{api_base_url}' description: 工作流应用 API 的基础 URL。将 {api_base_url} 替换为实际的 API 基础 URL。 variables: api_base_url: default: https://api.dify.ai/v1 description: API 的实际基础 URL security: - ApiKeyAuth: [] tags: - name: 工作流 description: 用于执行和管理工作流的操作。 - name: 文件操作 description: 文件上传和下载操作。 - name: 终端用户 description: 终端用户信息相关操作。 - name: 语音与文字转换 description: 语音转文字和文字转语音转换。 - name: 应用配置 description: 应用设置、参数和元数据。 - name: 人工介入 description: 暂停等待人工输入的工作流恢复操作。 paths: /end-users/{end_user_id}: get: tags: - 终端用户 summary: 获取终端用户信息 description: >- 根据 ID 获取终端用户信息。当其他 API 返回终端用户 ID(例如[上传文件](/api-reference/文件操作/上传文件)返回的 `created_by`)时很有用。 operationId: getEndUserWorkflowCn parameters: - name: end_user_id in: path required: true description: 终端用户 ID。 schema: type: string format: uuid responses: '200': description: 成功获取终端用户。 content: application/json: schema: $ref: '#/components/schemas/EndUserDetail' examples: endUserDetail: summary: 响应示例 value: id: f1e2d3c4-b5a6-7890-abcd-ef1234567890 tenant_id: 11223344-5566-7788-99aa-bbccddeeff00 app_id: a1b2c3d4-5678-90ab-cdef-1234567890ab type: service_api external_user_id: abc-123 name: null is_anonymous: false session_id: abc-123 created_at: '2024-01-16T12:00:29Z' updated_at: '2024-01-16T12:00:29Z' '404': description: '`end_user_not_found` : 未找到终端用户。' content: application/json: examples: end_user_not_found: summary: end_user_not_found value: status: 404 code: end_user_not_found message: End user not found. components: schemas: EndUserDetail: type: object properties: id: type: string format: uuid description: 终端用户 ID。 tenant_id: type: string format: uuid description: 租户 ID。 app_id: type: string format: uuid nullable: true description: 应用 ID。 type: type: string description: 终端用户类型。Service API 用户固定为 `service_api`。 external_user_id: type: string nullable: true description: >- API 请求中提供的 `user` 标识符(例如 [发送对话消息](/api-reference/对话消息/发送对话消息) 中的 `user` 字段)。 name: type: string nullable: true description: 终端用户名称。 is_anonymous: type: boolean description: 用户是否为匿名用户。当原始 API 请求中未提供 `user` 标识符时,值为 `true`。 session_id: type: string description: 会话标识符。默认为 `external_user_id` 的值。 created_at: type: string format: date-time description: 创建时间戳。 updated_at: type: string format: date-time description: 最后更新时间戳。 securitySchemes: ApiKeyAuth: type: http scheme: bearer bearerFormat: API_KEY description: >- API Key 认证。对于所有 API 请求,请在 `Authorization` HTTP 头中包含您的 API Key,并加上 `Bearer ` 前缀。示例:`Authorization: Bearer {API_KEY}`。**强烈建议将 API Key 存储在服务端,不要在客户端共享或存储,以避免 API Key 泄漏导致严重后果。** ``` -------------------------------- ### Start Web Service Source: https://docs.dify.ai/en/self-host/advanced-deployments/local-source-code Start the Dify web service using PNPM. This command runs the Next.js development server. ```bash pnpm start ``` -------------------------------- ### List Metadata Fields OpenAPI Specification Source: https://docs.dify.ai/api-reference/metadata/list-metadata-fields This OpenAPI specification defines the GET endpoint for listing metadata fields. It includes request parameters, response schemas, and an example of a successful response. ```yaml openapi: 3.0.1 info: title: Knowledge API description: >- API for managing knowledge bases, documents, chunks, metadata, and tags, including creation, retrieval, and configuration. **Note:** A single Knowledge Base API key has permission to operate on all visible knowledge bases under the same account. Please pay attention to data security. version: 1.0.0 servers: - url: '{apiBaseUrl}' description: The base URL for the Knowledge API. variables: apiBaseUrl: default: https://api.dify.ai/v1 description: Actual base URL of the API security: - ApiKeyAuth: [] tags: - name: Knowledge Bases description: >- Operations for managing knowledge bases, including creation, configuration, and retrieval. - name: Documents description: >- Operations for creating, updating, and managing documents within a knowledge base. - name: Chunks description: Operations for managing document chunks and child chunks. - name: Metadata description: >- Operations for managing knowledge base metadata fields and document metadata values. - name: Tags description: Operations for managing knowledge base tags and tag bindings. - name: Models description: Operations for retrieving available models. - name: Knowledge Pipeline description: >- Operations for managing and running knowledge pipelines, including datasource plugins and pipeline execution. paths: /datasets/{dataset_id}/metadata: get: tags: - Metadata summary: List Metadata Fields description: >- Returns the list of all metadata fields (both custom and built-in) for the knowledge base, along with the count of documents using each field. operationId: listMetadataFields parameters: - name: dataset_id in: path required: true schema: type: string format: uuid description: Knowledge base ID. responses: '200': description: Metadata fields for the knowledge base. content: application/json: schema: type: object properties: doc_metadata: type: array description: List of metadata field definitions. items: type: object properties: id: type: string description: Metadata field identifier. name: type: string description: Metadata field name. type: type: string description: Metadata field type. count: type: integer description: Number of documents using this metadata field. built_in_field_enabled: type: boolean description: >- Whether built-in metadata fields are enabled for this knowledge base. examples: success: summary: Response Example value: doc_metadata: - id: b5c6d7e8-f9a0-1b2c-3d4e-5f6a7b8c9d0e name: author type: string count: 3 built_in_field_enabled: true components: securitySchemes: ApiKeyAuth: type: http scheme: bearer bearerFormat: API_KEY description: >- API Key authentication. For all API requests, include your API Key in the `Authorization` HTTP Header, prefixed with `Bearer `. Example: `Authorization: Bearer {API_KEY}`. **Strongly recommend storing your API Key on the server-side, not shared or stored on the client-side, to avoid possible API-Key leakage that can lead to serious consequences.** ``` -------------------------------- ### Initialize Bundle Plugin Project (macOS ARM) Source: https://docs.dify.ai/en/develop-plugin/features-and-specs/advanced-development/bundle Use this command to start a new Bundle plugin project on macOS with an ARM processor. Ensure you have the Dify plugin scaffolding tool. ```bash ./dify-plugin-darwin-arm64 bundle init ```