dify - 💡(How to fix) Fix [Feature Request] Dynamic model provider API key selection per workflow run / per client

Official PRs (…)
ON THIS PAGE

Recommended Tools

×6

Utilities matched from this issue’s tags and category — try them while you read without losing context.

GitHub issue graph ai analysis

Paste a GitHub issue URL. We fetch that issue, discover linked issues from bodies/comments/timeline, collect linked pull requests, and produce a structured English report.

The report is written in English Markdown for sharing and archival.

Helpful · Quick feedback

Loading…

Currently, the model provider API key (e.g. OpenAI) is configured at the workspace level and cannot be overridden at runtime. As a service provider managing multiple clients — each with their own OpenAI API key — it's impossible to route LLM calls through the correct key within a single shared workflow.

Root Cause

Currently, the model provider API key (e.g. OpenAI) is configured at the workspace level and cannot be overridden at runtime. As a service provider managing multiple clients — each with their own OpenAI API key — it's impossible to route LLM calls through the correct key within a single shared workflow.

RAW_BUFFERClick to expand / collapse

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.

Summary

Currently, the model provider API key (e.g. OpenAI) is configured at the workspace level and cannot be overridden at runtime. As a service provider managing multiple clients — each with their own OpenAI API key — it's impossible to route LLM calls through the correct key within a single shared workflow.

Use Case

I manage multiple clients. Each client has their own OpenAI API key (for billing isolation, quota management, or contractual reasons). I want a single Dify workflow that dynamically uses the appropriate API key depending on which client is calling it.

Expected Behavior

One or more of the following approaches should be supported:

  1. Input variable for API key — allow passing a model_api_key as a workflow input variable, which overrides the workspace-level key for that specific run.
  2. Per-run credential override — support a credential_id or api_key parameter directly in the workflow trigger API call (e.g. in inputs or as a top-level field).
  3. Named credential profiles — allow storing multiple named credentials per provider (e.g. client_a_openai, client_b_openai) and selecting one via a workflow variable or condition node.

2. Additional context or comments

No response

3. Can you help us with this feature?

  • I am interested in contributing to this feature.

extent analysis

TL;DR

To address the limitation of using a single OpenAI API key at the workspace level, consider implementing an input variable for the API key or a per-run credential override in the workflow trigger API call.

Guidance

  • Evaluate the feasibility of adding a model_api_key input variable to the workflow, allowing it to override the workspace-level key for specific runs.
  • Investigate supporting a credential_id or api_key parameter directly in the workflow trigger API call to enable per-run credential overrides.
  • Consider implementing named credential profiles for storing multiple credentials per provider, selectable via a workflow variable or condition node.
  • Assess the potential impact of these changes on the existing workflow and API key management infrastructure.

Example

No code snippet is provided due to the lack of specific technical details in the issue.

Notes

The proposed solutions require further technical evaluation and implementation details, which are not provided in the issue. The feasibility of these approaches depends on the underlying architecture and existing workflow management system.

Recommendation

Apply a workaround by implementing an input variable for the API key, as this seems to be the most straightforward approach to override the workspace-level key for specific runs. This allows for dynamic selection of the API key based on the client calling the workflow.

Vote matrix · Quick signals

Works
Did the solution work? Tap to confirm.
Easy Fix
Was it a quick fix?
Time Saver
Did it save you time?
Blocking
Was it severely blocking?
Common Issue
Are others likely hitting this too?
Flaky / Intermittent
Is it intermittent?
Verified / Reproducible
Can you reproduce it reliably?
Loading…

Still need to ship something?

×6

Another batch ranked right after the header list — different links, same matching logic.

Back to top recommendations

TRENDING

dify - 💡(How to fix) Fix [Feature Request] Dynamic model provider API key selection per workflow run / per client