Package Information
Available Nodes
Documentation generatingβ¦
Documentation
n8n-nodes-cloudflare-ai
Cloudflare Workers AI nodes for n8n: a Cloudflare Chat Model that plugs directly into the AI Agent node, plus Embeddings, Text-to-Image, Text-to-Speech and Speech Recognition nodes. All share one Cloudflare Workers AI API credential. The chat and embeddings models are native LangChain models, so they compose with n8n's agent and RAG chains (streaming, tool calling, structured output, vector stores).
Note: this package assumes self-hosted n8n. Community nodes run with the permissions of your n8n instance, so only install packages you trust. If you are on n8n Cloud, check your community-node settings first.
Key features
- π§
Cloudflare Chat Modelfor the AI Agent node - π§²
Cloudflare Embeddingsfor Document Embedder / Vector Store (RAG chains) - πΌοΈ
Cloudflare Text to Imageβ generate an image from a prompt (binary output) - π
Cloudflare Text to Speechβ synthesize speech from text (binary output) - π€
Cloudflare Speech Recognitionβ transcribe audio to text (JSON output) - π One dedicated credential type: Cloudflare Workers AI API (shared by all nodes)
- π Dynamic model picker powered by Cloudflare's model-search endpoint, filtered per task
(chat pickers only list text-generation models, embeddings pickers only list embedding models, β¦) - β‘ Streaming support (chat)
- π§° Tool calling support (chat)
- π§± Structured output support (via LangChain tool binding)
- π Automatic retries with bounded backoff
- β±οΈ Automatic fallback across models, with a user-defined ordered list
- π "Free models only" filter in the picker
Requirements
- n8n (self-hosted) β v1.x
- Node.js β₯ 18 (the package uses the global
fetch) - A Cloudflare account with Workers AI enabled
- Account ID (32-hex string from your Workers AI dashboard)
- API Token with permissions for Workers AI
Getting your Cloudflare credentials
To get a Account ID and an API Token:
- Account ID β from the right-hand sidebar of the Cloudflare dashboard (a 32-character hex string), or under My Profile β API Tokens.
- API Token β go to My Profile β API Tokens β Create Token β use the Workers AI template (or a custom token with Account β Workers AI β Read).
The full, step-by-step guide (including a
curlverification command) is in the Installation guide.
Requirements of the install, at a glance
The package is distributed as an n8n community node. Detailed, step-by-step install options (n8n UI, local tarball, environment-variable management) are in the dedicated guide:
π Installation guide
Quick option β via the n8n Community Nodes flow:
- Open n8n β
SettingsβCommunity Nodes. - Install the package name
n8n-nodes-cloudflare-ai. - Refresh the nodes panel and search for Cloudflare Chat Model.
- Connect it to the AI Agent chat-model input.
Configuration
1. Create a credential
Create a credential of type Cloudflare Workers AI API and fill:
| Field | Description |
|---|---|
Account ID |
Your Cloudflare account ID (32-hex). |
API Token |
A token with access to Workers AI. |
AI Gateway ID |
Cloudflare AI Gateway to route requests through (sets the cf-aig-gateway-id header). default for the default gateway; leave empty to call Workers AI directly. |
The credential test calls Cloudflare's model-search endpoint to verify the token.
2. Configure the node
The Cloudflare Chat Model node exposes the following parameters:
| Parameter | Notes |
|---|---|
| Model Source | Automatic (from the picker) or Custom (type an ID manually). |
| Model | Dynamic options loaded from Cloudflare. Shown when source is Automatic. |
| Custom Model ID | e.g. @cf/qwen/qwen3-30b-a3b-fp8. Shown when Custom. |
| Show free models only | Only list models Cloudflare marks as free in the picker (default on). |
| Max Retries | 1β10 (default 3). Retry attempts for transient failures. |
| Auto Fallback | When enabled, try the next model if the primary fails. |
| Fallback Models | Ordered list of fallback models (shown when fallback is on). |
| Temperature | 0β2 (default 0.7). Creativity/randomness. |
| Top P | 0β1 (default 1). Nucleus sampling. |
| Max Tokens | -1 (no limit) up to 32768. Omitted when -1. |
| Frequency Penalty | -2β2 (default 0). |
| Presence Penalty | -2β2 (default 0). |
| System Prompt | Optional system message prepended to the conversation. |
β Important: These are symmetric documentation tables only. The exact node UI follows n8n convention, and the picker order respects your
Model Sourcesetting.
3. Other nodes
| Node | Output | Typical usage |
|---|---|---|
| Cloudflare Embeddings | ai_embedding (LangChain Embeddings) |
Connect to the Embeddings input of a Document Embedder or Vector Store. |
| Cloudflare Text to Image | binary (main) | Takes a Prompt string, returns an image (e.g. PNG) in the binary output. |
| Cloudflare Text to Speech | binary (main) | Takes a Text string, returns audio (e.g. MP3) in the binary output. |
| Cloudflare Speech Recognition | JSON (main) | Takes an audio file from the input binary, returns { text, ... }. |
All four use the same Cloudflare Workers AI API credential. The embeddings node is a model
node (no input); the other three are action nodes that pass through a main connection. Each hasModel Source (Automatic/Custom), a task-filtered model picker, and the Show free models only
toggle, matching the chat node's UX.
How it works
The chat node is implemented as a LangChain
BaseChatModel, so it appears in the AI Agent
model slot β not as a chat-action node.The embeddings node is a LangChain
Embeddingsmodel, so it appears in the Embeddings
slots of Document Embedder / Vector Store nodes.The image, TTS and ASR nodes are standard action nodes with standard n8n outputs
(binary image/audio, JSON text) that compose with any workflow, including chains.Requests go to Cloudflare's OpenAI-compatible endpoints through the AI Gateway (the credential's
AI Gateway ID, defaultdefault, is sent as thecf-aig-gateway-idheader):POST https://api.cloudflare.com/client/v4/accounts/{ACCOUNT_ID}/ai/v1/chat/completionsEmbeddings call the OpenAI-compatible embeddings endpoint (
{BASE}/ai/v1/embeddings, body{ model, text: [...] }) and returnresult.data[].embedding.Image and TTS call the model run endpoint (
{BASE}/ai/run/{MODEL_ID}, body{ prompt }
/{ text }) and return the raw binary body (image/png,audio/*).Speech Recognition calls the same run endpoint as multipart/form-data with an
audio
field, and returns JSON{ result: { text } }.Structured output is supported through LangChain tool binding, keeping it compatible with AI Agent workflows.
Tool calling forwards tool definitions and tool-call results as normal messages.
Streaming emits partial chunks as they arrive, so n8n chains can consume results incrementally.
On failure: the node retries up to
Max Retries, then (if enabled) tries each model in the fallback list before surfacing an error.
π‘ A good starting model is
@cf/qwen/qwen3-30b-a3b-fp8.
Compatibility & requirements
| Constraint | Value |
|---|---|
| n8n | v1.x (self-hosted) |
| Node runtime | β₯ 18 (global fetch) |
| Runtime dependency | @langchain/core ^1.1 |
| Peer dependency | n8n-workflow ^1.0 |
Development
# install
npm install
npm run build # strict TypeScript β dist/
# watch mode
npm run build:watch
# clean up
npm run clean
The only gate is npm run build (strict tsc); there is no test suite currently configured.
To try the node locally before publishing:
npm pack # produces n8n-nodes-cloudflare-ai-0.1.0.tgz
Then install the tarball into your n8n instance (e.g. a self-hosted n8n installation). See the Installation guide for Docker-based examples.
Publishing
npm publish # prepublishOnly runs the build automatically
Keep the package name stable once published β the Community Nodes flow will install that exact name. Changing credential or node names should be treated as a breaking change.
Roadmap & future plans
Planned direction for the next releases (private planning doc):
- More Workers AI nodes: Image-to-text / vision, RAG with Cloudflare Vectorize, Object detection, Reranker.
- Cloudflare AI Gateway options (logging, caching, observability).
- LoRA adapter support for select models.
- Cost / usage tracking and per-model budgets.
- Improved fallback UX.
License
MIT