Try Chat Free Docs Pricing AI Analysis Repo Insights Free Tools About Blog
Sign in Get started free
< Back to blog
Tutorial Velona Team ·26 July 2026 ·4 min read

Build an AI Study Buddy with Long-Term Memory Using Velona Memory Sessions

Standard AI chatbots are stateless. Every time a student starts a new chat, the AI forgets everything: what topics were covered yesterday, which formulas the student struggled with, or what quiz scores they got last week.

The usual fix is to resend the whole chat history on every API call, which means storing it yourself and trimming it as it grows. In this tutorial, we will build a personalised AI Study Buddy using Python and Velona Memory Sessions, which keep the conversation context on Velona's side so your code only sends the new message.

What Are Velona Memory Sessions?

A Memory Session is a server-side context store you create in your Velona dashboard. Each session gets an ID like mem_4a7b2c3d1e9f0a8b and a character limit you choose. When you pass that ID with a request to the native endpoint, Velona adds the stored context to the conversation and keeps it updated, so the tutor remembers past sessions without you managing a history database.

The stored context is sent to the model along with your message, so it counts as input tokens. The benefit is simplicity and persistence, not free tokens. Pick a session size that matches how much history the tutor really needs.

Step 1: Create a Memory Session and API Key

To set up memory for your AI tutor:

  1. Sign up on the Velona Registration Page.
  2. Fund your wallet on the Prepaid Wallet Dashboard starting at ₹10 via UPI, RuPay, or GPay.
  3. Open Memory Sessions, create a new session (for example the 150K character tier), and copy the generated mem_... ID. Session IDs must be created here first; a made-up string will not work.
  4. Go to API Key Management and create an API key named study-tutor-app.

Step 2: Build the Python AI Study Buddy

Create a file named study_buddy.py. Memory Sessions work on Velona's native endpoint (/gateway/v1/inference/run) through the velona.memory_session field.

import os
import requests

VELONA_API_KEY = os.environ["VELONA_API_KEY"]
MEMORY_SESSION_ID = os.environ["VELONA_MEMORY_ID"]   # e.g. mem_4a7b2c3d1e9f0a8b
VELONA_URL = "https://velona.in/gateway/v1/inference/run"
MODEL = "deepseek/deepseek-v4-flash"

headers = {
    "Authorization": f"Bearer {VELONA_API_KEY}",
    "Content-Type": "application/json",
}

SYSTEM_PROMPT = """You are 'Arya', an encouraging personal AI tutor for high school physics and math.
Keep track of the student's weak topics, praise their improvements, and offer short quizzes.
Keep responses concise and easy to understand."""


def chat_with_tutor(user_message: str) -> str:
    payload = {
        "model": MODEL,
        "velona": {"memory_session": MEMORY_SESSION_ID},
        "turns": [
            {"role": "system", "content": SYSTEM_PROMPT},
            {"role": "user", "content": user_message},
        ],
    }
    response = requests.post(VELONA_URL, json=payload, headers=headers, timeout=60)
    response.raise_for_status()
    result = response.json()
    # The native endpoint returns the reply in data.output and token counts in data.usage
    return result["data"]["output"]


print("--- AI Study Buddy started (memory active) ---")
print("Type 'exit' to quit.\n")

while True:
    user_input = input("Student: ")
    if user_input.lower() in ["exit", "quit"]:
        break
    reply = chat_with_tutor(user_input)
    print(f"\nTutor (Arya): {reply}\n")

Run it, tell Arya you find projectile motion confusing, close the script, and start it again tomorrow. Ask "what was I weak at?" and the tutor still knows.

Memory Sessions vs. Sending History Yourself

Send the message array yourselfVelona Memory Session
Where history livesYour database or app stateOn Velona, tied to the mem_ ID
Code you writeStorage, trimming, and reloading logicOne extra field in the request
PersistenceOnly as good as your storagePersists across days and weeks
Token costGrows with the history you sendContext is billed as input, capped by the session size
Best forThousands of short user threadsA small number of long-running assistants or learners

For a class of students, create one session per student in the dashboard and store each student's mem_ ID in your user table. For thousands of anonymous users, keeping a short history yourself is simpler, as shown in our WhatsApp support bot tutorial.

Model Selection and Cost in Rupees

Assume each tutor reply carries about 5,000 tokens of remembered context plus the question, and returns about 300 tokens:

Model ID₹ per 1M input / outputApprox. per replyBest for
deepseek/deepseek-v4-flash₹2.90 / ₹5.80₹0.017Everyday explanations and quizzes
openai/gpt-4o-mini₹15.54 / ₹62.17₹0.10Friendly tone, reads photos of homework
deepseek/deepseek-v4-pro₹21.63 / ₹43.27₹0.13Step-by-step maths and physics derivations
google/gemini-2.5-flash₹31.08 / ₹259.02₹0.24Diagrams and long reading material

On DeepSeek V4 Flash, ₹10 covers roughly 580 tutor replies. Your usage page shows the real token count and rupee cost of every request, so you can see exactly how much the memory adds. Live prices are on the Velona pricing page.

Developer Utilities and Testing

While tuning system prompts or inspecting raw API requests, use Velona's free developer tools such as the JSON Formatter and Character Counter. They run in your browser and never touch your wallet.

You can also try Memory Sessions in the browser with Velona Chat, or compare tutor answers across models in the Model Evaluator.

Conclusion

Adding long-term memory turns a static Q&A bot into an adaptive, personal tutor. With Velona Memory Sessions and rupee billing, students and developers in India can build persistent AI apps and pay with a simple UPI top-up.

Ready to build your study buddy? Create a free Velona account, add ₹10, and set up your first Memory Session.