OpenAI API Compatibility Layer for Free GitHub AI Models - n8n Workflow

Use this n8n workflow to create an OpenAI-compatible API endpoint that proxies requests to GitHub's free AI models, enabling their use within standard n8n AI agent configurations.

Workflow Preview

Ready to automate?

Download this n8n workflow template and start using it instantly.

Who is this best for?

AI developers prototyping solutions and seeking free models.
n8n users who want to integrate GitHub Models without altering existing LLM nodes.
Automation specialists needing flexible, self-hosted alternatives to paid OpenAI endpoints.
Users looking for advanced examples of customizing API interactions within an n8n workflow.

Overview

Leveraging free, state-of-the-art AI models often requires specialized API calls, which can complicate integration with standard tools like n8n's built-in LLM nodes. This n8n workflow solves that problem by acting as an OpenAI-compatible proxy. It intercepts standard OpenAI API calls (/models and /chat/completions) directed to a custom n8n webhook URL and forwards them to the GitHub Models API using the HTTP Request n8n node. Crucially, the n8n workflow then remaps the GitHub response data structure back into the format expected by the originating n8n node. This approach allows users to configure a custom OpenAI credential in n8n, pointing its Base URL to this local proxy, thereby accessing powerful free models using standard n8n templates and integrations.

How it Works

This comprehensive n8n workflow operates on two primary webhook endpoints that mimic the OpenAI API structure:


  1. Models Endpoint (/github-models/models): This is triggered when an LLM n8n node attempts to list available models. The n8n trigger Webhook node immediately passes control to the Github Models HTTP Request n8n node, which fetches the full model catalog from GitHub. The subsequent Aggregate node ensures all data is collected before the Models Response node uses a complex JSON expression to transform the GitHub data structure into the object: list format required by OpenAI API clients.


  1. Chat Completions Endpoint (/github-models/chat/completions): This endpoint, triggered by a POST request, handles actual inference requests. The POST ChatCompletions n8n trigger passes the request body (containing the model ID, messages, and stream flag) to the Github Chat Completions HTTP Request n8n node. This n8n node makes the corresponding request to the GitHub inference URL.


  1. Response Handling: The result then moves to the Is Agent? If n8n node, which checks the incoming JSON payload for the stream flag. If streaming is requested (typical for n8n AI agents), the Agent Response n8n node responds with the raw text data. If streaming is false, the Chat Response n8n node formats the response as JSON. This robust n8n workflow ensures compatibility across different integration methods.

Installation Guide

To deploy this n8n workflow and access GitHub Models:


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

  2. Set up GitHub Credentials: Ensure you have a valid GitHub API credential connected, as required by the Github Models and Github Chat Completions HTTP Request n8n nodes.

  3. Activate the Webhooks: Ensure your n8n workflow is active to register the webhook URLs.

  4. Create Custom OpenAI Credential: In n8n, create a new OpenAI credential.

API Key: Enter any placeholder value (e.g., '12345').
Base URL: Crucially, set this URL to point back to your active n8n instance's webhook prefix, specifically: https://n8nurl>/webhook/github-models (or adjust based on the path configured in the Webhook nodes). Note that this connection is typically required to use the production webhook URL.

  1. Integration: You can now select this custom credential in any LLM or AI Agent n8n node to route its requests through this custom n8n workflow proxy to GitHub Models.

Node Details

GET models (Webhook n8n node): Acts as the primary n8n trigger for model listing requests. It listens for GET requests at /github-models/models.
POST ChatCompletions (Webhook n8n node): The core n8n trigger for chat inference, listening for POST requests at /github-models/chat/completions.
Github Models (HTTP Request n8n node): Fetches the model list from the external GitHub Models API. Uses a GitHub credential for authentication and includes necessary headers (X-GitHub-Api-Version).
Models Response (Respond To Webhook n8n node): Essential for compatibility. It uses a JavaScript expression to restructure the GitHub model response data ($json.data) into the list format expected by standard OpenAI n8n node connections.
Github Chat Completions (HTTP Request n8n node): Sends the chat completion payload, dynamically generated from the incoming webhook body, to the GitHub inference endpoint.
Is Agent? (If n8n node): Determines the response type based on the stream parameter in the request payload. This is vital for correctly handling streaming responses required by certain n8n AI agent setups.


  • Chat Response / Agent Response (Respond To Webhook n8n nodes): These nodes handle the final output. Agent Response handles streaming requests as plain text, while Chat Response handles non-streaming requests as JSON. This completes the custom n8n workflow.

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*