n8n + Claude and GPT: Custom Base URL Credentials and an AI Agent Example
As of 2026-11-25, n8n can use Claude and GPT through one QCode key with two credentials: an Anthropic credential whose Base URL is https://api.qcode.cc/api (for the Anthropic Chat Model and Anthropic nodes) and an OpenAI account credential whose Base URL is https://api.qcode.cc/openai/v1 (for the OpenAI Chat Model and OpenAI nodes, including GPT-6.2 Sol and Chinese models such as GLM, DeepSeek, Qwen and Kimi). This guide shows a five-minute first run, both credentials field by field, an AI Agent workflow, a scheduled summary workflow, cost control, and fixes for the errors people hit most.
QCode is an independent third-party API service. It is not operated by, endorsed by, or partnered with n8n, Anthropic, OpenAI or any model vendor. Node and credential names come from n8n's documentation and QCode's tested setup on docs.qcode.cc.
Updated 2026-11-26
Key facts
- Claude needs the Anthropic credential. QCode serves Claude only on the Anthropic Messages endpoint. An OpenAI Chat Model node cannot reach Claude on QCode; you would get
model_not_available_on_endpoint. - Base URLs. Anthropic credential:
https://api.qcode.cc/api(no/v1; the client adds/v1/messages). OpenAI credential:https://api.qcode.cc/openai/v1(exactly this, no trailing slash, no/chat/completions). - Runtime. This guide follows n8n's standard credentials UI; check n8n's own install docs for the Node.js version your release requires when you start it with
npx. - Models.
claude-sonnet-5-5($2 / $10 per million tokens) is a solid agent default;claude-haiku-5-5($0.10 / $0.50 for prompts up to 100K) suits classification;gpt-6.2-sol($2 / $10) is the default GPT choice. Live prices: /models. - Billing. Official API price × service multiplier, currently ×1.0 for Anthropic and OpenAI models. Pay-as-you-go packs need no subscription.
Fastest path: first reply in about five minutes
- Start n8n with Docker (or
npx n8nif your Node.js version meets n8n's requirement):
docker volume create n8n_data
docker run -it --rm --name n8n -p 5678:5678 \
-e GENERIC_TIMEZONE="Asia/Shanghai" -e TZ="Asia/Shanghai" \
-e N8N_ENFORCE_SETTINGS_FILE_PERMISSIONS=true \
-v n8n_data:/home/node/.n8n \
n8nio/n8n
- Open
http://localhost:5678and create the owner account. - Add first step → search OpenAI → Message a model → Create new credential (type OpenAI account).
- API Key = your
cr_key, Organization ID empty, Base URL =https://api.qcode.cc/openai/v1. Save. - Model =
gpt-6.2-sol, Prompt = "Say hello", then Execute step. The answer appears underoutput[0].content[0].text.
Replace the timezone with your own. If that works, your key and network are fine; everything below is n8n configuration.
Prerequisites
| Item | What you need |
|---|---|
| n8n | Self-hosted (Docker or npm) or n8n Cloud with your own credentials |
| Node.js (npm installs) | the version n8n's install docs require; very new majors can break native modules such as sqlite3 |
| QCode key | A cr_ key; consider a separate key per n8n instance so usage is easy to read |
| Network | The n8n server must reach api.qcode.cc (or asia.qcode.cc / us.qcode.cc) over HTTPS |
Quick key test from the n8n host, independent of n8n:
curl -sS https://api.qcode.cc/api/v1/messages \
-H "x-api-key: cr_your_key" \
-H "anthropic-version: 2023-06-01" \
-H "content-type: application/json" \
-d '{"model":"claude-haiku-5-5","max_tokens":64,"messages":[{"role":"user","content":"ping"}]}'
Credential 1: OpenAI account (GPT and Chinese models)
Credentials → Create credential → OpenAI (the type is shown as "OpenAI account"):
| Field | Value |
|---|---|
| API Key | cr_your_key (no spaces or quotes) |
| Organization ID | leave empty |
| Base URL | https://api.qcode.cc/openai/v1 (clear the default https://api.openai.com/v1 first) |
On save, n8n requests the model list with your key; success means the credential is created. This one credential serves the OpenAI app node (Message a model, etc.) and the OpenAI Chat Model sub-node used by AI Agent, Basic LLM Chain and other AI nodes.
Model IDs you can use here include gpt-6.2-sol, gpt-6.2-astra, glm-5.3, deepseek-v4-pro, qwen3.8-max and kimi-k3. Use the exact IDs from /models; if the dropdown is empty, switch the Model field to By ID and type the ID.
In the OpenAI Chat Model node, leave Use Responses API off. This guide uses Chat Completions for both GPT and Chinese models; test any other API type with a small request first.
Credential 2: Anthropic (Claude models)
Credentials → Create credential → Anthropic:
| Field | Value |
|---|---|
| API Key | cr_your_key |
| Base URL | https://api.qcode.cc/api (default is https://api.anthropic.com) |
| Add Custom Header | off |
Why no /v1? The default value is the bare host https://api.anthropic.com, and the client appends /v1/messages. Replacing only the host part with https://api.qcode.cc/api keeps that behavior.
Known quirk: some n8n versions show "Couldn't connect with these settings" in the Anthropic credential's built-in connection test even when the key works. If curl in section 1 succeeds, save anyway, open an Anthropic Chat Model node, select the credential and run a test message. If the node answers, the credential is fine.
In the Anthropic Chat Model node, choose the model from the list or switch to By ID and enter claude-sonnet-5-5, claude-haiku-5-5 or claude-opus-5-5. Useful options:
- Maximum Number of Tokens: raise it for long outputs.
- Sampling Temperature or Top P: set one, not both. Recent Claude models may reject requests that set both.
- Prompt Caching: 5 Minutes or 1 Hour caches the system prompt, tool definitions and history. For agents with long system prompts this can cut input cost; test caching with a small request on QCode before relying on the discount.
Workflow 1: AI Agent with Claude, memory and a tool
This is the pattern most people want: a chat that can call tools.
- Add first step → On chat message (When chat message received).
- Add AI Agent. In its options, write a System Message, for example: "You are an operations assistant. Use the HTTP tool to look up order status. Answer in the user's language."
- Click Chat Model + → Anthropic Chat Model → credential "Anthropic" → model
claude-sonnet-5-5. - Click Memory + → Simple Memory (keeps the last messages of each session; a context window of around 10 is enough to start).
- Click Tool + → HTTP Request Tool (for your internal API) or Calculator to test tool use.
- In the AI Agent options, keep Max Iterations modest (for example 5–10) so a confused agent cannot loop and burn tokens.
- Open the chat panel at the bottom of the canvas and ask a question that needs the tool.
To compare models, swap only the Chat Model sub-node: gpt-6.2-sol via OpenAI Chat Model, or glm-5.3 / qwen3.8-max for Chinese-language work. Tool calling with Chinese models through QCode should be tested on your own workflow before you rely on it.
Workflow 2: scheduled summaries with a cheap model
Not every step needs a frontier model. A daily digest:
- Schedule Trigger (every day at 09:00).
- HTTP Request or RSS Read to fetch items from your sources.
- Basic LLM Chain with OpenAI Chat Model →
deepseek-v4-proorgpt-6.2-sol, prompt: "Summarize these items in 5 bullet points with links." - Send Email, Slack or Telegram node to deliver it.
For classification or routing steps in bigger workflows, claude-haiku-5-5 is the cheapest Claude at $0.10 / $0.50 per million tokens (prompts up to 100K; $0.50 / $2.50 above). Track spend per key in the QCode dashboard (usage query guide) and see multi-model routing for more patterns.
RAG in n8n: embeddings come from elsewhere
Vector Store nodes (and the "Question and Answer Chain" with a retriever) need an Embeddings sub-node. Configure embeddings with a provider that serves them (an official embeddings API, or a local model through the Embeddings Ollama node), and keep QCode for the chat model that writes the answer. Check /models for what QCode currently lists, and test the embedding setup with a small request first.
Choosing an endpoint
| Region | OpenAI credential Base URL | Anthropic credential Base URL |
|---|---|---|
| Global (default) | https://api.qcode.cc/openai/v1 |
https://api.qcode.cc/api |
| Asia | https://asia.qcode.cc/openai/v1 |
https://asia.qcode.cc/api |
| North America / Europe | https://us.qcode.cc/openai/v1 |
https://us.qcode.cc/api |
The same key works on all three. Edit the credential's Base URL and save; every node using that credential follows.
Errors and fixes
| Symptom | Likely cause | Fix |
|---|---|---|
Request goes to https://api.openai.com/v1 |
Base URL left at default | Set the QCode URL, save, reopen the node to refresh models |
| 401 | Key copied with spaces, wrong key type, or plan inactive | Re-paste the cr_ key; check the plan in the QCode console |
| 404 | Base URL ends with /v1/v1, /chat/completions, or Anthropic URL has /v1 |
Use the exact URLs in this guide |
model_not_available_on_endpoint |
Claude ID in an OpenAI node, or GPT ID in an Anthropic node | Claude → Anthropic credential; GPT → OpenAI credential |
| Anthropic credential test says "Couldn't connect" | Known test quirk in some n8n versions | Save, then test from an Anthropic Chat Model node |
| Model dropdown empty | Model list not loaded | Re-save the credential, or switch Model to By ID |
| 400 about temperature / top_p on Claude | Both sampling options set | Keep only one of Sampling Temperature or Top P |
| Agent loops or runs out of iterations | Unclear tool descriptions or prompt | Improve tool descriptions; cap Max Iterations |
sqlite3 or native module errors on npx n8n |
Node.js version outside the range n8n supports | Install the Node.js version from n8n's docs, reopen the terminal |
| Vector store fails on embeddings | No embedding model configured | Use another embeddings provider (section 6) |
FAQ
Can I use Claude in n8n with the OpenAI Chat Model node?
Not with QCode. QCode serves Claude only on the Anthropic protocol, so use the Anthropic credential with Base URL https://api.qcode.cc/api and the Anthropic Chat Model node.
What Base URL goes in the n8n Anthropic credential?
https://api.qcode.cc/api, with no /v1 and no trailing slash. The client appends /v1/messages to whatever host you enter.
Does one QCode key work for both credentials?
Yes. The same cr_ key works on the Anthropic and OpenAI endpoints; the path decides the protocol. You can still create two keys if you want separate usage lines.
Which model should power an n8n AI Agent?
Start with claude-sonnet-5-5 or gpt-6.2-sol, both $2 / $10 per million tokens. Use claude-haiku-5-5 for cheap classification steps and reserve claude-opus-5-5 for hard reasoning.
Can n8n use DeepSeek, GLM, Qwen or Kimi through QCode?
Yes, through the OpenAI account credential with https://api.qcode.cc/openai/v1 and model IDs such as deepseek-v4-pro or glm-5.3. Test tool calling before using them inside agents.
Does QCode work for n8n RAG workflows?
For the chat model, yes. For embeddings, configure a provider that serves them; check /models for what QCode currently lists and test with a small request before relying on it.
Does this work on n8n Cloud?
Credentials with a custom Base URL are configured the same way. n8n Cloud also offers its own gateway credits; with your own credentials, billing for model calls goes to your QCode key.
Pay only for the runs you make
Automations often run in bursts: a migration week, a batch of documents, a test phase. QCode pay-as-you-go packs fit that pattern: no subscription, packs from $4 (for $30 of usage, valid 7 days), stackable, at official prices × 1.0 for Claude and GPT. If your workflows run every day, compare daily-credit plans on /pricing.