---
title: "Infer Proactive Topics"
method: POST
path: "/api/v1/users/roleplay/proactive/{user_id}"
tags: ["roleplay"]
---

# Infer Proactive Topics

`POST /api/v1/users/roleplay/proactive/{user_id}`

Provide interest detection and personalized topics

## Path parameters

- `user_id` union, required — The ID of the user
  - string, uuid4
  - string, uuid5

## Query parameters

- `topk` integer — Number of profiles to retrieve, default is all
- `max_token_size` integer — Max token size of returned profile content, default is all
- `prefer_topics` string[] — Rank prefer topics at first to try to keep them in filtering, default order is by updated time
- `only_topics` string[] — Only return profiles with these topics, default is all
- `max_subtopic_size` integer — Max subtopic size of the same topic in returned profile, default is all
- `topic_limits_json` string — Set specific subtopic limits for topics in JSON, for example {"topic1": 3, "topic2": 5}. The limits in this param will override `max_subtopic_size`.

## Request body

- ProactiveTopicRequest
  - `messages` OpenAICompatibleMessage[], required — The latest messages between user/assistant
    - `role` 'user' | 'assistant', required
    - `content` string, required
    - `alias` string, nullable
    - `created_at` string, nullable
  - `agent_context` string, nullable — The agent's roleplay prompt

## Response `200`

Successful Response

- ProactiveTopicResponse
  - `data` ProactiveTopicData
    - `action` 'new_topic' | 'continue', required — The action to take
    - `topic_prompt` string, nullable — The topic prompt, insert it to your latest user message or system prompt
  - `errno` 0 | 400 | 401 | 403 | 404 | 405 | 409 | 422 | 500 | 501 | 502 | 503 | 504 | 520
  - `errmsg` string — Error message, empty when success

## Other responses

- `422` — Validation Error

## Changes

- **2025-09-01** `c5d39efe16d8` — 1 info
  - for the `path` request parameter `user_id`, the type/format was generalized from `string`/`` to ``/``
- **2025-06-04** `7e8f661d177c` — 1 info
  - endpoint added
- **2025-01-15** `a9bfbdf3d53b` — 1 breaking
  - api path removed without deprecation

[Change history](https://skmtc.dev/memodb-io/apis/memobase-api/changes/api/v1/users/roleplay/proactive/:user_id/post.md)

---

[API](https://skmtc.dev/memodb-io/apis/memobase-api.md) · [All operations](https://skmtc.dev/memodb-io/apis/memobase-api/llms.txt) · [OpenAPI document](https://skmtc-service-production.skmtc.workers.dev/v1/apis/memodb-io/memobase-api/revisions/4543f130c8e0/schema)
