Templates / Reduce LLM Costs with Semantic Caching using Redis Vector Store and HuggingFace

Reduce LLM Costs with Semantic Caching using Redis Vector Store and HuggingFace

Needs changes

by Tihomir Mateev · 1,833 views · created 2025-11-16 · Engineering, AI Chatbot

Needs changes. This template uses 1 thing(s) that n8n 3.0 removes: AI Agent v1 (old agent modes). 1 breaking item(s) found. Static check, last run 2026-10-19.

What this workflow does

This AI workflow has 19 nodes and runs manually, when you click “Execute workflow” (plus 1 other trigger). Along the way it connects OpenAI Chat Model, Redis Chat Memory, Redis Vector Store and Embeddings Hugging Face Inference.

How it runs

Trigger: Manually, when you click “Execute workflow” (plus 1 other trigger).

  1. Initialize Redis store (Redis Vector Store): stores documents in the Redis vector store, with embeddings: Use Huggingface for embeddings; document loader: Process sample data
  2. Check for similar prompts (Redis Vector Store): searches the Redis vector store, with embeddings: Embeddings Hugging Face Inference
  3. Analyze results from store (Code): runs custom JavaScript code
  4. Is this a cache hit? (If): checks a condition and branches into true / false
  5. Respond to Chat (from semantic cache) (Chat): uses Chat
  6. LLM Agent (AI Agent): runs an AI agent, with model: OpenAI Chat Model; memory: Redis Chat Memory
  7. Store entry in cache (Redis Vector Store): stores documents in the Redis vector store, with embeddings: Embeddings Hugging Face Inference; document loader: Add response as metadata
  8. Respond to Chat (from LLM) (Chat): uses Chat

Services it uses

OpenAI Chat ModelRedis Chat MemoryRedis Vector StoreEmbeddings Hugging Face Inference

Before you upgrade to n8n 3.0

1 thing in this workflow is removed in n8n 3.0. Fix it before you upgrade:

  • AI Agent v1 (old agent modes) in LLM Agent (v1.8): replace with Latest AI Agent node (Tools Agent). For SQL Agent, use a Postgres or MySQL tool with a recent AI Agent.
Removed in 3.0Replace with
AI Agent v1 (old agent modes)
LLM Agent (v1.8)
Latest AI Agent node (Tools Agent). For SQL Agent, use a Postgres or MySQL tool with a recent AI Agent.

Nodes used (12)

From the author

Stop Paying for the Same Answer Twice Your LLM is answering the same questions over and over. "What's the weather?" "How's the weather today?" "Tell me about the weather." Same answer, three API calls, triple the cost. This workflow fixes that. What Does It…

Excerpt from Tihomir Mateev's description on n8n.io.

View the original on n8n.io → Check your own copy

Get the weekly “what broke” email

New templates, newly broken ones, and n8n release changes. One short email a week.

Form not loading? Subscribe here.