Serve your agents fresh data at Redis speed.

Learn how
Platform
Solutions
Resources
Partners

Tutorial

Getting Started with Redis Iris

June 16, 202623 minute read
chanh-tran
Chanh Tran

#Getting Started with Redis Iris

#Introduction

Redis Iris is a purpose-built context and memory platform designed to bridge the gap between AI agents and fragmented enterprise data. It acts as a foundational layer in the AI stack, providing AI agents with live, accurate, and navigable data so they can operate reliably in production.
Redis Iris consists of five core tools that work together:
ToolDescription
Context RetrieverDefines a semantic model of your business entities (e.g., customers, tickets, policies) and automatically generates Model Context Protocol (MCP) tools. Instead of querying databases blindly, agents can dynamically discover and execute these tools with scoped keys and row-level security.
Agent MemoryManages both short-term session state and long-term durable memory across multiple interactions.
Redis Data Integration (RDI)Continuously ingests and synchronizes data from external systems (such as relational databases and data warehouses) into Redis so agents always act on fresh context.
LangCacheA semantic caching service that stores and reuses LLM responses for similar queries, drastically reducing API costs and latency.
Redis SearchThe core data layer powering the platform, enabling fast retrieval across structured, unstructured, and vector data.
This tutorial will cover LangCache, Agent Memory, and Context Retriever.
Note: This tutorial uses the code from the following git repository:

#Prerequisites

  • Python >= 3.11
  • Jupyter
  • Redis Cloud account
  • Redis Insight (optional, for inspecting data)

#Setup

#1. Create a database

From the Redis Cloud console, select New Database. Then click Try 30 MB for free to create a free Redis database in the cloud.
01-create-db

#Cloud settings

SettingDescription
NameName of your database.
Database versionVersion of your cloud database, leave as default.
Cloud vendorThe cloud infrastructure service provider.
RegionThe region where your database will be hosted.
Name your database and click Create database.

#2. Redis Insight

You can use the web version of Redis Insight or optionally download the desktop app. The Redis Insight desktop app will allow for faster bulk loading of data, but this tutorial will cover how to load data with both.
In the Redis Cloud console in your database's Configuration page, click Connect.
Choose either Open in desktop or Launch Redis Insight web.
01-connect-db

#3. Clone the repo

In your cloned repo, copy .env.example to .env

#4. Set up a Python environment and install Jupyter

#Redis LangCache

#1. Create a LangCache Service

From the Redis Cloud console, select LangCache from the left-hand menu. This takes you to the Create LangCache service page.
02-create-langcache

#General settings

SettingDescription
Service nameA name that describes your service's purpose.
Select databaseThe Redis Cloud database to use for this service.
TTLTime to live for cache entries, in milliseconds. Default: no expiration.
User for this serviceDatabase access user. Only the default user is supported during public preview.

#Embedding settings

SettingDescription
Embedding ProviderChoose between Redis, OpenAI, or Bring your own. Any provider must support the OpenAI embeddings API.
Embedding provider API keyYour provider's API key (OpenAI and Bring your own only).
Embedding provider URLYour provider's API URL (Bring your own only).
ModelThe embedding model to use.
Similarity thresholdMinimum similarity score to consider a cached response a match. Range: 0.5–1.0. Default: 0.92.
Tip: Higher values mean more precise matches; lower values increase match rate but may include less relevant results.

#Attributes settings (optional)

Attributes provide scoping capabilities for your cache operations — think of them as tags that help organize cached data.
You can define up to 5 custom attributes:
  1. Select Add attribute.
  2. Enter a descriptive name and select the checkmark to save.
  3. Repeat to add additional attributes (up to 5).

#Create the service

When you have finished configuring your service, select Create.
A window will display your LangCache service key. Select Copy to save it.
Warning: This is the only time the service key is shown. Save it to a secure location before closing the dialog. If you lose it, you will need to generate a new key.

#2. Configure your environment

Edit the .env file to fill in the LangCache values that you saved from the Redis Cloud console:
Find LANGCACHE_ENDPOINT and LANGCACHE_ID on your service's Configuration page in the Redis Cloud console under Connectivity. For LANGCACHE_ENDPOINT, copy the URL of the region closest to you. LANGCACHE_KEY is the service key you copied when creating the service.
03-langcache-vars

#3. Jupyter Notebook Walkthrough

#Install dependencies

#Import libraries

#Load environment variables and initialize the client

#Save a cache entry

#Search for a cached entry

Even though the search prompt differs slightly from the saved prompt, the semantic similarity is high enough that LangCache returns the cached response — no LLM call required.

#View data in Redis Insight

Open Redis Insight and connect to your database to browse the cached entries stored by LangCache.
04-langcache-insight

#4. Clean up

Go to the LangCache configuration page in the Redis Cloud console. Scroll down to Actions, click Delete next Delete service.

#Redis Agent Memory

#1. Create an Agent Memory Service

From the Redis Cloud console, select Agent Memory from the left-hand menu. Select Create custom and configure the service settings.
05-create-agent-memory

#General settings

SettingDescription
Service nameA name that describes your service's purpose.
Select databaseThe Redis Cloud database to use for this service.
User for this serviceDatabase access user. Only the default user is supported during public preview.

#Memory configuration

SettingDescription
Short-term TTLTime to live for session (short-term) memory. Can be set in seconds, minutes, hours, or days. Default: 1 hour.
Long-term TTLTime to live for long-term memory. Default: 365 days.

#Create the service

When you have finished configuring your service, select Create.
A window will display your Agent Memory service key. Select Copy to save it.
Warning: This is the only time the service key is shown. Save it to a secure location before closing the dialog. If you lose it, you will need to generate a new key.

#2. Configure your environment

Find AGENT_MEMORY_ENDPOINT and AGENT_MEMORY_STORE_ID on your service's Configuration page in the Redis Cloud console. AGENT_MEMORY_KEY is the service key you just copied in the last step.
06-agent-memory-vars
Edit the Agent Memory variables in your .env file:

#3. Jupyter Notebook Walkthrough

#Install dependencies

#Import libraries

#Load environment variables and initialize the client

#Add a session (short-term) memory event

#Retrieve session memory

#Add a long-term memory

#Get or search long-term memory

The search uses semantic similarity, so the query does not need to exactly match the stored memory text.

#View data in Redis Insight

Open Redis Insight and connect to your database to browse the session and long-term memory entries stored by Agent Memory.
07-agent-memory-insight

#4. Clean up

Go to the Agent Memory configuration page in the Redis Cloud console. Scroll down to Actions, click Delete next Delete service.

#Redis Context Retriever

#1. Load data into Redis

In the Redis Cloud console, open your redis-iris database confiuration page create during the Setup step and click Connect.
Choose either Open in desktop for the desktop app or Launch Redis Insight web.
01-connect-db

#If using Redis Insight Desktop

Click Bulk Actions then Upload Data tab.
Drag and drop the data.redis file from this repo into Redis Insight and click Upload to load in the hospital management dataset.
08-load-data-desktop

#If using Redis Insight Web

Click on the Workbench tab and paste in the contents of data.redis. Then click Run to load in the hospital management dataset.
08-load-data-web

#2. Create a Context Retriever Service

From the Redis Cloud console, select Context Retriever from the left-hand menu.
If this is your first service, you'll see an introduction page. Otherwise, select New service. From the introduction page, select Create custom service to manually configure your settings.
09-create-context-retriever

#General settings

SettingDescription
Service nameA name that describes your service's purpose.
Select databaseThe Redis Cloud database to use for this service.
DescriptionA description of your context retriever.
Select Entities to continue.

#Define entities

Entities map to the business objects stored in your Redis database.
  1. Select Add Entity.
  2. In the Entity name field, enter the name of a business object (e.g., Treatment).
  3. In the Key Template field, enter the Redis key pattern, using {id} to denote the ID location (e.g., treatment:{id}).
  4. Optionally add a description.
  5. Select the checkmark to confirm the entity.
  6. Repeat for all 5 entities, then select Fields to continue.
Note: I recommend creating all 5 entities but for this tutorial you will only need a minimum of the Treatement and Appointment entities mapped.
Entity NameKey Template
Treatmenttreatment:{id}
Appointmentappointment:{id}
Patientpatient:{id}
Doctordoctor:{id}
Billbill:{id}
10-context-retriever-entities

#Configure fields

In this step, you define the fields of each entity and the relationships between them. You have two options:
  • Auto-detect fields — scans your database automatically using a model to detect fields. You will need to agree to let the model scan your key names and schemas.
  • Manual configuration — define each field yourself, marking them as NUMERIC or TEXT to generate additional find and search MCP tools.
We'll use a combination of both. We'll first use Auto-detect to define the fields and relationshships then manually configure certain fields to be NUMERIC or TEXT.
  1. Click Auto-detect fields, this will scan your database and infer entity fields. This will also automatically map the relationships between your entities based on the entity's field key names.
  2. Consent to auto-detect scand and click Scan Database.
  3. Configure the field indexes. At a minimum, you'll need to configure 3 fields in the Treatement entity. Click on the entity's pencil icon then the Configure button to configure indexes of the entities:
  • Treatment entity:
    • treatment_type to be TEXT
    • descritption to be TEXT
    • cost to be NUMERIC
Note: Each field can only be a part of 1 index. You might encounter errors if you tried to include fields in both the TAG and TEXT indexes.
  1. Make sure to click the checkmark to confirm the changes.
  2. Optionally, go through the other entites and configure the field indexes as TEXT or NUMERIC as needed.
11-context-retriever-fields
  1. After configuring all fields, select Create to create the service.

#3. Configure your environment

You will access your Context Retriever via an agent key. To create a Context Retriever agent key, go to the Redis Cloud console and open your Context Retriever service page.
  1. Navigate to the Agent key tab in your service configuration page and select New Agent Key. Name and generate your agent key.
12-context-retriever-agent-key
  1. Copy and save the agent key
  2. Edit the CONTEXT_RETRIEVER_AGENT_KEY variable in your .env file:

#4. Jupyter Notebook Walkthrough

#Install dependencies

#Import libraries

#Load environment variables

#Initialize the client and list available tools

Context Retriever automatically generates MCP tools from your entity definitions. List them to see what's available:

#Call the tools

Use query_tool to call any of the generated MCP tools directly:

#Context Retriever tool names

The tool names (e.g. filter_appointment_by_patient_id, get_doctor_by_id, etc.) reflect the entities defined in a sample healthcare dataset. Your tool names will match the entities you defined in your own Context Retriever service.
IndexMCP tool generated
PKget_<entity>_by_id
TAGfilter_<entity>_by_<field>
TEXTsearch_<entity>_by_text
NUMERICfind_<entity>_by_<field>_range

#5. Clean up

Go to the Context Retriever configuration page in the Redis Cloud console. Scroll down to Actions, next to Delete service click Delete.

#Next Steps

#References

#Tutorials

  1. Semantic caching with Redis LangCache
  2. Redis Agent Memory and LangGraph
  3. Real-time AI agent with Redis Iris