Integration · n8n

n8n with any OpenAI-compatible API

Use n8n for the triggers, approvals and system updates; use an OpenAI-compatible endpoint for the model. Here is the credential setup, the HTTP Request node and a workflow that survives a 429.

Short answer. Create an n8n credential with the provider's base URL and API key, then call POST /v1/chat/completions with the OpenAI JSON body. Use the HTTP Request node when you want the URL visible; use the OpenAI node when the credential supports a custom base URL. For batch jobs, add retry with backoff and a Wait node instead of hammering the endpoint.

1. Create the credential

In n8n, create an OpenAI credential (or a generic Header Auth credential) with:

FieldValue
Base URLhttps://api.plugsky.com/v1
API keyYour Plugsky key
Organization / projectLeave blank unless the provider requires it

If the node does not expose a base URL field, use Header Auth with Authorization: Bearer YOUR_KEY and the HTTP Request node. Do not put the key in a Set node.

2. Call chat completions with HTTP Request

Add an HTTP Request node:

  • Method: POST
  • URL: https://api.plugsky.com/v1/chat/completions
  • Authentication: Generic Credential / Header Auth
  • Send Body: JSON
{
  "model": "plugsky-plus",
  "messages": [
    {"role": "system", "content": "You are a support triage assistant. Return JSON only."},
    {"role": "user", "content": "{{ $json.ticket_text }}"}
  ],
  "response_format": {"type": "json_object"},
  "temperature": 0.2
}

Map the response with {{ $json.choices[0].message.content }}. If you use JSON mode, parse the string before passing it to the next node.

3. A support triage workflow

Webhook (new ticket)
  → HTTP Request (chat completions, JSON mode)
  → Code (parse JSON, validate required fields)
  → IF (confidence < 0.7 or category = billing)
      → true:  Slack approval → Update ticket
      → false: Update ticket with the suggested reply
  → Error workflow on 429/5xx

Keep the model output as a proposal, not an action. The IF node is where you enforce escalation; do not let the model decide whether a refund is allowed.

4. Parsing and validating the response

const raw = $json.choices[0].message.content;
const out = JSON.parse(raw);

if (!out.category || typeof out.confidence !== "number") {
  throw new Error("Model returned an invalid triage object");
}

return [{ json: out }];

n8n's Code node runs JavaScript. Throw on invalid output so the execution is marked failed and the error workflow can route it to a human.

5. Handle rate limits and retries

  • Enable Retry On Fail with 3 attempts and a delay.
  • Read Retry-After from the 429 response; use a Wait node for longer delays.
  • For batches, split items with a Loop node and add a small delay between requests.
  • Route exhausted retries to an error workflow that creates a ticket or a Slack alert.

A retry storm turns a temporary 429 into a sustained outage. Cap attempts and back off.

6. Streaming

The HTTP Request node returns the full response. If you need token streaming, call the API from a Code node or a small service and consume the SSE stream there. For most automations, non-streaming is simpler and easier to validate.

7. Security

  • Store keys in n8n credentials, not in node parameters or exported workflow JSON.
  • Restrict who can execute the workflow; a model call can leak data in its prompt.
  • Log the model, prompt version, token counts and decision for audit.
  • Use a private deployment if ticket data cannot leave your environment.

FAQ

Can n8n call any OpenAI-compatible API?

Yes. Use the HTTP Request node with the base URL, Bearer token and chat-completions body, or the OpenAI node with a custom credential.

Why does my n8n OpenAI node ignore the custom base URL?

Some versions only expose it on the credential. Create the credential with the base URL, or use HTTP Request.

Does n8n support streaming responses?

The HTTP Request node returns a complete response. Use a Code node or a small service for SSE streaming.

How do I keep the API key out of the workflow JSON?

Use an n8n credential or environment variable; never paste the key into a Set node.

How do I handle rate limits in n8n?

Retry with backoff, respect Retry-After, add Wait nodes for batches and route exhausted retries to an error workflow.

Reviewed 20 November 2026. n8n node names and credential fields vary by version; check the current node documentation. Test the error workflow before production.