快速开始

Install the Dify Plugin CLI, scaffold a new plugin project, and run it against a Dify instance for local development

The Dify Plugin CLI manages your plugin development workflow, from project initialization to packaging. This guide covers installing the CLI, scaffolding a plugin project, and running it against a Dify instance.

This is the Dify Plugin CLI (the dify command) for building plugins. It is not the Dify CLI (difyctl), which runs and manages Dify apps from the command line.

Prerequisites

Before you begin, make sure you have:

  • Python 3.12
  • Homebrew (macOS only, used to install the CLI)

Install the CLI

brew tap langgenius/dify
brew install dify
Download the latest binary from the [Dify Plugin Daemon releases page](https://github.com/langgenius/dify-plugin-daemon/releases). Pick `dify-plugin-linux-amd64` for x86\_64 hosts or `dify-plugin-linux-arm64` for ARM hosts.
chmod +x dify-plugin-linux-amd64
sudo mv dify-plugin-linux-amd64 /usr/local/bin/dify
Download `dify-plugin-windows-amd64.exe` (or `dify-plugin-windows-arm64.exe`) from the [Dify Plugin Daemon releases page](https://github.com/langgenius/dify-plugin-daemon/releases), rename it to `dify.exe`, and add its folder to your `PATH`.

Verify the installation:

dify version

Create a Plugin Project

Create a new plugin project with:

dify plugin init

Fill in the required fields when prompted:

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

Choose python and press Enter to use the Python plugin template, then select the type of plugin you want to build:

Select the type of plugin you want to create, and press `Enter` to continue
Before starting, here's some basic knowledge about Plugin types in Dify:

- Tool: Tool Providers like Google Search, Stable Diffusion, etc. Used to perform specific tasks.
- Model: Model Providers like OpenAI, Anthropic, etc. Use their models to enhance AI capabilities.
- Endpoint: Similar to Service API in Dify and Ingress in Kubernetes. Extend HTTP services as endpoints with custom logic.
- Trigger: Webhook-based providers that turn third-party platform events into workflow start signals.
- Agent Strategy: Implement your own agent strategies like Function Calling, ReAct, ToT, CoT, etc.

Based on the ability you want to extend, Plugins are divided into six types: Tool, Model, Extension, Agent Strategy, Datasource, and Trigger.

- Tool: A tool provider that can also implement endpoints. For example, building a Discord Bot requires both sending and receiving messages.
- Model: Strictly for model providers, no other extensions allowed.
- Extension: For simple HTTP services that extend functionality.
- Agent Strategy: Implement custom agent logic with a focused approach.
- Datasource: Provide datasource for Dify Knowledge Pipeline.
- Trigger: Build webhook integrations that emit events to kick off workflows.

We've provided templates to help you get started. Choose one of the options below:
-> tool
  agent-strategy
  llm
  text-embedding
  rerank
  tts
  speech2text
  moderation
  extension
  datasource
  trigger

When prompted for the minimal Dify version, leave it blank to use the latest version:

Edit minimal Dify version requirement, leave it blank by default
Minimal Dify version (press Enter to next step):

The CLI creates a new directory named after your plugin and sets up the basic project structure. Move into it:

cd hello-world

Run the Plugin

From the hello-world directory, copy the example environment file:

cp .env.example .env

Edit the .env file to set your plugin's environment variables, such as API keys or other configurations. To get the debugging credentials, log in to your Dify environment, click Plugins in the top-right corner, then click the debug icon. In the pop-up window, copy the API Key and Host Address.

INSTALL_METHOD=remote
REMOTE_INSTALL_URL=debug-plugin.dify.dev:5003
REMOTE_INSTALL_KEY=********-****-****-****-************

REMOTE_INSTALL_URL combines host and port in host:port form. The host and port are shown together in the API Key card on the Plugins page.

Install the dependencies and run your plugin:

pip install -r requirements.txt
python -m main

Modular components that extend Dify AI applications with external services, custom logic, and specialized tools

Dify plugins are modular components that extend your Dify-built AI applications with external services, custom functions, and specialized tools.

<img alt="Marketplace" />

Through plugins, your AI applications can:

  • Connect to external APIs
  • Process different types of data
  • Perform specialized calculations
  • Execute real-world actions

Start Here

A short decision guide for picking between Tool, Model, Agent Strategy, Extension, Datasource, and Trigger plugins.



Set up `dify` on your machine and scaffold a new plugin project in minutes.

Types of Plugins

<AccordionGroup>

Package and manage AI models as plugins

[/en/develop-plugin/dev-guides-and-walkthroughs/creating-new-model-provider](Learn more)



Build specialized capabilities for Agents and workflows

[/en/develop-plugin/dev-guides-and-walkthroughs/tool-plugin](Learn more)



Create custom reasoning strategies for autonomous Agents

[/en/develop-plugin/dev-guides-and-walkthroughs/agent-strategy-plugin](Learn more)



Integrate with external services through HTTP webhooks

[/en/develop-plugin/dev-guides-and-walkthroughs/endpoint](Learn more)



Feed external content into Dify's Knowledge Pipeline

[/en/develop-plugin/dev-guides-and-walkthroughs/datasource-plugin](Learn more)



Kick off workflows from third-party platform events received via webhooks

[/en/develop-plugin/dev-guides-and-walkthroughs/trigger-plugin](Learn more)

</AccordionGroup>

Additional Resources

Tools and techniques for efficient plugin development



Package and share your plugins with the Dify community



Technical specifications and documentation



Communicate with other developers and contribute to the ecosystem

A short decision guide for picking between Tool, Model, Agent Strategy, Extension, Datasource, and Trigger plugins

Dify supports several plugin types, each targeting a different extension point inside the platform. Pick the one that matches how your code will be invoked.

Quick Decision

You want to... Build a...
Add a callable action to Agents and Workflows (search, send email, transform data, etc.) Tool
Make a new LLM, embedding, rerank, TTS, STT, or moderation model selectable inside Dify Model
Implement a custom reasoning loop for Agents (ReAct, Function Calling variant, etc.) Agent Strategy
Expose an HTTP endpoint that external services can call to drive a Dify workflow Extension (Endpoint)
Ingest documents from an external system into a knowledge base Datasource
Start a workflow when something happens upstream (a webhook fires, a file lands) Trigger

Common Questions

<AccordionGroup>

Yes. A Tool plugin can also expose endpoints. For example, a Discord bot plugin sends messages (tool) and receives webhooks (endpoint) in one package. Model plugins are stricter: they cannot bundle tools or endpoints.



A Tool is an individual capability the Agent decides to call (like "search the web"). An Agent Strategy is the *reasoning loop itself*: the policy that decides which tools to call, in what order, and when to stop. Build a tool unless you're replacing how Agents think.



Datasource brings documents into a knowledge base for retrieval. Trigger fires a workflow in real time on an upstream event. The same systems can power both, but the consumption pattern differs: indexing vs. event-driven execution.



Extensions are for the other direction: an outside service calls *into* Dify. Tools are for Agents/Workflows calling *out* to a service. Build an Extension when your plugin is the entry point, not the action.

</AccordionGroup>

Next Steps

Once you've picked a type, set up the CLI and scaffold a project:

Get `dify` on your machine and run `dify plugin init`.



Understand the YAML structure every plugin shares.

Orchestrate, publish, and monitor AI applications in your workspace

<div> <div> <div> <h1>Use Dify</h1>

  &lt;p>
    Your workspace is where everything happens: build AI applications, ground them in your own data, then publish and monitor them.
  &lt;/p>

  &lt;div>
    [/en/quick-start](Quick Start)

    &lt;span>
      [/en/learn/key-concepts](Key Concepts)
      &lt;span>·&lt;/span>
      [/en/learn/tutorials/workflow-101/lesson-01](Tutorials)
    &lt;/span>
  &lt;/div>
&lt;/div>

</div>

<div>

  Build workflows and chatflows on the visual canvas, plus agents, chatbots, and more.



  Import documents and data so your apps can retrieve and cite them.



  Ship your app as a web app, embed it in a website, or call it over the API.



  Track usage, review logs, and refine answers with annotations.



  Connect model providers, tools, data sources, and external services.



  Ask the community or report a problem.

  &lt;div>
    [https://discord.gg/FngNHpbcY7](Discord)
    &lt;span>·&lt;/span>
    [https://github.com/langgenius/dify/issues](GitHub Issues)
    &lt;span>·&lt;/span>
    [https://github.com/langgenius/dify/discussions](Discussions)
  &lt;/div>

</div> </div>


Orchestrate, publish, and monitor AI applications in your workspace

<div> <div> <div> <h1>Use Dify</h1>

  &lt;p>
    Your workspace is where everything happens: build AI applications, ground them in your own data, then publish and monitor them.
  &lt;/p>

  &lt;div>
    [/en/quick-start](Quick Start)

    &lt;span>
      [/en/learn/key-concepts](Key Concepts)
      &lt;span>·&lt;/span>
      [/en/learn/tutorials/workflow-101/lesson-01](Tutorials)
    &lt;/span>
  &lt;/div>
&lt;/div>

</div>

<div>

  Build workflows and chatflows on the visual canvas, plus agents, chatbots, and more.



  Import documents and data so your apps can retrieve and cite them.



  Ship your app as a web app, embed it in a website, or call it over the API.



  Track usage, review logs, and refine answers with annotations.



  Connect model providers, tools, data sources, and external services.



  Ask the community or report a problem.

  &lt;div>
    [https://discord.gg/FngNHpbcY7](Discord)
    &lt;span>·&lt;/span>
    [https://github.com/langgenius/dify/issues](GitHub Issues)
    &lt;span>·&lt;/span>
    [https://github.com/langgenius/dify/discussions](Discussions)
  &lt;/div>

</div> </div>