Skip to main content

n8n

n8n is a workflow automation platform with visual AI nodes for agents, chains, models, memory, tools, and data sources. Its OpenAI Chat Model sub-node can use a custom OpenAI-compatible endpoint instead of calling OpenAI directly.

Connect that model sub-node to AISIX when an n8n AI Agent or chain should use gateway-managed credentials, model aliases, routing, policy, and telemetry. n8n continues to run the workflow and execute tools; AISIX governs the model requests emitted by the configured sub-node.

This integration covers the OpenAI Chat Model sub-node. It does not claim compatibility for every operation in n8n's general OpenAI application node, which also calls provider-specific file, image, audio, assistant, and other APIs.

Prerequisites

Before starting, prepare the following:

  • An n8n project where you can create credentials and edit workflows.
  • An AISIX proxy URL the n8n deployment can reach.
  • An AISIX caller API key dedicated to the workflow or n8n project.
  • A chat-capable model alias the caller key can access through the OpenAI-Compatible API.

Create the OpenAI Credential

Create a credential for the AISIX connection from an OpenAI Chat Model sub-node:

  1. Add or open an OpenAI Chat Model sub-node in the workflow.
  2. Under Credential to connect with, create an OpenAI credential.
  3. Set API Key to the AISIX caller API key.
  4. Set Base URL to the AISIX proxy API root, including /v1, for example https://gateway.example.com/v1.
  5. Leave Organization ID empty.
  6. Save the credential.

n8n validates the credential with GET /v1/models. AISIX authenticates the caller key and returns the aliases it can access.

Configure the Chat Model

Select the AISIX connection and Chat Completions path:

  1. Select the AISIX-backed OpenAI credential.
  2. Under Model, select a chat-capable AISIX model alias returned from the gateway. If it does not appear, choose the model ID entry mode and enter the alias exactly.
  3. Turn off Use Responses API so the sub-node sends POST /v1/chat/completions.
  4. Connect the model output to the Chat Model input of the AI Agent or chain that should use AISIX.

Set Use Responses API explicitly rather than relying on a version-dependent default. It must be off for the Chat Completions path documented here.

Do not enable OpenAI-hosted built-in tools such as Web Search, File Search, or Code Interpreter for this configuration. Those tools belong to OpenAI's Responses service rather than the n8n workflow tool loop.

The model value is the AISIX alias, not the upstream provider model ID. n8n sends prompts and tool definitions to AISIX, while the workflow continues to own node execution, memory, branching, retries, and data movement.

Test the Model Connection

For a minimal interactive test, connect a Chat Trigger to an AI Agent, attach the configured OpenAI Chat Model, and run the workflow chat. To verify incremental output, set the Chat Trigger's response mode to Streaming.

Send a short prompt and confirm these results:

  • The n8n chat displays the model response.
  • AISIX records a successful POST /v1/chat/completions request.
  • The recorded caller key and model match the n8n credential and selected alias.

When the workflow runs from a webhook, schedule, or another trigger, verify that execution separately. Test and production executions may use different credentials or workflow versions.

Verify an Agent Tool

Attach a deterministic n8n tool, such as a Calculator, to the AI Agent and ask a question that requires it. Confirm that the agent calls the tool, receives the result, and returns a final answer.

One tool-using turn normally produces at least two model requests: the first returns the tool call, and the next includes the tool result. Account for that request fan-out when setting AISIX rate limits and reviewing usage. With AISIX Cloud, include it when setting budgets.

Troubleshoot the Model

SymptomCheck
Credential validation failsConfirm Base URL ends in /v1 and GET /v1/models accepts the caller key.
Model list is emptyConfirm the caller key can access at least one AISIX alias, or enter the alias through the model ID mode.
Request reaches /v1/responsesTurn off Use Responses API on the OpenAI Chat Model sub-node.
Request returns 403Confirm the n8n credential's caller key can access the selected alias.
Agent answers without using a toolConfirm the tool is attached to the AI Agent and the selected upstream model supports OpenAI-compatible tool calling.
General OpenAI node operation failsUse this integration only for the OpenAI Chat Model sub-node unless the specific AISIX endpoint has been verified separately.

Next Steps

  • OpenAI-Compatible API: review the request path used by the model sub-node.
  • Tool Calling: verify agent tool definitions and results.
  • Budgets: account for multi-request agent workflows with AISIX Cloud.