Proxy OpenAI-style chat completions to Gemini with async webhooks
Quick overview This workflow exposes an OpenAI-compatible /v1/chat/completions endpoint in n8n that forwards requests (including optional file attachments) to a configurable LLM HTTP provider, supporting both synchronous replies and asynchronous processing via a callback URL.
How it works Receives a POST request on /v1/chat/completions via a webhook, accepting JSON or multipart form-data with optional binary file uploads. Converts any uploaded files into OpenAI-style message content (images as image_url data URLs and other files as text entries) and merges them into the last user message. Prepares a job ID, extracts optional callback and provider override settings (URL and headers), and keeps the original request body for later use. If a callback URL is provided, immediately returns HTTP 202 with the job ID, then sends the request (without callback/provider fields) to the configured LLM provider endpoint. Formats the provider response (or error) into a completion payload with a status code and posts the result to the callback URL with job metadata. If no callback URL is provided, sends the request to the LLM provider synchronously and returns the provider response (or error) to the original caller with the same HTTP status code.
Setup Deploy this workflow and copy the production webhook URL for /v1/chat/completions to use as your OpenAI-compatible endpoint in your client or application. Configure the upstream LLM provider URL and any required authorization headers (either by sending them in the request body under provider.url/provider.headers or by using the default Google Generative Language OpenAI-compatible endpoint and supplying its auth header). If you want asynchronous mode, provide a reachable callback.url (and optional callback.method and callback.headers) that can accept the completion payload posted by this workflow. If you plan to send attachments, ensure your client can send multipart form-data with a JSON body field plus additional file fields so the workflow can convert them into message content.
Related Templates
Track Demo Bookings with Google Calendar to Meta Conversions API Integration
Who is this workflow for? If you're using Meta Ads to generate new leads to your sales pipeline, this workflow is for yo...
Build an MCP Server which answers questions with Retrieval Augmented Generation
Build an MCP Server which has access to a semantic database to perform Retrieval Augmented Generation (RAG) Tutorial C...
Transcribe & Summarize Audio with Whisper and GPT, from Google Drive to Notion
This workflow contains community nodes that are only compatible with the self-hosted version of n8n. Overview This work...
🔒 Please log in to import templates to n8n and favorite templates
Workflow Visualization
Loading...
Preparing workflow renderer
Comments (0)
Login to post comments