n8n Integration
Connect n8n to Antbase for intelligent model routing in your automation workflows. The community node wraps Antbase's OpenAI-compatible API so every n8n workflow gets automatic model selection, failover, and cost optimization without any prompt changes.
What this enables
- Drop-in AI node for any n8n workflow -- chat completions, classification, extraction
- Virtual model routing (
ant:auto,ant:fast,ant:reasoning, etc.) - Automatic failover across 30+ providers -- your workflows never break when one provider goes down
- Streaming support for real-time webhook responses
- Works with self-hosted n8n and n8n Cloud
Installation
Community Nodes UI (recommended)
In your n8n instance, go to Settings > Community Nodes and install:
n8n-nodes-antbaseCLI
If you manage n8n via the command line:
cd ~/.n8n
npm install n8n-nodes-antbaseRestart n8n after installing.
Docker
Mount the node into your container or add it to a custom Dockerfile:
FROM n8nio/n8n:latest
RUN cd /usr/local/lib/node_modules/n8n && \
npm install n8n-nodes-antbaseSetup
After installing the node, configure your Antbase credentials in n8n.
1. Create an API key
Go to the API Keys page in your Antbase dashboard and generate a new key.
2. Add credentials in n8n
In n8n, go to Credentials > Add Credential and search for Antbase API. Fill in the fields:
| Field | Value |
|---|---|
| API Key | Your Antbase API key (ant_...) |
| Base URL | https://antbase.ai/v1 (pre-filled) |
3. Test the connection
Click Test Credential in n8n. It calls the /v1/models endpoint and should return a green checkmark.
Ready to use
You can now drag the Antbase node into any workflow.
Node Operations
The Antbase node exposes three operations. Pick the one that fits your workflow.
Chat Completion
Full chat completions endpoint with message history, system prompts, and all OpenAI-compatible parameters.
| Parameter | Type | Default | Description |
|---|---|---|---|
| model | string | ant:auto | Virtual model or provider model ID |
| messages | array | -- | Chat messages array (role + content) |
| temperature | number | 0.7 | Sampling temperature (0--2) |
| max_tokens | number | 4096 | Maximum tokens to generate |
| stream | boolean | false | Enable SSE streaming |
| response_format | object | -- | Force JSON output ({"type":"json_object"}) |
Simple Chat
Single-turn prompt with just a text input. Ideal for quick classification, summarization, or extraction steps where you don't need message history.
| Parameter | Type | Default | Description |
|---|---|---|---|
| model | string | ant:auto | Virtual model or provider model ID |
| prompt | string | -- | The user prompt text |
| system | string | -- | Optional system prompt |
| temperature | number | 0.7 | Sampling temperature |
| response_format | object | -- | Force JSON output |
List Models
Returns all available virtual and provider models. Useful for dynamic model selection or populating dropdown fields in subsequent nodes.
No additional parameters. Returns an array of model objects.
Virtual Models
Use virtual models to let Antbase route to the best provider and model for each request.
| Model | Best for | Notes |
|---|---|---|
| ant:auto | General use | Classifies the prompt and picks the optimal model automatically |
| ant:fast | Classification, extraction, triage | Lowest latency; ideal for high-volume workflow steps |
| ant:best | Complex analysis, long-form generation | Routes to frontier models (GPT-4o, Claude, Gemini) |
| ant:free | Development, testing, low-priority tasks | Zero cost; uses free-tier provider endpoints |
| ant:reasoning | Multi-step logic, math, planning | Thinking models with chain-of-thought (o-series, DeepSeek R1) |
| ant:coder | Code generation, transformation | Favors code-optimized models |
You can also pass any specific provider model ID (e.g. gpt-4o, claude-sonnet-4-20250514) to bypass routing. See Virtual Models for the full list.
Workflow Examples
Email Classifier
Trigger on incoming email, classify it with ant:fast, then route to different branches based on the category.
// Antbase node configuration (Simple Chat operation)
{
"model": "ant:fast",
"system": "Classify the following email into exactly one category: support, sales, billing, spam. Respond with JSON: {"category": "...", "confidence": 0.0}",
"prompt": "{{ $json.body }}",
"temperature": 0,
"response_format": { "type": "json_object" }
}
// Output (piped to a Switch node):
// { "category": "support", "confidence": 0.95 }Invoice Data Extraction
Extract structured data from invoice text. Use ant:auto so Antbase picks the best model for the document complexity.
// Antbase node configuration (Simple Chat operation)
{
"model": "ant:auto",
"system": "Extract invoice fields from the text. Return JSON with: invoice_number, date, vendor, line_items (array of {description, quantity, unit_price, total}), subtotal, tax, grand_total.",
"prompt": "{{ $json.invoiceText }}",
"temperature": 0,
"response_format": { "type": "json_object" }
}
// Output:
// {
// "invoice_number": "INV-2026-0042",
// "date": "2026-03-15",
// "vendor": "Acme Corp",
// "line_items": [
// { "description": "Widget A", "quantity": 10, "unit_price": 25.00, "total": 250.00 }
// ],
// "subtotal": 250.00,
// "tax": 20.00,
// "grand_total": 270.00
// }Content Translation Pipeline
Translate content into multiple languages in parallel using n8n's Split in Batches node. Use ant:best for high-quality translation.
// Antbase node configuration (Simple Chat operation)
{
"model": "ant:best",
"system": "You are a professional translator. Translate the following text to {{ $json.targetLanguage }}. Preserve formatting and tone. Return only the translation, no commentary.",
"prompt": "{{ $json.sourceText }}",
"temperature": 0.3
}
// Workflow structure:
// Trigger -> Set languages ["es","fr","de","ja"]
// -> Split in Batches
// -> Antbase (translate)
// -> Merge -> Save to CMSOutput Schema
The Antbase node returns a standard OpenAI-compatible chat completion object. Access the generated text in subsequent nodes.
// The node outputs the full completion object:
{
"id": "chatcmpl-abc123",
"object": "chat.completion",
"model": "gpt-4o-2024-08-06", // actual model used
"choices": [
{
"index": 0,
"message": {
"role": "assistant",
"content": "The generated response text..."
},
"finish_reason": "stop"
}
],
"usage": {
"prompt_tokens": 42,
"completion_tokens": 128,
"total_tokens": 170
}
}
// In subsequent nodes, reference:
// {{ $json.choices[0].message.content }} -- the response text
// {{ $json.model }} -- which model was actually used
// {{ $json.usage.total_tokens }} -- token countError Handling
Antbase handles retries and failover automatically, but some errors will surface to n8n. Use n8n's built-in Error Trigger node to catch these.
| HTTP Status | Error | Cause | Action |
|---|---|---|---|
| 401 | Unauthorized | Invalid or expired API key | Regenerate key in dashboard |
| 402 | Payment Required | Insufficient credits | Top up credits or switch to ant:free |
| 429 | Rate Limited | Too many requests per minute | Add a Wait node or reduce concurrency in Split in Batches |
| 500 | Internal Error | All providers failed for this request | Retry with a different model or check status page |
| 503 | Service Unavailable | Gateway is down or restarting | n8n's built-in retry will handle transient outages |
Self-Hosted Gateway
Running your own Antbase instance?
If you self-host the Antbase gateway (e.g. on your local network or Kubernetes cluster), change the Base URL in your n8n credential to point to your instance:
# In n8n Antbase credential settings:
Base URL: http://antbase.internal:3001/v1
# Or if running n8n and Antbase in the same Docker network:
Base URL: http://orqa-api:3001/v1All node operations work identically against a self-hosted gateway. You bring your own provider API keys, configured in the gateway's environment.
Tips
- Use
ant:fastfor triage steps. In multi-step workflows, use a fast model for classification or routing decisions, then escalate toant:bestonly when needed. This keeps costs low and latency tight. - Always set
response_formatfor structured output. When you need to parse the AI response in downstream nodes, force JSON mode. This prevents the model from wrapping its answer in markdown or natural language. - Set
temperature: 0for deterministic tasks. Classification, extraction, and data transformation should use zero temperature for consistent results across runs. - Use n8n expressions in prompts. Reference data from previous nodes with
{{ $json.fieldName }}to build dynamic prompts without code nodes. - Monitor usage in the Antbase dashboard. The dashboard shows per-request routing decisions, latency, and cost breakdown -- useful for optimizing which virtual model each workflow step uses.
- Handle errors gracefully. Connect an Error Trigger node to send alerts (Slack, email) when AI steps fail. For critical workflows, add a fallback branch that uses a different model.