前言
這個 n8n 串接 OpenAI 教學教學我會分享 2 種不同節點分別串接 Open AI 的語言模型及生成圖片的方法。
- Open AI 節點串接 ChatGPT 語言模型
- HTTP 節點串接 ChatGPT Image-1 製作圖片模型
建立 AI Agent、OpenAI 與 HTTP Request 節點
先把以下 3 個節點建立起來
- AI Agent
- Open AI
- HTTP Request

申請 OpenAI API 金鑰
- Open AI 官網
- API Keys →
Create new secret key
- 先把這個 Key 保留下來
設定 HTTP Request 節點
- URL:
https://api.openai.com/v1/images/generations
- Authentication:
Generic Credential Type
- Generic Auth Type:
Header Auth
- Header Auth:
Create New Credential
- Name:
Authorization
- Value:
Bearer Your API KEY
(Bearer 後面要空一格後才把你 Open AI 的 API Key 貼上去)
- Name:
- Send Body
打開
- Body Content Type:
JSON
- Specify Body:
Using JSON
- JSON: 貼上 ↓
{ "model": "gpt-image-1", "prompt": "Generate a high-quality image with this prompt: {{ $json.prompt }}", "size": "1536x1024", "quality": "high", "moderation": "low", "output_format": "jpeg", "background": "opaque", "output_compression": 50 }
- Body Content Type:
設定 OpenAI 節點串接語言模型
- Credential to connect with:
Create New Credential
- API Key:
Your API KEY
需要協助?加入 Discord 社群尋求支援
如果你遇到任何問題的話,歡迎你進來 Discord 找我。