Antbase/Documentation

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-antbase

CLI

If you manage n8n via the command line:

cd ~/.n8n
npm install n8n-nodes-antbase

Restart 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-antbase

Setup

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:

FieldValue
API KeyYour Antbase API key (ant_...)
Base URLhttps://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.

ParameterTypeDefaultDescription
modelstringant:autoVirtual model or provider model ID
messagesarray--Chat messages array (role + content)
temperaturenumber0.7Sampling temperature (0--2)
max_tokensnumber4096Maximum tokens to generate
streambooleanfalseEnable SSE streaming
response_formatobject--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.

ParameterTypeDefaultDescription
modelstringant:autoVirtual model or provider model ID
promptstring--The user prompt text
systemstring--Optional system prompt
temperaturenumber0.7Sampling temperature
response_formatobject--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.

ModelBest forNotes
ant:autoGeneral useClassifies the prompt and picks the optimal model automatically
ant:fastClassification, extraction, triageLowest latency; ideal for high-volume workflow steps
ant:bestComplex analysis, long-form generationRoutes to frontier models (GPT-4o, Claude, Gemini)
ant:freeDevelopment, testing, low-priority tasksZero cost; uses free-tier provider endpoints
ant:reasoningMulti-step logic, math, planningThinking models with chain-of-thought (o-series, DeepSeek R1)
ant:coderCode generation, transformationFavors 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 CMS

Output 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 count

Error 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 StatusErrorCauseAction
401UnauthorizedInvalid or expired API keyRegenerate key in dashboard
402Payment RequiredInsufficient creditsTop up credits or switch to ant:free
429Rate LimitedToo many requests per minuteAdd a Wait node or reduce concurrency in Split in Batches
500Internal ErrorAll providers failed for this requestRetry with a different model or check status page
503Service UnavailableGateway is down or restartingn8n'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/v1

All 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:fast for triage steps. In multi-step workflows, use a fast model for classification or routing decisions, then escalate to ant:best only when needed. This keeps costs low and latency tight.
  • Always set response_format for 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: 0 for 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.