---
title: "n8n AI Agent with a cheap OpenAI-compatible LLM | BroadRouter"
description: "Build n8n AI Agent workflows on a low-cost OpenAI-compatible model: which model to pick for tools, the settings that cut tokens, and the cost math per 10,000 runs."
url: https://broadrouter.com/blog/n8n-ai-agent-cheap-llm/
lang: en
updated: 2026-11-14
publisher: BroadRouter (a BroadNet site); API by BroadNet Inference, https://inference.broadnet.ai
---

# n8n AI Agent on a cheap LLM: setup, model choice and cost per run

By the BroadNet Inference team · 5 min read · Published 2026-11-14 · Updated 2026-11-16

Point n8n's OpenAI credential at a low-cost OpenAI-compatible API, enter the model by ID and turn off Use Responses API. Give the AI Agent a model with tool calling, such as Qwen3.8 27B or GLM 5.3. Keep Max Iterations low, memory short and tools few, and route simple classification to a cheaper model first.

## Key takeaways

-   n8n's AI Agent now always works as a Tools Agent and needs at least one tool, so the model must handle tool calls.
-   Cost per run is mostly input: system message, tool definitions and memory are resent on every iteration.
-   Max Iterations defaults to 10. Lower it, and keep Simple Memory's Context Window Length short.
-   At published prices, our example agent costs about 3 times more per run on GLM 5.3 than on Qwen3.8 27B.
-   Route easy steps to a Basic LLM Chain on Gemma 4 VL 26B, which is also available as a flat $0.50 hourly key.

**On this page**

1.  How do you connect the AI Agent to a cheaper model?
2.  Which cheap model can handle n8n tools?
3.  Where does an n8n agent spend tokens?
4.  Which settings cut cost the most?
5.  What does an n8n agent run cost?
6.  What breaks with cheap models in n8n?
7.  Where BroadNet Inference fits

n8n’s AI Agent node makes it easy to build an assistant that reads email, looks up records and replies. It also makes it easy to spend more than you planned, because each run can call the model up to ten times, resending the full prompt each time. This post shows how to run AI Agent workflows on a low-cost [OpenAI-compatible](https://broadrouter.com/glossary/openai-compatible-api/) model, which model to choose for tool use, which settings cut tokens, and what a run costs. For the credential and node setup itself, follow our [n8n setup guide](https://broadrouter.com/guides/n8n-openai-compatible/).

## How do you connect the AI Agent to a cheaper model?

1.  **Create an OpenAI credential** with your provider’s key and its Base URL, for example `https://inference.broadnet.ai/v1`.
2.  **Add an AI Agent node** and attach an **OpenAI Chat Model** sub-node with that credential.
3.  **Enter the model by ID**, not from the list, for example `broadnet/qwen3.8-27b`.
4.  **Turn off Use Responses API** if your provider serves chat completions, as BroadNet does.
5.  **Attach at least one tool.** n8n’s docs say you must connect at least one tool sub-node to an AI Agent.

When you set a non-OpenAI Base URL, n8n shows a notice that not every model supports tools or JSON response format. Take it seriously: it decides your model choice.

## Which cheap model can handle n8n tools?

n8n’s docs say all AI Agent nodes now work as a **Tools Agent**. The model must emit [tool calls](https://broadrouter.com/glossary/tool-calling/) reliably, or the agent loops or answers without using your tools.

| Model on BroadNet | Tools listed | Context | Best n8n use |
| --- | --- | --- | --- |
| [Qwen3.8 27B](https://broadrouter.com/models/qwen3.8-27b/) | Yes | 262,144 | Default for AI Agent; image input, Arabic tested |
| [GLM 5.3](https://broadrouter.com/models/glm-5.3/) | Yes | 1,048,576 | Agents over long documents |
| [Gemma 4 VL 26B](https://broadrouter.com/models/gemma-4-vl-26b/) | Not listed | 32,768 | Basic LLM Chain: classify, extract, route |
| [DeepSeek V4.1 Flash](https://broadrouter.com/models/deepseek-v4.1-flash/) | Not listed | 1,048,576 | Long-document chains, image input; test before agent use |

Qwen3.8 27B is the cheaper of the two tool-capable models on input, and n8n agents are input-heavy. Start there and move to GLM 5.3 if your tests show it handles your tools better; [GLM 5.3 vs Qwen3.8 27B](https://broadrouter.com/compare/glm-5.3-vs-qwen3.8-27b/) compares the two.

## Where does an n8n agent spend tokens?

Every iteration is a separate model call carrying:

-   the **System Message** you wrote,
-   the **definition of every connected tool**, including all tools from an MCP Client Tool node set to All,
-   the **memory window** from Simple Memory,
-   the user input, plus earlier tool calls and results in this run.

The output is usually short. So the bill is driven by input size times iterations. Our [agent token budget](https://broadrouter.com/blog/agent-token-budget/) post shows how to measure each part.

## Which settings cut cost the most?

1.  **Max Iterations.** It defaults to 10. Most support-style agents finish in 2 to 4. Set it to 4 or 5 so a confused run stops early.
2.  **Simple Memory’s Context Window Length.** It sets how many previous interactions are kept. Every one is resent on every iteration. Keep it small, for example 5.
3.  **Fewer tools.** On an MCP Client Tool node, use **Selected** or **All Except** instead of All.
4.  **Short tool output.** Have HTTP Request tools return only the fields the agent needs, not whole API responses.
5.  **Maximum Number of Tokens.** Qwen3.8 27B and GLM 5.3 reason first, and reasoning counts toward the limit. Leave it at the default or set a few thousand. Too small gives [empty output](https://broadrouter.com/guides/reasoning-tokens-empty-response/).
6.  **Route before the agent.** Put a Basic LLM Chain on Gemma 4 VL 26B in front to classify requests. Only the ones that need tools reach the agent.

For a fixed output shape, turn on **Require Specific Output Format** and attach a Structured Output Parser. It’s cheaper than asking the agent to reformat. More in [structured output](https://broadrouter.com/blog/structured-output-json-schema/).

## What does an n8n agent run cost?

Take a support agent: 3 iterations per run, about 4,000 input tokens and 300 output tokens per iteration. That’s 12,000 input and 900 output tokens per run. At 10,000 runs a month:

| Monthly tokens | Qwen3.8 27B | GLM 5.3 |
| --- | --- | --- |
| 120M input | $0.175 per 1M | $0.78 per 1M |
| 9M output | $2.17 per 1M | $3.46 per 1M |

Multiply and add. At the prices synced on 2026-11-14, GLM 5.3 costs about **3 times** more than Qwen3.8 27B for this workflow, before any cache discount. Halving iterations roughly halves the input line on either model; a shorter memory window cuts it by the share of each prompt that memory takes up.

A Gemma 4 VL 26B routing step adds little: 10,000 classifications at 800 input and 20 output tokens is 8M input at $0.10 per 1M and 0.2M output at $0.22 per 1M. If 40% of requests never reach the agent, that saves 40% of the agent line. For steady high volume on Gemma, BroadNet also sells a flat hourly key at $0.50 an hour: 120 requests a minute, one stream, 300,000 tokens a minute.

Run your own numbers in the [LLM API cost calculator](https://broadrouter.com/tools/llm-api-cost-calculator/), and check how far 30 requests a minute stretches with the [rate limit calculator](https://broadrouter.com/tools/llm-rate-limit-calculator/).

## What breaks with cheap models in n8n?

-   **Agent ignores tools.** The model isn’t listed with tool support. Switch to Qwen3.8 27B or GLM 5.3.
-   **“Bad request”.** Usually the Responses API toggle. The [setup guide](https://broadrouter.com/guides/n8n-openai-compatible/) has the fixes.
-   **429 in batches.** A pay-as-you-go key allows 30 requests a minute and 4 at once. Use Loop Over Items with a Wait node. See [errors and retries](https://broadrouter.com/guides/errors-and-retries/).
-   **MCP tools.** The MCP Client Tool node lets the agent call an external MCP server. Read [MCP with OpenAI-compatible models](https://broadrouter.com/blog/mcp-with-openai-compatible-models/) first.

## Where BroadNet Inference fits

BroadNet Inference gives n8n one OpenAI-compatible credential for Qwen3.8 27B and GLM 5.3 with tools, Gemma 4 VL 26B for cheap routing, and a $0.50 hourly Gemma key for steady batches. New accounts get $5 of credit, which covers Gemma 4 VL 26B; the tool-capable models need a top-up. It doesn’t fit workflows that need OpenAI-only features such as the Responses API’s built-in tools. Create a key at [inference.broadnet.ai](https://inference.broadnet.ai/?utm_source=broadrouter&utm_medium=referral&utm_campaign=blog-n8n-ai-agent-cheap-llm&utm_content=body).

Free tools for this

-   [Agent run cost estimator](https://broadrouter.com/tools/agent-run-cost-estimator/) Context growth per step, total tokens and cost of one agent run, with a DeepSeek session comparison.
-   [LLM batch job planner](https://broadrouter.com/tools/llm-batch-job-planner/) Run time, binding limit, cost per model and the flat sessions needed to finish a big job by a deadline.
-   [Flat-rate vs per-token LLM cost calculator](https://broadrouter.com/tools/flat-rate-vs-per-token-calculator/) Break-even between an unlimited plan and paying per token, per agent.
-   [LLM rate limit and concurrency calculator](https://broadrouter.com/tools/llm-rate-limit-calculator/) Which limit binds first: RPM, TPM or concurrency, with Little's law.

[All free tools](https://broadrouter.com/tools/)

## Terms in this article

[Token](https://broadrouter.com/glossary/token/)

A token is the unit of text a language model reads and writes: a word, part of a word, a punctuation mark or a byte sequence produced by the model's tokenizer. LLM APIs count, limit and usually bill usage in tokens.

[Tool calling](https://broadrouter.com/glossary/tool-calling/)

Tool calling, also called function calling, is an LLM API feature in which the model returns a structured request to run a function the developer has defined, with JSON arguments. The application runs the function and sends the result back; the model never runs code itself.

[AI agent](https://broadrouter.com/glossary/agent/)

An AI agent is a system in which a language model directs its own steps toward a goal: it decides which tools to call, reads the results and repeats until it produces a final answer or hits a limit. A fixed script that calls a model at set points is usually called a workflow instead.

[MCP (Model Context Protocol)](https://broadrouter.com/glossary/mcp/)

MCP (Model Context Protocol) is an open protocol, built on JSON-RPC 2.0, that standardises how LLM applications connect to external tools and data. An MCP server exposes tools, resources and prompts; an MCP client inside the host application discovers them and passes tool calls from the model to the server.

[Rate limit](https://broadrouter.com/glossary/rate-limit/)

A rate limit is a cap an API places on how much a client can use it in a time window, such as requests per minute or tokens per minute. Requests over the limit are refused, usually with HTTP 429 Too Many Requests, until usage falls back under it.

[Input and output tokens](https://broadrouter.com/glossary/input-and-output-tokens/)

Input tokens are the tokens a language model reads in a request, including the system prompt, conversation history, tool definitions and images. Output tokens are the tokens it generates in reply, including any reasoning. LLM APIs usually price them separately, and output usually costs more.

[Pay-as-you-go](https://broadrouter.com/glossary/pay-as-you-go/)

Pay-as-you-go is a pricing model in which you pay only for what you use, metered per unit such as tokens, requests or audio minutes, with no subscription or minimum commitment. Most LLM APIs bill this way, from a prepaid balance or a periodic invoice.

[Base URL](https://broadrouter.com/glossary/base-url/)

A base URL is the fixed root address of an API, such as https://api.example.com/v1, that a client puts in front of every endpoint path, such as /chat/completions. In OpenAI-compatible SDKs, changing the base URL, together with the API key and model ID, points the same code at a different provider.

## Questions

### Can I use a cheap LLM with the n8n AI Agent node?

Yes. The OpenAI Chat Model sub-node uses the OpenAI credential, which has a Base URL field. Point it at any OpenAI-compatible API, enter the model by ID and turn off Use Responses API if your provider serves chat completions.

### Which cheap model works with n8n tools?

One that supports tool calling, because the AI Agent always works as a Tools Agent. On BroadNet Inference, Qwen3.8 27B and GLM 5.3 list tool support. Gemma 4 VL 26B is cheaper but is not listed with tools, so use it in a Basic LLM Chain instead.

### Why is my n8n AI Agent so expensive?

Each iteration resends the system message, every tool definition and the memory window. An agent that loops five times with ten tools and long memory reads many times more tokens than the user typed. Lower Max Iterations, trim tools and shorten memory.

### What does Max Iterations do in the n8n AI Agent?

It limits how many times the model runs to produce an answer. The default is 10. Each iteration is a separate model call billed on its own.

### Why does my n8n agent hit 429 errors?

Parallel executions and loops share the key's limits. A BroadNet pay-as-you-go key allows 30 requests a minute and 4 at once. Pace batches with Loop Over Items and a Wait node.

## Keep reading

-   [OpenClaw and Hermes Agent on a cheap model: setup and token math](https://broadrouter.com/blog/openclaw-hermes-agent-cheap-model/)
-   [Use MCP servers with OpenAI-compatible models (any provider)](https://broadrouter.com/blog/mcp-with-openai-compatible-models/)
-   [Tool calling with open models: schemas, parallel calls, retries](https://broadrouter.com/blog/tool-calling-open-models/)
-   [JSON mode vs json\_schema: structured output that holds up](https://broadrouter.com/blog/structured-output-json-schema/)
-   [Agent token budget: where an agent loop's tokens go](https://broadrouter.com/blog/agent-token-budget/)
-   [Claude Code with open models: proxies, native endpoints and limits](https://broadrouter.com/blog/claude-code-with-openai-compatible-models/)
-   [Prompt injection in coding agents: defences that actually hold](https://broadrouter.com/blog/prompt-injection-coding-agents/)
-   [Guide: Use BroadNet Inference in n8n (OpenAI credential, Base URL)](https://broadrouter.com/guides/n8n-openai-compatible/)
-   [Guide: Use LangChain with BroadNet Inference](https://broadrouter.com/guides/langchain-openai-base-url/)
-   [Guide: BroadNet Inference error codes and when to retry](https://broadrouter.com/guides/errors-and-retries/)

Try it on your real workload. New accounts start with $5 of credit for Gemma and transcription. DeepSeek, GLM and Qwen3.8 need a top-up.

[Get started](https://inference.broadnet.ai/account/?utm_source=broadrouter&utm_medium=referral&utm_campaign=blog-n8n-ai-agent-cheap-llm&utm_content=page-cta) ·

**Sources**

-   [n8n docs, AI Agent node (checked 2026-11-14)](https://docs.n8n.io/integrations/builtin/cluster-nodes/root-nodes/n8n-nodes-langchain.agent/)
-   [n8n docs, Tools Agent options (checked 2026-11-14)](https://docs.n8n.io/integrations/builtin/cluster-nodes/root-nodes/n8n-nodes-langchain.agent/tools-agent/)
-   [n8n docs, OpenAI Chat Model node (checked 2026-11-14)](https://docs.n8n.io/integrations/builtin/cluster-nodes/sub-nodes/n8n-nodes-langchain.lmchatopenai/)
-   [n8n docs, Simple Memory node (checked 2026-11-14)](https://docs.n8n.io/integrations/builtin/cluster-nodes/sub-nodes/n8n-nodes-langchain.memorybufferwindow/)
-   [n8n docs, MCP Client Tool node (checked 2026-11-14)](https://docs.n8n.io/integrations/builtin/cluster-nodes/sub-nodes/n8n-nodes-langchain.toolmcp/)
-   [BroadNet Inference machine-readable prices (pricing.json)](https://inference.broadnet.ai/pricing.json?utm_source=broadrouter&utm_medium=referral&utm_campaign=blog-n8n-ai-agent-cheap-llm&utm_content=sources)
-   [BroadNet Inference API reference, limits](https://inference.broadnet.ai/docs?utm_source=broadrouter&utm_medium=referral&utm_campaign=blog-n8n-ai-agent-cheap-llm&utm_content=sources#limits)
