Documentation

n8n-nodes-vercel-ai-gateway

The Ultimate Vercel AI Gateway Toolkit for n8n. Unlock enterprise-grade multi-provider routing, automatic & explicit prompt caching, session affinity, automatic model fallbacks, Zero Data Retention (ZDR) compliance, multimodal PDF/document analysis, vector embeddings, native Cohere-compatible reranking, typed decisions, and image generation—all through a single unified API key or Vercel OIDC token.

Developed and maintained by Jay Nguyen (Nguyễn Thiệu Toàn).

🛡️ Verified n8n Creator | 💼 CEO/Founder of GenStaff

Connect with me:
LinkedIn Facebook Website Email


🌟 Why is this package a game-changer for n8n?

n8n's built-in Vercel AI Gateway Chat Model only exposes bare sampling parameters and lacks action nodes, prompt caching controls, provider routing, fallback chains, ZDR compliance, embeddings, reranking, decisions, and image generation. This toolkit fills every single gap while keeping zero external runtime dependencies.

1. Vercel AI Gateway Chat Model (Advanced AI / LangChain Sub-Node)

Supercharges AI Agents and LLM Chains with full Gateway control:

  • 3 Prompt Caching Modes:
    • Gateway Auto (caching: "auto"): Automatically injects cache breakpoints for Anthropic, MiniMax, and Alibaba while letting OpenAI, Google, and DeepSeek cache implicitly.
    • Explicit Breakpoints (cache_control): Targets system messages or system + last user turns, with 5-Minute or 1-Hour extended TTL support.
  • Session Affinity (sessionId + x-session-id): Keeps multi-turn AI Agent tool loops pinned to the upstream provider holding your warm prompt cache.
  • Live Provider Endpoint Discovery: Inspects /v1/models/{model}/endpoints dynamically—displaying prompt/completion pricing per 1M tokens, cache read/write rates, 1h TTFT latency, throughput (tok/s), 24h uptime, [ZDR], [No-Train], and caching capabilities right inside the dropdown.
  • Soft Ordering vs. Strict Pinning: Choose Prefer First (order) for failover resilience or Lock Strictly (only) when compliance/pricing demands exact upstream providers, plus dynamic sorting by cost, ttft, or tps.
  • Automatic Server-Side Model Fallbacks (models): Specify backup models (e.g. anthropic/claude-sonnet-4.6, google/gemini-2.5-flash) tried automatically by Vercel AI Gateway if your primary model fails.
  • Enterprise Compliance & Observability: Per-request Zero Data Retention (zeroDataRetention), Disallow Prompt Training (disallowPromptTraining), Provider Headquarters (headquarters), capability filters (has), user, tags, safetyIdentifier, BYOK providerTimeouts, and reasoning_effort.
  • Tool-Calling Stability: Automatically repairs empty or object-typed tool_calls[].function.arguments payloads so non-OpenAI providers never crash LangChain agents.

2. Vercel AI Gateway (Standard Action Node)

  • Chat / Generate Text: Direct completions with full prompt caching, fallback models, ZDR, reasoning, and provider routing.
  • Analyze Content (Multimodal & Documents): Native support for PDFs, documents (TXT, CSV, DOCX, XLSX), images, audio, and video via binary inputs, smart URL extraction (preserving presigned URLs), or server-side Download & Base64 delivery—using Vercel's exact { type: 'file', file: { data, media_type, filename } } contract.
  • Credits & Generation Inspection: Built-in Get Credits Balance (GET /v1/credits) and Get Generation Details (GET /v1/generation) operations.

3. Vercel AI Gateway Embeddings (Advanced AI / LangChain)

Generates vector embeddings via /v1/embeddings across 25+ live models (OpenAI, Cohere, Voyage, Alibaba Qwen3, Google) with optional dimensions, batch size, provider routing, ZDR, and observability tags.

4. Vercel AI Gateway Reranker (Advanced AI / LangChain)

Connects to Vercel AI Gateway's native Cohere-compatible POST /v1/rerank endpoint (cohere/rerank-v3.5, cohere/rerank-v4-pro, voyage/rerank-3, etc.) to score and compress RAG documents with Top N and Max Tokens Per Document controls.

5. Vercel AI Gateway Decisions (Standard Action Node)

Interacts with Vercel AI Gateway's POST /v1/decisions endpoint (openai/gpt-6-luna-decisions, typesafe-ai/jev-1.14.0, liquid/d1.2, microsoft/decision-1.1, perplexity/pplx-decider-v1.3) for sub-second predicate, choice, and score evaluations, complete with flattened $json.verdict / $json.decision outputs and ambiguity flagging for IF/Switch branching.

6. Vercel AI Gateway Image Generation (Standard Action Node)

Supports both image-only models (/v1/images/generations for GPT Image 2, FLUX, Recraft) and multimodal image LLMs (/v1/chat/completions with modalities: ['text', 'image'] for Gemini Image), automatically outputting binary files into n8n items.


🚀 Installation

In n8n, navigate to Settings > Community Nodes and install:

n8n-nodes-vercel-ai-gateway

⚙️ Credentials Configuration

  1. Create an AI Gateway API Key in your Vercel AI Gateway Dashboard (or use a Vercel OIDC token).
  2. In n8n, create a new Vercel AI Gateway API credential:
    • API Key or OIDC Token: Enter your vck_... key or OIDC token.
    • Base URL: Defaults to https://ai-gateway.vercel.sh/v1.
    • Default Session ID (Optional): Optional fallback x-session-id header for prompt cache affinity.

(Click Test Connection to validate your credentials at zero token cost via GET /v1/credits!)

📚 Included Nodes

Node Type Description
Vercel AI Gateway Standard Action Node Chat completions, multimodal/PDF analysis, credit balance, and generation metadata lookup.
Vercel AI Gateway Chat Model Advanced AI (LangChain) Chat model with auto/explicit prompt caching, session affinity, provider routing, model fallbacks, ZDR, and no-training controls.
Vercel AI Gateway Embeddings Advanced AI (LangChain) Vector embeddings across all live Vercel AI Gateway embedding models.
Vercel AI Gateway Reranker Advanced AI (LangChain) Native /v1/rerank document compressor for high-accuracy RAG pipelines.
Vercel AI Gateway Decisions Standard Action Node Typed probabilistic predicate, choice, and score decisions via /v1/decisions.
Vercel AI Gateway Image Generation Standard Action Node Unified image generation supporting both /v1/images/generations and multimodal /v1/chat/completions.

License

MIT

Discussion