获取记忆
curl --request GET \
--url https://api.moonshot.cn/v1/memory-stores/{id}/memories/{memory_id} \
--header 'Authorization: Bearer <token>'import requests
url = "https://api.moonshot.cn/v1/memory-stores/{id}/memories/{memory_id}"
headers = {"Authorization": "Bearer <token>"}
response = requests.get(url, headers=headers)
print(response.text)const options = {method: 'GET', headers: {Authorization: 'Bearer <token>'}};
fetch('https://api.moonshot.cn/v1/memory-stores/{id}/memories/{memory_id}', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://api.moonshot.cn/v1/memory-stores/{id}/memories/{memory_id}",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "GET",
CURLOPT_HTTPHEADER => [
"Authorization: Bearer <token>"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}package main
import (
"fmt"
"net/http"
"io"
)
func main() {
url := "https://api.moonshot.cn/v1/memory-stores/{id}/memories/{memory_id}"
req, _ := http.NewRequest("GET", url, nil)
req.Header.Add("Authorization", "Bearer <token>")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(string(body))
}HttpResponse<String> response = Unirest.get("https://api.moonshot.cn/v1/memory-stores/{id}/memories/{memory_id}")
.header("Authorization", "Bearer <token>")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.moonshot.cn/v1/memory-stores/{id}/memories/{memory_id}")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Get.new(url)
request["Authorization"] = 'Bearer <token>'
response = http.request(request)
puts response.read_body{
"id": "mem_01h455vb4pex5vsknk084sn02q",
"memory_store_id": "mstr_01h455vb4pex5vsknk084sn02q",
"path": "README.md",
"content": "SGVsbG8=",
"content_sha256": "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",
"content_size_bytes": 5,
"created_at": "2026-01-01T00:00:00.000Z",
"updated_at": "2026-01-01T00:00:00.000Z"
}{
"error": {
"type": "invalid_parameter_error",
"message": "<string>",
"param": "<string>",
"request_id": "<string>"
}
}{
"error": {
"type": "invalid_parameter_error",
"message": "<string>",
"param": "<string>",
"request_id": "<string>"
}
}{
"error": {
"type": "invalid_parameter_error",
"message": "<string>",
"param": "<string>",
"request_id": "<string>"
}
}{
"error": {
"type": "invalid_parameter_error",
"message": "<string>",
"param": "<string>",
"request_id": "<string>"
}
}返回单个文件的元数据和当前的 base64 编码内容。已删除的文件返回 404。已归档的记忆库仍可读取。
GET
/
v1
/
memory-stores
/
{id}
/
memories
/
{memory_id}
获取记忆
curl --request GET \
--url https://api.moonshot.cn/v1/memory-stores/{id}/memories/{memory_id} \
--header 'Authorization: Bearer <token>'import requests
url = "https://api.moonshot.cn/v1/memory-stores/{id}/memories/{memory_id}"
headers = {"Authorization": "Bearer <token>"}
response = requests.get(url, headers=headers)
print(response.text)const options = {method: 'GET', headers: {Authorization: 'Bearer <token>'}};
fetch('https://api.moonshot.cn/v1/memory-stores/{id}/memories/{memory_id}', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://api.moonshot.cn/v1/memory-stores/{id}/memories/{memory_id}",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "GET",
CURLOPT_HTTPHEADER => [
"Authorization: Bearer <token>"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}package main
import (
"fmt"
"net/http"
"io"
)
func main() {
url := "https://api.moonshot.cn/v1/memory-stores/{id}/memories/{memory_id}"
req, _ := http.NewRequest("GET", url, nil)
req.Header.Add("Authorization", "Bearer <token>")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(string(body))
}HttpResponse<String> response = Unirest.get("https://api.moonshot.cn/v1/memory-stores/{id}/memories/{memory_id}")
.header("Authorization", "Bearer <token>")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.moonshot.cn/v1/memory-stores/{id}/memories/{memory_id}")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Get.new(url)
request["Authorization"] = 'Bearer <token>'
response = http.request(request)
puts response.read_body{
"id": "mem_01h455vb4pex5vsknk084sn02q",
"memory_store_id": "mstr_01h455vb4pex5vsknk084sn02q",
"path": "README.md",
"content": "SGVsbG8=",
"content_sha256": "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",
"content_size_bytes": 5,
"created_at": "2026-01-01T00:00:00.000Z",
"updated_at": "2026-01-01T00:00:00.000Z"
}{
"error": {
"type": "invalid_parameter_error",
"message": "<string>",
"param": "<string>",
"request_id": "<string>"
}
}{
"error": {
"type": "invalid_parameter_error",
"message": "<string>",
"param": "<string>",
"request_id": "<string>"
}
}{
"error": {
"type": "invalid_parameter_error",
"message": "<string>",
"param": "<string>",
"request_id": "<string>"
}
}{
"error": {
"type": "invalid_parameter_error",
"message": "<string>",
"param": "<string>",
"request_id": "<string>"
}
}路径参数
记忆库 ID。
Pattern:
^mstr_[0-9a-hjkmnp-tv-z]{26}$记忆文件 ID。
Pattern:
^mem_[0-9a-hjkmnp-tv-z]{26}$响应
文件的元数据与当前的 base64 编码内容。
记忆库中的一个文件。
id 在重命名后保持不变。删除文件后,其 ID 和版本历史仍可读取。
记忆文件 ID。文件重命名时保持不变。
Pattern:
^mem_[0-9a-hjkmnp-tv-z]{26}$所属记忆库的 ID。
Pattern:
^mstr_[0-9a-hjkmnp-tv-z]{26}$相对于记忆库根目录的路径。
解码后内容的 SHA-256 哈希。更新时回传用作乐观并发检查。
解码后内容的大小,单位为字节。
创建时间戳。
最近一次内容或路径更新的时间戳。
文件内容,经 base64 编码。在创建/获取/更新响应中存在。列表响应中省略。该字段存在与否可区分空文件与内容未加载两种情况。
此页面对您有帮助吗?