API docs · Guide

Add memory

Does your chatbot forget yesterday's conversation? Send one user ID with each request and HRUM remembers each user separately, then carries it into the next conversation. You don't need to store chat history on your own server.

Before you start

  1. Sign up with Google

    On the HRUM console, press the Google button to sign up.

  2. Get an API key

    Create a key on the API keys screen of the console. The key is shown only once, right when you create it.

  3. Put the key in an environment variable

    The examples below read the key from HRUM_API_KEY. To write it into the code instead, replace YOUR_API_KEY.

Talk to the same person twice

The first message gives a name and a favorite food, the second asks whether the bot remembers. Last, the same question with only the user ID changed.

Paste into a terminal (macOS, Linux) as it is
# Replace YOUR_API_KEY with the key from the console
export HRUM_API_KEY="YOUR_API_KEY"

# First: tell your name and favorite food
curl -s -w "\n" https://api.hrum.ai/api/v1/partners/v1/chat/completions \
  -H "X-Partner-Api-Key: $HRUM_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "model": "ridm/gpt-6-luna",
    "user": "user-sky",
    "historyCount": 10,
    "systemPrompt": "You are a friendly chatbot. Reply in English.",
    "messages": [{ "role": "user", "content": "My name is Haneul and I love spicy food. Please remember that." }]
  }'

# Second: same user, ask whether it remembers
curl -s -w "\n" https://api.hrum.ai/api/v1/partners/v1/chat/completions \
  -H "X-Partner-Api-Key: $HRUM_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "model": "ridm/gpt-6-luna",
    "user": "user-sky",
    "historyCount": 10,
    "systemPrompt": "You are a friendly chatbot. Reply in English.",
    "messages": [{ "role": "user", "content": "Do you remember my name and my favorite food?" }]
  }'

# Someone else: change only the user, ask the same question
curl -s -w "\n" https://api.hrum.ai/api/v1/partners/v1/chat/completions \
  -H "X-Partner-Api-Key: $HRUM_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "model": "ridm/gpt-6-luna",
    "user": "user-bada",
    "historyCount": 10,
    "systemPrompt": "You are a friendly chatbot. Reply in English.",
    "messages": [{ "role": "user", "content": "Do you remember my name and my favorite food?" }]
  }'

The reply is in choices[0].message.content of the response JSON.

Save as memory.py and run python memory.py (needs requests)
import os
import requests

API_KEY = os.environ.get("HRUM_API_KEY", "YOUR_API_KEY")
URL = "https://api.hrum.ai/api/v1/partners/v1/chat/completions"
SYSTEM = "You are a friendly chatbot. Reply in English."


def ask(user_id, text):
    resp = requests.post(
        URL,
        headers={"X-Partner-Api-Key": API_KEY.strip()},
        json={
            "model": "ridm/gpt-6-luna",
            "user": user_id,     # your app's user ID
            "historyCount": 10,  # the server adds this user's recent turns
            "systemPrompt": SYSTEM,
            "messages": [{"role": "user", "content": text}],  # only the new message
        },
        timeout=60,
    )
    resp.raise_for_status()
    return resp.json()["choices"][0]["message"]["content"]


print(ask("user-sky", "My name is Haneul and I love spicy food. Please remember that."))
print(ask("user-sky", "Do you remember my name and my favorite food?"))
print(ask("user-bada", "Do you remember my name and my favorite food?"))
Save as memory.mjs and run node memory.mjs (server-side code)
const API_KEY = process.env.HRUM_API_KEY ?? "YOUR_API_KEY";
const URL = "https://api.hrum.ai/api/v1/partners/v1/chat/completions";
const SYSTEM = "You are a friendly chatbot. Reply in English.";

async function ask(userId, text) {
  const res = await fetch(URL, {
    method: "POST",
    headers: { "X-Partner-Api-Key": API_KEY.trim(), "Content-Type": "application/json" },
    body: JSON.stringify({
      model: "ridm/gpt-6-luna",
      user: userId,     // your app's user ID
      historyCount: 10, // the server adds this user's recent turns
      systemPrompt: SYSTEM,
      messages: [{ role: "user", content: text }], // only the new message
    }),
  });
  if (!res.ok) throw new Error(`${res.status} ${await res.text()}`);
  const data = await res.json();
  return data.choices[0].message.content;
}

console.log(await ask("user-sky", "My name is Haneul and I love spicy food. Please remember that."));
console.log(await ask("user-sky", "Do you remember my name and my favorite food?"));
console.log(await ask("user-bada", "Do you remember my name and my favorite food?"));

Use the key on your server only. Put it in browser or app code and anyone can read it.

What you get

The same user is remembered; a different user knows nothing. That is the point.

user-sky

My name is Haneul and I love spicy food. Please remember that.

I’ll remember that your name is Haneul and that you love spicy food.

Do you remember my name and my favorite food?

Your name is Haneul, and you love spicy food. I don’t know your specific favorite dish.

user-bada

Do you remember my name and my favorite food?

I don’t have your name or favorite food in this conversation. Please tell me, and I’ll keep them in mind for this chat.

These are replies from a real run. They are AI replies, so the wording changes a little each time.

Three things that turn memory on

user
Put your app's own user ID here (member number, login ID and so on). Same value, same person; different value, different person. Each person is stored separately and never mixed.
A ridm/ model
Memory is on only when the model name starts with ridm/. Without the prefix the model answers once, with no memory.
historyCount
The server adds this user's recent turns, so messages holds only the new message. Leave it out and the server adds no earlier turns.

systemPrompt holds your chatbot's role and tone. It is separate from memory; send it with every request.

As the conversation grows, HRUM summarizes it on its own and collects facts such as name and tastes into the user's profile. Older stories come back when they relate to the current conversation.

Next