OpenAI Responses API Adapter for LLM and AI Agents - n8n Workflow

Use this technical n8n workflow template to create an API adapter that seamlessly integrates the cutting-edge OpenAI Responses API with existing n8n LLM and AI Agent nodes, handling both streaming and standard responses.

Workflow Preview

Ready to automate?

Download this n8n workflow template and start using it instantly.

Who is this best for?

n8n Automation Specialists who need immediate access to the latest OpenAI API features.
Developers implementing complex AI Agent workflows in n8n.
Users looking for advanced examples of n8n code node scripting and webhook configuration.
Anyone needing an n8n solution to bridge API compatibility gaps.

Overview

When integrating new APIs, compatibility challenges often arise, especially with rapidly evolving AI services like OpenAI. The newer OpenAI Responses API, while powerful and supporting multimodal use cases, has a response structure fundamentally different from older Langchain-compatible models. This complex n8n workflow acts as an API adapter, using n8n's robust webhook and code capabilities to translate requests and responses in real-time.

By configuring a custom OpenAI credential within your n8n LLM or AI Agent n8n node to point to the webhooks of this n8n template, you can effectively trick the older n8n agent infrastructure into communicating with the new Responses API. This provides a crucial workaround for advanced users who require the new API features immediately without waiting for official n8n node support, maximizing the potential of their existing n8n workflow designs.

How it Works

This technical n8n workflow is designed around two primary webhook endpoints that mimic the standard OpenAI API structure:


  1. Model Listing (/n8n-responses-api/models): This n8n trigger handles GET requests requesting a list of available models. It executes an HTTP request to the actual OpenAI /v1/models endpoint and responds directly to the requester, ensuring the agent system sees the expected model list.


  1. Chat Completions (/n8n-responses-api/chat/completions): This is the core adapter endpoint, activated by a POST n8n trigger. When an n8n node (like an LLM or Agent node) sends a request here:

The Remap to Response API Schema code node transforms the incoming standard chat completion request JSON into the format required by the OpenAI Responses API (specifically formatting the messages array into the input structure).
The OpenAI Responses API n8n node sends this transformed request to the actual OpenAI Responses API (/v1/responses).
The Is Agent? If n8n node checks the original request's stream parameter to determine the required response format.
If streaming is required, the Format Stream Response code node parses the Server-Sent Events (SSE) response and generates the necessary chunked SSE format compatible with the n8n Langchain Agent, sent via the Text Response n8n node.
* If non-streaming (standard JSON) is required, the Format Completion Response code node structures the JSON output to match the standard OpenAI chat.completion schema, sent via the JSON Response n8n node.

An example flow is also included demonstrating how an AI Agent n8n node uses this custom configuration after being activated by a When chat message received n8n trigger.

Installation Guide

To utilize this advanced n8n workflow, follow these setup steps:


  1. Import the n8n template: Copy the provided JSON and import it into your n8n instance.

  2. Activate the n8n workflow: The webhooks must be active to function as an API proxy. Use the production webhook URL for reliability.

  3. Set up Custom OpenAI Credentials (crucial step):

Go to Credentials within n8n and create a new OpenAI API credential.
Name it something descriptive (e.g., "n8n-responses-api-adapter").
Enter an arbitrary API key (e.g., '12345').
Crucially, set the Base URL to point to your activated n8n workflow's webhook base path, typically https://n8nurl>/webhook/n8n-responses-api.

  1. Apply the Credential: In any existing n8n workflow using an OpenAI LLM n8n node, change the credential selected for that n8n node to the custom credential created in Step 3. Your LLM n8n node will now communicate through this adapter.

Node Details

Webhook (n8n-nodes-base.webhook): Used as the primary n8n trigger for two endpoints: /models (GET) and /chat/completions (POST). These define the entry points for the adapted API.
HTTP Request (n8n-nodes-base.httpRequest): Two instances are used: one to retrieve the list of OpenAI Models and a second, critical instance that posts the transformed payload to the external OpenAI Responses API.
Remap to Response API Schema (n8n-nodes-base.code): This vital custom code n8n node translates the incoming request body (messages array) into the expected input array structure for the new Responses API, utilizing custom JavaScript functions for content transformation.
Is Agent? (n8n-nodes-base.if): An important flow control n8n node that branches the n8n workflow based on whether the original request specified streaming (stream: true).
Format Completion Response / Format Stream Response (n8n-nodes-base.code): These two code n8n nodes handle the complex task of re-shaping the Responses API output back into a format (either standard JSON or SSE text stream) that the requesting n8n LLM node can understand and parse.
Respond to Webhook (n8n-nodes-base.respondToWebhook): Used in three locations (Models Response, JSON Response, Text Response) to send the final, correctly formatted data back to the originating n8n agent or LLM n8n node.

Related n8n Workflows

Free

Nodes: 9 Nodes
Updated: December 26 2025
View all
Created by
Jimleuk
Jimleuk

Freelance consultant based in the UK specialising in AI-powered automations. I work with select clients tackling their most challenging projects. For business enquiries, send me an email at [email protected] LinkedIn: https://www.linkedin.com/in/jimleuk/ X/Twitter: https://x.com/jimle_uk

Featured*