Use this powerful n8n workflow to create universal OpenAI-compatible API endpoints for all your custom n8n AI agents and LLM automation logic, supporting both streaming and standard responses.
Download this n8n workflow template and start using it instantly.
Automation Specialists who want to expose their n8n workflow logic as standardized AI models.
Developers building frontends or third-party applications that require an OpenAI-compatible API structure.
Users seeking to deploy n8n templates as scalable, external LLM services.
Anyone needing robust core logic flow control for AI services within n8n.
This sophisticated n8n workflow provides a standardized façade for all your underlying n8n AI agents. Instead of configuring unique API calls for every different n8n workflow, this solution creates two universal endpoints mimicking the behavior of the native OpenAI API: one for listing available models (/models) and one for executing chat completions (/chat/completions).
When you use this n8n template, it automatically discovers all your internal n8n workflows tagged 'aimodel' and lists them as available AI models. When a chat request comes in, the n8n workflow processes the request, intelligently transforms the input schema (handling complex inputs like image URLs), routes the request to the correct internal n8n agent via an HTTP Request n8n node, and meticulously formats the output, supporting both standard JSON responses and real-time Server-Sent Event (SSE) streaming responses, exactly like a high-end OpenAI API implementation.
This n8n workflow operates based on two distinct webhook triggers, providing comprehensive OpenAI API mimicry:
GET models n8n trigger (a Webhook n8n node) receives an incoming GET request.Get many workflows n8n node queries the internal n8n instance for all active n8n workflows that possess the tag aimodel.Edit Fields n8n node extracts crucial metadata (name, ID, and the internal webhook path of the targeted n8n workflow).Models Response n8n node, which structures the output into the required OpenAI /models JSON format, listing all your custom n8n templates.POST ChatCompletions n8n trigger (Webhook n8n node with header authentication) receives a chat request payload.Remap to Response API Schema Code n8n node translates the incoming OpenAI message structure (which might contain complex content types like image_url) into a simplified JSON structure suitable for execution by the target n8n agent workflow.Is Stream? If n8n node checks the incoming payload for the stream: true parameter.Call workflow webhook HTTP Request n8n node calls the webhook of the specific internal n8n workflow corresponding to the requested model. The Format Stream Response Code n8n node wraps the output into standard SSE chunks (data: {...}\n\ndata: [DONE]). The Text Response n8n node sends this data back with the correct headers for real-time streaming.Call workflow webhook1 HTTP Request n8n node executes the internal n8n agent. The Format Completion Response Code n8n node structures the output into the standard OpenAI chat completion JSON schema. The JSON Response n8n node returns the final JSON output.To deploy this powerful n8n workflow, follow these steps:
POST ChatCompletions n8n trigger node requires 'Header Auth'. You must configure a webhook credential to secure this API endpoint.aimodel and contains a Webhook n8n node (or Chat Trigger) to receive requests.Call workflow webhook and Call workflow webhook1) rely on an internal n8nApi credential type. This is crucial for securely calling webhooks within your own n8n instance. Configure this credential to ensure the routing works correctly.https://n8n.lucidusfortis.com). You must update this URL to match the public URL of your own n8n instance. GET models / POST ChatCompletions (Webhook n8n trigger nodes): These nodes serve as the external entry points. They listen on specific paths (youragents/models and youragents/chat/completions) to receive and initiate the n8n workflow execution.
Get many workflows (n8n node): Essential for the /models endpoint, this n8n node queries the list of all internal n8n workflows, filtering specifically by the aimodel tag, enabling dynamic model discovery.
Edit Fields (Set n8n node): Used to map the raw internal n8n workflow metadata into the required id and path variables needed for the OpenAI /models response schema.
Remap to Response API Schema (Code n8n node): Handles complex data transformation, converting the standard OpenAI input structure (including image links and text blocks) into a consumable format for internal n8n agents. This is vital for maintaining compatibility across different n8n templates.
Is Stream? (If n8n node): Provides core logic flow control, routing the execution path based on whether the inbound API call requested a streaming response (stream: true) or a standard synchronous response.
Call workflow webhook / Call workflow webhook1 (HTTP Request n8n node): These nodes execute the core LLM logic by making an authenticated POST call to the internal webhook of the specified target n8n workflow. They are crucial for routing the request to the correct n8n agent.
Automate SecOps incident response using this n8n workflow. Route Splunk alerts to Jira, creating unique tickets or adding comments to existing incidents, preventing alert duplication.

Use this advanced n8n workflow template to create a self-contained AI Travel Agent. It parses chat messages, plans comprehensive itineraries using Gemini AI and real-time data, and sends professional HTML confirmations via Gmail.

Use this sophisticated n8n workflow template to automate the creation of multi-post, complex threads on Bluesky Social. This n8n workflow leverages custom code and HTTP requests for precise sequencing.

Automate user profile creation, including email validation, dynamic PDF generation from HTML, and delivery via Gmail. This powerful n8n workflow logs verified data to Google Sheets.

Use this robust n8n workflow to automatically generate custom backgrounds using Gemini AI and composite them with your foreground video, saving the result directly to Google Drive. Perfect for marketing and social media automation.

Award winning IT pro. Serial entrepreneur. Mentor. Investor. Ex-MD/VP Cavista Holdings. Builds tech solutions for business problems. Founder, Lucidus Fortis.







































