TokenLab

Frameworks & Platforms

n8n

Use TokenLab chat models as the language model inside n8n AI Agent workflows

Overview

n8n runs AI Agent workflows through the LangChain-style node set: an AI Agent node takes a Chat Model sub-node. The community node package n8n-nodes-tokenlab provides that chat model for TokenLab, so one credential and one Base URL cover every chat model in the catalog.

The package contains two pieces:

  • Credential TokenLab API (tokenlabApi): a Base URL and an API key.
  • Sub-node TokenLab Chat Model (tokenLabChatModel): outputs ai_languageModel, and loads the model list from GET /v1/models?category=chat.

Install

Community nodes have to be enabled on the instance first: Settings → Community Nodes, turn on community nodes (N8N_COMMUNITY_PACKAGES_ENABLED=true for self-hosted Docker).

n8n-nodes-tokenlab is an unverified community node, so it installs on self-hosted n8n only: n8n Cloud only lists verified community nodes. On a self-hosted instance, open Settings → Community Nodes → Install and enter n8n-nodes-tokenlab as the package name.

For a self-hosted instance where the package is baked into the image instead, add n8n-nodes-tokenlab to the instance dependencies and restart n8n; installing it with npm inside the n8n container alone does not register the node.

Create the credential

  1. Create an API key in the TokenLab dashboard.
  2. In n8n create a TokenLab API credential:
    • Base URL: https://api.tokenlab.sh (change it only if you call through your own proxy).
    • API Key: the key from step 1.
  3. Save. n8n sends the key as Authorization: Bearer <API key> and tests it by listing chat models.

Use it in a workflow

Add an AI Agent node

Add AI Agent to the canvas.

Attach the model

Add TokenLab Chat Model and connect it to the Agent with the ai_languageModel connection type.

Pick a model

Choose a model from the dropdown (it is loaded from your TokenLab catalog) or type a model ID directly, for example claude-sonnet-5-5, claude-haiku-4-5 or qwen3.8-max.

Run

Execute the workflow. Every run is billed to your TokenLab account at the same per-token price as the API.

A minimal workflow export with the two nodes wired together:

{
  "nodes": [
    {
      "parameters": {},
      "id": "agent-1",
      "name": "AI Agent",
      "type": "@n8n/n8n-nodes-langchain.agent",
      "typeVersion": 1.7,
      "position": [0, 0]
    },
    {
      "parameters": { "model": "claude-sonnet-5-5", "temperature": 0.7, "maxTokens": -1 },
      "id": "model-1",
      "name": "TokenLab Chat Model",
      "type": "n8n-nodes-tokenlab.tokenLabChatModel",
      "typeVersion": 1,
      "position": [-240, 0],
      "credentials": { "tokenlabApi": { "id": "REPLACE_WITH_CREDENTIAL_ID", "name": "TokenLab API" } }
    }
  ],
  "connections": {
    "TokenLab Chat Model": {
      "ai_languageModel": [[{ "node": "AI Agent", "type": "ai_languageModel", "index": 0 }]]
    }
  }
}

Choose a model

The dropdown lists the chat models your account can call. Copy the exact ID from the Models page when you want to pin a specific model ID. Non-chat modalities (images, embeddings, video) are not covered by this package; call them with the HTTP Request node against https://api.tokenlab.sh/v1.

Troubleshooting

SymptomFix
TokenLab Chat Model does not appear in the node listCommunity nodes are disabled on the instance, or the package is not installed; reinstall n8n-nodes-tokenlab and restart n8n
Credential test fails with 401The key was deleted or copied with a trailing space; create a new key in the dashboard
Model dropdown is emptyThe key has no model access on that account; check the account's catalog on the Models page
429 from a workflow runThe account hit its rate limit; see Rate limits

On this page