Endpoint
This document uses the Neko Cat project as an example to explain the structure of Endpoints within a plugin. Endpoints are HTTP interfaces exposed by the plugin, which can be used for integration with external systems. For the complete plugin code, please refer to the GitHub repository.Group Definition
AnEndpoint group is a collection of multiple Endpoints. When creating a new Endpoint within a Dify plugin, you might need to fill in the following configuration.
Besides the Endpoint Name, you can add new form items by writing the group’s configuration information. After clicking save, you can see the multiple interfaces it contains, which will use the same configuration information.
Structure
settings(map[string] ProviderConfig): Endpoint configuration definition.endpoints(list[string], required): Points to the specificendpointinterface definitions.
Interface Definition
path(string): Follows the Werkzeug interface standard.method(string): Interface method, only supportsHEAD,GET,POST,PUT,DELETE,OPTIONS.extra(object): Configuration information beyond the basic details.python(object)source(string): The source code that implements this interface.
Interface Implementation
You need to implement a subclass that inherits fromdify_plugin.Endpoint and implement the _invoke method.
- Input Parameters
r(Request): TheRequestobject fromwerkzeug.values(Mapping): Path parameters parsed from the path.settings(Mapping): Configuration information for thisEndpoint.
- Return
- A
Responseobject fromwerkzeug, supports streaming responses. - Directly returning a string is not supported.
- A
Notes
- Endpoints are only instantiated when the plugin is called; they are not long-running services.
- Pay attention to security when developing Endpoints and avoid executing dangerous operations.
- Endpoints can be used to handle Webhook callbacks or provide interfaces for other systems to connect.
Related Resources
- Basic Concepts of Plugin Development - Understand the overall architecture of plugin development.
- Neko Cat Example - An example of extension plugin development.
- General Specifications Definition - Understand common structures like ProviderConfig.
- Develop a Slack Bot Plugin Example - Another plugin development example.
- Getting Started with Plugin Development - Develop a plugin from scratch.
- Reverse Invocation of Dify Services - Learn how to use the reverse invocation feature.
Edit this page | Report an issue