こんにちは。
Dify上でOpenAIの画像生成(GPT Image Generate / gpt-image-1)を呼び出せず困っています。
まず、**実際のエラー出力(鍵はマスク済み)**を共有します。
Node: GPT Image Generate
Status: failed
Output (redacted):
{
"text": "Failed to generate image: Error code: 401 - {'error': {'message': 'Incorrect API key provided: sk-proj-********************************************************************************************************************************************************LqAA. You can find your API key at https://platform.openai.com/account/api-keys.', 'type': 'invalid_request_error', 'param': null, 'code': 'invalid_api_key'}}",
"files": [],
"json": [
{ "data": [] }
]
}
- OpenAI側のUsage:実行毎に約$0.01加算(ただし画像は返らず401で失敗)
同じ症状を解消できた方、原因や設定のコツをご教示ください。
環境
-
Dify:[クラウド版 ]
-
プロバイダ:OpenAI
-
機能/モデル:GPT Image Generate(
gpt-image-1) -
APIキー:OpenAIコンソールで発行したProjectスコープのキー(
sk-proj-…)
やったこと
-
OpenAI Console → Projects → API keys で
sk-proj-…を発行 -
Dify → Settings → Model Provider → OpenAI にキーを登録
-
ワークフローで「GPT Image Generate」を追加して実行(他ノードはSuccess、当該ノードのみ失敗)
期待する動作
- DifyからOpenAIの画像生成が正常に実行され、画像が返ること
質問したいポイント
-
Difyは**
sk-proj-形式(Projectスコープ)のAPIキー**に対応していますか? 旧形式のsk-キーでないと認証できない制約はありますか? -
画像生成で設定すべき正しいモデルID(例:
gpt-image-1)や必要な追加設定(Base URL、OpenAI-Organizationヘッダー等)があれば具体的に知りたいです。 -
もし未対応/既知の不具合がある場合、ワークアラウンド(対応バージョン、設定変更、互換プロバイダ設定など)があれば教えてください。
-
同様の環境で成功している方がいれば、Difyのバージョンと具体的な設定値を共有いただけると助かります。
English Version
Title
Can’t use OpenAI Image Generation in Dify with sk-proj- API key (auth error)
Body
Hi! I’m unable to call OpenAI image generation (GPT Image Generate / gpt-image-1) from Dify.
Here is the actual error output (key redacted):
Node: GPT Image Generate
Status: failed
Output (redacted):
{
"text": "Failed to generate image: Error code: 401 - {'error': {'message': 'Incorrect API key provided: sk-proj-********************************************************************************************************************************************************LqAA. You can find your API key at https://platform.openai.com/account/api-keys.', 'type': 'invalid_request_error', 'param': null, 'code': 'invalid_api_key'}}",
"files": [],
"json": [
{ "data": [] }
]
}
- OpenAI Usage increases by about $0.01 per run, but no image is returned (401 error).
I’d appreciate any pointers on the root cause or the correct setup.
Environment
-
Dify: [Cloud ]
-
Provider: OpenAI
-
Feature/Model: GPT Image Generate (
gpt-image-1) -
API key: Project-scoped key from OpenAI Console (
sk-proj-…)
Steps Taken
-
Issued an
sk-proj-…key from OpenAI Console → Projects → API keys -
Added the key in Dify → Settings → Model Provider → OpenAI
-
Added “GPT Image Generate” to the workflow and executed (other nodes succeed; this one fails)
Expected Behavior
- Dify should successfully call OpenAI image generation and return an image
Questions
-
Does Dify support project-scoped
sk-proj-keys, or does it require the legacysk-keys? -
What are the correct model ID (e.g.,
gpt-image-1) and any required extra settings (Base URL,OpenAI-Organizationheader, etc.)? -
If there’s a known limitation/bug, what’s the workaround (supported version, config changes, alternate provider settings, etc.)?
-
If you have this working, could you share your Dify version and exact settings?