メモリからのチャットコンテキストを割り当てます(デフォルトのソース:エポック、セマンティック、最近のタームは enabled_sources に stm を含めます)。プロジェクトスコープは ルート ID パス パラメーターによって保持され、 組織はそのプロジェクトから派生します。空でないクエリ(通常は最新のユーザー メッセージ)と、アセンブルするメモリを持つ user_id を指定します。
body
必須
コンテキスト構築リクエスト
-
EnabledSources は、メモリ ソース(stm、エポック、セマンティック、分類、手順)を選択します。省略された場合、デフォルトはエポック、セマンティックです。
-
MaxTokens は、総コンテキスト構築の予算(取得コストではありません)。検索とランキングの結果、メモリサーバーは500 トークンのフォーマット 予約を減算し、 が に収まるメモリ チャンク全体を必要に応じて選択します。 500 以下の正の値では、メモリの予算はありません。 500 を超える値では、チャンクが収まらない場合でも空のコンテキストが生成されることがあります。
の最小値は
1です。 -
追加のプロパティが許可されます。
-
最小値は
1、最大値は200です。
POST /api/v1 /projects/{id}/memory/context
curl \
--request POST 'https://agentengine.mongodb.com/api/v1/projects/{id}/memory/context' \
--header "Authorization: $API_KEY" \
--header "Content-Type: application/json" \
--data '{
"enabled_sources": [
"string"
],
"format_style": "string",
"include_memories": true,
"max_tokens": 42,
"metadata_filter": {},
"model_type": "string",
"query": "string",
"query_embedding": [
42.0
],
"session_id": "string",
"similarity_threshold": 42.0,
"top_k": 42,
"user_id": "string",
"visibility": "string"
}'
リクエスト例
{
"enabled_sources": [
"string"
],
"format_style": "string",
"include_memories": true,
"max_tokens": 42,
"metadata_filter": {},
"model_type": "string",
"query": "string",
"query_embedding": [
42.0
],
"session_id": "string",
"similarity_threshold": 42.0,
"top_k": 42,
"user_id": "string",
"visibility": "string"
}
応答の例(406)
操作は利用できません
{
"detail": "This operation is not available in API version 2026-09-20-preview.",
"error": 406,
"errorCode": "OPERATION_NOT_IN_API_VERSION",
"parameters": [
"Accept"
],
"reason": "Not Acceptable"
}
{
"detail": "This operation supports text/event-stream, which the Accept header excludes. Remove unsupported media-type parameters or accept this type with a positive q value.",
"error": 406,
"errorCode": "UNACCEPTABLE_MEDIA_TYPE",
"parameters": [
"Accept"
],
"reason": "Not Acceptable"
}
{
"detail": "The requested API version is not supported. Supported versions: 2026-09-20-preview.",
"error": 406,
"errorCode": "UNSUPPORTED_API_VERSION",
"parameters": [
"Accept"
],
"reason": "Not Acceptable"
}
応答の例(406)
{
"detail": "This operation is not available in API version 2026-09-20-preview.",
"error": 406,
"errorCode": "OPERATION_NOT_IN_API_VERSION",
"parameters": [
"Accept"
],
"reason": "Not Acceptable"
}
応答の例(200)
{}
応答の例(200)
{}
応答の例(400)
{
"code": "string",
"error": "string",
"success": true
}
応答の例(400)
{
"code": "string",
"error": "string",
"success": true
}
応答の例(401)
{
"code": "string",
"error": "string",
"success": true
}
応答の例(401)
{
"code": "string",
"error": "string",
"success": true
}
応答の例(403)
{
"code": "string",
"error": "string",
"success": true
}
応答の例(403)
{
"code": "string",
"error": "string",
"success": true
}
応答の例(500)
{
"code": "string",
"error": "string",
"success": true
}
応答の例(500)
{
"code": "string",
"error": "string",
"success": true
}
応答の例(502)
{
"code": "string",
"error": "string",
"success": true
}
応答の例(502)
{
"code": "string",
"error": "string",
"success": true
}