Skip to main content

A model plugin describes itself with two entities: a Provider that handles authentication and lists supported models, and one AIModelEntity per model declaring its type, features, and parameters.

Note

All entities below are Pydantic BaseModel subclasses from the dify_plugin.entities.model module.

Quick Decision#

Authentication only: predefined models

User pastes an API key, gets your full model list. Set configurate_methods: [predefined-model] and define each model’s AIModelEntity in YAML.

User-supplied models

User configures their own model name and base URL (OpenAI-compatible endpoints, custom deployments). Use configurate_methods: [customizable-model] and see Customizable Model.

Mixed

Built-in catalog plus user-added custom models. Combine both configurate_methods values.

Walkthrough

For an end-to-end example, see Creating a New Model Provider.

Provider#

providerstring#

Provider identifier, for example openai.

labelobject#

Provider display name (i18n). Supports en_US (English) and zh_Hans (Chinese).

zh_Hansstring#

Chinese label. Falls back to en_US if not set.

en_USstringrequired#

English label

descriptionobject#

Provider description (i18n).

zh_Hansstring#

Chinese description.

en_USstringrequired#

English description.

icon_smallobject#

Small provider icon, stored in the _assets directory under the provider implementation directory.

zh_Hansstring#

Chinese icon.

en_USstringrequired#

English icon.

icon_largeobject#

Large provider icon, stored in the _assets directory under the provider implementation directory.

zh_Hansstring#

Chinese icon.

en_USstringrequired#

English icon.

backgroundstring#

Background color value, for example #FFFFFF. If empty, the frontend default color is used.

helpobject#

Help information.

titleobject#

Help title (i18n).

zh_Hansstring#

Chinese title.

en_USstringrequired#

English title.

urlobject#

Help link (i18n).

zh_Hansstring#

Chinese link.

en_USstringrequired#

English link.

supported_model_typesarray[ModelType]required#

Supported model types.

configurate_methodsarray[ConfigurateMethod]required#

Configuration methods.

provider_credential_schemaProviderCredentialSchemarequired#

Provider credential specification.

model_credential_schemaModelCredentialSchema#

Model credential specification.

AIModelEntity#

modelstringrequired#

Model identifier, for example gpt-3.5-turbo.

labelobject#

Model display name (i18n). Supports en_US (English) and zh_Hans (Chinese).

zh_Hansstring#

Chinese label.

en_USstringrequired#

English label.

model_typeModelTyperequired#

Model type.

featuresarray[ModelFeature]#

Supported features.

model_propertiesobjectrequired#

Model properties.

modeLLMMode#

Mode (model type llm).

context_sizeinteger#

Context size (model types llm and text-embedding).

max_chunksinteger#

Maximum number of chunks (model types text-embedding and moderation).

file_upload_limitinteger#

Maximum file upload size in MB (model type speech2text).

supported_file_extensionsstring#

Supported file extensions, for example mp3,mp4 (model type speech2text).

default_voicestring#

Default voice; one of alloy, echo, fable, onyx, nova, shimmer (model type tts).

voicesarray#

Available voices (model type tts).

modestring#

Voice model.

namestring#

Voice model display name.

languagestring#

Languages the voice model supports.

word_limitinteger#

Word limit per conversion; defaults to splitting by paragraph (model type tts).

audio_typestring#

Supported audio file extensions, for example mp3,wav (model type tts).

max_workersinteger#

Number of concurrent text-to-audio conversion tasks (model type tts).

max_characters_per_chunkinteger#

Maximum characters per chunk (model type moderation).

parameter_rulesarray[ParameterRule]#

Rules for model call parameters.

pricingPriceConfig#

Pricing information.

deprecatedboolean#

Whether the model is deprecated. Deprecated models no longer appear in the model list, but existing configurations keep working. Defaults to False.

ModelType#

llmstring#

Text generation model.

text-embeddingstring#

Text embedding model.

rerankstring#

Rerank model.

speech2textstring#

Speech to text.

ttsstring#

Text to speech.

moderationstring#

Content moderation.

ConfigurateMethod#

predefined-modelstring#

Predefined model. The user configures unified provider credentials once to use all predefined models under the provider.

customizable-modelstring#

Customizable model. The user adds a credential configuration for each model.

fetch-from-remotestring#

Fetch from remote. Like predefined-model, only unified provider credentials are needed, but the model list is fetched from the provider using those credentials.

ModelFeature#

agent-thoughtstring#

Agent reasoning. Generally, models over 70B have chain-of-thought capabilities.

visionstring#

Vision (image understanding).

tool-callstring#

Tool calling.

multi-tool-callstring#

Multiple tool calling.

stream-tool-callstring#

Streaming tool calling.

FetchFrom#

predefined-modelstring#

Predefined model.

fetch-from-remotestring#

Remote model.

LLMMode#

completionstring#

Text completion.

chatstring#

Chat.

ParameterRule#

namestringrequired#

Actual parameter name used in the model call.

use_templatestring#

Template to use.

Five parameter templates are predefined:

  • temperature
  • top_p
  • frequency_penalty
  • presence_penalty
  • max_tokens

Set one of these names in use_template to inherit the default configuration from entities.defaults.PARAMETER_RULE_TEMPLATE; you then only need name and use_template. Any additional parameters you set override the template defaults. See openai/llm/gpt-3.5-turbo.yaml and the examples in Creating a New Model Provider.

labelobject#

Label (i18n).

zh_Hansstring#

Chinese label.

en_USstringrequired#

English label.

typestring#

Parameter type.

intstring#

Integer.

floatstring#

Floating point.

stringstring#

String.

booleanstring#

Boolean.

helpobject#

Help information (i18n).

zh_Hansstring#

Chinese help text.

en_USstringrequired#

English help text.

requiredboolean#

Whether the parameter is required. Defaults to False.

defaultint/float/string/boolean#

Default value.

minint/float#

Minimum value. Numeric types only.

maxint/float#

Maximum value. Numeric types only.

precisioninteger#

Number of decimal places to keep. Numeric types only.

optionsarray[string]#

Dropdown option values. Only applies when type is string. If not set or null, values are unrestricted.

PriceConfig#

inputfloat#

Input (prompt) unit price.

outputfloat#

Output (returned content) unit price.

unitfloat#

Price unit. For example, if pricing is per 1M tokens, the unit token count corresponding to the unit price is 0.000001.

currencystring#

Currency unit.

ProviderCredentialSchema#

credential_form_schemasarray[CredentialFormSchema]required#

Credential form specification.

ModelCredentialSchema#

modelobjectrequired#

Model identifier. The default variable name is model.

labelobjectrequired#

Display name of the model form item.

en_USstringrequired#

English.

zh_Hansstring#

Chinese.

placeholderobjectrequired#

Placeholder text for the model form item.

en_USstringrequired#

English.

zh_Hansstring#

Chinese.

credential_form_schemasarray[CredentialFormSchema]required#

Credential form specification.

CredentialFormSchema#

variablestringrequired#

Form item variable name.

labelobjectrequired#

Form item label.

en_USstringrequired#

English.

zh_Hansstring#

Chinese.

typeFormTyperequired#

Form item type.

requiredboolean#

Whether the form item is required.

defaultstring#

Default value.

optionsarray[FormOption]#

Dropdown content. Specific to the select and radio types.

placeholderobject#

Form item placeholder. Specific to the text-input type.

en_USstringrequired#

English.

zh_Hansstring#

Chinese.

max_lengthinteger#

Maximum input length. Specific to the text-input type. 0 means no limit.

show_onarray[FormShowOnObject]#

Show this item only when other form item values meet the given conditions. Empty means always show.

FormType#

text-inputstring#

Text input component.

secret-inputstring#

Password input component.

selectstring#

Single-select dropdown.

radiostring#

Radio component.

switchstring#

Switch component. Only supports true and false.

FormOption#

labelobjectrequired#

Label.

en_USstringrequired#

English.

zh_Hansstring#

Chinese.

valuestringrequired#

Dropdown option value.

show_onarray[FormShowOnObject]#

Show this option only when other form item values meet the given conditions. Empty means always show.

FormShowOnObject#

variablestringrequired#

Variable name of the other form item.

valuestringrequired#

Variable value of the other form item.