# Connect n8n to Claude and GPT via API, step by step

> Set up n8n's OpenAI and Anthropic credentials with our base URL, choose the model by ID, build an AI Agent workflow and see what each run costs.

Updated: 2026-11-03

n8n's OpenAI and Anthropic credentials both have a Base URL field. To run your workflows on 5abeer, put our base URL there, paste a key for that provider and set the model by its ID. Then connect the chat model to an AI Agent node, and each call is paid per token from your 5abeer balance.

## How does n8n connect to Claude and GPT?

An AI workflow in n8n has a root node, such as **AI Agent**, and a chat model sub-node, such as **OpenAI Chat Model** or **Anthropic Chat Model**, that sends the requests. The chat model reads its address and key from a credential with a **Base URL** field, so you need no community node.

5abeer is OpenAI-compatible: change the base URL and keep your code. It is also compatible with the Anthropic Messages API, the format the Anthropic node sends. [What is a base URL?](https://5abeer.ai/en/guides/what-is-base-url) explains the term.

Each key works with one provider's models, and all keys draw on one balance, as [One key per provider](https://5abeer.ai/en/docs/start/keys.md#per-provider) explains.

## What you need

- A 5abeer balance, topped up with one of the [payment methods](https://5abeer.ai/en/docs/start/payment.md).
- A key for each provider you will use, created as in [Create a key](https://5abeer.ai/en/docs/start/keys.md#create).
- n8n Cloud or self-hosted n8n. The AI nodes are built into both.

Every setting below matches n8n 2.45.7, the stable release when we checked on 2026-11-03. Labels can change in later releases. Each credential takes its own base URL:

| n8n credential | n8n's default Base URL | Our base URL |
| --- | --- | --- |
| OpenAI | `https://api.openai.com/v1` | `https://api.5abeer.ai/v1` |
| Anthropic | `https://api.anthropic.com` | `https://api.5abeer.ai` |

The OpenAI URL keeps `/v1`. The Anthropic URL has none, because the node adds `/v1/messages` itself.

## How to set up your first AI agent

### 1. Add a Chat Trigger

Add a **Chat Trigger** node to a new workflow. It appears as **When chat message received** and runs the workflow for each message you send in the chat panel.

### 2. Add an AI Agent

Add an **AI Agent** node after the trigger and keep **Source for Prompt (User Message)** on **Connected Chat Trigger Node**.

### 3. Attach a chat model

Click the agent's **Chat Model** connector and pick **OpenAI Chat Model** for GPT or **Anthropic Chat Model** for Claude.

### 4. Send a test message

A reply means the credential, base URL and model ID all work. If a node turns red, open it, read the error and see the common errors below.

## How to connect GPT models

The newest GPT models, at our price per million tokens:

| Model | Id | Input (ours) | Output (ours) | Context |
| --- | --- | --- | --- | --- |
| GPT-6.1 Sol | `gpt-6.1-sol` | $0.60 | $3 | 922K |
| GPT-6 Astra | `gpt-6-astra` | $3 | $15 | — |
| GPT-6 Sol | `gpt-6-sol` | $0.60 | $3 | 922K |

### 1. Create a key for GPT models

Create a key for the OpenAI provider, as in [Create a key](https://5abeer.ai/en/docs/start/keys.md#create). Name it after the workflow, such as `n8n-support`, to find its usage easily.

### 2. Create the OpenAI credential

In the **OpenAI Chat Model** node, create a new **OpenAI** credential. Paste your key in **API Key**, leave **Organization ID (optional)** empty and set **Base URL** to `https://api.5abeer.ai/v1`. On save, n8n tests the credential by asking that address for the model list.

### 3. Set the model by ID

In **Model**, switch from **From List** to **ID** and paste a model ID from the table above, exactly as written. The full catalog is on the [models page](https://5abeer.ai/en/models).

### 4. Check two switches

Keep **Use Responses API** on, its default, since 5abeer serves GPT models in the Responses format. Leave **Built-in Tools** empty: its Web Search, File Search and Code Interpreter run on OpenAI's own platform, so give the agent tool nodes instead.

## How to connect Claude models

The newest Claude models, at our price per million tokens:

| Model | Id | Input (ours) | Output (ours) | Context |
| --- | --- | --- | --- | --- |
| Claude Sonnet 5.5 | `claude-sonnet-5.5` | $0.60 | $3 | 1M |
| Claude Opus 5.5 | `claude-opus-5.5` | $1.20 | $6 | 1M |
| Claude Fable 5.1 | `claude-fable-5.1` | $3 | $15 | — |

### 1. Create a key for Claude models

Create a second key, this time for the Anthropic provider. It draws on the same balance as your GPT key.

### 2. Create the Anthropic credential

In the **Anthropic Chat Model** node, create a new **Anthropic** credential. Paste your Claude key in **API Key** and set **Base URL** to `https://api.5abeer.ai`. A URL ending in `/v1` doubles the path, and every request fails.

### 3. Set the model by ID

In **Model**, switch to **ID** and paste [`claude-sonnet-5.5`](https://5abeer.ai/en/models/claude-sonnet-5.5), the default model, for most workflows. Use [`claude-opus-5.5`](https://5abeer.ai/en/models/claude-opus-5.5) or [`claude-fable-5.1`](https://5abeer.ai/en/models/claude-fable-5.1) for the hardest steps.

### 4. Leave Options empty for the first run

Add no options until your first test gets a reply; the next section covers them.

## Which node options matter on 5abeer?

These entries in each node's **Options** list change what you get or pay on 5abeer:

| Node | Option | What to do |
| --- | --- | --- |
| OpenAI Chat Model | **Sampling Temperature**, **Top P** | Skip them: our [Responses reference](https://5abeer.ai/en/docs/api/responses.md#params) lists both as ignored for GPT models. |
| OpenAI Chat Model | **Conversation ID** | Leave it empty. Each request [stands alone](https://5abeer.ai/en/docs/api/responses.md#conversation) here, so keep the chat history with a memory node. |
| OpenAI Chat Model | **Prompt Cache Key** | Set one fixed value per workflow, so its similar requests [hit the same cache](https://5abeer.ai/en/docs/api/caching.md#gpt). |
| Anthropic Chat Model | **Sampling Temperature**, **Top K**, **Top P** | Skip them: n8n's hint says newer Claude models don't support them, so the node drops them. |
| Anthropic Chat Model | **Thinking Mode** | Leave it unset, so each model uses its default. For harder steps, choose **Adaptive (Recommended)** with an **Effort** of Low, Medium or High, the levels our [Messages reference](https://5abeer.ai/en/docs/api/messages.md#params) lists. Skip the legacy **Manual (Deprecated)**. |

Never set **Thinking Mode** to **Disabled** on [`claude-fable-5.1`](https://5abeer.ai/en/models/claude-fable-5.1): Anthropic's [migration guide](https://platform.claude.com/docs/en/models/fable-5-1/migration-guide), checked on 2026-11-03, says this model always thinks and rejects a request that turns thinking off. Thinking adds output tokens, so after you raise **Effort**, run one test and read its usage.

## How to add memory, tools and a fallback model

- **Memory**: attach **Simple Memory** to the agent's **Memory** connector. Its **Context Window Length**, 5 by default, sets how many past exchanges go with each call, each billed again as input.
- **Tools**: attach tool nodes, such as **HTTP Request Tool** or **Call n8n Sub-Workflow Tool**, to the **Tool** connector, and the agent calls them when needed. Claude and GPT both accept tools, as [What each family supports](https://5abeer.ai/en/docs/api/tools.md#support) shows.
- **Fallback model**: turn on **Enable Fallback Model** in the agent and attach a chat model from the other provider, such as GPT behind Claude, to the new **Fallback Model** connector. The agent uses it when the main model fails.

For one prompt per item, such as tagging rows, use **Basic LLM Chain** with the same chat model.

## What does an n8n agent cost?

You pay per token from your balance. Input grows fastest in an agent: each call carries the system message, the remembered messages, the tool definitions and the new message, and one chat turn can take several calls when the agent uses tools.

For example, a support agent that sends ten million tokens a month and gets one million back, on the default model:

Example: 10,000,000 input tokens and 1,000,000 output tokens on Claude Sonnet 5.5 (`claude-sonnet-5.5`) cost $9.00 at our price against $30.00 at the official price (70% lower). Official price checked October 19, 2026.

To keep the bill down:

- Keep the system message short, attach only the tools the agent needs and keep **Context Window Length** low.
- Use a cheaper model for simple steps.
- Give each workflow its own key and read its usage, as in [Track your usage](https://5abeer.ai/en/docs/start/pricing.md#usage).

[Prompt caching](https://5abeer.ai/en/docs/api/caching.md) and [Cut your LLM API bill](https://5abeer.ai/en/guides/cut-llm-api-costs) cover more ways to spend less. The official price of each model sits next to ours on the [Claude API page](https://5abeer.ai/en/api/claude) and the [OpenAI API page](https://5abeer.ai/en/api/openai).

## Common errors and fixes

If the credential test fails on save, check the base URL first (`/v1` for OpenAI, none for Anthropic), then the key. During a run:

- [`INVALID_API_KEY`](https://5abeer.ai/en/docs/help/errors.md#INVALID_API_KEY): the key is wrong or incomplete. Paste it again.
- [`MODEL_PLATFORM_NOT_ALLOWED`](https://5abeer.ai/en/docs/help/errors.md#MODEL_PLATFORM_NOT_ALLOWED): the key belongs to another provider, such as a GPT key in the Anthropic credential.
- `The model "…" was not found at …`: the Anthropic node shows this when the address answers that the model doesn't exist. Paste the exact ID from the [models page](https://5abeer.ai/en/models).
- `does not support disabling thinking`: **Thinking Mode** is **Disabled** on a model that always thinks. Remove the option or choose **Adaptive (Recommended)**.
- [`INSUFFICIENT_BALANCE`](https://5abeer.ai/en/docs/help/errors.md#INSUFFICIENT_BALANCE): your balance doesn't cover the request. Top up and retry.
- [`API_KEY_QUOTA_EXHAUSTED`](https://5abeer.ai/en/docs/help/errors.md#API_KEY_QUOTA_EXHAUSTED): the key reached the spend limit you set on it.

Every code is explained in [Errors and fixes](https://5abeer.ai/en/docs/help/errors.md).

## FAQ

### Does this work on n8n Cloud and on self-hosted n8n?

Yes, the credentials and nodes are the same. On a self-hosted server with a fixed IP, you can also add that IP to the key's allow-list, as in [Control every key](https://5abeer.ai/en/docs/start/keys.md#controls).

### Can I use Gemini models in n8n?

Yes, through the **OpenAI Chat Model** node. Use a key for Gemini models in an **OpenAI** credential with our OpenAI-format URL, set the model by ID and turn **Use Responses API** off: our [Responses format](https://5abeer.ai/en/docs/api/responses.md) serves Claude and GPT only. Gemini model IDs and prices are on the [Gemini API page](https://5abeer.ai/en/api/gemini).

### Which model should an n8n agent start with?

[`claude-sonnet-5.5`](https://5abeer.ai/en/models/claude-sonnet-5.5), the default model, handles most agent work. Move a step to [`claude-opus-5.5`](https://5abeer.ai/en/models/claude-opus-5.5) only when your tests show the default model gets it wrong.

### How do I stop one workflow from overspending?

Give the workflow its own key with a spend limit and an expiry date, as in [Control every key](https://5abeer.ai/en/docs/start/keys.md#controls). At the limit, its calls return `API_KEY_QUOTA_EXHAUSTED`, while your other keys keep working.

### Who bills the model calls, n8n or 5abeer?

With a 5abeer key, each model call is billed per token from your 5abeer balance, which you top up with any method in [Payment methods](https://5abeer.ai/en/docs/start/payment.md#methods). Running n8n itself, on n8n Cloud or on your own server, is a separate cost.

### Is 5abeer part of n8n, OpenAI or Anthropic?

No. 5abeer is an independent service, not affiliated with OpenAI, Anthropic or Google, and not part of n8n. It works in n8n because our API accepts the formats these nodes send.

## Get started

Top up your balance, create a key for each provider and paste it into the n8n credential. Every model and price is on the [API page](https://5abeer.ai/en/api).
