n8n OpenAI-Compatible API: Claude, GPT, DeepSeek

Connect n8n to an OpenAI-compatible API: the right Base URL for each credential, AI Agent model picks, 401/404 fixes, and cost per run in USD.

GoiAPI · · 14 min read

Ask AI and more
View as Markdown

Diagram of an n8n AI Agent connected through an OpenAI credential to a terminal showing Base URL https://api.goiapi.com/v1, an API key and the model gpt-6.1-sol

To use an OpenAI-compatible API in n8n, add a Custom Endpoint Chat Model (n8n 2.50.0 or later) or an OpenAI Chat Model to your AI Agent, and set the credential's Base URL to the endpoint including /v1, for GoiAPI https://api.goiapi.com/v1. Then type the model name, for example deepseek-v4.1-flash or gpt-6-luna. For Claude, use the Anthropic Chat Model with the Base URL https://api.goiapi.com (no /v1).

This guide walks through all three routes, the field values to type, which models suit an AI Agent, the exact 401 and 404 errors you will see when a field is wrong, and what a workflow run costs in USD.

Disclosure: GoiAPI sells API access to the models mentioned in this article.

What you need before you start

  • An n8n instance. The Custom Endpoint Chat Model node needs n8n 2.50.0 or later; the OpenAI and Anthropic routes work on older versions too. The latest n8n release on GitHub when we checked was 3.4.4 (December 4, 2026).
  • An API key that works with an OpenAI-compatible endpoint. For GoiAPI it looks like sk-... and is created on the API Keys page of the dashboard.
  • The exact model name (slug) you want to call. You can list them from GET /v1/models or copy them from the model list.

How we checked this guide: n8n field names, defaults and behavior come from the n8n docs and the n8n source code on GitHub, both checked on December 5, 2026. The GoiAPI responses (model list, error messages) come from direct API calls on December 3, 2026. We did not run these nodes inside n8n ourselves, so after each step click Execute step on the node to confirm it works on your instance.

If the terms base URL and endpoint are new to you, read what an OpenAI-compatible API is first.

Which n8n node to use with an OpenAI-compatible endpoint

n8n's AI features are built around a root node such as AI Agent, with sub-nodes attached to it: a chat model, memory and tools. The chat model sub-node is where you point n8n at a non-OpenAI endpoint. There are three useful options:

Custom Endpoint Chat ModelOpenAI Chat ModelAnthropic Chat Model
Best forGPT, DeepSeek, GLM through any OpenAI-compatible gatewaySame, on older n8n versionsClaude models
n8n version2.50.0 or laterOlder and newer versionsOlder and newer versions
CredentialCustom Model Endpoint (or an existing OpenAI credential)OpenAIAnthropic
Base URL for GoiAPIhttps://api.goiapi.com/v1https://api.goiapi.com/v1https://api.goiapi.com
API it calls by defaultChat CompletionsResponses on node version 1.3 (see below)Messages
Model listFrom List calls GET /modelsCalls GET /modelsCalls GET /v1/models

The n8n docs for the OpenAI Chat Model recommend the Custom Endpoint Chat Model node when you call an OpenAI-compatible gateway or proxy, so start there if your n8n version has it.

Sources, checked December 5, 2026: Custom Endpoint Chat Model docs, Custom Model Endpoint credential docs, OpenAI Chat Model docs, and the n8n source for the OpenAI credential, OpenAI Chat Model node and Anthropic credential.

Method 1: Custom Endpoint Chat Model (n8n 2.50.0+)

Create the Custom Model Endpoint credential

This credential is meant for any endpoint that accepts OpenAI-format requests. Fill it in like this:

n8n fieldValue for GoiAPI
AuthenticationBearer Token
API Keyyour key, sk-...
Base URLhttps://api.goiapi.com/v1
Gateway Headersleave empty

The n8n docs for this credential state that the node appends routes such as /chat/completions and /models to the Base URL, and that if the version segment is missing the gateway returns a 404 rather than an n8n error. So the /v1 at the end is required, and nothing should come after it.

Tip: create a separate key just for n8n and set daily and monthly spending limits on it in the dashboard. A workflow stuck in a loop then stops at the limit instead of draining your balance. You can also restrict the key to the models the workflow uses; see Authentication.

Configure the node

Inside your AI Agent, add the Custom Endpoint Chat Model sub-node, pick the credential you just created, then set:

  • API Format: keep Chat Completions (the default). The node also offers Responses.
  • Model: the default mode is By ID. Type the exact slug, for example deepseek-v4.1-flash. Switch to From List if you want n8n to fetch the list through GET /models.
  • Options > Maximum Number of Tokens: set a sensible cap. n8n sends it as max_tokens, or as max_completion_tokens for reasoning models. GoiAPI holds funds based on this value before each call, so a cap close to what you need keeps requests from being rejected when your balance is low (Limits and balance).

The node also sends x-n8n-workflow-id, x-n8n-workflow-name and x-n8n-execution-id headers by default (Send n8n Context Headers). They do no harm; turn the option off if you prefer not to send them.

Method 2: OpenAI credential with a custom Base URL

On older n8n versions, or if you already use the OpenAI Chat Model node, you can point the OpenAI credential somewhere else. The n8n docs page for this credential only lists API Key and Organization ID, but the credential in the n8n source has a Base URL field with the default https://api.openai.com/v1.

Create an OpenAI credential with:

  • API Key: your GoiAPI key, sk-...
  • Organization ID (optional): leave empty
  • Base URL: replace https://api.openai.com/v1 with https://api.goiapi.com/v1

When you save, n8n tests the credential with GET <Base URL>/models, so a wrong key or a wrong URL fails right away.

Three things to watch on the OpenAI Chat Model node (node version 1.3):

  1. Use Responses API. In the n8n source this toggle defaults to on for node version 1.3, which sends requests to /v1/responses. The n8n docs say it is off by default. Since the two disagree, open the node and check. GoiAPI does serve the Responses API, but our tests of all nine models went through /v1/chat/completions, so turn the toggle off to follow the tested path. OpenAI's built-in tools (Web Search, File Search, Code Interpreter) only exist on the Responses side and are ignored by GoiAPI, so the model never sees them.
  2. The model list is not filtered. When the Base URL does not start with https://api.openai.com/, n8n shows every model the endpoint returns instead of filtering the list down to OpenAI chat models (gpt-*, o1, o3 and fine-tuned models). All nine GoiAPI slugs appear.
  3. Base URL lives only in the credential. The per-node Base URL option is hidden from node version 1.1 onward. To have one node call OpenAI and another call GoiAPI, create two OpenAI credentials and pick one per node.

Method 3: Claude in n8n with the Anthropic credential

For Claude models, use the Anthropic Chat Model node. The n8n docs page for the Anthropic credential mentions only API Key and an optional custom header, but the credential in the n8n source also has a Base URL field (default https://api.anthropic.com, described as "Override the default base URL for the API").

Fill in:

  • API Key: your GoiAPI key, sk-...
  • Base URL: https://api.goiapi.com, without /v1. The Anthropic client adds /v1/messages itself.

When you save, n8n tests the credential with GET <Base URL>/v1/models plus an anthropic-version header. GoiAPI detects that header and answers in the Anthropic list format (List models). On December 3, 2026, direct calls to claude-haiku-5-5 and claude-opus-5-5 through /v1/messages both returned 200.

Why not send Claude through the OpenAI route? GoiAPI's docs recommend the Anthropic format for Claude models (Anthropic Messages). In our tests on December 3, 2026, all nine models returned 200 through /v1/chat/completions in the main run, but claude-haiku-5-5 returned a 503 through the OpenAI format in a separate run the same day. For OpenAI-format nodes, GPT, DeepSeek and GLM are the safer picks.

Check the model list n8n will see

Both OpenAI-style routes load models with GET /v1/models. Without an anthropic-version header, GoiAPI returns the OpenAI list format ({"object": "list", "data": [...]}), which is what n8n expects. You can run the same call yourself:

BASH
curl https://api.goiapi.com/v1/models -H "Authorization: Bearer sk-..."

On December 3, 2026 this returned HTTP 200 with nine models: claude-haiku-5-5, claude-opus-5-5, deepseek-v4-pro-0813, deepseek-v4.1-flash, glm-5.3, glm-5.3-flash, gpt-6-luna, gpt-6.1-sol, gpt-6.2-sol. Each item looks like this:

JSON
{"id": "claude-haiku-5-5", "object": "model", "created": 1796205941, "owned_by": "anthropic"}

If you restricted the key to certain models, only those appear. Listing models is not charged.

Build a minimal AI Agent workflow

The smallest chatbot you can test inside n8n has five pieces:

  1. Chat Trigger: receives messages from n8n's chat panel. Every message runs the workflow once, so a 10-message conversation is 10 executions (Chat Trigger docs, checked December 5, 2026).
  2. AI Agent: connected after the Chat Trigger.
  3. A chat model sub-node (Custom Endpoint Chat Model, OpenAI Chat Model or Anthropic Chat Model) attached to the agent's Chat Model connector. Without it, the agent fails with the "A Chat Model sub-node must be connected" error described in the n8n docs.
  4. Simple Memory (optional): lets the agent remember earlier turns in the conversation.
  5. At least one tool. The AI Agent docs (checked December 5, 2026) say you must connect at least one tool sub-node, and that all AI Agent nodes now work as a Tools Agent: the model decides when to call a tool.

Because the agent depends on tool calling, the model you pick has to handle it. GoiAPI passes the request parameters through to the model, but we have not tested tool calling with any model yet. Send a message that forces the agent to use its tool, then open the AI Agent's execution log and confirm the tool was actually called before you rely on the workflow.

Choosing a model for the n8n AI Agent

GoiAPI prices per 1M tokens, checked on December 5, 2026 on the pricing page:

ModelGood forInputOutput
gpt-6-lunaTesting, simple Q&A bots$0.0208$0.1248
deepseek-v4.1-flashHigh-volume, many-turn jobs$0.0408408$0.1225224
glm-5.3-flashSame role as DeepSeek V4.1 Flash$0.0408408$0.1225224
deepseek-v4-pro-0813, glm-5.3More careful answers$0.144144$0.432432
gpt-6.1-sol, gpt-6.2-solHard tasks, long writing$0.13$0.78
claude-haiku-5-5Claude via the Anthropic node$0.0221$0.1105
claude-opus-5-5Claude via the Anthropic node, hardest tasks$0.442$2.21

A note on the two "flash" models: deepseek-v4.1-flash and glm-5.3-flash produce reasoning tokens before the answer, and those count as output tokens. In our tests, a low output cap on deepseek-v4.1-flash was used up entirely by reasoning, so the reply came back empty but was still billed. Do not set Maximum Number of Tokens too low for these two. Model details: DeepSeek V4.1 Flash, GLM 5.3 Flash, GPT-6 Luna. For deeper price comparisons, see DeepSeek V4 API pricing, GLM 5.3 API pricing and Claude API pricing.

Fixing 401 and 404 errors in n8n

n8n usually shows the API's error message in the node's error panel. These are the messages GoiAPI returns for English accounts, from the error codes docs; the causes match the failures we reproduced with curl on December 3, 2026.

CodeCauseMessage from GoiAPIFix
401No key in the credentialMissing API key. Send your key in the Authorization: Bearer <key> header or the x-api-key header.Paste the key into the credential
401Wrong or revoked keyThe API key is invalid or has been revoked.Create a new key and paste it again
404Base URL missing /v1 (https://api.goiapi.com)Request goes to /chat/completions and fails with 404Add /v1 at the end
404Base URL ends with /chat/completionsThe path POST /v1/chat/completions/chat/completions does not exist.Use only https://api.goiapi.com/v1
404Anthropic credential Base URL ends with /v1The path POST /v1/v1/messages does not exist.Use https://api.goiapi.com
404Model name typoThe model <name> does not exist. See the list at /v1/models.Use From List, or copy the slug from the pricing page

A Base URL without /v1 also breaks the model list and the credential test, because GET /models misses the /v1 path too. Other codes you may hit: 402 (balance too low for the hold), 403 (the key is not allowed to use that model), 429 (requests per minute, spending limit or an overloaded model) and 503 (model temporarily not responding). They are all listed in Error codes. If you are used to Anthropic's own API, note that GoiAPI never returns 529; see Claude 529 overloaded error for how that maps.

How much does an n8n AI workflow cost to run?

One AI Agent run can call the model several times (once to decide on a tool, again to answer), and Simple Memory resends the conversation history on every call. The table below assumes one run makes 2 model calls, each with 2,000 input tokens and 500 output tokens, and no caching:

Model1 call1 run (2 calls)1,000 runs30,000 runs (about 1,000 a day for a month)
claude-haiku-5-5$0.000099$0.000199$0.20$5.97
gpt-6-luna$0.000104$0.000208$0.21$6.24
deepseek-v4.1-flash$0.000143$0.000286$0.29$8.58
glm-5.3-flash$0.000143$0.000286$0.29$8.58
deepseek-v4-pro-0813$0.000505$0.001009$1.01$30.27
gpt-6.1-sol$0.00065$0.0013$1.30$39.00
claude-opus-5-5$0.001989$0.003978$3.98$119.34

Formula: (input tokens × input price + output tokens × output price) ÷ 1,000,000, using the prices checked on December 5, 2026. Real costs can be higher because of the small minimum charge per request, reasoning tokens and the tool definitions the agent sends with every call. Put your own numbers into the cost calculator, then compare with the Request history page in the dashboard after a few test runs. If tokens and per-million pricing are new to you, AI API tokens explained covers the basics.

When this setup is not the right fit

  • You use n8n Cloud and only need OpenAI or Anthropic models. You can pick Use Gateway credits in the credential field of supported nodes and skip creating a key (OpenAI credential docs, checked December 5, 2026).
  • You already have a DeepSeek key and only use DeepSeek. n8n has a dedicated DeepSeek Chat Model node; its credential has the Base URL fixed at https://api.deepseek.com.
  • You need embeddings (for example a RAG chatbot over your documents) or OpenAI's built-in tools. GoiAPI does not offer an embeddings endpoint, and built-in tools such as web search are ignored.

FAQ

Can I use Claude in n8n with an API key that is not from Anthropic?

Yes. Use the Anthropic Chat Model node and an Anthropic credential, put your GoiAPI key in API Key and set Base URL to https://api.goiapi.com. The Base URL field exists in the credential even though the n8n docs page does not list it.

Does the n8n Base URL need /v1?

For the OpenAI credential and the Custom Model Endpoint credential: yes, use https://api.goiapi.com/v1. For the Anthropic credential: no, use https://api.goiapi.com. Never add /chat/completions or /messages; n8n appends those.

Why does my n8n credential test fail with a 404?

Usually the Base URL is missing /v1, has an extra path at the end, or (for Anthropic) has an extra /v1. A message starting with "The path" means the URL is wrong; "The model … does not exist" means the model name is wrong.

Can I set a custom Base URL on the OpenAI Chat Model node itself?

Only on node version 1.0. From version 1.1 onward the Base URL is set in the OpenAI credential, so create one credential per endpoint.

Should I turn off "Use Responses API" in n8n?

When the node points at GoiAPI, we suggest turning it off so the node uses Chat Completions, the path we tested with all nine models. The Responses API works too, but OpenAI's built-in tools are ignored and responses are not stored.

Which model is the most budget-friendly for an n8n AI Agent?

At the December 5, 2026 prices, gpt-6-luna, deepseek-v4.1-flash and glm-5.3-flash are the low-priced group on the OpenAI route, and claude-haiku-5-5 is in a similar range on the Anthropic route. Test that the model calls your tools correctly before going live, since we have not tested tool calling.

Get started with GoiAPI in n8n

  1. Create a GoiAPI account.
  2. Top up with USDT (TRC20 or BEP20) or Binance Pay. No credit card and no monthly fee. Top-ups are final and non-refundable, so add only what you plan to use; a few dollars covers thousands of test runs with the low-priced models above.
  3. Create a separate key for n8n on the API Keys page, with daily and monthly spending limits.
  4. Set the Base URL in your n8n credential: https://api.goiapi.com/v1 for the OpenAI and Custom Model Endpoint credentials, https://api.goiapi.com for Anthropic.
  5. Build the Chat Trigger + AI Agent workflow above and click Execute step.

The quickstart shows your first API call with curl if you want to confirm the key works before opening n8n.

Related posts