Integration guide

Connect n8n to ModelGate

Use the ModelGate Community Node to send LLM requests from n8n through your ModelGate gateway.

Community NodeThis package is a community node and is not currently an n8n-verified node.

Before you start

  • A self-hosted n8n instance. n8n installs unverified community nodes from npm only on self-hosted instances — they aren’t available on n8n Cloud. Installing needs an n8n Owner or Admin.
  • A ModelGate account with a provider key stored under Providers for your project’s default provider.

1. Install the node

Recommended — from the n8n interface. In n8n, go to Settings → Community Nodes and select Install. Enter the package name:

n8n-nodes-modelgate

Accept the risk prompt n8n shows for community nodes (unverified code from a public source), then select Install.

Alternative — manual install. If your instance can’t install from the interface (for example, it runs in queue mode), install from the command line inside ~/.n8n/nodes and restart n8n:

npm install n8n-nodes-modelgate

n8n’s own instructions: Community node installation (opens in a new tab) · Manual installation (opens in a new tab). Package: npm (opens in a new tab) · GitHub (opens in a new tab).

2. Create a ModelGate API key

Sign in to ModelGate, or create an account. New accounts go through the normal 14-day trial setup before the dashboard opens; after signing in, open API Keys from the dashboard sidebar.

Choose the Inference only access preset. The node only calls POST /v1/chat/completions, which needs the inference:write scope and nothing more — a narrower key limits what a leaked n8n credential could do.

ModelGate shows the full key once, when it is created. Copy it before you leave the page. Keys start with mg_…. Paste it only into n8n’s credential form — never into a workflow field, a URL or a shared document.

3. Create the n8n credential

In n8n, create a credential of type ModelGate API (or select it when you first add the node). It has two fields:

FieldValue
API KeyRequired. Your ModelGate key, starting with mg_.
Base URLDefaults to https://gw.modelgatehq.com. Leave it unless you intentionally use another ModelGate gateway deployment.

The node sends the key as Authorization: Bearer <API key>. There is nothing else to configure for authentication.

4. Add the ModelGate node

Add the ModelGate node to a workflow and select your credential. Its operation is Chat / Generate, with two input modes:

  • Simple Prompt — a Prompt, plus an optional System Prompt.
  • Define Messages — a list of Messages, each with a system, user or assistant role.

Set Model to the model name, for example gpt-4o-mini.

Options that take effect

  • Temperature and Maximum Number of Tokens — forwarded to the provider. Your project’s token, rate and spend ceilings still apply.
  • Response Format (JSON Object) — forwarded for OpenAI and Azure OpenAI.
  • Metadata — extra key/value pairs stored with the request in ModelGate.
  • Timeout — how long n8n waits for the gateway.

The node also lists Top P, Frequency Penalty and Presence Penalty. The gateway doesn’t currently forward those three, so setting them has no effect.

Output

Simplify Output is on by default and returns a compact item. Turn it off to get the full OpenAI-format response instead; _modelgate.requestId is included either way.

{
  "text": "…",
  "model": "…",
  "finish_reason": "…",
  "usage": { … },
  "_modelgate": { "requestId": "…" }
}

Each request is tagged with source: "n8n" plus the workflow, execution and node it came from, so its usage in ModelGate can be traced back to the workflow.

5. Test the connection

Credential test. Saving or testing the credential in n8n sends a real, one-token completion for gpt-4o-mini through the gateway. It is an actual request — logged in ModelGate and billed by your provider like any other, though tiny. An invalid key fails with 401. If your project’s default provider isn’t OpenAI, this test can fail even with a valid key; verify with a workflow run instead.

Workflow run. Execute the workflow once. The node’s output carries _modelgate.requestId. Open Requests in the dashboard — the call appears in the request ledger with its model, tokens and cost, and the search box finds it by request ID among recent requests.

6. Example workflow

A minimal workflow has three nodes:

Manual Trigger  →  Set  →  ModelGate
  1. Manual Trigger starts the run.
  2. Set adds a string field named text with the content to summarize.
  3. ModelGate, in Simple Prompt mode, with this prompt:
Write a one-sentence summary of: {{ $json.text }}

The summary is in text on the ModelGate node’s output. The package repository includes an importable example workflow (opens in a new tab) with the same shape; after importing it, select your own credential and set a model your default provider serves.

What the node supports

Packagen8n-nodes-modelgate
NodeModelGate
CredentialModelGate API
OperationChat / Generate
InputSimple Prompt · Define Messages
Gatewayhttps://gw.modelgatehq.com
EndpointPOST /v1/chat/completions
AuthAuthorization: Bearer <API key>
Key access neededinference:write (the “Inference only” preset)
Output includestext, model, finish_reason, usage, _modelgate.requestId
Current limitationsNon-streaming · no tool calling · no automatic retries

Questions

For the gateway itself — authentication, errors and ceilings — see the documentation. Report node issues on GitHub (opens in a new tab), or email support@modelgatehq.com.