n8n is a workflow automation tool with AI nodes. Its OpenAI credential has a Base URL field, so the OpenAI Chat Model node, and through it the AI Agent node, can send OpenAI Chat Completions requests to Tokens at https://tokens.bd/v1. You set the address once on the credential and every node that uses that credential follows it.
This guide was checked against n8n 2.42.6 (the stable release of 9 October 2026), using n8n's documentation and the source of the OpenAI Chat Model node (node version 1.3), in October 2026. It was checked against the documentation and source, not run end to end against a live Tokens key.
What you need#
- A Tokens key. API keys covers creating one with a spend cap.
- A model ID from the model catalog. This guide uses
deepseek/deepseek-v4.1-flash. - n8n, either n8n Cloud or self-hosted, with a workflow where you can add an AI Agent node.
Where the Base URL lives#
The sources disagree, so here is what was checked.
- n8n's documentation does not mention it. The OpenAI credentials page lists only an API key and an Organization ID. The OpenAI Chat Model page does not mention a base URL either. Not documented by n8n.
- n8n's source does have it. The OpenAI credential defines a field named Base URL, described as "Override the default base URL for the API", with the default
https://api.openai.com/v1. The credential's own connection test calls/modelson that URL. - The node used to have its own. The OpenAI Chat Model node has a Base URL option only in node version 1. From node version 1.1 it is hidden, and the node reads the credential's Base URL instead. A workflow created today gets version 1.3, so use the credential.
- GitHub issue 14431 ("Allow setting custom base URL in OpenAI node") was closed as not planned on the day it was opened, with a maintainer reply that this is already possible. Later comments in that thread suggest using the provider's base URL directly. That matches the credential field.
If your n8n is older than the version checked and the credential has no Base URL field, update n8n first.
Set up the credential#
- In n8n, open Credentials and create a new credential of type OpenAI.
- API Key: your Tokens key.
- Organization ID (optional): leave it empty.
- Base URL:
https://tokens.bd/v1. End it at/v1, with no trailing slash and no/chat/completions. - Leave Add Custom Header off. Tokens needs no extra header.
- Save. n8n tests the credential by calling
GET /modelson the Base URL. A green result means the key and address are right.
API Key: tok_live_your_key
Base URL: https://tokens.bd/v1Not the gateway credits
On n8n Cloud, supported nodes offer "Use Gateway credits" in the credential field. That is n8n's own billing and does not go through Tokens. Pick the credential you just made instead.
On self-hosted n8n, keep the key in n8n's credential store rather than in workflow JSON or a node field you might export.
Use it in the AI Agent node#
- Add an AI Agent node, then click the Chat Model connector and add an OpenAI Chat Model sub-node.
- Credential to connect with: the credential you made.
- Model: choose By ID and type
deepseek/deepseek-v4.1-flash. Details are in the next section. - If the node shows a Use Responses API toggle, turn it off (see below).
- Connect tools or memory to the agent as usual.
Model IDs with a slash#
Tokens IDs look like provider/model. In node version 1.2 and later the Model field has two modes, From List and By ID.
- From List calls
GET /modelson your Base URL and lists what comes back. For a Base URL that is not api.openai.com, the node lists every model returned without filtering. The list shows only the models your key can use, so a key with an allowed-models list shows a shorter list. - By ID sends the text you type as the model name, unchanged. Use it if the list is empty or the model you want is missing. The slash needs no escaping.
A third-party report says you can switch the field to expression mode and type the ID as a string. The n8n documentation does not describe that, and By ID makes it unnecessary, so this guide does not rely on it. On older workflows whose node version is 1.1 or lower, the Model field is a plain dropdown without a By ID mode. n8n's documentation does not say how to enter an ID there. Recreate the node, which gives you the current version.
Turn off Use Responses API#
In node version 1.3 the OpenAI Chat Model has a Use Responses API toggle. n8n's documentation says Chat Completions is the default. The node source defaults the toggle to on for newly added nodes. Open the node and check the toggle yourself.
Tokens serves /v1/responses only when the upstream behind the model supports it (Responses API). Chat Completions works across the catalog, so switch the toggle off. The Built-in Tools (Web Search, File Search, Code Interpreter) belong to the Responses API and to OpenAI itself, so they do not apply to Tokens.
Check that it works#
Test the key and model with curl first. If this works and n8n fails, the problem is in n8n's settings.
export TOKENS_API_KEY=tok_live_your_key
curl -s https://tokens.bd/v1/chat/completions \
-H "Authorization: Bearer $TOKENS_API_KEY" \
-H "Content-Type: application/json" \
-d '{"model": "deepseek/deepseek-v4.1-flash", "max_tokens": 16, "messages": [{"role": "user", "content": "Reply with OK"}]}'In n8n, add a Chat Trigger and the AI Agent node, open the chat and send a short message. The agent answers, and the request appears in your Tokens dashboard usage analytics. To compare against the node, an HTTP Request node pointed at the same URL gives you the raw error body, which n8n's own documentation also suggests when the OpenAI node reports "Bad request".
Tool calling#
The AI Agent node always works as a tools agent: it decides which connected tools to call, and n8n documents the OpenAI Chat Model as one of the models it supports. Tool calling needs a model that supports it, and no n8n setting turns it on. When a Base URL override is set, the OpenAI Chat Model node itself warns that models other than OpenAI's may not support tool calling or JSON response format.
Check the model's page in the model catalog before building an agent on it, and see Tool calling and Choosing a model. The node sets strict tool calling off, which is what OpenAI-compatible backends expect.
What costs credits in the background#
Every model call is billed to the key. An n8n agent can make many.
- The agent calls the model again after each tool result. Max Iterations (default 10 in the Tools Agent options) is the limit on those rounds for one run.
- Each round sends the conversation again, plus memory and tool output, so input tokens grow with every round.
- The Chat Model has a Max Retries option. n8n's source uses 2 when it is unset, so a failing call can be sent more than once.
- A Schedule or Webhook trigger starts the loop with nobody watching, and a workflow that processes many items runs the agent once per item.
Use a dedicated key for n8n with a monthly spend cap and an allowed-models list (API keys). When the cap is reached, requests fail with 403 monthly_spend_cap_exceeded instead of running up a bill. Lower Max Iterations for simple agents and set Maximum Number of Tokens in the node's options.
Limits and what is not covered#
- Only the OpenAI Chat Model sub-node was checked. The standalone OpenAI node and the Embeddings OpenAI node use the same credential, but n8n does not document them against a custom Base URL, so they are not covered here. Tokens' embeddings endpoint works only for embedding models (Models and usage).
- Tokens does not support image, audio, file or assistants endpoints, so those operations in the OpenAI node return 404
unsupported_endpoint. - The Responses-only options and built-in tools are not usable (see above).
Troubleshooting#
The credential test fails with 401. missing_api_key or invalid_api_key means the key was not pasted correctly, or it was revoked or rotated. Copy it again from the dashboard.
404 on the credential test or on every request. Check that the Base URL is https://tokens.bd/v1: it needs /v1, no trailing slash, and no /chat/completions on the end.
404 model_not_found. The model ID must be the full Tokens ID, for example deepseek/deepseek-v4.1-flash, not the part after the slash. Choose By ID and check it against GET /v1/models.
403 model_not_allowed_on_key. The key has an allowed-models list that does not include this model. Use an allowed model or a key without the restriction.
400 invalid_request, or an error about the Responses API. Turn off Use Responses API. For other 400s, use the HTTP Request node to see the whole error body, then check that the model supports the parameters the node sends.
The agent never calls its tools, or tool arguments come back broken. The model probably does not handle tool calling well. Try another model from the catalog.
429 rate_limited or concurrency_limit. A workflow processing many items sends requests in parallel. n8n's documentation suggests the Loop Over Items node with a Wait node at the end to send smaller batches. Wait for Retry-After seconds (Rate limits).
402 insufficient_credits. Top up or renew in billing. Note that n8n's own help text for "Insufficient quota" is written for OpenAI accounts and does not apply to Tokens.
Every code is listed in Errors. When you contact support, include the x-tokens-request-id header from a curl run of the same call.
Sources: n8n OpenAI credentials, OpenAI Chat Model node and its common issues, AI Agent node and its Tools Agent page, n8n issue 14431, and the n8n source tagged [email protected] (the OpenAI credential and the OpenAI Chat Model node), checked October 2026.