This document defines in detail the core concepts and structures for Dify model plugin development, including model providers (Provider), AI model entities (AIModelEntity), model types (ModelType), configuration methods (ConfigurateMethod), model features (ModelFeature), parameter rules (ParameterRule), price configuration (PriceConfig), and detailed data structure specifications for various credential modes.
All entities below are based onPydantic BaseModel
, and can be found in theentities
module.
provider
(string) Provider identifier, e.g.: openai
label
(object) Provider display name, i18n, can set both en_US
(English) and zh_Hans
(Chinese) languages
zh_Hans
(string) [optional] Chinese label, if not set, will default to using en_US
en_US
(string) English labeldescription
(object) [optional] Provider description, i18n
zh_Hans
(string) [optional] Chinese descriptionen_US
(string) English descriptionicon_small
(string) [optional] Provider small icon, stored in the _assets
directory under the corresponding provider implementation directory, same language strategy as label
zh_Hans
(string) [optional] Chinese iconen_US
(string) English iconicon_large
(string) [optional] Provider large icon, stored in the _assets
directory under the corresponding provider implementation directory, same language strategy as label
zh_Hans
(string) [optional] Chinese iconen_US
(string) English iconbackground
(string) [optional] Background color value, e.g.: #FFFFFF, if empty, will display the frontend default color valuehelp
(object) [optional] Help information
title
(object) Help title, i18n
zh_Hans
(string) [optional] Chinese titleen_US
(string) English titleurl
(object) Help link, i18n
zh_Hans
(string) [optional] Chinese linken_US
(string) English linksupported_model_types
(array[ModelType]) Supported model typesconfigurate_methods
(array[ConfigurateMethod]) Configuration methodsprovider_credential_schema
([ProviderCredentialSchema]) Provider credential specificationsmodel_credential_schema
([ModelCredentialSchema]) Model credential specificationsmodel
(string) Model identifier, e.g.: gpt-3.5-turbo
label
(object) [optional] Model display name, i18n, can set both en_US
(English) and zh_Hans
(Chinese) languages
zh_Hans
(string) [optional] Chinese labelen_US
(string) English labelmodel_type
(ModelType) Model typefeatures
(array[ModelFeature]) [optional] List of supported featuresmodel_properties
(object) Model properties
mode
(LLMMode) Mode (available for model type llm
)context_size
(int) Context size (available for model types llm
and text-embedding
)max_chunks
(int) Maximum number of chunks (available for model types text-embedding moderation
)file_upload_limit
(int) Maximum file upload limit, unit: MB. (available for model type speech2text
)supported_file_extensions
(string) Supported file extension formats, e.g.: mp3,mp4 (available for model type speech2text
)default_voice
(string) Default voice, required: alloy,echo,fable,onyx,nova,shimmer (available for model type tts
)voices
(list) List of available voices.
mode
(string) Voice model. (available for model type tts
)name
(string) Voice model display name. (available for model type tts
)language
(string) Supported languages for voice model. (available for model type tts
)word_limit
(int) Word limit for single conversion, defaults to paragraph segmentation (available for model type tts
)audio_type
(string) Supported audio file extension formats, e.g.: mp3,wav (available for model type tts
)max_workers
(int) Number of concurrent tasks supported for text-to-audio conversion (available for model type tts
)max_characters_per_chunk
(int) Maximum characters per chunk (available for model type moderation
)parameter_rules
(array[ParameterRule]) [optional] Model call parameter rulespricing
([PriceConfig]) [optional] Pricing informationdeprecated
(bool) Whether deprecated. If deprecated, the model list will no longer display it, but those already configured can continue to be used. Default is False.llm
Text generation modeltext-embedding
Text embedding modelrerank
Rerank modelspeech2text
Speech to texttts
Text to speechmoderation
Content moderationpredefined-model
Predefined modelcustomizable-model
Customizable modelfetch-from-remote
Fetch from remotepredefined-model
configuration method, only unified provider credentials are needed, but the models are fetched from the provider using the credential information.
agent-thought
Agent reasoning, generally models over 70B have chain-of-thought capabilities.vision
Vision, i.e.: image understanding.tool-call
Tool callingmulti-tool-call
Multiple tool callingstream-tool-call
Streaming tool callingpredefined-model
Predefined modelfetch-from-remote
Remote modelcompletion
Text completionchat
Chatname
(string) Actual parameter name for model calluse_template
(string) [optional] Use templateFor details on using templates, you can refer to the examples in Creating a New Model Provider.There are 5 pre-configured variable content templates by default:
temperature
top_p
frequency_penalty
presence_penalty
max_tokens
use_template
, which will use the default configuration from entities.defaults.PARAMETER_RULE_TEMPLATE without needing to set any parameters other than name
and use_template
. If additional configuration parameters are set, they will override the default configuration. You can refer to openai/llm/gpt-3.5-turbo.yaml
for examples.
label
(object) [optional] Label, i18nzh_Hans
(string) [optional] Chinese labelen_US
(string) English labeltype
(string) [optional] Parameter type
int
Integerfloat
Floating pointstring
Stringboolean
Booleanhelp
(string) [optional] Help informationzh_Hans
(string) [optional] Chinese help informationen_US
(string) English help informationrequired
(bool) Whether required, default is False.default
(int/float/string/bool) [optional] Default valuemin
(int/float) [optional] Minimum value, only applicable to numeric typesmax
(int/float) [optional] Maximum value, only applicable to numeric typesprecision
(int) [optional] Precision, decimal places to retain, only applicable to numeric typesoptions
(array[string]) [optional] Dropdown option values, only applicable when type
is string
, if not set or is null, then option values are not restrictedinput
(float) Input unit price, i.e., Prompt unit priceoutput
(float) Output unit price, i.e., returned content unit priceunit
(float) Price unit, e.g., if priced per 1M tokens, then the unit token number corresponding to the unit price is 0.000001
currency
(string) Currency unitcredential_form_schemas
(array[CredentialFormSchema]) Credential form specificationsmodel
(object) Model identifier, default variable name is model
label
(object) Model form item display name
en_US
(string) Englishzh_Hans
(string) [optional] Chineseplaceholder
(object) Model prompt content
en_US
(string) Englishzh_Hans
(string) [optional] Chinesecredential_form_schemas
(array[CredentialFormSchema]) Credential form specificationsvariable
(string) Form item variable namelabel
(object) Form item label
en_US
(string) Englishzh_Hans
(string) [optional] Chinesetype
(FormType) Form item typerequired
(bool) Whether requireddefault
(string) Default valueoptions
(array[FormOption]) Form item attribute specific to select
or radio
, defines dropdown contentplaceholder
(object) Form item attribute specific to text-input
, form item placeholder
en_US
(string) Englishzh_Hans
(string) [optional] Chinesemax_length
(int) Form item attribute specific to text-input
, defines maximum input length, 0 means no limit.show_on
(array[FormShowOnObject]) Display when other form item values meet conditions, empty means always display.text-input
Text input componentsecret-input
Password input componentselect
Single-select dropdownradio
Radio componentswitch
Switch component, only supports true
and false
label
(object) Label
en_US
(string) Englishzh_Hans
(string) [optional] Chinesevalue
(string) Dropdown option valueshow_on
(array[FormShowOnObject]) Display when other form item values meet conditions, empty means always display.variable
(string) Other form item variable namevalue
(string) Other form item variable value