Redis Agent Memory REST API quickstart

Explore session memory, automatic extraction, summarization, custom memory types, and sensitive-data exclusions with the Redis Agent Memory REST API.

Use this quickstart to follow a travel planning conversation through Redis Agent Memory. You will retrieve the conversation from session memory, recall information extracted in the background, inspect an automatically generated session summary, extract structured travel information, and guide extraction away from sensitive data.

Before you begin

To complete this quickstart, you need:

  • A Redis Cloud account that can create Redis Agent Memory services.
  • An eligible Redis Cloud database, or permission to create one.
  • A shell with curl and jq installed.

Create a Redis Agent Memory service

  1. Sign in to the Redis Cloud console.

  2. Select Agent Memory from the navigation menu.

  3. If Redis Cloud displays the public preview terms, review and accept them.

  4. Select Create custom service.

  5. Enter a service name, select an eligible database, and select its default user.

  6. Under Memory configuration, enter these values:

    Setting Value What it controls
    Short-term TTL 1 day How long session memory is retained.
    Long-term TTL 365 days How long long-term memories are retained.
    Extraction cadence 1 minute How often session events are processed for extraction. One minute is for this quickstart; use a longer production interval unless you need rapid extraction.
    Automatic summarization Enabled Whether older session events are condensed into a summary.
    Summarize after (messages) 6 The event count that triggers summarization. Six is for this quickstart; use a higher production threshold.
    Keep most recent (messages) 2 How many recent events remain in full. Two is for this quickstart; retain more in production when recent turns are needed.
  7. Under Memory types & extraction, select Add type and configure this custom memory type:

    Setting Value What it controls
    Name trip_preference The identifier stored in memoryType and used in search filters.
    Description Structured requirements for a planned trip The purpose of the custom memory type.
    Extraction prompt Extract trip requirements only when the user states a destination or travel plan. Preserve explicit dietary requirements and food preferences. When to create the memory and which information to capture.
    Enabled Enabled Whether new memories of this type are extracted.
  8. Add these custom fields:

    Field Type Description
    destinations list[str] Cities or countries the user plans to visit.
    travel_period str When the user plans to travel.
    dietary_requirements list[str] Dietary requirements that affect recommendations.
    food_preferences list[str] Cuisines, flavors, or dining preferences stated by the user.
  9. Under Sensitive-data exclusions, enable Semantic exclusions and enter this exclusion prompt:

    Do not keep passwords, access tokens, recovery codes, payment card information, or booking confirmation codes in long-term memory.
    
  10. Select Create.

  11. Copy the Redis Agent Memory API key and store it securely.

Warning:
Redis Cloud displays the Redis Agent Memory API key only once. If you lose it, generate a new API key.

These settings keep the background stages short enough to observe during the quickstart. For screenshots and configuration details, see create a Redis Agent Memory service.

Warning:
Sensitive-data exclusions guide the extraction model but do not guarantee exclusion. Sensitive session content still reaches the model provider. Exclusions do not apply when an application creates long-term memories directly.

Save the connection values

  1. Open the Redis Agent Memory service in the Redis Cloud console.

  2. On the Configuration tab, copy the Endpoint and Store ID.

  3. Export the values in your shell:

    export AGENT_MEMORY_URL='<ENDPOINT>'
    export STORE_ID='<STORE_ID>'
    export API_KEY='<API_KEY>'
    export SESSION_ID='travel-planning-session'
    export OWNER_ID='quickstart-user'
    

AGENT_MEMORY_URL must include https://. Keep the API key out of source control, application logs, and other unsecured locations.

Check the service health

Verify that the service is available:

curl --fail-with-body --silent --show-error \
  --header "Authorization: Bearer $API_KEY" \
  "$AGENT_MEMORY_URL/health" | jq

1. Build conversation context with session memory

Session memory stores a conversation as an ordered sequence of events. Add a user message that contains details the travel agent will need later:

export EVENT_CREATED_AT="$(date -u +'%Y-%m-%dT%H:%M:%SZ')"

curl --fail-with-body --silent --show-error \
  --request POST \
  --header "Authorization: Bearer $API_KEY" \
  --header 'Content-Type: application/json' \
  --data @- \
  "$AGENT_MEMORY_URL/v1/stores/$STORE_ID/session-memory/events" <<JSON | jq
{
  "sessionId": "$SESSION_ID",
  "actorId": "$OWNER_ID",
  "role": "USER",
  "content": [
    {
      "text": "I am visiting Tokyo and Kyoto next month. I am vegetarian and prefer spicy food."
    }
  ],
  "createdAt": "$EVENT_CREATED_AT"
}
JSON

Retrieve the session:

curl --fail-with-body --silent --show-error \
  --header "Authorization: Bearer $API_KEY" \
  "$AGENT_MEMORY_URL/v1/stores/$STORE_ID/session-memory/$SESSION_ID" | jq

The events array contains the stored message, its role, actor, and timestamps. An application can retrieve this session before the next agent turn and add the events to the model's context.

Note:
What to expect: The events array contains the travel message. Redis Agent Memory adds an eventId and systemTimestamp, showing that the application can recover the complete event later using only the session ID.

2. Recall automatically extracted information

Redis Agent Memory processes session events in the background and creates long term memories for information that may be useful in later conversations. You configured the extraction cadence to one minute when you created the service. You do not need to submit a separate memory creation request.

Wait at least one minute, then search for the user's dietary requirements:

curl --fail-with-body --silent --show-error \
  --request POST \
  --header "Authorization: Bearer $API_KEY" \
  --header 'Content-Type: application/json' \
  --data @- \
  "$AGENT_MEMORY_URL/v1/stores/$STORE_ID/long-term-memory/search" <<JSON | jq
{
  "text": "What dietary requirements and food preferences does the user have?",
  "filter": {
    "ownerId": {
      "eq": "$OWNER_ID"
    }
  },
  "limit": 5
}
JSON

The items array should contain memories derived from the conversation, such as the vegetarian requirement or preference for spicy food. Extraction is asynchronous, so run the search again if the array is empty.

Note:
What to expect: Results similar to User is a vegetarian and User prefers spicy food. Your application did not create these memories directly. Redis Agent Memory derived them from the session event. The exact text and memory types can vary.

The extracted memory remains searchable after the session expires, subject to the long term memory TTL. You can change the extraction cadence and both TTLs in the Redis Agent Memory service configuration.

3. Keep long conversations concise with automatic summarization

Automatic summarization condenses older events and retains the most recent events in full. The retrieved session then contains a summary object and the recent events array, so the application can provide useful history without filling the model's context window with every original message.

You enabled automatic summarization when you created the service. When the session reaches six events, Redis Agent Memory summarizes the older events and retains the two most recent events in full.

Add conversation turns

Add enough user and assistant events to reach the configured threshold. Use the request from the first step and change role, actorId, content, and createdAt for each event. The Python and TypeScript quickstarts use six additional turns about travel dates, restaurant style, and budget.

Summarization runs in the background after the session reaches the threshold.

Retrieve the summarized session

After a short wait, retrieve the session again:

curl --fail-with-body --silent --show-error \
  --header "Authorization: Bearer $API_KEY" \
  "$AGENT_MEMORY_URL/v1/stores/$STORE_ID/session-memory/$SESSION_ID" | jq

Repeat the retrieval after a short wait if summary is not present. Compare summary.text with the recent events. The summary should preserve earlier decisions about the trip while recent turns remain available in full.

Note:
What to expect: A summary object that preserves details such as Tokyo, Kyoto, the travel dates, and food preferences. summarizedUpToEventId identifies the last event covered by the summary, while events contains the newer turns that remain in full. The exact summary text can vary.

See automatic summarization configuration for details.

4. Extract business specific data with a custom memory type

Built in memories preserve generally useful information. Custom memory types let an application extract structured information for its business domain. You configured trip_preference when you created the service, so it processed the same travel planning event independently.

Search for the structured memory:

curl --fail-with-body --silent --show-error \
  --request POST \
  --header "Authorization: Bearer $API_KEY" \
  --header 'Content-Type: application/json' \
  --data @- \
  "$AGENT_MEMORY_URL/v1/stores/$STORE_ID/long-term-memory/search" <<JSON | jq
{
  "text": "What are the requirements for the user's trip?",
  "filter": {
    "ownerId": {
      "eq": "$OWNER_ID"
    },
    "memoryType": {
      "eq": "trip_preference"
    }
  },
  "limit": 5
}
JSON

The result uses trip_preference as its memoryType and contains travel information extracted from the conversation. The exact text and returned fields depend on the conversation, extraction model, and client.

Note:
What to expect: A result with memoryType set to trip_preference that combines the destinations, travel period, and dietary preferences. This shows that the custom type processed the same conversation independently from the built-in memory types.

See custom memory types for configuration requirements and limits.

5. Guide extraction away from sensitive data

The semantic exclusion prompt tells Redis Agent Memory which information should not be kept in long-term memory. Add an event containing a fictional booking code and information that is safe to retain:

export EVENT_CREATED_AT="$(date -u +'%Y-%m-%dT%H:%M:%SZ')"

curl --fail-with-body --silent --show-error \
  --request POST \
  --header "Authorization: Bearer $API_KEY" \
  --header 'Content-Type: application/json' \
  --data @- \
  "$AGENT_MEMORY_URL/v1/stores/$STORE_ID/session-memory/events" <<JSON | jq
{
  "sessionId": "$SESSION_ID",
  "actorId": "$OWNER_ID",
  "role": "USER",
  "content": [
    {
      "text": "I booked Hotel Sakura in Tokyo. For this example, the fictional booking confirmation code is DEMO-7QX9."
    }
  ],
  "createdAt": "$EVENT_CREATED_AT"
}
JSON

Wait at least one minute and search for the safe hotel information:

curl --fail-with-body --silent --show-error \
  --request POST \
  --header "Authorization: Bearer $API_KEY" \
  --header 'Content-Type: application/json' \
  --data @- \
  "$AGENT_MEMORY_URL/v1/stores/$STORE_ID/long-term-memory/search" <<JSON | jq
{
  "text": "Where is the user staying in Tokyo?",
  "filter": {
    "ownerId": {
      "eq": "$OWNER_ID"
    }
  },
  "limit": 5
}
JSON

Inspect the returned memories. They can retain the hotel name, but should not contain DEMO-7QX9 because the exclusion prompt covers booking confirmation codes.

Note:
What to expect: A memory similar to User booked Hotel Sakura in Tokyo without the fictional confirmation code. If the code appears, refine the exclusion prompt and test again. Exclusions remain advisory.
Warning:
Semantic exclusions are advisory and do not guarantee that sensitive information is excluded. Session content still reaches the extraction model provider. Do not use real sensitive data in this exercise. Exclusions do not apply to directly created long-term memories.

See sensitive-data exclusions for configuration details.

Next steps

RATE THIS PAGE
Back to top ↑