node cookbook

N8N OpenAI Node Cookbook

Use the OpenAI node for AI workflow steps such as summarization, classification, extraction, drafting, and lightweight agentic automation.

Use when
n8n workflows, OpenAI, AI automation
First check
Configure OpenAI credentials.
Time to check
5-10 minutes
Next step
Run the recommended steps, then verify a production execution.

Independent third-party notes. n8n is a trademark of its owner and is referenced only for compatibility and troubleshooting context.

Quick Answer

Use the OpenAI node for AI workflow steps such as summarization, classification, extraction, drafting, and lightweight agentic automation.

Version awareness

Last reviewed 2026-05-21

Key Facts

Node role
Connect n8n workflows to OpenAI capabilities.
Common uses
Summaries, classification, extraction, enrichment, and generation.
Best fit
Structured AI steps inside broader business automations.
Common companion nodes
Gmail, Slack, Google Sheets, HTTP Request, Code, and Webhook.
  1. Configure OpenAI credentials.
  2. Choose the OpenAI operation that matches the task.
  3. Map workflow input into the prompt or message fields.
  4. Constrain output shape when downstream nodes need structured data.
  5. Add fallback behavior for API errors, empty responses, or unsafe output.

Verification

  • The node authenticates successfully.
  • The response format matches downstream expectations.
  • Failure paths are tested before production use.

Warnings

  • Do not send sensitive data to AI services unless the data policy allows it.
  • AI output should be validated before it drives irreversible workflow actions.

Production Cookbook

Common production use cases

  • Summarize support emails or incidents.
  • Classify inbound requests.
  • Draft internal handoff notes from structured workflow data.

Required credentials/scopes

  • OpenAI credential in n8n.
  • Model access for the selected account.
  • Optional downstream app credentials for where the output is stored.

Input fields that usually break

  • Long unredacted prompts.
  • Missing body text.
  • HTML email bodies.
  • Assuming one fixed output key across node versions.

Common errors

  • Credential test passes but model name is unavailable.
  • Prompt includes secrets or private customer data.
  • Downstream node expects text but receives a structured response.
Output shape example
{
  "text": "Short summary",
  "usage": {
    "prompt_tokens": 100,
    "completion_tokens": 40
  }
}

Small working pattern

Normalize the input with Set, redact private fields, call OpenAI, then Set a stable summary field for downstream nodes.

When to use HTTP Request or Code instead: Use HTTP Request when the built-in node lacks a new API parameter; use Code only for deterministic transformation, not prompt assembly with secrets.

Sources