MCPcopy Create free account
hub / github.com/AQ-MedAI/MedMemoryBench / __init__

Method __init__

methods/memOS/MemOS/src/memos/api/client.py:34–60  ·  view source on GitHub ↗
(
        self,
        api_key: str | None = None,
        base_url: str | None = None,
        is_global: str | bool = "false",
    )

Source from the content-addressed store, hash-verified

32 """MemOS API client"""
33
34 def __init__(
35 self,
36 api_key: str | None = None,
37 base_url: str | None = None,
38 is_global: str | bool = "false",
39 ):
40 # Priority:
41 # 1. base_url argument
42 # 2. MEMOS_BASE_URL environment variable (direct URL)
43 # 3. MEMOS_IS_GLOBAL environment variable (True/False toggle)
44 arg_is_global = str(is_global).lower() in ("true", "1", "yes")
45 memos_is_global = os.getenv("MEMOS_IS_GLOBAL", "false").lower() in ("true", "1", "yes")
46 final_is_global = arg_is_global or memos_is_global
47 default_url = (
48 "https://api.memt.ai/platform/api/openmem/v1"
49 if final_is_global
50 else "https://memos.memtensor.cn/api/openmem/v1"
51 )
52
53 self.base_url = base_url or os.getenv("MEMOS_BASE_URL") or default_url
54
55 api_key = api_key or os.getenv("MEMOS_API_KEY")
56
57 if not api_key:
58 raise ValueError("MemOS API key is required")
59 self.api_key = api_key
60 self.headers = {"Content-Type": "application/json", "Authorization": f"Token {api_key}"}
61
62 def _validate_required_params(self, **params):
63 """Validate required parameters - if passed, they must not be empty"""

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected