{"id":3455,"library":"dify-plugin","title":"Dify Plugin SDK","description":"The Dify Plugin SDK allows developers to build custom plugins for the Dify platform. It provides classes and decorators to define plugin metadata, inputs, outputs, and API endpoints, enabling seamless integration with Dify AI applications. Currently at version 0.7.4, the library is under active development with frequent releases.","status":"active","version":"0.7.4","language":"en","source_language":"en","source_url":"https://github.com/langgenius/dify-plugin-sdks","tags":["dify","plugin","sdk","fastapi","ai","developer-tools"],"install":[{"cmd":"pip install dify-plugin","lang":"bash","label":"Install latest version"}],"dependencies":[{"reason":"Web framework for API endpoints","package":"fastapi"},{"reason":"Data validation and settings management","package":"pydantic"},{"reason":"ASGI server for running the plugin API","package":"uvicorn"},{"reason":"Logging utility","package":"loguru"},{"reason":"Environment variable management","package":"python-dotenv"},{"reason":"HTTP client for making external requests","package":"requests"}],"imports":[{"symbol":"DifyPlugin","correct":"from dify_plugin import DifyPlugin"},{"symbol":"PluginMetadata","correct":"from dify_plugin import PluginMetadata"},{"symbol":"Category","correct":"from dify_plugin import Category"},{"symbol":"Input","correct":"from dify_plugin import Input"},{"symbol":"Output","correct":"from dify_plugin import Output"},{"symbol":"HttpAPI","correct":"from dify_plugin import HttpAPI"},{"symbol":"Markdown","correct":"from dify_plugin import Markdown"}],"quickstart":{"code":"import os\nfrom dify_plugin import DifyPlugin, PluginMetadata, Category, Input, Output\n\nplugin = DifyPlugin(\n    metadata=PluginMetadata(\n        name=\"Hello Dify\",\n        description=\"A simple plugin that says hello.\",\n        icon=\"https://dify.ai/favicon.ico\",\n        category=Category.TOOLS,\n        inputs=[\n            Input(name=\"name\", type=\"string\", required=True, description=\"Your name\"),\n        ],\n        outputs=[\n            Output(name=\"greeting\", type=\"string\"),\n        ],\n    )\n)\n\n@plugin.api(\"hello\")\ndef hello_world_api(name: str):\n    return {\"greeting\": f\"Hello, {name}!\"}\n\nif __name__ == \"__main__\":\n    # In a real Dify environment, the plugin would be served externally.\n    # For local testing, run this script and access at http://127.0.0.1:PORT/.well-known/ai-plugin.json\n    plugin.run()","lang":"python","description":"This quickstart demonstrates how to define a basic Dify plugin with metadata, inputs, outputs, and a single API endpoint. The `plugin.run()` call starts a local server for development and testing, exposing the plugin's OpenAPI specification."},"warnings":[{"fix":"Refer to the official GitHub repository's release notes and README for the latest API specifications and migration guides when upgrading.","message":"The library is under rapid development. API changes, including breaking ones, may occur frequently between minor versions (e.g., 0.x.x to 0.y.x) as the project matures.","severity":"breaking","affected_versions":"<1.0.0"},{"fix":"Ensure your development environment and deployment target use Python 3.11 or a newer compatible version.","message":"Plugins require Python 3.11 or higher. Using older Python versions will result in installation failures or runtime errors.","severity":"gotcha","affected_versions":"All versions"},{"fix":"Always use `@plugin.api()` on functions intended to be called by Dify, matching the endpoint name defined in your Dify plugin configuration.","message":"To expose functionality, plugin methods must be decorated with `@plugin.api(\"endpoint_name\")`. Forgetting this decorator or using an incorrect endpoint name will prevent Dify from discovering and invoking your plugin's capabilities.","severity":"gotcha","affected_versions":"All versions"},{"fix":"Carefully review and provide all required fields in `PluginMetadata`, ensuring they accurately reflect your plugin's purpose and interface.","message":"The `PluginMetadata` object requires essential fields like `name`, `description`, `icon`, `category`, `inputs`, and `outputs` to be correctly and completely defined. Incomplete or incorrect metadata can lead to the plugin not being recognized or functioning improperly within Dify.","severity":"gotcha","affected_versions":"All versions"}],"env_vars":null,"last_verified":"2026-04-11T00:00:00.000Z","next_check":"2026-07-10T00:00:00.000Z"}