From ca8bdd128e445decbe1bc5dd9e9b9ca6af3825d3 Mon Sep 17 00:00:00 2001 From: Riskey Date: Sat, 22 Nov 2025 00:23:33 +0800 Subject: [PATCH] add manage model credential and configure load balancing --- .../pages/workspace/model-providers.mdx | 109 +++++++++++++++++ .../pages/workspace/model-providers.mdx | 112 +++++++++++++++++- .../pages/workspace/model-providers.mdx | 111 +++++++++++++++++ 3 files changed, 331 insertions(+), 1 deletion(-) diff --git a/cn/documentation/pages/workspace/model-providers.mdx b/cn/documentation/pages/workspace/model-providers.mdx index 09fb8cd8..d3c91f21 100644 --- a/cn/documentation/pages/workspace/model-providers.mdx +++ b/cn/documentation/pages/workspace/model-providers.mdx @@ -84,6 +84,115 @@ icon: "brain-arrow-curved-right" +## 管理模型凭据 + +为模型供应商的预定义模型和自定义模型添加多个凭据,并轻松进行切换、删除、修改等操作。 + +在以下场景中,推荐添加多个模型凭据: + +- **环境隔离**:为开发、测试、生产等不同环境配置独立的模型凭据。例如,在开发环境中选择有速率限制的凭据用于功能调试,在生产环境中选择性能稳定、配额充足的付费凭据以保障服务质量。 + +- **成本优化**:通过添加和切换来自不同账户或模型供应商的多个凭据,最大限度地利用免费或低成本额度,降低应用开发与运营成本。 + +- **模型实验**:在模型微调或迭代过程中,可能会产出多个模型版本。通过添加不同模型版本的凭据,快速切换并测试其应用效果。 + + +可使用多个凭据为模型配置负载均衡。 + + + + + + 安装模型供应商并配置首个凭据后,点击供应商面板右上角的 **配置**,可进行以下操作: + + - 添加新凭据 + - 选择任一凭据作为所有预定义模型的默认凭据 + - 修改凭据 + - 删除凭据 + + + 若默认凭据被删除,需手动指定新的默认凭据。 + + + ![Manage credentials for predefined models](/images/predefined_model_credential.png) + + + + + ### 管理单个自定义模型的凭据 + + 安装模型供应商并添加自定义模型后,按照以下步骤操作: + + 1. 在模型列表中,点击模型对应的 **配置**。 + + 2. 在 **指定模型凭据** 面板中,点击默认凭据以打开凭据列表,可进行以下操作: + + - 添加新凭据 + - 选择任一凭据作为该自定义模型的默认凭据 + - 修改凭据 + - 删除凭据 + + + 若删除某个自定义模型的唯一凭据,该模型将被一同删除。 + + + ![Manage credentials for a single custom model](/images/custom_model_credential.png) + + + 添加自定义模型时,若填写的模型名称与模型类型与一个已存在的自定义模型完全相同,系统将不会创建重复的模型,而是会为已存在的模型添加一个新的凭据。 + + + ### 管理所有自定义模型的凭据 + + 点击 **管理凭据**,查看、修改或删除所有自定义模型的凭据。 + + ![Manage credentials for all custom models](/images/custom_model_credential_list.png) + + 对于被移除的自定义模型,其所有凭据仍将保留在 **管理凭据** 列表中。当你点击 **添加模型** 时,系统将展示所有已移除但凭据尚存的自定义模型,供你快速重新添加。 + + ![Removed models displayed for quick re-add](/images/removed_custom_model_re-add.png) + + 若从 **管理凭据** 列表中删除某个已移除的自定义模型的所有凭据,该模型将不会在点击 **添加模型** 时出现。 + + + + +## 配置模型负载均衡 + + +负载均衡为付费特性,可通过[订阅 SaaS 付费服务或者购买企业版](https://dify.ai/zh/pricing)以启用。 + + +通常,模型供应商会限制用户在指定时间内访问 API 服务的次数(模型速率限制),以确保服务的稳定性与合理使用。对于企业级应用,来自单一凭据的高并发请求容易触发模型速率限制,从而影响用户访问。 + +而负载均衡可将请求流量分配至多个模型凭据,有效避免模型速率限制和单点故障,并为所有用户提供更快的响应速度,保障业务稳定运行。 + +Dify 采用轮询策略的负载均衡机制,即:将模型请求按顺序依次分配给负载均衡池中的各个凭据。若某个凭据触发模型速率限制,系统将在接下来一分钟内的轮询中暂时跳过该凭据,以避免无效重试。 + +为模型配置负载均衡,按照以下步骤操作: + +1. 在模型列表中找到目标模型,点击对应的 **配置**,选择 **负载均衡** 模式。 + +2. 在负载均衡池中,点击 **添加凭据**,从已有凭据中选择或添加新凭据。 + + +**默认配置** 为当前指定的默认凭据。 + + + +若某个凭据的配额充足或性能更优,可重复添加该凭据以增加其在负载均衡中的权重,使其承担更大比例的请求负载。 + + +![Add credentials for load balancing](/images/add_load_balancing_credential.png) + +3. 在负载均衡池中启用至少 2 个凭据,点击 **保存**。已启用负载均衡的模型将带有特殊标识。 + +![Load balancing icon](/images/load_balancing_icon.png) + + +从负载均衡模式切换回默认的单凭据模式时,系统将保留负载均衡配置以备后用。 + + ## 访问和计费 系统供应商通过你的Dify订阅计费,使用限制基于你的计划。自定义供应商直接通过供应商(OpenAI、Anthropic等)向你收费,通常提供更高的速率限制。 diff --git a/en/documentation/pages/workspace/model-providers.mdx b/en/documentation/pages/workspace/model-providers.mdx index a3061e2e..2f7ea019 100644 --- a/en/documentation/pages/workspace/model-providers.mdx +++ b/en/documentation/pages/workspace/model-providers.mdx @@ -14,7 +14,7 @@ Model providers give your workspace access to AI models. Every application you b You can use both simultaneously—system providers for prototyping, custom providers for production. -## Configuring Custom Providers +## Configure Custom Providers Only workspace admins and owners can configure model providers. The process is consistent across providers: @@ -82,6 +82,116 @@ Only workspace admins and owners can configure model providers. The process is c +## Manage Model Credentials + +Add multiple credentials for a model provider's predefined and custom models, and easily switch between, delete, or modify these credentials. + +Here are some scenarios where adding multiple credentials is particularly helpful: + +- **Environment Isolation**: Configure separate model credentials for different environments, such as development, testing, and production. For example, use a rate-limited credential in the development environment for debugging, and a paid credential with stable performance and a sufficient quota in the production environment to ensure service quality. + +- **Cost Optimization**: Add and switch between multiple credentials from different accounts or model providers to maximize the use of free or low-cost quotas, thereby reducing application development and operational costs. + +- **Model Testing**: During model fine-tuning or iteration, you may create multiple model versions. By adding credentials for these different versions, you can quickly switch between them to test and evaluate their performance. + + +Use multiple credentials to configure load balancing for a model. + + + + + + After installing a model provider and configuring the first credential, click **Config** in the upper-right corner to perform the following actions: + + - Add a new credential + - Select a credential as the default for all predefined models + - Edit a credential + - Delete a credential + + + If the default credential is deleted, you must manually specify a new one. + + + ![Manage credentials for predefined models](/images/predefined_model_credential.png) + + + + ### Manage Credentials for a Single Custom Model + + After installing a model provider and adding a custom model, follow these steps: + + 1. In the model list, click the corresponding **Config**. + + 2. In the **Specify model credential** panel, click the default credential to open the credential list, then perform the following actions: + + - Add a new credential + + - Select a credential as the default for that custom model + + - Edit a credential + + - Delete a credential + + + If you delete the only credential for a custom model, the model will also be deleted. + + + ![Manage credentials for a single custom model](/images/custom_model_credential.png) + + + When you add a new custom model with a name and type identical to an existing custom model, the system will add the new credential to that existing model rather than creating a duplicate. + + + ### Manage Credentials for All Custom Models + + Click **Manage Credentials** to view, edit, or delete the credentials for all custom models. + + ![Manage credentials for all custom models](/images/custom_model_credential_list.png) + + After a custom model is removed, its credentials will remain in the **Manage Credentials** list. When you click **Add Model**, the system will display all removed custom models whose credentials still exist, allowing you to quickly re-add them. + + ![Removed models displayed for quick re-add](/images/removed_custom_model_re-add.png) + + If you delete all credentials for a removed custom model from the **Manage Credentials** list, that model will no longer appear when you click **Add Model**. + + + +## Configure Model Load Balancing + + +Load balancing is a paid feature. You can enable it through [a paid SaaS subscription or an Enterprise license](https://dify.ai/pricing). + + +Model providers typically enforce rate limits on API access within a specific timeframe to ensure stability and fair use. For enterprise applications, a high volume of concurrent requests from a single credential can easily trigger these limits, disrupting user access. + +An effective solution is load balancing, which distributes request traffic across multiple model credentials. This prevents rate limit issues and single points of failure, ensuring business continuity and faster response times for all users. + +Dify employs a round-robin strategy for load balancing, sequentially routing model requests to each credential in the load balancing pool. If a credential hits a rate limit, it is temporarily removed from rotation for one minute to avoid futile retries. + +To configure load balancing for a model, follow these steps: + +1. In the model list, find the target model, click the corresponding **Config**, and select **Load balancing**. + +2. In the load balancing pool, click **Add credential** to select from existing credentials or add a new one. + + +**Default Config** refers to the default credential currently specified for that model. + + + +If a credential has a higher quota or better performance, you can add it multiple times to increase its weight in the load balancing rotation, allowing it to handle a larger share of the request load. + + +![Add credentials for load balancing](/images/add_load_balancing_credential.png) + +3. Enable at least two credentials in the load balancing pool, then click **Save**. Models with load balancing enabled will be marked with a special icon. + +![Load balancing icon](/images/load_balancing_icon.png) + + +When you switch from load-balancing mode back to the default single-credential mode, your load-balancing configuration is preserved for future use. + + ## Access and Billing System providers are billed through your Dify subscription with usage limits based on your plan. Custom providers bill you directly through the provider (OpenAI, Anthropic, etc.) and often provide higher rate limits. diff --git a/jp/documentation/pages/workspace/model-providers.mdx b/jp/documentation/pages/workspace/model-providers.mdx index 66910278..76f9b996 100644 --- a/jp/documentation/pages/workspace/model-providers.mdx +++ b/jp/documentation/pages/workspace/model-providers.mdx @@ -85,6 +85,117 @@ icon: "brain-arrow-curved-right" + +## モデルの認証情報を管理 + +モデルプロバイダーの定義済みモデルやカスタムモデルに対して、複数の認証情報を追加し、それらの認証情報の切り替え、削除、変更を簡単に行うことができます。 + +以下のシナリオでは、複数のモデル認証情報を追加することをお勧めします。 + +- **環境の分離**: 開発、テスト、本番など、環境ごとに別々のモデル認証情報を設定します。例えば、開発環境ではデバッグ用にレート制限のある認証情報を使用し、本番環境ではサービスの品質を確保するために、安定したパフォーマンスと十分なクォータを持つ有料の認証情報を使用します。 + +- **コストの最適化**: 異なるアカウントやモデルプロバイダーから複数の認証情報を追加して切り替えることで、無料または低コストのクォータを最大限に活用し、アプリケーションの開発・運用コストを削減します。 + +- **モデルのテスト**: モデルのファインチューニングやイテレーションの過程で、複数のモデルバージョンを作成することがあります。これらの異なるバージョンの認証情報を追加することで、素早く切り替えてパフォーマンスのテストや評価を行うことができます。 + + +複数の認証情報を使用して、モデルのロードバランシングを設定することもできます。 + + + + + + モデルプロバイダーをインストールして最初の認証情報を設定した後、右上の **コンフィグ** をクリックして、以下の操作を実行します。 + + - 新しい認証情報を追加する + - すべての定義済みモデルのデフォルトとして認証情報を選択する + - 認証情報を編集する + - 認証情報を削除する + + + デフォルトの認証情報を削除した場合は、手動で新しい認証情報を指定する必要があります。 + + + ![Manage credentials for predefined models](/images/predefined_model_credential.png) + + + + ### 個別のカスタムモデルの認証情報を管理する + + モデルプロバイダーをインストールし、カスタムモデルを追加したら、以下の手順に従います。 + + 1. モデルリストで、対応する **コンフィグ** をクリックします。 + + 2. **モデルの資格情報を指定してください** パネルで、デフォルトの認証情報をクリックして認証情報リストを開き、次の操作を行います。 + + - 新しい認証情報を追加する + + - 認証情報をそのカスタムモデルのデフォルトとして選択する + + - 認証情報を編集する + + - 認証情報を削除する + + + カスタムモデルの唯一の認証情報を削除すると、そのモデルも削除されます。 + + + ![Manage credentials for a single custom model](/images/custom_model_credential.png) + + + 既存のカスタムモデルと名前およびタイプが同一の新しいカスタムモデルを追加しようとすると、システムは重複したモデルを作成する代わりに、その既存モデルに新しい認証情報を追加します。 + + + ### すべてのカスタムモデルの認証情報を管理する + + **Manage Credentials** をクリックすると、すべてのカスタムモデルの認証情報を表示、編集、または削除できます。 + + ![Manage credentials for all custom models](/images/custom_model_credential_list.png) + + カスタムモデルを削除した後も、その認証情報は **Manage Credentials** リストに残ります。**モデルの追加** をクリックすると、認証情報が残っている削除済みのカスタムモデルがすべて表示され、それらをすばやく再追加できます。 + + ![Removed models displayed for quick re-add](/images/removed_custom_model_re-add.png) + + 削除したカスタムモデルの認証情報をすべて **Manage Credentials** リストから削除した場合、そのモデルは **モデルの追加** をクリックしても表示されなくなります。 + + + +## 負荷分散の構成 + + +ロードバランシングは有料機能です。[SaaS有料プランのサブスクリプションまたはエンタープライズ版の購入](https://dify.ai/jp/pricing)によって有効化できます。 + + +モデルプロバイダーは通常、安定性と公平な利用を確保するため、特定の時間枠内でのAPIアクセスにレート制限を設けています。エンタープライズアプリケーションでは、単一の認証情報に対して大量の同時リクエストが発生すると、この制限に容易に達してしまい、ユーザーアクセスが中断される可能性があります。 + +効果的な解決策はロードバランシングです。これは、リクエストのトラフィックを複数のモデル認証情報に分散させる手法です。これにより、レート制限の問題や単一障害点を回避し、ビジネスの継続性を確保するとともに、すべてのユーザーに対してより速い応答時間を実現します。 + +Difyはロードバランシングにラウンドロビン方式を採用しており、モデルへのリクエストをロードバランシングプール内の各認証情報に順番にルーティングします。ある認証情報がレート制限に達した場合、無駄な再試行を避けるために、その認証情報は1分間、ローテーションから一時的に除外されます。 + +モデルのロードバランシングを設定するには、次の手順に従います。 + +1. モデルリストで対象のモデルを探し、対応する **コンフィグ** をクリックして **負荷分散** を選択します。 + +2. ロードバランシングプールで **認証情報を追加する** をクリックし、既存の認証情報を選択するか、新しい認証情報を追加します。 + + +**デフォルトの設定** は、そのモデルに現在指定されているデフォルトの認証情報を指します。 + + + +特定の認証情報がより高いクォータを持つ、またはより優れたパフォーマンスを示す場合は、その認証情報を複数回追加することでロードバランシングにおける重みを増し、より多くのリクエストを処理させることができます。 + + +![Add credentials for load balancing](/images/add_load_balancing_credential.png) + +3. 負荷分散プールで少なくとも2つの認証情報を有効にし、**保存** をクリックします。負荷分散が有効になったモデルには、特別なアイコンが表示されます。 + +![Load balancing icon](/images/load_balancing_icon.png) + + +ロード バランシング モードからデフォルトの単一認証情報モードに戻しても、ロード バランシングの設定は将来の使用のために保持されます。 + + ## アクセスと請求 システムプロバイダーはDifyサブスクリプションを通じて請求され、プランに基づく使用制限があります。カスタムプロバイダーはプロバイダー(OpenAI、Anthropicなど)を通じて直接請求され、多くの場合より高いレート制限を提供します。