How to add llm credentials through dify official apis? #863

Closed
opened 2026-02-16 10:20:46 -05:00 by yindo · 7 comments
Owner

Originally created by @RobertWangWang on GitHub (Dec 10, 2025).

Self Checks

  • I have read the Contributing Guide and Language Policy.
  • I have searched for existing issues search for existing issues, including closed ones.
  • I confirm that I am using English to submit this report, otherwise it will be closed.
  • Please do not modify this template :) and fill in all the required fields.

1. Is this request related to a challenge you're experiencing? Tell me about your story.

Hello! I am trying to add some llm models to the dify framework. It seems I can not find relevant apis to use python to add them. So:

  1. How to use python to add llm models into dify through apis?
  2. Do I need to download the plugins first? Can I use api to automatically download the necessary plugins?
  3. Where can I find the encrypt algorithm for the api-key encryption?

Thank you and have a nice day!

2. Additional context or comments

No response

3. Can you help us with this feature?

  • I am interested in contributing to this feature.
Originally created by @RobertWangWang on GitHub (Dec 10, 2025). ### Self Checks - [x] I have read the [Contributing Guide](https://github.com/langgenius/dify/blob/main/CONTRIBUTING.md) and [Language Policy](https://github.com/langgenius/dify/issues/1542). - [x] I have searched for existing issues [search for existing issues](https://github.com/langgenius/dify-official-plugins/issues), including closed ones. - [x] I confirm that I am using English to submit this report, otherwise it will be closed. - [x] Please do not modify this template :) and fill in all the required fields. ### 1. Is this request related to a challenge you're experiencing? Tell me about your story. Hello! I am trying to add some llm models to the dify framework. It seems I can not find relevant apis to use python to add them. So: 1. How to use python to add llm models into dify through apis? 2. Do I need to download the plugins first? Can I use api to automatically download the necessary plugins? 3. Where can I find the encrypt algorithm for the api-key encryption? Thank you and have a nice day! ### 2. Additional context or comments _No response_ ### 3. Can you help us with this feature? - [ ] I am interested in contributing to this feature.
yindo added the enhancementquestion labels 2026-02-16 10:20:46 -05:00
yindo closed this issue 2026-02-16 10:20:46 -05:00
Author
Owner

@dosubot[bot] commented on GitHub (Dec 10, 2025):

You can add LLM credentials to Dify using its official REST APIs. For provider-level credentials, use the endpoint:

POST /workspaces/current/model-providers/<provider>/credentials

with a JSON payload like:

{
  "credentials": { /* your API keys or secrets */ },
  "name": "optional-credential-name"
}

For model-specific credentials, use:

POST /workspaces/current/model-providers/<provider>/models/credentials

with:

{
  "model": "model-name",
  "model_type": "model-type",
  "credentials": { /* your API keys or secrets */ },
  "name": "optional-credential-name"
}

You can interact with these endpoints using Python's requests library. Authentication and admin privileges are required for these operations. There are also endpoints for updating, deleting, validating, and switching credentials. See details in the API controller code and model credential controller.

Plugins (such as for new LLMs or datasources) must be installed manually using the CLI, e.g.:

dify-plugin install plugin-name.difypkg

There is currently no API for automated plugin downloads. See the GitLab plugin README.

For API-key encryption, Dify uses a hybrid RSA/AES scheme. Tokens are encrypted with a tenant-specific RSA public key and base64 encoded. The encryption function generates a random AES key, encrypts your secret with AES, then encrypts the AES key with RSA. The private key is stored securely per tenant. See the implementation in encrypter.py and rsa.py.

Let me know if you need example Python code for these API calls!

To reply, just mention @dosu.


How did I do? Good | Irrelevant | Incorrect | Verbose | Hallucination | Report 🐛 | Other

Open in Cursor Join Discord Share on X

@dosubot[bot] commented on GitHub (Dec 10, 2025): <!-- Answer --> You can add LLM credentials to Dify using its official REST APIs. For provider-level credentials, use the endpoint: ``` POST /workspaces/current/model-providers/<provider>/credentials ``` with a JSON payload like: ```json { "credentials": { /* your API keys or secrets */ }, "name": "optional-credential-name" } ``` For model-specific credentials, use: ``` POST /workspaces/current/model-providers/<provider>/models/credentials ``` with: ```json { "model": "model-name", "model_type": "model-type", "credentials": { /* your API keys or secrets */ }, "name": "optional-credential-name" } ``` You can interact with these endpoints using Python's `requests` library. Authentication and admin privileges are required for these operations. There are also endpoints for updating, deleting, validating, and switching credentials. See details in the [API controller code](https://github.com/langgenius/dify/blob/693877e5e48dcc0f3a707d56838c4d84b2a0628b/api/controllers/console/workspace/model_providers.py#L25-L251) and [model credential controller](https://github.com/langgenius/dify/blob/693877e5e48dcc0f3a707d56838c4d84b2a0628b/api/controllers/console/workspace/models.py#L123-L501). Plugins (such as for new LLMs or datasources) must be installed manually using the CLI, e.g.: ``` dify-plugin install plugin-name.difypkg ``` There is currently no API for automated plugin downloads. See the [GitLab plugin README](https://github.com/langgenius/dify-official-plugins/blob/0ed1a65d4d73ece4aee83271d4711fd47e3f0c26/datasources/gitlab_datasource/README.md#L14-L100). For API-key encryption, Dify uses a hybrid RSA/AES scheme. Tokens are encrypted with a tenant-specific RSA public key and base64 encoded. The encryption function generates a random AES key, encrypts your secret with AES, then encrypts the AES key with RSA. The private key is stored securely per tenant. See the implementation in [`encrypter.py`](https://github.com/langgenius/dify/blob/693877e5e48dcc0f3a707d56838c4d84b2a0628b/api/core/helper/encrypter.py#L18-L44) and [`rsa.py`](https://github.com/langgenius/dify/blob/693877e5e48dcc0f3a707d56838c4d84b2a0628b/api/libs/rsa.py#L13-L90). Let me know if you need example Python code for these API calls! <!-- Dosu Comment Footer --> *To reply, just mention [@dosu](https://go.dosu.dev/dosubot).* --- <sup>How did I do? [Good](https://app.dosu.dev/response-feedback/504f47f2-b3e4-411b-8de3-5f924d8de9f7?feedback_type=great_response) | [Irrelevant](https://app.dosu.dev/response-feedback/504f47f2-b3e4-411b-8de3-5f924d8de9f7?feedback_type=irrelevant_answer) | [Incorrect](https://app.dosu.dev/response-feedback/504f47f2-b3e4-411b-8de3-5f924d8de9f7?feedback_type=incorrect_sources) | [Verbose](https://app.dosu.dev/response-feedback/504f47f2-b3e4-411b-8de3-5f924d8de9f7?feedback_type=too_verbose) | [Hallucination](https://app.dosu.dev/response-feedback/504f47f2-b3e4-411b-8de3-5f924d8de9f7?feedback_type=hallucination) | [Report 🐛](https://app.dosu.dev/response-feedback/504f47f2-b3e4-411b-8de3-5f924d8de9f7?feedback_type=bug_report) | [Other](https://app.dosu.dev/response-feedback/504f47f2-b3e4-411b-8de3-5f924d8de9f7?feedback_type=other)</sup> [![Open in Cursor](https://dosu.dev/dosu-in-cursor.svg)](https://cursor.com/link/prompt?text=You%20can%20add%20LLM%20credentials%20to%20Dify%20using%20its%20official%20REST%20APIs.%20For%20provider-level%20credentials%2C%20use%20the%20endpoint%3A%0A%0A%60%60%60%0APOST%20/workspaces/current/model-providers/%3Cprovider%3E/credentials%0A%60%60%60%0A%0Awith%20a%20JSON%20payload%20like%3A%0A%60%60%60json%0A%7B%0A%20%20%22credentials%22%3A%20%7B%20/%2A%20your%20API%20keys%20or%20secrets%20%2A/%20%7D%2C%0A%20%20%22name%22%3A%20%22optional-credential-name%22%0A%7D%0A%60%60%60%0AFor%20model-specific%20credentials%2C%20use%3A%0A%60%60%60%0APOST%20/workspaces/current/model-providers/%3Cprovider%3E/models/credentials%0A%60%60%60%0Awith%3A%0A%60%60%60json%0A%7B%0A%20%20%22model%22%3A%20%22model-name%22%2C%0A%20%20%22model_type%22%3A%20%22model-type%22%2C%0A%20%20%22credentials%22%3A%20%7B%20/%2A%20your%20API%20keys%20or%20secrets%20%2A/%20%7D%2C%0A%20%20%22name%22%3A%20%22optional-credential-name%22%0A%7D%0A%60%60%60%0AYou%20can%20interact%20with%20these%20endpoints%20using%20Python%27s%20%60requests%60%20library.%20Authentication%20and%20admin%20privileges%20are%20required%20for%20these%20operations.%20There%20are%20also%20endpoints%20for%20updating%2C%20deleting%2C%20validating%2C%20and%20switching%20credentials.%20See%20details%20in%20the%20%5BAPI%20controller%20code%5D%28https%3A//github.com/langgenius/dify/blob/693877e5e48dcc0f3a707d56838c4d84b2a0628b/api/controllers/console/workspace/model_providers.py%23L25-L251%29%20and%20%5Bmodel%20credential%20controller%5D%28https%3A//github.com/langgenius/dify/blob/693877e5e48dcc0f3a707d56838c4d84b2a0628b/api/controllers/console/workspace/models.py%23L123-L501%29.%0A%0APlugins%20%28such%20as%20for%20new%20LLMs%20or%20datasources%29%20must%20be%20installed%20manually%20using%20the%20CLI%2C%20e.g.%3A%0A%60%60%60%0Adify-plugin%20install%20plugin-name.difypkg%0A%60%60%60%0AThere%20is%20currently%20no%20API%20for%20automated%20plugin%20downloads.%20See%20the%20%5BGitLab%20plugin%20README%5D%28https%3A//github.com/langgenius/dify-official-plugins/blob/0ed1a65d4d73ece4aee83271d4711fd47e3f0c26/datasources/gitlab_datasource/README.md%23L14-L100%29.%0A%0AFor%20API-key%20encryption%2C%20Dify%20uses%20a%20hybrid%20RSA/AES%20scheme.%20Tokens%20are%20encrypted%20with%20a%20tenant-specific%20RSA%20public%20key%20and%20base64%20encoded.%20The%20encryption%20function%20generates%20a%20random%20AES%20key%2C%20encrypts%20your%20secret%20with%20AES%2C%20then%20encrypts%20the%20AES%20key%20with%20RSA.%20The%20private%20key%20is%20stored%20securely%20per%20tenant.%20See%20the%20implementation%20in%20%5B%60encrypter.py%60%5D%28https%3A//github.com/langgenius/dify/blob/693877e5e48dcc0f3a707d56838c4d84b2a0628b/api/core/helper/encrypter.py%23L18-L44%29%20and%20%5B%60rsa.py%60%5D%28https%3A//github.com/langgenius/dify/blob/693877e5e48dcc0f3a707d56838c4d84b2a0628b/api/libs/rsa.py%23L13-L90%29.%0A%0ALet%20me%20know%20if%20you%20need%20example%20Python%20code%20for%20these%20API%20calls%21)&nbsp;[![Join Discord](https://img.shields.io/badge/join-5865F2?logo=discord&logoColor=white&label=)](https://go.dosu.dev/discord-bot)&nbsp;[![Share on X](https://img.shields.io/badge/X-share-black)](https://twitter.com/intent/tweet?text=%40dosu_ai%20helped%20me%20solve%20this%20issue!&url=https%3A//github.com/langgenius/dify-official-plugins/issues/2230)
Author
Owner

@RobertWangWang commented on GitHub (Dec 10, 2025):

You can add LLM credentials to Dify using its official REST APIs. For provider-level credentials, use the endpoint:

POST /workspaces/current/model-providers/<provider>/credentials

with a JSON payload like:

{
"credentials": { /* your API keys or secrets */ },
"name": "optional-credential-name"
}
For model-specific credentials, use:

POST /workspaces/current/model-providers/<provider>/models/credentials

with:

{
"model": "model-name",
"model_type": "model-type",
"credentials": { /* your API keys or secrets */ },
"name": "optional-credential-name"
}
You can interact with these endpoints using Python's requests library. Authentication and admin privileges are required for these operations. There are also endpoints for updating, deleting, validating, and switching credentials. See details in the API controller code and model credential controller.

Plugins (such as for new LLMs or datasources) must be installed manually using the CLI, e.g.:

dify-plugin install plugin-name.difypkg

There is currently no API for automated plugin downloads. See the GitLab plugin README.

For API-key encryption, Dify uses a hybrid RSA/AES scheme. Tokens are encrypted with a tenant-specific RSA public key and base64 encoded. The encryption function generates a random AES key, encrypts your secret with AES, then encrypts the AES key with RSA. The private key is stored securely per tenant. See the implementation in encrypter.py and rsa.py.

Let me know if you need example Python code for these API calls!

To reply, just mention @dosu.

How did I do? Good | Irrelevant | Incorrect | Verbose | Hallucination | Report 🐛 | Other

Open in Cursor Join Discord Share on X

can you show me a minimal workable version of python code? thank you

@RobertWangWang commented on GitHub (Dec 10, 2025): > You can add LLM credentials to Dify using its official REST APIs. For provider-level credentials, use the endpoint: > > ``` > POST /workspaces/current/model-providers/<provider>/credentials > ``` > > with a JSON payload like: > > { > "credentials": { /* your API keys or secrets */ }, > "name": "optional-credential-name" > } > For model-specific credentials, use: > > ``` > POST /workspaces/current/model-providers/<provider>/models/credentials > ``` > > with: > > { > "model": "model-name", > "model_type": "model-type", > "credentials": { /* your API keys or secrets */ }, > "name": "optional-credential-name" > } > You can interact with these endpoints using Python's `requests` library. Authentication and admin privileges are required for these operations. There are also endpoints for updating, deleting, validating, and switching credentials. See details in the [API controller code](https://github.com/langgenius/dify/blob/693877e5e48dcc0f3a707d56838c4d84b2a0628b/api/controllers/console/workspace/model_providers.py#L25-L251) and [model credential controller](https://github.com/langgenius/dify/blob/693877e5e48dcc0f3a707d56838c4d84b2a0628b/api/controllers/console/workspace/models.py#L123-L501). > > Plugins (such as for new LLMs or datasources) must be installed manually using the CLI, e.g.: > > ``` > dify-plugin install plugin-name.difypkg > ``` > > There is currently no API for automated plugin downloads. See the [GitLab plugin README](https://github.com/langgenius/dify-official-plugins/blob/0ed1a65d4d73ece4aee83271d4711fd47e3f0c26/datasources/gitlab_datasource/README.md#L14-L100). > > For API-key encryption, Dify uses a hybrid RSA/AES scheme. Tokens are encrypted with a tenant-specific RSA public key and base64 encoded. The encryption function generates a random AES key, encrypts your secret with AES, then encrypts the AES key with RSA. The private key is stored securely per tenant. See the implementation in [`encrypter.py`](https://github.com/langgenius/dify/blob/693877e5e48dcc0f3a707d56838c4d84b2a0628b/api/core/helper/encrypter.py#L18-L44) and [`rsa.py`](https://github.com/langgenius/dify/blob/693877e5e48dcc0f3a707d56838c4d84b2a0628b/api/libs/rsa.py#L13-L90). > > Let me know if you need example Python code for these API calls! > > _To reply, just mention [@dosu](https://go.dosu.dev/dosubot)._ > > How did I do? [Good](https://app.dosu.dev/response-feedback/504f47f2-b3e4-411b-8de3-5f924d8de9f7?feedback_type=great_response) | [Irrelevant](https://app.dosu.dev/response-feedback/504f47f2-b3e4-411b-8de3-5f924d8de9f7?feedback_type=irrelevant_answer) | [Incorrect](https://app.dosu.dev/response-feedback/504f47f2-b3e4-411b-8de3-5f924d8de9f7?feedback_type=incorrect_sources) | [Verbose](https://app.dosu.dev/response-feedback/504f47f2-b3e4-411b-8de3-5f924d8de9f7?feedback_type=too_verbose) | [Hallucination](https://app.dosu.dev/response-feedback/504f47f2-b3e4-411b-8de3-5f924d8de9f7?feedback_type=hallucination) | [Report 🐛](https://app.dosu.dev/response-feedback/504f47f2-b3e4-411b-8de3-5f924d8de9f7?feedback_type=bug_report) | [Other](https://app.dosu.dev/response-feedback/504f47f2-b3e4-411b-8de3-5f924d8de9f7?feedback_type=other) > > [![Open in Cursor](https://camo.githubusercontent.com/bdf7dbded65ee585887f47e5fd6fa099ea0933088b4b03d02e83b4def50154d4/68747470733a2f2f646f73752e6465762f646f73752d696e2d637572736f722e737667)](https://cursor.com/link/prompt?text=You%20can%20add%20LLM%20credentials%20to%20Dify%20using%20its%20official%20REST%20APIs.%20For%20provider-level%20credentials%2C%20use%20the%20endpoint%3A%0A%0A%60%60%60%0APOST%20/workspaces/current/model-providers/%3Cprovider%3E/credentials%0A%60%60%60%0A%0Awith%20a%20JSON%20payload%20like%3A%0A%60%60%60json%0A%7B%0A%20%20%22credentials%22%3A%20%7B%20/%2A%20your%20API%20keys%20or%20secrets%20%2A/%20%7D%2C%0A%20%20%22name%22%3A%20%22optional-credential-name%22%0A%7D%0A%60%60%60%0AFor%20model-specific%20credentials%2C%20use%3A%0A%60%60%60%0APOST%20/workspaces/current/model-providers/%3Cprovider%3E/models/credentials%0A%60%60%60%0Awith%3A%0A%60%60%60json%0A%7B%0A%20%20%22model%22%3A%20%22model-name%22%2C%0A%20%20%22model_type%22%3A%20%22model-type%22%2C%0A%20%20%22credentials%22%3A%20%7B%20/%2A%20your%20API%20keys%20or%20secrets%20%2A/%20%7D%2C%0A%20%20%22name%22%3A%20%22optional-credential-name%22%0A%7D%0A%60%60%60%0AYou%20can%20interact%20with%20these%20endpoints%20using%20Python%27s%20%60requests%60%20library.%20Authentication%20and%20admin%20privileges%20are%20required%20for%20these%20operations.%20There%20are%20also%20endpoints%20for%20updating%2C%20deleting%2C%20validating%2C%20and%20switching%20credentials.%20See%20details%20in%20the%20%5BAPI%20controller%20code%5D%28https%3A//github.com/langgenius/dify/blob/693877e5e48dcc0f3a707d56838c4d84b2a0628b/api/controllers/console/workspace/model_providers.py%23L25-L251%29%20and%20%5Bmodel%20credential%20controller%5D%28https%3A//github.com/langgenius/dify/blob/693877e5e48dcc0f3a707d56838c4d84b2a0628b/api/controllers/console/workspace/models.py%23L123-L501%29.%0A%0APlugins%20%28such%20as%20for%20new%20LLMs%20or%20datasources%29%20must%20be%20installed%20manually%20using%20the%20CLI%2C%20e.g.%3A%0A%60%60%60%0Adify-plugin%20install%20plugin-name.difypkg%0A%60%60%60%0AThere%20is%20currently%20no%20API%20for%20automated%20plugin%20downloads.%20See%20the%20%5BGitLab%20plugin%20README%5D%28https%3A//github.com/langgenius/dify-official-plugins/blob/0ed1a65d4d73ece4aee83271d4711fd47e3f0c26/datasources/gitlab_datasource/README.md%23L14-L100%29.%0A%0AFor%20API-key%20encryption%2C%20Dify%20uses%20a%20hybrid%20RSA/AES%20scheme.%20Tokens%20are%20encrypted%20with%20a%20tenant-specific%20RSA%20public%20key%20and%20base64%20encoded.%20The%20encryption%20function%20generates%20a%20random%20AES%20key%2C%20encrypts%20your%20secret%20with%20AES%2C%20then%20encrypts%20the%20AES%20key%20with%20RSA.%20The%20private%20key%20is%20stored%20securely%20per%20tenant.%20See%20the%20implementation%20in%20%5B%60encrypter.py%60%5D%28https%3A//github.com/langgenius/dify/blob/693877e5e48dcc0f3a707d56838c4d84b2a0628b/api/core/helper/encrypter.py%23L18-L44%29%20and%20%5B%60rsa.py%60%5D%28https%3A//github.com/langgenius/dify/blob/693877e5e48dcc0f3a707d56838c4d84b2a0628b/api/libs/rsa.py%23L13-L90%29.%0A%0ALet%20me%20know%20if%20you%20need%20example%20Python%20code%20for%20these%20API%20calls%21) [![Join Discord](https://camo.githubusercontent.com/7d2066700925db1e370d956834f9ea0e5bc92cecbe84963fbd2a363e45091b4e/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f6a6f696e2d3538363546323f6c6f676f3d646973636f7264266c6f676f436f6c6f723d7768697465266c6162656c3d)](https://go.dosu.dev/discord-bot) [![Share on X](https://camo.githubusercontent.com/a8bd7f3fcf3f5e3bd124eee9ae50ae2ac17b40971726665ac2121d48f9aee155/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f582d73686172652d626c61636b)](https://twitter.com/intent/tweet?text=%40dosu_ai%20helped%20me%20solve%20this%20issue!&url=https%3A//github.com/langgenius/dify-official-plugins/issues/2230) can you show me a minimal workable version of python code? thank you
Author
Owner

@dosubot[bot] commented on GitHub (Dec 10, 2025):

Here’s a minimal Python example for adding LLM credentials to Dify using its REST API. You don’t need to encrypt credentials client-side—just send them in plaintext; Dify will handle encryption and validation server-side. Required credential fields depend on the provider/model schema (e.g., for OpenAI-compatible providers, usually api_key, endpoint_url, etc.). If any required fields are missing or invalid, the API will return a validation error.

import requests

# Set your Dify instance base URL and your admin access token
base_url = "https://your-dify-instance/api"
headers = {
    "Authorization": "Bearer YOUR_ACCESS_TOKEN",
    "Content-Type": "application/json"
}

# --- Provider-level credentials ---
provider = "your-provider"  # e.g., "openai_api_compatible"
payload_provider = {
    "credentials": {
        "api_key": "your-api-key",           # Replace with your actual key
        "endpoint_url": "https://api.example.com/v1"  # If required by your provider
        # Add other fields as required by your provider's schema
    },
    "name": "my-credential"  # Optional, max 30 chars
}
response_provider = requests.post(
    f"{base_url}/workspaces/current/model-providers/{provider}/credentials",
    headers=headers,
    json=payload_provider
)
print("Provider credential response:", response_provider.json())

# --- Model-specific credentials ---
model_name = "your-model"      # e.g., "gpt-3.5-turbo"
model_type = "your-model-type" # e.g., "chat"
payload_model = {
    "model": model_name,
    "model_type": model_type,
    "credentials": {
        "api_key": "your-model-api-key",    # Replace as needed
        # Add other fields as required by your model's schema
    },
    "name": "model-credential"  # Optional, max 30 chars
}
response_model = requests.post(
    f"{base_url}/workspaces/current/model-providers/{provider}/models/credentials",
    headers=headers,
    json=payload_model
)
print("Model credential response:", response_model.json())

Replace all placeholders with your actual values. If you’re unsure which fields are required, check your provider’s plugin documentation or try adding credentials in the Dify UI to see the expected fields. If you send incomplete or invalid data, the API will return a descriptive error message.
Encryption and validation are handled server-side—no need to do anything special in your Python code.
Reference: Dify API controller and service code

To reply, just mention @dosu.


How did I do? Good | Irrelevant | Incorrect | Verbose | Hallucination | Report 🐛 | Other

Open in Cursor Join Discord Share on X

@dosubot[bot] commented on GitHub (Dec 10, 2025): <!-- Answer --> Here’s a minimal Python example for adding LLM credentials to Dify using its REST API. You don’t need to encrypt credentials client-side—just send them in plaintext; Dify will handle encryption and validation server-side. Required credential fields depend on the provider/model schema (e.g., for OpenAI-compatible providers, usually `api_key`, `endpoint_url`, etc.). If any required fields are missing or invalid, the API will return a validation error. ```python import requests # Set your Dify instance base URL and your admin access token base_url = "https://your-dify-instance/api" headers = { "Authorization": "Bearer YOUR_ACCESS_TOKEN", "Content-Type": "application/json" } # --- Provider-level credentials --- provider = "your-provider" # e.g., "openai_api_compatible" payload_provider = { "credentials": { "api_key": "your-api-key", # Replace with your actual key "endpoint_url": "https://api.example.com/v1" # If required by your provider # Add other fields as required by your provider's schema }, "name": "my-credential" # Optional, max 30 chars } response_provider = requests.post( f"{base_url}/workspaces/current/model-providers/{provider}/credentials", headers=headers, json=payload_provider ) print("Provider credential response:", response_provider.json()) # --- Model-specific credentials --- model_name = "your-model" # e.g., "gpt-3.5-turbo" model_type = "your-model-type" # e.g., "chat" payload_model = { "model": model_name, "model_type": model_type, "credentials": { "api_key": "your-model-api-key", # Replace as needed # Add other fields as required by your model's schema }, "name": "model-credential" # Optional, max 30 chars } response_model = requests.post( f"{base_url}/workspaces/current/model-providers/{provider}/models/credentials", headers=headers, json=payload_model ) print("Model credential response:", response_model.json()) ``` Replace all placeholders with your actual values. If you’re unsure which fields are required, check your provider’s plugin documentation or try adding credentials in the Dify UI to see the expected fields. If you send incomplete or invalid data, the API will return a descriptive error message. Encryption and validation are handled server-side—no need to do anything special in your Python code. [Reference: Dify API controller and service code](https://github.com/langgenius/dify/blob/acdbcdb6f82b2ed2d48d5dd20cbfd745375588a6/api/controllers/console/workspace/model_providers.py#L36-L153) <!-- Dosu Comment Footer --> *To reply, just mention [@dosu](https://go.dosu.dev/dosubot).* --- <sup>How did I do? [Good](https://app.dosu.dev/response-feedback/0434b315-ccf0-49fa-accb-931146c246d4?feedback_type=great_response) | [Irrelevant](https://app.dosu.dev/response-feedback/0434b315-ccf0-49fa-accb-931146c246d4?feedback_type=irrelevant_answer) | [Incorrect](https://app.dosu.dev/response-feedback/0434b315-ccf0-49fa-accb-931146c246d4?feedback_type=incorrect_sources) | [Verbose](https://app.dosu.dev/response-feedback/0434b315-ccf0-49fa-accb-931146c246d4?feedback_type=too_verbose) | [Hallucination](https://app.dosu.dev/response-feedback/0434b315-ccf0-49fa-accb-931146c246d4?feedback_type=hallucination) | [Report 🐛](https://app.dosu.dev/response-feedback/0434b315-ccf0-49fa-accb-931146c246d4?feedback_type=bug_report) | [Other](https://app.dosu.dev/response-feedback/0434b315-ccf0-49fa-accb-931146c246d4?feedback_type=other)</sup> [![Open in Cursor](https://dosu.dev/dosu-in-cursor.svg)](https://cursor.com/link/prompt?text=Here%E2%80%99s%20a%20minimal%20Python%20example%20for%20adding%20LLM%20credentials%20to%20Dify%20using%20its%20REST%20API.%20You%20don%E2%80%99t%20need%20to%20encrypt%20credentials%20client-side%E2%80%94just%20send%20them%20in%20plaintext%3B%20Dify%20will%20handle%20encryption%20and%20validation%20server-side.%20Required%20credential%20fields%20depend%20on%20the%20provider/model%20schema%20%28e.g.%2C%20for%20OpenAI-compatible%20providers%2C%20usually%20%60api_key%60%2C%20%60endpoint_url%60%2C%20etc.%29.%20If%20any%20required%20fields%20are%20missing%20or%20invalid%2C%20the%20API%20will%20return%20a%20validation%20error.%0A%0A%60%60%60python%0Aimport%20requests%0A%0A%23%20Set%20your%20Dify%20instance%20base%20URL%20and%20your%20admin%20access%20token%0Abase_url%20%3D%20%22https%3A//your-dify-instance/api%22%0Aheaders%20%3D%20%7B%0A%20%20%20%20%22Authorization%22%3A%20%22Bearer%20YOUR_ACCESS_TOKEN%22%2C%0A%20%20%20%20%22Content-Type%22%3A%20%22application/json%22%0A%7D%0A%0A%23%20---%20Provider-level%20credentials%20---%0Aprovider%20%3D%20%22your-provider%22%20%20%23%20e.g.%2C%20%22openai_api_compatible%22%0Apayload_provider%20%3D%20%7B%0A%20%20%20%20%22credentials%22%3A%20%7B%0A%20%20%20%20%20%20%20%20%22api_key%22%3A%20%22your-api-key%22%2C%20%20%20%20%20%20%20%20%20%20%20%23%20Replace%20with%20your%20actual%20key%0A%20%20%20%20%20%20%20%20%22endpoint_url%22%3A%20%22https%3A//api.example.com/v1%22%20%20%23%20If%20required%20by%20your%20provider%0A%20%20%20%20%20%20%20%20%23%20Add%20other%20fields%20as%20required%20by%20your%20provider%27s%20schema%0A%20%20%20%20%7D%2C%0A%20%20%20%20%22name%22%3A%20%22my-credential%22%20%20%23%20Optional%2C%20max%2030%20chars%0A%7D%0Aresponse_provider%20%3D%20requests.post%28%0A%20%20%20%20f%22%7Bbase_url%7D/workspaces/current/model-providers/%7Bprovider%7D/credentials%22%2C%0A%20%20%20%20headers%3Dheaders%2C%0A%20%20%20%20json%3Dpayload_provider%0A%29%0Aprint%28%22Provider%20credential%20response%3A%22%2C%20response_provider.json%28%29%29%0A%0A%23%20---%20Model-specific%20credentials%20---%0Amodel_name%20%3D%20%22your-model%22%20%20%20%20%20%20%23%20e.g.%2C%20%22gpt-3.5-turbo%22%0Amodel_type%20%3D%20%22your-model-type%22%20%23%20e.g.%2C%20%22chat%22%0Apayload_model%20%3D%20%7B%0A%20%20%20%20%22model%22%3A%20model_name%2C%0A%20%20%20%20%22model_type%22%3A%20model_type%2C%0A%20%20%20%20%22credentials%22%3A%20%7B%0A%20%20%20%20%20%20%20%20%22api_key%22%3A%20%22your-model-api-key%22%2C%20%20%20%20%23%20Replace%20as%20needed%0A%20%20%20%20%20%20%20%20%23%20Add%20other%20fields%20as%20required%20by%20your%20model%27s%20schema%0A%20%20%20%20%7D%2C%0A%20%20%20%20%22name%22%3A%20%22model-credential%22%20%20%23%20Optional%2C%20max%2030%20chars%0A%7D%0Aresponse_model%20%3D%20requests.post%28%0A%20%20%20%20f%22%7Bbase_url%7D/workspaces/current/model-providers/%7Bprovider%7D/models/credentials%22%2C%0A%20%20%20%20headers%3Dheaders%2C%0A%20%20%20%20json%3Dpayload_model%0A%29%0Aprint%28%22Model%20credential%20response%3A%22%2C%20response_model.json%28%29%29%0A%60%60%60%0A%0AReplace%20all%20placeholders%20with%20your%20actual%20values.%20If%20you%E2%80%99re%20unsure%20which%20fields%20are%20required%2C%20check%20your%20provider%E2%80%99s%20plugin%20documentation%20or%20try%20adding%20credentials%20in%20the%20Dify%20UI%20to%20see%20the%20expected%20fields.%20If%20you%20send%20incomplete%20or%20invalid%20data%2C%20the%20API%20will%20return%20a%20descriptive%20error%20message.%20%20%0AEncryption%20and%20validation%20are%20handled%20server-side%E2%80%94no%20need%20to%20do%20anything%20special%20in%20your%20Python%20code.%20%20%0A%5BReference%3A%20Dify%20API%20controller%20and%20service%20code%5D%28https%3A//github.com/langgenius/dify/blob/acdbcdb6f82b2ed2d48d5dd20cbfd745375588a6/api/controllers/console/workspace/model_providers.py%23L36-L153%29)&nbsp;[![Join Discord](https://img.shields.io/badge/join-5865F2?logo=discord&logoColor=white&label=)](https://go.dosu.dev/discord-bot)&nbsp;[![Share on X](https://img.shields.io/badge/X-share-black)](https://twitter.com/intent/tweet?text=%40dosu_ai%20helped%20me%20solve%20this%20issue!&url=https%3A//github.com/langgenius/dify-official-plugins/issues/2230)
Author
Owner

@RobertWangWang commented on GitHub (Dec 10, 2025):

Here’s a minimal Python example for adding LLM credentials to Dify using its REST API. You don’t need to encrypt credentials client-side—just send them in plaintext; Dify will handle encryption and validation server-side. Required credential fields depend on the provider/model schema (e.g., for OpenAI-compatible providers, usually api_key, endpoint_url, etc.). If any required fields are missing or invalid, the API will return a validation error.

import requests

Set your Dify instance base URL and your admin access token

base_url = "https://your-dify-instance/api"
headers = {
"Authorization": "Bearer YOUR_ACCESS_TOKEN",
"Content-Type": "application/json"
}

--- Provider-level credentials ---

provider = "your-provider" # e.g., "openai_api_compatible"
payload_provider = {
"credentials": {
"api_key": "your-api-key", # Replace with your actual key
"endpoint_url": "https://api.example.com/v1" # If required by your provider
# Add other fields as required by your provider's schema
},
"name": "my-credential" # Optional, max 30 chars
}
response_provider = requests.post(
f"{base_url}/workspaces/current/model-providers/{provider}/credentials",
headers=headers,
json=payload_provider
)
print("Provider credential response:", response_provider.json())

--- Model-specific credentials ---

model_name = "your-model" # e.g., "gpt-3.5-turbo"
model_type = "your-model-type" # e.g., "chat"
payload_model = {
"model": model_name,
"model_type": model_type,
"credentials": {
"api_key": "your-model-api-key", # Replace as needed
# Add other fields as required by your model's schema
},
"name": "model-credential" # Optional, max 30 chars
}
response_model = requests.post(
f"{base_url}/workspaces/current/model-providers/{provider}/models/credentials",
headers=headers,
json=payload_model
)
print("Model credential response:", response_model.json())
Replace all placeholders with your actual values. If you’re unsure which fields are required, check your provider’s plugin documentation or try adding credentials in the Dify UI to see the expected fields. If you send incomplete or invalid data, the API will return a descriptive error message. Encryption and validation are handled server-side—no need to do anything special in your Python code. Reference: Dify API controller and service code

To reply, just mention @dosu.

How did I do? Good | Irrelevant | Incorrect | Verbose | Hallucination | Report 🐛 | Other

Open in Cursor Join Discord Share on X

where can I find the english name for the variable '{provider}' ? I tried using 'deepseek' but it gave me the 400 error:

Provider credential response: {'code': 'invalid_param', 'message': 'Provider deepseek/credentials does not exist.', 'status': 400}

@RobertWangWang commented on GitHub (Dec 10, 2025): > Here’s a minimal Python example for adding LLM credentials to Dify using its REST API. You don’t need to encrypt credentials client-side—just send them in plaintext; Dify will handle encryption and validation server-side. Required credential fields depend on the provider/model schema (e.g., for OpenAI-compatible providers, usually `api_key`, `endpoint_url`, etc.). If any required fields are missing or invalid, the API will return a validation error. > > import requests > > # Set your Dify instance base URL and your admin access token > base_url = "https://your-dify-instance/api" > headers = { > "Authorization": "Bearer YOUR_ACCESS_TOKEN", > "Content-Type": "application/json" > } > > # --- Provider-level credentials --- > provider = "your-provider" # e.g., "openai_api_compatible" > payload_provider = { > "credentials": { > "api_key": "your-api-key", # Replace with your actual key > "endpoint_url": "https://api.example.com/v1" # If required by your provider > # Add other fields as required by your provider's schema > }, > "name": "my-credential" # Optional, max 30 chars > } > response_provider = requests.post( > f"{base_url}/workspaces/current/model-providers/{provider}/credentials", > headers=headers, > json=payload_provider > ) > print("Provider credential response:", response_provider.json()) > > # --- Model-specific credentials --- > model_name = "your-model" # e.g., "gpt-3.5-turbo" > model_type = "your-model-type" # e.g., "chat" > payload_model = { > "model": model_name, > "model_type": model_type, > "credentials": { > "api_key": "your-model-api-key", # Replace as needed > # Add other fields as required by your model's schema > }, > "name": "model-credential" # Optional, max 30 chars > } > response_model = requests.post( > f"{base_url}/workspaces/current/model-providers/{provider}/models/credentials", > headers=headers, > json=payload_model > ) > print("Model credential response:", response_model.json()) > Replace all placeholders with your actual values. If you’re unsure which fields are required, check your provider’s plugin documentation or try adding credentials in the Dify UI to see the expected fields. If you send incomplete or invalid data, the API will return a descriptive error message. Encryption and validation are handled server-side—no need to do anything special in your Python code. [Reference: Dify API controller and service code](https://github.com/langgenius/dify/blob/acdbcdb6f82b2ed2d48d5dd20cbfd745375588a6/api/controllers/console/workspace/model_providers.py#L36-L153) > > _To reply, just mention [@dosu](https://go.dosu.dev/dosubot)._ > > How did I do? [Good](https://app.dosu.dev/response-feedback/0434b315-ccf0-49fa-accb-931146c246d4?feedback_type=great_response) | [Irrelevant](https://app.dosu.dev/response-feedback/0434b315-ccf0-49fa-accb-931146c246d4?feedback_type=irrelevant_answer) | [Incorrect](https://app.dosu.dev/response-feedback/0434b315-ccf0-49fa-accb-931146c246d4?feedback_type=incorrect_sources) | [Verbose](https://app.dosu.dev/response-feedback/0434b315-ccf0-49fa-accb-931146c246d4?feedback_type=too_verbose) | [Hallucination](https://app.dosu.dev/response-feedback/0434b315-ccf0-49fa-accb-931146c246d4?feedback_type=hallucination) | [Report 🐛](https://app.dosu.dev/response-feedback/0434b315-ccf0-49fa-accb-931146c246d4?feedback_type=bug_report) | [Other](https://app.dosu.dev/response-feedback/0434b315-ccf0-49fa-accb-931146c246d4?feedback_type=other) > > [![Open in Cursor](https://camo.githubusercontent.com/bdf7dbded65ee585887f47e5fd6fa099ea0933088b4b03d02e83b4def50154d4/68747470733a2f2f646f73752e6465762f646f73752d696e2d637572736f722e737667)](https://cursor.com/link/prompt?text=Here%E2%80%99s%20a%20minimal%20Python%20example%20for%20adding%20LLM%20credentials%20to%20Dify%20using%20its%20REST%20API.%20You%20don%E2%80%99t%20need%20to%20encrypt%20credentials%20client-side%E2%80%94just%20send%20them%20in%20plaintext%3B%20Dify%20will%20handle%20encryption%20and%20validation%20server-side.%20Required%20credential%20fields%20depend%20on%20the%20provider/model%20schema%20%28e.g.%2C%20for%20OpenAI-compatible%20providers%2C%20usually%20%60api_key%60%2C%20%60endpoint_url%60%2C%20etc.%29.%20If%20any%20required%20fields%20are%20missing%20or%20invalid%2C%20the%20API%20will%20return%20a%20validation%20error.%0A%0A%60%60%60python%0Aimport%20requests%0A%0A%23%20Set%20your%20Dify%20instance%20base%20URL%20and%20your%20admin%20access%20token%0Abase_url%20%3D%20%22https%3A//your-dify-instance/api%22%0Aheaders%20%3D%20%7B%0A%20%20%20%20%22Authorization%22%3A%20%22Bearer%20YOUR_ACCESS_TOKEN%22%2C%0A%20%20%20%20%22Content-Type%22%3A%20%22application/json%22%0A%7D%0A%0A%23%20---%20Provider-level%20credentials%20---%0Aprovider%20%3D%20%22your-provider%22%20%20%23%20e.g.%2C%20%22openai_api_compatible%22%0Apayload_provider%20%3D%20%7B%0A%20%20%20%20%22credentials%22%3A%20%7B%0A%20%20%20%20%20%20%20%20%22api_key%22%3A%20%22your-api-key%22%2C%20%20%20%20%20%20%20%20%20%20%20%23%20Replace%20with%20your%20actual%20key%0A%20%20%20%20%20%20%20%20%22endpoint_url%22%3A%20%22https%3A//api.example.com/v1%22%20%20%23%20If%20required%20by%20your%20provider%0A%20%20%20%20%20%20%20%20%23%20Add%20other%20fields%20as%20required%20by%20your%20provider%27s%20schema%0A%20%20%20%20%7D%2C%0A%20%20%20%20%22name%22%3A%20%22my-credential%22%20%20%23%20Optional%2C%20max%2030%20chars%0A%7D%0Aresponse_provider%20%3D%20requests.post%28%0A%20%20%20%20f%22%7Bbase_url%7D/workspaces/current/model-providers/%7Bprovider%7D/credentials%22%2C%0A%20%20%20%20headers%3Dheaders%2C%0A%20%20%20%20json%3Dpayload_provider%0A%29%0Aprint%28%22Provider%20credential%20response%3A%22%2C%20response_provider.json%28%29%29%0A%0A%23%20---%20Model-specific%20credentials%20---%0Amodel_name%20%3D%20%22your-model%22%20%20%20%20%20%20%23%20e.g.%2C%20%22gpt-3.5-turbo%22%0Amodel_type%20%3D%20%22your-model-type%22%20%23%20e.g.%2C%20%22chat%22%0Apayload_model%20%3D%20%7B%0A%20%20%20%20%22model%22%3A%20model_name%2C%0A%20%20%20%20%22model_type%22%3A%20model_type%2C%0A%20%20%20%20%22credentials%22%3A%20%7B%0A%20%20%20%20%20%20%20%20%22api_key%22%3A%20%22your-model-api-key%22%2C%20%20%20%20%23%20Replace%20as%20needed%0A%20%20%20%20%20%20%20%20%23%20Add%20other%20fields%20as%20required%20by%20your%20model%27s%20schema%0A%20%20%20%20%7D%2C%0A%20%20%20%20%22name%22%3A%20%22model-credential%22%20%20%23%20Optional%2C%20max%2030%20chars%0A%7D%0Aresponse_model%20%3D%20requests.post%28%0A%20%20%20%20f%22%7Bbase_url%7D/workspaces/current/model-providers/%7Bprovider%7D/models/credentials%22%2C%0A%20%20%20%20headers%3Dheaders%2C%0A%20%20%20%20json%3Dpayload_model%0A%29%0Aprint%28%22Model%20credential%20response%3A%22%2C%20response_model.json%28%29%29%0A%60%60%60%0A%0AReplace%20all%20placeholders%20with%20your%20actual%20values.%20If%20you%E2%80%99re%20unsure%20which%20fields%20are%20required%2C%20check%20your%20provider%E2%80%99s%20plugin%20documentation%20or%20try%20adding%20credentials%20in%20the%20Dify%20UI%20to%20see%20the%20expected%20fields.%20If%20you%20send%20incomplete%20or%20invalid%20data%2C%20the%20API%20will%20return%20a%20descriptive%20error%20message.%20%20%0AEncryption%20and%20validation%20are%20handled%20server-side%E2%80%94no%20need%20to%20do%20anything%20special%20in%20your%20Python%20code.%20%20%0A%5BReference%3A%20Dify%20API%20controller%20and%20service%20code%5D%28https%3A//github.com/langgenius/dify/blob/acdbcdb6f82b2ed2d48d5dd20cbfd745375588a6/api/controllers/console/workspace/model_providers.py%23L36-L153%29) [![Join Discord](https://camo.githubusercontent.com/7d2066700925db1e370d956834f9ea0e5bc92cecbe84963fbd2a363e45091b4e/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f6a6f696e2d3538363546323f6c6f676f3d646973636f7264266c6f676f436f6c6f723d7768697465266c6162656c3d)](https://go.dosu.dev/discord-bot) [![Share on X](https://camo.githubusercontent.com/a8bd7f3fcf3f5e3bd124eee9ae50ae2ac17b40971726665ac2121d48f9aee155/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f582d73686172652d626c61636b)](https://twitter.com/intent/tweet?text=%40dosu_ai%20helped%20me%20solve%20this%20issue!&url=https%3A//github.com/langgenius/dify-official-plugins/issues/2230) where can I find the english name for the variable '{provider}' ? I tried using 'deepseek' but it gave me the 400 error: Provider credential response: {'code': 'invalid_param', 'message': 'Provider deepseek/credentials does not exist.', 'status': 400}
Author
Owner

@dosubot[bot] commented on GitHub (Dec 10, 2025):

To find the correct value for the {provider} variable in Dify's API, use the internal provider ID—not the human-readable name. The provider ID is defined by the plugin or integration and must match exactly what Dify has registered.

Here’s how to find it:

  1. Check the Dify UI: Go to System Settings → Model Providers. The provider ID is listed for each provider in the management interface. Use that exact value in your API calls.
  2. API Endpoint: You can call /workspaces/current/model-providers and look for the provider field in the response. Use that string as {provider} in your requests.
  3. Provider ID Format: For built-in providers, it’s usually a simple string like openai, anthropic, or deepseek. For plugin-based providers, it may be a compound string like openai_api_compatible/openai or langgenius/deepseek/deepseek depending on how the plugin registers it. Dify will internally expand a single word (e.g., deepseek) to langgenius/deepseek/deepseek if needed, but only if the provider is installed and registered in your workspace. If the provider is not registered, you’ll get a 400 error like you saw source.

Troubleshooting:
If you get a "provider does not exist" error, double-check that the provider is installed, initialized, and visible in your Dify UI. For DeepSeek, the correct provider ID may be deepseek, deepseek-chat, or deepseek-coder depending on your plugin version and registration source. Always use the exact string shown in your Dify UI or returned by the provider list API.

If you need to inspect the canonical list of built-in provider IDs, you can find them in the Dify codebase at _position.yaml.

Let me know if you need help with a specific provider or want to check your provider list via API!

To reply, just mention @dosu.


How did I do? Good | Irrelevant | Incorrect | Verbose | Hallucination | Report 🐛 | Other

Open in Cursor Join Discord Share on X

@dosubot[bot] commented on GitHub (Dec 10, 2025): <!-- Answer --> To find the correct value for the `{provider}` variable in Dify's API, use the internal provider ID—not the human-readable name. The provider ID is defined by the plugin or integration and must match exactly what Dify has registered. Here’s how to find it: 1. **Check the Dify UI:** Go to System Settings → Model Providers. The provider ID is listed for each provider in the management interface. Use that exact value in your API calls. 2. **API Endpoint:** You can call `/workspaces/current/model-providers` and look for the `provider` field in the response. Use that string as `{provider}` in your requests. 3. **Provider ID Format:** For built-in providers, it’s usually a simple string like `openai`, `anthropic`, or `deepseek`. For plugin-based providers, it may be a compound string like `openai_api_compatible/openai` or `langgenius/deepseek/deepseek` depending on how the plugin registers it. Dify will internally expand a single word (e.g., `deepseek`) to `langgenius/deepseek/deepseek` if needed, but only if the provider is installed and registered in your workspace. If the provider is not registered, you’ll get a 400 error like you saw [source](https://github.com/langgenius/dify/blob/acdbcdb6f82b2ed2d48d5dd20cbfd745375588a6/api/core/model_runtime/model_providers/_position.yaml#L1-L44). **Troubleshooting:** If you get a "provider does not exist" error, double-check that the provider is installed, initialized, and visible in your Dify UI. For DeepSeek, the correct provider ID may be `deepseek`, `deepseek-chat`, or `deepseek-coder` depending on your plugin version and registration [source](https://github.com/langgenius/dify/issues/23361). Always use the exact string shown in your Dify UI or returned by the provider list API. If you need to inspect the canonical list of built-in provider IDs, you can find them in the Dify codebase at [`_position.yaml`](https://github.com/langgenius/dify/blob/acdbcdb6f82b2ed2d48d5dd20cbfd745375588a6/api/core/model_runtime/model_providers/_position.yaml#L1-L44). Let me know if you need help with a specific provider or want to check your provider list via API! <!-- Dosu Comment Footer --> *To reply, just mention [@dosu](https://go.dosu.dev/dosubot).* --- <sup>How did I do? [Good](https://app.dosu.dev/response-feedback/c76b81b6-7f41-4208-bf4d-5d0de75f3098?feedback_type=great_response) | [Irrelevant](https://app.dosu.dev/response-feedback/c76b81b6-7f41-4208-bf4d-5d0de75f3098?feedback_type=irrelevant_answer) | [Incorrect](https://app.dosu.dev/response-feedback/c76b81b6-7f41-4208-bf4d-5d0de75f3098?feedback_type=incorrect_sources) | [Verbose](https://app.dosu.dev/response-feedback/c76b81b6-7f41-4208-bf4d-5d0de75f3098?feedback_type=too_verbose) | [Hallucination](https://app.dosu.dev/response-feedback/c76b81b6-7f41-4208-bf4d-5d0de75f3098?feedback_type=hallucination) | [Report 🐛](https://app.dosu.dev/response-feedback/c76b81b6-7f41-4208-bf4d-5d0de75f3098?feedback_type=bug_report) | [Other](https://app.dosu.dev/response-feedback/c76b81b6-7f41-4208-bf4d-5d0de75f3098?feedback_type=other)</sup> [![Open in Cursor](https://dosu.dev/dosu-in-cursor.svg)](https://cursor.com/link/prompt?text=To%20find%20the%20correct%20value%20for%20the%20%60%7Bprovider%7D%60%20variable%20in%20Dify%27s%20API%2C%20use%20the%20internal%20provider%20ID%E2%80%94not%20the%20human-readable%20name.%20The%20provider%20ID%20is%20defined%20by%20the%20plugin%20or%20integration%20and%20must%20match%20exactly%20what%20Dify%20has%20registered.%0A%0AHere%E2%80%99s%20how%20to%20find%20it%3A%0A%0A1.%20%2A%2ACheck%20the%20Dify%20UI%3A%2A%2A%20Go%20to%20System%20Settings%20%E2%86%92%20Model%20Providers.%20The%20provider%20ID%20is%20listed%20for%20each%20provider%20in%20the%20management%20interface.%20Use%20that%20exact%20value%20in%20your%20API%20calls.%0A2.%20%2A%2AAPI%20Endpoint%3A%2A%2A%20You%20can%20call%20%60/workspaces/current/model-providers%60%20and%20look%20for%20the%20%60provider%60%20field%20in%20the%20response.%20Use%20that%20string%20as%20%60%7Bprovider%7D%60%20in%20your%20requests.%0A3.%20%2A%2AProvider%20ID%20Format%3A%2A%2A%20For%20built-in%20providers%2C%20it%E2%80%99s%20usually%20a%20simple%20string%20like%20%60openai%60%2C%20%60anthropic%60%2C%20or%20%60deepseek%60.%20For%20plugin-based%20providers%2C%20it%20may%20be%20a%20compound%20string%20like%20%60openai_api_compatible/openai%60%20or%20%60langgenius/deepseek/deepseek%60%20depending%20on%20how%20the%20plugin%20registers%20it.%20Dify%20will%20internally%20expand%20a%20single%20word%20%28e.g.%2C%20%60deepseek%60%29%20to%20%60langgenius/deepseek/deepseek%60%20if%20needed%2C%20but%20only%20if%20the%20provider%20is%20installed%20and%20registered%20in%20your%20workspace.%20If%20the%20provider%20is%20not%20registered%2C%20you%E2%80%99ll%20get%20a%20400%20error%20like%20you%20saw%20%5Bsource%5D%28https%3A//github.com/langgenius/dify/blob/acdbcdb6f82b2ed2d48d5dd20cbfd745375588a6/api/core/model_runtime/model_providers/_position.yaml%23L1-L44%29.%0A%0A%2A%2ATroubleshooting%3A%2A%2A%20%20%0AIf%20you%20get%20a%20%22provider%20does%20not%20exist%22%20error%2C%20double-check%20that%20the%20provider%20is%20installed%2C%20initialized%2C%20and%20visible%20in%20your%20Dify%20UI.%20For%20DeepSeek%2C%20the%20correct%20provider%20ID%20may%20be%20%60deepseek%60%2C%20%60deepseek-chat%60%2C%20or%20%60deepseek-coder%60%20depending%20on%20your%20plugin%20version%20and%20registration%20%5Bsource%5D%28https%3A//github.com/langgenius/dify/issues/23361%29.%20Always%20use%20the%20exact%20string%20shown%20in%20your%20Dify%20UI%20or%20returned%20by%20the%20provider%20list%20API.%0A%0AIf%20you%20need%20to%20inspect%20the%20canonical%20list%20of%20built-in%20provider%20IDs%2C%20you%20can%20find%20them%20in%20the%20Dify%20codebase%20at%20%5B%60_position.yaml%60%5D%28https%3A//github.com/langgenius/dify/blob/acdbcdb6f82b2ed2d48d5dd20cbfd745375588a6/api/core/model_runtime/model_providers/_position.yaml%23L1-L44%29.%0A%0ALet%20me%20know%20if%20you%20need%20help%20with%20a%20specific%20provider%20or%20want%20to%20check%20your%20provider%20list%20via%20API%21)&nbsp;[![Join Discord](https://img.shields.io/badge/join-5865F2?logo=discord&logoColor=white&label=)](https://go.dosu.dev/discord-bot)&nbsp;[![Share on X](https://img.shields.io/badge/X-share-black)](https://twitter.com/intent/tweet?text=%40dosu_ai%20helped%20me%20solve%20this%20issue!&url=https%3A//github.com/langgenius/dify-official-plugins/issues/2230)
Author
Owner

@RobertWangWang commented on GitHub (Dec 10, 2025):

To find the correct value for the {provider} variable in Dify's API, use the internal provider ID—not the human-readable name. The provider ID is defined by the plugin or integration and must match exactly what Dify has registered.

Here’s how to find it:

  1. Check the Dify UI: Go to System Settings → Model Providers. The provider ID is listed for each provider in the management interface. Use that exact value in your API calls.
  2. API Endpoint: You can call /workspaces/current/model-providers and look for the provider field in the response. Use that string as {provider} in your requests.
  3. Provider ID Format: For built-in providers, it’s usually a simple string like openai, anthropic, or deepseek. For plugin-based providers, it may be a compound string like openai_api_compatible/openai or langgenius/deepseek/deepseek depending on how the plugin registers it. Dify will internally expand a single word (e.g., deepseek) to langgenius/deepseek/deepseek if needed, but only if the provider is installed and registered in your workspace. If the provider is not registered, you’ll get a 400 error like you saw source.

Troubleshooting: If you get a "provider does not exist" error, double-check that the provider is installed, initialized, and visible in your Dify UI. For DeepSeek, the correct provider ID may be deepseek, deepseek-chat, or deepseek-coder depending on your plugin version and registration source. Always use the exact string shown in your Dify UI or returned by the provider list API.

If you need to inspect the canonical list of built-in provider IDs, you can find them in the Dify codebase at _position.yaml.

Let me know if you need help with a specific provider or want to check your provider list via API!

To reply, just mention @dosu.

How did I do? Good | Irrelevant | Incorrect | Verbose | Hallucination | Report 🐛 | Other

Open in Cursor Join Discord Share on X

Another question:

how does dify load the plugins after the plugin is installed?

@RobertWangWang commented on GitHub (Dec 10, 2025): > To find the correct value for the `{provider}` variable in Dify's API, use the internal provider ID—not the human-readable name. The provider ID is defined by the plugin or integration and must match exactly what Dify has registered. > > Here’s how to find it: > > 1. **Check the Dify UI:** Go to System Settings → Model Providers. The provider ID is listed for each provider in the management interface. Use that exact value in your API calls. > 2. **API Endpoint:** You can call `/workspaces/current/model-providers` and look for the `provider` field in the response. Use that string as `{provider}` in your requests. > 3. **Provider ID Format:** For built-in providers, it’s usually a simple string like `openai`, `anthropic`, or `deepseek`. For plugin-based providers, it may be a compound string like `openai_api_compatible/openai` or `langgenius/deepseek/deepseek` depending on how the plugin registers it. Dify will internally expand a single word (e.g., `deepseek`) to `langgenius/deepseek/deepseek` if needed, but only if the provider is installed and registered in your workspace. If the provider is not registered, you’ll get a 400 error like you saw [source](https://github.com/langgenius/dify/blob/acdbcdb6f82b2ed2d48d5dd20cbfd745375588a6/api/core/model_runtime/model_providers/_position.yaml#L1-L44). > > **Troubleshooting:** If you get a "provider does not exist" error, double-check that the provider is installed, initialized, and visible in your Dify UI. For DeepSeek, the correct provider ID may be `deepseek`, `deepseek-chat`, or `deepseek-coder` depending on your plugin version and registration [source](https://github.com/langgenius/dify/issues/23361). Always use the exact string shown in your Dify UI or returned by the provider list API. > > If you need to inspect the canonical list of built-in provider IDs, you can find them in the Dify codebase at [`_position.yaml`](https://github.com/langgenius/dify/blob/acdbcdb6f82b2ed2d48d5dd20cbfd745375588a6/api/core/model_runtime/model_providers/_position.yaml#L1-L44). > > Let me know if you need help with a specific provider or want to check your provider list via API! > > _To reply, just mention [@dosu](https://go.dosu.dev/dosubot)._ > > How did I do? [Good](https://app.dosu.dev/response-feedback/c76b81b6-7f41-4208-bf4d-5d0de75f3098?feedback_type=great_response) | [Irrelevant](https://app.dosu.dev/response-feedback/c76b81b6-7f41-4208-bf4d-5d0de75f3098?feedback_type=irrelevant_answer) | [Incorrect](https://app.dosu.dev/response-feedback/c76b81b6-7f41-4208-bf4d-5d0de75f3098?feedback_type=incorrect_sources) | [Verbose](https://app.dosu.dev/response-feedback/c76b81b6-7f41-4208-bf4d-5d0de75f3098?feedback_type=too_verbose) | [Hallucination](https://app.dosu.dev/response-feedback/c76b81b6-7f41-4208-bf4d-5d0de75f3098?feedback_type=hallucination) | [Report 🐛](https://app.dosu.dev/response-feedback/c76b81b6-7f41-4208-bf4d-5d0de75f3098?feedback_type=bug_report) | [Other](https://app.dosu.dev/response-feedback/c76b81b6-7f41-4208-bf4d-5d0de75f3098?feedback_type=other) > > [![Open in Cursor](https://camo.githubusercontent.com/bdf7dbded65ee585887f47e5fd6fa099ea0933088b4b03d02e83b4def50154d4/68747470733a2f2f646f73752e6465762f646f73752d696e2d637572736f722e737667)](https://cursor.com/link/prompt?text=To%20find%20the%20correct%20value%20for%20the%20%60%7Bprovider%7D%60%20variable%20in%20Dify%27s%20API%2C%20use%20the%20internal%20provider%20ID%E2%80%94not%20the%20human-readable%20name.%20The%20provider%20ID%20is%20defined%20by%20the%20plugin%20or%20integration%20and%20must%20match%20exactly%20what%20Dify%20has%20registered.%0A%0AHere%E2%80%99s%20how%20to%20find%20it%3A%0A%0A1.%20%2A%2ACheck%20the%20Dify%20UI%3A%2A%2A%20Go%20to%20System%20Settings%20%E2%86%92%20Model%20Providers.%20The%20provider%20ID%20is%20listed%20for%20each%20provider%20in%20the%20management%20interface.%20Use%20that%20exact%20value%20in%20your%20API%20calls.%0A2.%20%2A%2AAPI%20Endpoint%3A%2A%2A%20You%20can%20call%20%60/workspaces/current/model-providers%60%20and%20look%20for%20the%20%60provider%60%20field%20in%20the%20response.%20Use%20that%20string%20as%20%60%7Bprovider%7D%60%20in%20your%20requests.%0A3.%20%2A%2AProvider%20ID%20Format%3A%2A%2A%20For%20built-in%20providers%2C%20it%E2%80%99s%20usually%20a%20simple%20string%20like%20%60openai%60%2C%20%60anthropic%60%2C%20or%20%60deepseek%60.%20For%20plugin-based%20providers%2C%20it%20may%20be%20a%20compound%20string%20like%20%60openai_api_compatible/openai%60%20or%20%60langgenius/deepseek/deepseek%60%20depending%20on%20how%20the%20plugin%20registers%20it.%20Dify%20will%20internally%20expand%20a%20single%20word%20%28e.g.%2C%20%60deepseek%60%29%20to%20%60langgenius/deepseek/deepseek%60%20if%20needed%2C%20but%20only%20if%20the%20provider%20is%20installed%20and%20registered%20in%20your%20workspace.%20If%20the%20provider%20is%20not%20registered%2C%20you%E2%80%99ll%20get%20a%20400%20error%20like%20you%20saw%20%5Bsource%5D%28https%3A//github.com/langgenius/dify/blob/acdbcdb6f82b2ed2d48d5dd20cbfd745375588a6/api/core/model_runtime/model_providers/_position.yaml%23L1-L44%29.%0A%0A%2A%2ATroubleshooting%3A%2A%2A%20%20%0AIf%20you%20get%20a%20%22provider%20does%20not%20exist%22%20error%2C%20double-check%20that%20the%20provider%20is%20installed%2C%20initialized%2C%20and%20visible%20in%20your%20Dify%20UI.%20For%20DeepSeek%2C%20the%20correct%20provider%20ID%20may%20be%20%60deepseek%60%2C%20%60deepseek-chat%60%2C%20or%20%60deepseek-coder%60%20depending%20on%20your%20plugin%20version%20and%20registration%20%5Bsource%5D%28https%3A//github.com/langgenius/dify/issues/23361%29.%20Always%20use%20the%20exact%20string%20shown%20in%20your%20Dify%20UI%20or%20returned%20by%20the%20provider%20list%20API.%0A%0AIf%20you%20need%20to%20inspect%20the%20canonical%20list%20of%20built-in%20provider%20IDs%2C%20you%20can%20find%20them%20in%20the%20Dify%20codebase%20at%20%5B%60_position.yaml%60%5D%28https%3A//github.com/langgenius/dify/blob/acdbcdb6f82b2ed2d48d5dd20cbfd745375588a6/api/core/model_runtime/model_providers/_position.yaml%23L1-L44%29.%0A%0ALet%20me%20know%20if%20you%20need%20help%20with%20a%20specific%20provider%20or%20want%20to%20check%20your%20provider%20list%20via%20API%21) [![Join Discord](https://camo.githubusercontent.com/7d2066700925db1e370d956834f9ea0e5bc92cecbe84963fbd2a363e45091b4e/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f6a6f696e2d3538363546323f6c6f676f3d646973636f7264266c6f676f436f6c6f723d7768697465266c6162656c3d)](https://go.dosu.dev/discord-bot) [![Share on X](https://camo.githubusercontent.com/a8bd7f3fcf3f5e3bd124eee9ae50ae2ac17b40971726665ac2121d48f9aee155/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f582d73686172652d626c61636b)](https://twitter.com/intent/tweet?text=%40dosu_ai%20helped%20me%20solve%20this%20issue!&url=https%3A//github.com/langgenius/dify-official-plugins/issues/2230) Another question: how does dify load the plugins after the plugin is installed?
Author
Owner

@dosubot[bot] commented on GitHub (Dec 10, 2025):

Dify loads plugins by scanning specific directories for extension modules at application startup. When you install a plugin (for example, using the CLI or uploading a .difypkg file), the plugin files are placed in the appropriate directory. On the next app start or reload, Dify's extension system scans these directories, dynamically imports the plugin modules, and registers any new providers or tools it finds. No hot-reload is needed—just ensure the plugin files are present and restart the app if necessary for them to be picked up. The core scanning and loading logic is implemented in the scan_extensions method of the Extensible base class (see code).

If you upload a plugin via the web UI or CLI, the plugin daemon processes the package, installs dependencies, and moves the plugin into the active directory. This activation step requires Python and, often, internet access for dependency installation. If the daemon can't activate the plugin (for example, due to missing Python or dependencies), the plugin won't appear in the UI or API, even if the upload succeeds (details).

If a plugin doesn't show up after installation, check the plugin daemon logs for errors, verify that all dependencies are installed, and restart the Dify app to trigger a rescan. In offline or restricted environments, you may need to pre-bundle dependencies or set up a local PyPI mirror for the plugin daemon.

In summary: install the plugin, ensure dependencies are met, and restart the app to load new plugins. No manual registration is needed beyond this process.

To reply, just mention @dosu.


How did I do? Good | Irrelevant | Incorrect | Verbose | Hallucination | Report 🐛 | Other

Open in Cursor Join Discord Share on X

@dosubot[bot] commented on GitHub (Dec 10, 2025): <!-- Answer --> Dify loads plugins by scanning specific directories for extension modules at application startup. When you install a plugin (for example, using the CLI or uploading a `.difypkg` file), the plugin files are placed in the appropriate directory. On the next app start or reload, Dify's extension system scans these directories, dynamically imports the plugin modules, and registers any new providers or tools it finds. No hot-reload is needed—just ensure the plugin files are present and restart the app if necessary for them to be picked up. The core scanning and loading logic is implemented in the `scan_extensions` method of the `Extensible` base class ([see code](https://github.com/langgenius/dify/blob/91f6d25daebb3e8889fdc544fc232bf320694745/api/core/extension/extensible.py#L42-L135)). If you upload a plugin via the web UI or CLI, the plugin daemon processes the package, installs dependencies, and moves the plugin into the active directory. This activation step requires Python and, often, internet access for dependency installation. If the daemon can't activate the plugin (for example, due to missing Python or dependencies), the plugin won't appear in the UI or API, even if the upload succeeds ([details](https://github.com/langgenius/dify/issues/25950#issuecomment-3310351928)). If a plugin doesn't show up after installation, check the plugin daemon logs for errors, verify that all dependencies are installed, and restart the Dify app to trigger a rescan. In offline or restricted environments, you may need to pre-bundle dependencies or set up a local PyPI mirror for the plugin daemon. In summary: install the plugin, ensure dependencies are met, and restart the app to load new plugins. No manual registration is needed beyond this process. <!-- Dosu Comment Footer --> *To reply, just mention [@dosu](https://go.dosu.dev/dosubot).* --- <sup>How did I do? [Good](https://app.dosu.dev/response-feedback/816c5780-6307-41d3-be40-79cd957caa24?feedback_type=great_response) | [Irrelevant](https://app.dosu.dev/response-feedback/816c5780-6307-41d3-be40-79cd957caa24?feedback_type=irrelevant_answer) | [Incorrect](https://app.dosu.dev/response-feedback/816c5780-6307-41d3-be40-79cd957caa24?feedback_type=incorrect_sources) | [Verbose](https://app.dosu.dev/response-feedback/816c5780-6307-41d3-be40-79cd957caa24?feedback_type=too_verbose) | [Hallucination](https://app.dosu.dev/response-feedback/816c5780-6307-41d3-be40-79cd957caa24?feedback_type=hallucination) | [Report 🐛](https://app.dosu.dev/response-feedback/816c5780-6307-41d3-be40-79cd957caa24?feedback_type=bug_report) | [Other](https://app.dosu.dev/response-feedback/816c5780-6307-41d3-be40-79cd957caa24?feedback_type=other)</sup> [![Open in Cursor](https://dosu.dev/dosu-in-cursor.svg)](https://cursor.com/link/prompt?text=Dify%20loads%20plugins%20by%20scanning%20specific%20directories%20for%20extension%20modules%20at%20application%20startup.%20When%20you%20install%20a%20plugin%20%28for%20example%2C%20using%20the%20CLI%20or%20uploading%20a%20%60.difypkg%60%20file%29%2C%20the%20plugin%20files%20are%20placed%20in%20the%20appropriate%20directory.%20On%20the%20next%20app%20start%20or%20reload%2C%20Dify%27s%20extension%20system%20scans%20these%20directories%2C%20dynamically%20imports%20the%20plugin%20modules%2C%20and%20registers%20any%20new%20providers%20or%20tools%20it%20finds.%20No%20hot-reload%20is%20needed%E2%80%94just%20ensure%20the%20plugin%20files%20are%20present%20and%20restart%20the%20app%20if%20necessary%20for%20them%20to%20be%20picked%20up.%20The%20core%20scanning%20and%20loading%20logic%20is%20implemented%20in%20the%20%60scan_extensions%60%20method%20of%20the%20%60Extensible%60%20base%20class%20%28%5Bsee%20code%5D%28https%3A//github.com/langgenius/dify/blob/91f6d25daebb3e8889fdc544fc232bf320694745/api/core/extension/extensible.py%23L42-L135%29%29.%0A%0AIf%20you%20upload%20a%20plugin%20via%20the%20web%20UI%20or%20CLI%2C%20the%20plugin%20daemon%20processes%20the%20package%2C%20installs%20dependencies%2C%20and%20moves%20the%20plugin%20into%20the%20active%20directory.%20This%20activation%20step%20requires%20Python%20and%2C%20often%2C%20internet%20access%20for%20dependency%20installation.%20If%20the%20daemon%20can%27t%20activate%20the%20plugin%20%28for%20example%2C%20due%20to%20missing%20Python%20or%20dependencies%29%2C%20the%20plugin%20won%27t%20appear%20in%20the%20UI%20or%20API%2C%20even%20if%20the%20upload%20succeeds%20%28%5Bdetails%5D%28https%3A//github.com/langgenius/dify/issues/25950%23issuecomment-3310351928%29%29.%0A%0AIf%20a%20plugin%20doesn%27t%20show%20up%20after%20installation%2C%20check%20the%20plugin%20daemon%20logs%20for%20errors%2C%20verify%20that%20all%20dependencies%20are%20installed%2C%20and%20restart%20the%20Dify%20app%20to%20trigger%20a%20rescan.%20In%20offline%20or%20restricted%20environments%2C%20you%20may%20need%20to%20pre-bundle%20dependencies%20or%20set%20up%20a%20local%20PyPI%20mirror%20for%20the%20plugin%20daemon.%20%0A%0AIn%20summary%3A%20install%20the%20plugin%2C%20ensure%20dependencies%20are%20met%2C%20and%20restart%20the%20app%20to%20load%20new%20plugins.%20No%20manual%20registration%20is%20needed%20beyond%20this%20process.)&nbsp;[![Join Discord](https://img.shields.io/badge/join-5865F2?logo=discord&logoColor=white&label=)](https://go.dosu.dev/discord-bot)&nbsp;[![Share on X](https://img.shields.io/badge/X-share-black)](https://twitter.com/intent/tweet?text=%40dosu_ai%20helped%20me%20solve%20this%20issue!&url=https%3A//github.com/langgenius/dify-official-plugins/issues/2230)
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: langgenius/dify-official-plugins#863