Agentic memory service¶
Premium
DataRobot's Agentic AI capabilities are a premium feature; contact your DataRobot representative for enablement information. Try this functionality for yourself in a limited capacity in the DataRobot trial experience.
The agentic memory surface in DataRobot exposes two different APIs that address different use cases. Choose the path that matches your build, then follow the documentation for that path. You do not need to merge the two in a single application.
If you need to persist and retrieve chat-style history (sessions) through DataRobot's REST API and Python API client with a DataRobot model (accessed via datarobot.models.memory.Session or datarobot.models.memory.MemorySpace), use the chat history API described in the Chat history API section. Read the REST API and Python API client reference documentation for complete details.
If you are working with long-term, mem0-style memory (including migrating from the open-source mem0 stack), or you want examples and request shapes that match the mem0 product, use the mem0 API. For that interface, the canonical resource is the mem0 documentation.
The chat history API is the DataRobot-integrated path: the same REST API you use for other DataRobot resources, with matching coverage in the DataRobot Python API client.
Python API client: The Python API client adds dedicated types to make build-out straightforward:
datarobot.models.memory.MemorySpaceoffers a basic CRUD for memory spaces (containers for stored conversation data).datarobot.models.memory.Sessionanddatarobot.models.memory.Eventwork with sessions and events (messages within a session) when you build chat-style agentic applications.
REST API: Use the REST API for these resources alongside the same authentication and base URL patterns as the rest of the DataRobot API. Details appear in the REST API reference for the relevant operations and schemas.
Choose this path when you want a DataRobot chat history and session model aligned with the platform's API and Python package.
DataRobot also offers a mem0-compatible REST API that is intended as a one-to-one match to the open-source mem0 product's interface.
For conceptual overviews, endpoint behavior, and especially examples (including language- and framework-specific snippets), use the official mem0 documentation, which is maintained for that product.
Access the primary mem0 documentation at https://docs.mem0.ai to learn request and response shapes, how to add and search memory, and how to integrate with common agent frameworks. Because the DataRobot service is built to be compatible with the same API surface, those guides apply with your DataRobot endpoint and authentication. Choose this path when you are targeting mem0's semantics and ecosystem, or porting an integration that was written against the open-source service.
Quickstart¶
Review a quickstart workflow below.
Prerequisites¶
- Python 3.9+
- A DataRobot account, an API key, and the endpoint URL (e.g.
https://app.datarobot.com/api/v2) pip install datarobot mem0ai
Set credentials once, either via environment (DATAROBOT_API_TOKEN, DATAROBOT_ENDPOINT) or ~/.config/datarobot/drconfig.yaml. The snippets below pass them explicitly.
Connect¶
import datarobot as dr
dr.Client(token="<YOUR_DATAROBOT_API_TOKEN>", endpoint="https://app.datarobot.com/api/v2")
Create a memory space¶
A memory space is the isolation boundary for one application or one end user.
from datarobot.models.memory import MemorySpace
space = MemorySpace.create(
description="Acme support assistant",
llm_model_name="gpt-4o", # used for mem0 fact extraction
)
print(space.id)
Create a session¶
A session is one conversation. participants is a list of MongoDB-ObjectId strings - typically your end user.
from datarobot.models.memory import Session
session = Session.create(
memory_space_id=space.id,
participants=["67500a000000000000000001"],
description="Triage chat #42",
)
print(session.id)
The server attaches a default soft-delete lifecycle strategy (180 days) if you do not supply one.
Post messages¶
Each message is an event. body is free-form JSON; emitter identifies who sent it.
event = session.post_event(
body={"content": "Hello, my deployment is failing"},
emitter={"type": "user", "id": "67500a000000000000000001"},
event_type="MESSAGE",
)
print(event.sequence_id) # 0
Batched append (up to 200 events, single transaction):
session.post_events([
{
"body": {"content": "Looking at it now."},
"emitter": {"type": "agent", "id": "67500a000000000000000002"},
"event_type": "MESSAGE",
},
{
"body": {"content": "Found the issue - rolling back."},
"emitter": {"type": "agent", "id": "67500a000000000000000002"},
"event_type": "MESSAGE",
},
])
Read and edit events¶
# Newest 20 events:
recent = session.events(last_n=20)
for e in recent:
print(e.sequence_id, e.emitter_type, e.body)
# Edit message #1:
session.update_event(
sequence_id=1,
body={"content": "Looking at it now (ETA 5min)."},
)
update_event accepts an optional created_at for optimistic concurrency: if the event has changed since that timestamp, the server rejects the update and the caller must reload and retry.
Memory extraction via stock mem0 client¶
The service exposes a mem0-compatible sub-route per memory space. Point a stock mem0ai.MemoryClient at it and the standard mem0 client works unchanged - add(), get(), search(), get_all(), delete().
from mem0 import MemoryClient
endpoint = f"https://app.datarobot.com/api/v2/memory/{space.id}"
memory = MemoryClient(host=endpoint, api_key="<YOUR_DATAROBOT_API_TOKEN>")
memory.add(
[{"role": "user", "content": "I deploy on Fridays using ArgoCD"}],
user_id="alice",
agent_id="support-bot",
)
hits = memory.search("when do we deploy", user_id="alice", agent_id="support-bot")
The api_key is your DataRobot API token. Memory-space scoping is entirely in the URL path - no extra headers.