Models → Pricing → Docs → Blog → Changelog → Contact → Status →
Get started freeLog in

Build an n8n AI Agent with FreeModel

A small, working n8n workflow: a chat trigger, an AI Agent, a FreeModel chat model, memory and one tool. Then the same call done by hand with an HTTP Request node.

n8n is a workflow automation tool with built-in AI nodes. Its OpenAI credential has a Base URL field, which means any OpenAI-compatible API can stand in for OpenAI. In this tutorial we build a small agent on FreeModel and look at the parts that usually trip people up.

What we are building: a chat window where you ask a question, an agent that can use a calculator tool, and memory so it remembers the last few messages.

What you need

  • n8n, either n8n Cloud or self-hosted. Both reach https://freemodel.in over the internet.
  • A FreeModel key from Dashboard → API Keys. Create a dedicated key for n8n so you can revoke it on its own.
  • A model id. This tutorial uses gpt-6-luna, one of the free models. Free tokens need a one-time Telegram verification, no card.

Step 1: Create the credential

In n8n, create a new credential of type OpenAI and fill it in:

FieldValue
API Keyyour fm_ key
Organization IDleave empty
Base URLhttps://freemodel.in/v1

Save it. n8n tests the credential by calling the API; with FreeModel that means GET /v1/models, so the key needs the models:read scope (new keys have it by default). Give the credential a clear name such as "FreeModel" so you do not confuse it with a real OpenAI credential later.

Step 2: Add a chat trigger and an AI Agent

  1. Create a new workflow.
  2. Add a chat trigger (the trigger that fires when a chat message is received). It gives you a test chat window inside n8n.
  3. Add an AI Agent node after it. The agent takes the chat message as its input.

The AI Agent node has slots underneath it for a chat model, memory and tools. We fill those next.

Step 3: Attach the FreeModel chat model

  1. In the agent's chat model slot, add OpenAI Chat Model.
  2. Select the FreeModel credential from Step 1.
  3. For the model, pick gpt-6-luna from the list, or switch the field to enter an ID and type it.

The model list comes from FreeModel's /v1/models. If the model you want is not shown, enter the id by hand; it must match exactly. FreeModel only serves listed ids and does not map names like gpt-4o to another model.

Leave the node's options at their defaults to start. If you later raise the maximum tokens, remember that output tokens count toward your plan just like input tokens.

Step 4: Add memory and a tool

  • Memory: add n8n's simple in-workflow memory to the memory slot and keep the default context window. The agent now sees recent messages from the same chat session.
  • Tool: add the Calculator tool to the tools slot. It is the simplest tool to test with.

Tools work through tool calling, so the chat model must have the Tools capability. All free models do; for others, check the models page.

Step 5: Test it

Open the chat window and ask: "What is 1234 multiplied by 5678? Use the calculator." In the execution view you should see the agent call the model, the model ask for the Calculator tool, the tool run, and a final answer.

Each turn is at least two model calls when a tool is used: one to decide on the tool and one to write the answer. That is normal and is why agent workflows use more tokens than a single prompt.

The manual route: HTTP Request node

Sometimes you want full control over the request, for example to use a model the AI nodes do not offer, or to send exactly the JSON you tested with curl. An HTTP Request node does that:

  • Method: POST
  • URL: https://freemodel.in/v1/chat/completions
  • Header Authorization: Bearer fm_your_key_here (better: a header-auth credential)
  • Body: JSON
{
  "model": "gpt-6-luna",
  "messages": [
    { "role": "system", "content": "You summarise support tickets in one sentence." },
    { "role": "user", "content": "{{ $json.ticket_text }}" }
  ]
}

The answer is at choices[0].message.content in the response. The full request and response format is in the Chat Completions docs. In n8n, write the body as an expression so the ticket text is inserted safely.

Running it in production

  • Handle errors. Turn on n8n's error output for the AI node or HTTP node and branch on the status: 402 means tokens are used up (tokens_exhausted) and nothing was charged; 429 means the per-key rate limit; 503 means the model is temporarily unavailable.
  • Respect rate limits. Limits are per key and per plan: 30 requests per minute on the free plan (whole account), from 120 on Starter up to 1,500 on Ultra. Batch-heavy workflows should add a wait between items.
  • Watch your volume. The free plan has no daily cap, but a free account is limited to 400K tokens per minute. A workflow that runs on every incoming e-mail can reach that faster than you expect.
  • Paid models. Claude Haiku 5.5 and GPT-6.2 Astra are on the free plan; the other Claude models, GPT-6 Astra, Gemini and the other premium models need a paid plan. Plans are prepaid for 30 days, from $1.20, with no auto-renew. See pricing.

FAQ

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

Yes. Both call https://freemodel.in/v1 over the internet, so the same credential works in either.

My model is not in the model list. What now?

Switch the model field to enter an ID and type the FreeModel id exactly, for example gpt-6-luna. The list is only a convenience; the id is what is sent.

Does the AI Agent node need tool calling?

Yes, as soon as you connect a tool. Pick a model with the Tools capability, which all of the free models have.

Why did my workflow stop with a 402 error?

The account ran out of tokens. Nothing is charged for that request. Add an error branch in n8n so the workflow handles it.

Ready to build?

Grab a free API key — 1M tokens on 8 free models after a one-time Telegram verification, no card. Every model from $1.20.