Connect n8n to an OpenAI-compatible endpoint, the paths that actually work.

Updated 2026-07-16

n8n's OpenAI credential takes a custom Base URL, and the AI Agent's OpenAI Chat Model node runs reliably against it. The standalone OpenAI node has a version-specific sharp edge worth knowing before you debug for an evening. This page maps what works today, honestly.

Quick answer: change the Base URL on an OpenAI credential.

In current n8n, the endpoint override lives on the credential, not the node. Create a new OpenAI credential, paste your key, and set the Base URL field to https://api.apisrouter.com/v1 in place of the OpenAI default. Every node that authenticates with that credential then sends its requests to the gateway. The node to pair it with is the OpenAI Chat Model node, the sub-node that plugs into AI Agent, Basic LLM Chain, and the rest of n8n's AI cluster. That combination is the one the community and the bug tracker consistently report as working against compatible endpoints. Pick the model by id, and if the dropdown misbehaves against a third-party endpoint, switch the model field to expression mode and type the id as a string; ids are forwarded verbatim, so claude-haiku-4-5-20251001 or deepseek-v4-flash work the same as any OpenAI id.

API Key:   sk-APIsRouter-...
Base URL:  https://api.apisrouter.com/v1   (replaces the OpenAI default)

then: AI Agent -> Chat Model -> OpenAI Chat Model
      -> select this credential -> set model id

The honest map: three surfaces, not one.

n8n (roughly 196K stars on GitHub) is the dominant self-hostable workflow automation platform, and its AI story spans three different surfaces that guides routinely blur together. The AI cluster nodes, AI Agent with its pluggable Chat Model sub-nodes, are surface one. The standalone OpenAI node, the one under app actions with operations like message a model, is surface two, and it is versioned independently of n8n itself. The HTTP Request node is surface three, the escape hatch that predates both. A custom base URL has been a long-running community request, and the credential-level Base URL field is the answer that exists today: one credential, reused by AI nodes across your workflows. What the request history tells you is that this area moved recently and unevenly, which is why a 2024 forum answer, a 2025 tutorial, and the current product all describe slightly different n8n. When something disagrees with this page, trust the version you are running and test the credential against a live workflow rather than assuming. The reason to bother is the same as everywhere else: with a multi-vendor gateway behind the Base URL, the same credential serves Claude for an agent that drafts replies, a fast Gemini id for classification steps, and DeepSeek for volume extraction, each workflow picking its id while billing lands on one key.

The sharp edge: the standalone OpenAI node.

Here is the part most pages omit. There is a reported, reproducible failure where the standalone OpenAI node at version two returns 404s at runtime against an OpenAI-compatible endpoint even though the credential test passes, on an n8n from the 1.118 era. The same credentials work through the AI Agent's OpenAI Chat Model sub-node, and the same standalone node at its earlier version 1.8 also works. In other words: the credential is fine, the endpoint is fine, and one specific node version still fails. The practical guidance follows directly. Build LLM steps on the AI cluster nodes, where the compatible-endpoint path is solid. If you specifically need the standalone OpenAI node and it 404s against a working credential, you have hit the known edge, not your configuration; the AI-cluster route is the fix, and pinning the node's earlier version has been the community workaround. When neither fits, the HTTP Request node always works, because it is just the API call with none of the node plumbing: POST to the chat completions URL, bearer auth from a credential, JSON body with model and messages. It costs you the convenience fields, and it removes every abstraction that could be the bug.

Method:  POST
URL:     https://api.apisrouter.com/v1/chat/completions
Auth:    Generic -> Header Auth
         Authorization: Bearer sk-APIsRouter-...
Body (JSON):
{
  "model": "claude-haiku-4-5-20251001",
  "messages": [{ "role": "user", "content": "{{ $json.prompt }}" }]
}

Choosing models for automation volume.

The tuning loop for automation is unforgiving in a good way: workflows run the same step thousands of times, so a model swap shows up in the usage numbers within days, priced. Compare candidates on the same workflow and let the log decide.

  • Workflows multiply everything. A step that runs on every inbound email or webhook executes thousands of times a month, so default LLM steps to fast ids: claude-haiku-4-5-20251001, gemini-3.5-flash, deepseek-v4-flash, gpt-5.4-mini.
  • Classification, extraction, and routing steps are machine-read output; they want consistency and speed, not eloquence. This is exactly the volume tier.
  • Agent steps that plan across tools, or steps whose output a human reads, earn claude-sonnet-4-6. Use it where judgment shows, not on plumbing.
  • Per-step model choice is free through one credential: each Chat Model node picks its own id, so a workflow can classify on a fast id and draft on a strong one without a second credential.
  • Measure per workflow, not per month. Tokens per execution times executions per day is the number that decides whether an automation pays for itself, and the usage log gives you both factors.

Pay-as-you-go · transparent per-model pricing

Selected models are priced below official list prices. Exact input, output, cache, and per-request prices are shown for each model.

ModelOfficial PriceOur Price
Claude Haiku 4.5 20251001$1.00 / $5.00 per M$0.80 / $4.00 per M
Gemini 3.5 Flash$1.50 / $9.00 per M$1.20 / $7.20 per M
DeepSeek V4 Flash$0.14 / $0.28 per M$0.13 / $0.25 per M
GPT-5.4 Mini$0.75 / $4.50 per M$0.60 / $3.60 per M
Claude Sonnet 4.6$3.00 / $15.00 per M$2.40 / $12.00 per M

Failure modes specific to n8n.

Credential test passing while the workflow 404s is the signature of the standalone-node edge described above. The credential test and the node's runtime requests are built differently, so the test proves the key and the host, not every request the node will make. Move the step to an AI-cluster node before touching the credential again. The Base URL wants the /v1 included: https://api.apisrouter.com/v1. n8n replaces the OpenAI default, which itself carries the /v1, so a bare host produces path errors once nodes append their routes. A model dropdown that shows nothing, or shows ids that then error, reflects how a given node version lists models from a third-party endpoint. The expression-mode model field sidesteps the dropdown entirely; the id string is what actually travels. Self-hosted upgrade drift causes the version confusion: node versions are pinned inside existing workflows, so an old workflow can keep working while a freshly added node of the same name behaves differently. When two seemingly identical workflows disagree, compare the node version numbers first. And the automation classic: a looping workflow with an LLM step inside the loop multiplies calls invisibly. If spend jumps, check executions in n8n before blaming the model; the per-request log on the gateway side gives you the timestamps to line up.

Who routes n8n through a gateway.

  • Automation builders adding LLM steps to real business workflows, where per-execution cost decides which automations survive and fast catalog ids keep that number workable.
  • Teams wanting Claude-quality agents inside n8n without a separate vendor account, key rotation, and billing surface next to their existing stack.
  • Self-hosters running one n8n for many teams, giving each team a key so the usage log reports cost per team without extra tooling.
  • Builders comparing models per workflow step, since one credential serves every id and each Chat Model node picks its own.
  • Developers without access to a given vendor's billing. Top-up based access with no card requirement removes the per-provider sign-up dependency.

Verify the endpoint and debug the first workflow.

Prove the endpoint with curl before creating anything in n8n: list the models, then run one chat completion with the exact id you plan to use. If those pass, every remaining symptom is in n8n's node layer, which narrows the search fast. Then build the smallest possible workflow: manual trigger, AI Agent or Basic LLM Chain, OpenAI Chat Model with your credential, one hard-coded prompt. Run it once. A 401 is the key on the credential; a 404 here, after curl worked, means the Base URL lost its /v1 or you are on the standalone node's affected version; a model error is the id string. Only after this one-node workflow passes should you wire the real trigger and data, because debugging a compatible endpoint and a data-mapping mistake at the same time is how evenings disappear. Once workflows run, the APIsRouter console shows per-request model, token counts, and spend. Automation is where LLM spend compounds quietly, the same step firing all day, and the usage log is the difference between discovering that in the data and discovering it on the invoice.

curl -s https://api.apisrouter.com/v1/chat/completions \
  -H "Authorization: Bearer $APISROUTER_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{"model":"claude-haiku-4-5-20251001",
       "messages":[{"role":"user","content":"ping"}]}'

FAQ

Does n8n support a custom OpenAI-compatible base URL?

Yes, on the OpenAI credential: current versions expose a Base URL field that replaces the OpenAI default. Set it to https://api.apisrouter.com/v1 and the AI cluster nodes using that credential route through the gateway. The standalone OpenAI node has a version-specific edge covered on this page.

Why does my credential test pass but the workflow return 404?

That is the reported behavior of the standalone OpenAI node at version two against compatible endpoints: the credential test succeeds while runtime requests 404. The same credential works through the AI Agent's OpenAI Chat Model sub-node, which is the recommended surface; the node's earlier version has also been used as a workaround.

Which n8n node should I use with a gateway endpoint?

The OpenAI Chat Model sub-node, plugged into AI Agent or Basic LLM Chain, with your custom credential. It is the path consistently reported working. The HTTP Request node is the always-works fallback for anything the node layer complicates.

Can n8n workflows use Claude or DeepSeek through this credential?

Yes. The model id travels as a plain string to whatever the Base URL serves, so claude-haiku-4-5-20251001, claude-sonnet-4-6, and deepseek-v4-flash all work. If a model dropdown misbehaves, set the model field by expression and type the id.

Should the Base URL include /v1?

Yes: https://api.apisrouter.com/v1. The field replaces OpenAI's default, which carries the /v1 itself, and nodes append their request paths to whatever base you set.

How do I keep LLM costs visible across many workflows?

One gateway key per team or per project turns the APIsRouter usage log into a cost report: per-request model, tokens, and spend, filterable by key. Pair it with n8n's execution counts and you get cost per workflow execution, which is the number automation decisions should run on.