n8n: automating workflows with Claude and GPT

Set up one credential in n8n and call Claude, GPT and GLM from any workflow. Covers the built-in node and the HTTP Request node for edge cases.

5 min · · Updated · автоматизация

n8n can reach the gateway two ways: through the built-in node for the OpenAI-compatible API (works for GPT, GLM, and Claude too if you go through the OpenAI-style path) or through a raw HTTP Request node when you need something non-standard, like count_tokens.

Method 1 — the built-in OpenAI node

n8n's OpenAI-based nodes (including the AI Agent / Chat Model LangChain nodes) have a Base URL field in their credentials alongside API Key. Create a new credential:

  • API Key: fetch_your_key
  • Base URL: https://api.zukko.pro/v1

After saving, enter the exact model id in the node's model field: claude-opus-5-5, claude-sonnet-5, gpt-5.6-sol, gpt-5.6-luna, glm-5.3, or glm-5.3-flash (current list: GET https://api.zukko.pro/v1/models). If the node offers a fixed dropdown instead of a text field, there's usually a "custom model" toggle or a plain text field underneath it, since n8n's dropdown normally pulls from OpenAI's own model list and won't include ours.

Method 2 — HTTP Request for Claude and anything the node doesn't cover

For the Anthropic Messages API or token counting, it's simpler to build the request by hand with an HTTP Request node.

A node for Claude (POST https://api.zukko.pro/v1/messages):

  • Method: POST
  • URL: https://api.zukko.pro/v1/messages
  • Headers: Authorization: Bearer fetch_your_key, anthropic-version: 2023-06-01, Content-Type: application/json
  • Body (JSON):
bash
{
  "model": "claude-sonnet-5",
  "max_tokens": 512,
  "messages": [
    {"role": "user", "content": "{{ $json.text }}"}
  ]
}

The same shape works for /v1/messages/count_tokens, a free endpoint useful for estimating prompt length before an expensive step in the workflow, without an actual call to a model.

Handling errors in the workflow

n8n stops execution on a non-2xx response by default unless you enable "Continue On Fail" on the HTTP Request node. For automations that run unattended, it's worth branching explicitly on the error code:

  • 402 with insufficient_balance — the balance ran out; better to send a notification to a separate channel than let the workflow fail silently.
  • 429 with key_daily_limit_reached or key_monthly_limit_reached — you hit that specific key's cap (configured on the key's page under /app/api-keys); raise it there if a production automation needs more headroom.
  • 503 with model_disabled — the model has been switched off in the catalogue (this is not a 404 and not model_retired); worth logging separately and moving the node to a model from the current GET https://api.zukko.pro/v1/models list so a catalogue change doesn't slip by unnoticed.
  • 503 with provider_unavailable — a temporary state for that specific model; for critical workflows it's worth a delayed retry keyed specifically on this code, separate from other errors.

Idempotency for reruns

If a workflow can be rerun manually or auto-retried after a node failure, add an Idempotency-Key header derived deterministically from the input (a hash of the current item's $json, for instance). Repeating the same idempotency key within 24 hours returns the same response without charging again — this saves you when a text generation step already succeeded but a later node failed, and the whole workflow gets rerun.

Caching repeated prompts

If a step in the workflow sends the same prompt for the same kind of input (fixed-category classification, for example), turn on caching with the X-Zukko-Cache: true header (temperature: 0 also enables the cache, but only on models that accept that parameter; Claude models — claude-sonnet-5, claude-opus-5-5 — may reject a temperature other than 1 with a 400, so don't pass it to them) — an identical repeat request from the same user comes back instantly and free, with X-Zukko-Cache: hit in the response. For chat, the cache lasts up to 7 days, which covers most periodic workflows (daily digests, recurring reports).

Cost per run

Every regular (non-streaming) gateway response carries X-Zukko-Cost-Micros and X-Fetch-Balance-Cents headers (despite the name, the balance there is in microdollars: 1,000,000 = $1); responses with stream: true don't have them. In the HTTP Request node you can pull them out as separate fields via "Response" → "Include Response Headers" and log them to a table — handy for a workflow that tracks spend per step rather than only the final balance.

Keys are created at https://zukko.pro/app/api-keys and shown once. For production automations it's worth issuing a separate key with its own daily cap — that way a bug causing an infinite loop in a workflow doesn't drain the whole account balance.

Web search as a separate step before the main call

If a workflow builds its answer with a model that has no built-in search and needs current data, add another node hitting /v1/web-search before the main HTTP Request, and feed the result into the next step's prompt:

bash
{
  "method": "POST",
  "url": "https://api.zukko.pro/v1/web-search",
  "body": {"query": "{{ $json.searchQuery }}"}
}

That gives a two-step workflow: fresh data first, then the model processes it — without this step the model answers from what it knew at training time.

Monitoring spend with a separate workflow

A useful side scenario in n8n is a separate scheduled workflow (a Cron trigger once a day) that hits /v1/usage with cursor pagination and /v1/balance, sending a Slack or Telegram alert when the balance runs low:

bash
GET https://api.zukko.pro/v1/balance
Authorization: Bearer fetch_your_key

The model list with limits and pricing for such a dashboard comes from GET /v1/models/info — no key required, so that node can live in a shared workflow available to the whole team without exposing the key itself.

Referral program for agencies building on n8n

If you set up workflows like this for multiple clients and point them toward their own zukko.pro account, the referral program pays 10% of their top-ups — that's handled through the dashboard and needs no extra setup in n8n.

zukko

Pay 25×
less

for Claude Code & ChatGPT

One fetch_* key and base URL api.zukko.pro — for Cursor, Claude Code, Codex, and any SDK.

Get API keyDocumentation

api.zukko.pro · fetch_*

n8n + Claude/GPT node setup for automation · Zukko