---
dimensions:
  type:
    primary: conceptual
    detail: architecture
  level: beginner
standard_title: CLI
language: en
title: CLI
description: Install the Dify CLI, scaffold a new plugin project, and run it against a Dify instance for local development
---

Set up and package your Dify plugins using the Command Line Interface (CLI). The CLI provides a streamlined way to manage your plugin development workflow, from initialization to packaging.

This guide will instruct you on how to use the CLI for Dify plugin development.

## Prerequisites
Before you begin, ensure you have the following installed:
- Python version 3.12
- Dify CLI
- Homebrew (for Mac users)

## Create a Dify Plugin Project

<Tabs>
  <Tab title="Mac">
    ```bash
    brew tap langgenius/dify
    brew install dify
    ```
  </Tab>
  <Tab title="Linux">
    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.

    ```bash
    chmod +x dify-plugin-linux-amd64
    sudo mv dify-plugin-linux-amd64 /usr/local/bin/dify
    ```
  </Tab>
  <Tab title="Windows">
    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`.
  </Tab>
</Tabs>

Now you have successfully installed the Dify CLI. You can verify the installation by running:

```bash
dify version
```

You can create a new Dify plugin project using the following command:

```bash
dify plugin init
```

Fill in the required fields when prompted:

```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
```

Choose `python` and hit Enter to proceed with the Python plugin template.

```bash
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
```

Enter the default dify version, leave it blank to use the latest version:

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

Now you are ready to go! The CLI will create a new directory with the plugin name you provided, and set up the basic structure for your plugin.

```bash
cd hello-world
```

## Run the Plugin

Make sure you are in the hello-world directory

```bash
cp .env.example .env
```

Edit the `.env` file to set your plugin's environment variables, such as API keys or other configurations. You can find these variables in the Dify dashboard. Log in to your Dify environment, click the “Plugins” icon in the top right corner, then click the debug icon (or something that looks like a bug). In the pop-up window, copy the “API Key” and “Host Address”. (Please refer to your local corresponding screenshot, which shows the interface for obtaining the key and host address)

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

<Note>
  `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.
</Note>

Now you can run your plugin locally using the following command:

```bash
pip install -r requirements.txt
python -m main
```

{/*
Contributing Section
DO NOT edit this section!
It will be automatically generated by the script.
*/}

---

[Edit this page](https://github.com/langgenius/dify-docs/edit/main/en/develop-plugin/getting-started/cli.mdx) | [Report an issue](https://github.com/langgenius/dify-docs/issues/new?template=docs.yml)

