n8n Workflow: OpenAI Chat Completion Automation
Integrate OpenAI GPT models into your n8n workflows. Generate content, analyze data, and build AI-powered automation pipelines.

How This Blueprint Works
Supercharge your workflows with OpenAI’s GPT and DALL-E models. This pipeline accepts content generation requests via webhook, calls the OpenAI Chat Completion or Image Generation API, and delivers the result wherever you need it.

The Execution Sequence
- Webhook Node — Accepts POST requests with prompt, model parameters (model, temperature, max_tokens), and optional system_prompt. Supports both JSON and form-data payloads.
- Prompt Assembler Node — A Code node that structures the OpenAI messages array from the webhook input. Sets system role message, few-shot examples (optional), and the user’s prompt. Validates token count against model limits.
- OpenAI Call Node — The OpenAI node configured for chat completion. Connects to GPT-4o, GPT-4o-mini, or GPT-4-turbo. Configurable temperature (0.0-2.0), max_tokens, top_p, frequency_penalty, and presence_penalty.
- Result Handler Node — Sends the model’s response (content + token usage) back to the webhook caller as JSON. Can also store results in a database or pass to downstream workflow nodes.
- Token Tracker Node — A Code node that calculates cost per call using OpenAI’s per-model pricing. Logs each call’s prompt_tokens, completion_tokens, model, and estimated cost to a Google Sheet for billing.
FAQ
What OpenAI models does this workflow support?
All chat-compatible models: GPT-4o, GPT-4o-mini, GPT-4-turbo, GPT-4, GPT-3.5-turbo. For image generation, the workflow supports DALL-E 3 with configurable size (1024x1024, 1792x1024) and quality (standard, hd).
How can I manage OpenAI API costs?
The Token Tracker node logs every call to a Google Sheet. Set monthly budget alerts by adding a Code node that sums costs and sends a warning if a threshold is exceeded.
Can I chain multiple AI calls in one workflow?
Yes. Connect the output of one OpenAI node to another. A common pattern: first call generates a blog post outline, second call expands each section, third call generates an SEO meta description.
The JSON Blueprint Structure
{
"name": "OpenAI Content Pipeline",
"nodes": [
{ "name": "Webhook", "type": "n8n-nodes-base.webhook", "position": [250, 300] },
{ "name": "Prompt Builder", "type": "n8n-nodes-base.code", "position": [450, 300] },
{ "name": "OpenAI Chat", "type": "n8n-nodes-base.openAi", "position": [650, 300] },
{ "name": "Cost Logger", "type": "n8n-nodes-base.googleSheets", "position": [850, 300] }
]
}
What You Get Inside Your SynthOperator System
This workflow is one of 27,400+ blueprints included in the n8n Business Automation OS ($17, one-time). When you deploy the complete system, you get:
- 27,400+ pre-built workflow JSON files across every business domain
- 15 elite AI agents integrated into your automation pipelines
- Lifetime updates, offline operation, and zero recurring fees
**Deploy your complete automation infrastructure today.
System Requirements
Operational Benefits
Trusted by Operators
"Deployed the full OS across 7 client accounts in week one. The 27K template library meant I stopped building workflows from scratch — I search, import, configure credentials, and deploy. Estimated 80+ hours/month saved in workflow development alone. The 15 AI agents replaced $12K/month in contractor overhead."
"The infrastructure architecture is production-grade. I've run 15,000+ workflow executions over 90 days with zero critical failures. The error-handling patterns (retry logic, dead-letter queues, Slack alerting) are already wired in. I spent 3 years building similar tooling in-house — this saved me 6+ months of engineering."
Free: Top 10 n8n Workflows
Get 10 industrial-grade n8n blueprints — ready to import into any instance. Save 10h/week with these ready-to-deploy automations.
- Industrial-grade n8n blueprints
- Recursive Claude subagent instructions
- Localhost deployment guide
- Lifetime update protocol