{"record":{"id":"b52cc57e66a40690","repo":"mem0ai/mem0","slug":"mem0-api-key-not-provided-please-provide-an-api-k","errorCode":null,"errorMessage":"Mem0 API Key not provided. Please provide an API Key.","messagePattern":"Mem0 API Key not provided\\. Please provide an API Key\\.","errorType":"validation","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"mem0/client/main.py","lineNumber":123,"sourceCode":"                     provided, it will attempt to use the MEM0_API_KEY\n                     environment variable.\n            host: The base URL for the Mem0 API. Defaults to\n                  \"https://api.mem0.ai\".\n            client: A custom httpx.Client instance. If provided, it will be\n                    used instead of creating a new one. Note that base_url and\n                    headers will be set/overridden as needed.\n\n        Raises:\n            ValueError: If no API key is provided or found in the environment.\n        \"\"\"\n        self.api_key = api_key or os.getenv(\"MEM0_API_KEY\")\n        self.host = host or \"https://api.mem0.ai\"\n        self.org_id = None\n        self.project_id = None\n        self.user_id = get_user_id()\n\n        if not self.api_key:\n            raise ValueError(\"Mem0 API Key not provided. Please provide an API Key.\")\n\n        # Create MD5 hash of API key for user_id\n        self.user_id = hashlib.md5(self.api_key.encode()).hexdigest()\n\n        if client is not None:\n            self.client = client\n            # Ensure the client has the correct base_url and headers\n            self.client.base_url = httpx.URL(self.host)\n            self.client.headers.update(\n                {\n                    \"Authorization\": f\"Token {self.api_key}\",\n                    \"Mem0-User-ID\": self.user_id,\n                }\n            )\n        else:\n            self.client = httpx.Client(\n                base_url=self.host,\n                headers={","sourceCodeStart":105,"sourceCodeEnd":141,"githubUrl":"https://github.com/mem0ai/mem0/blob/001c235229be8795e3834520467bd0d661ed8f34/mem0/client/main.py#L105-L141","documentation":"Error \"Mem0 API Key not provided. Please provide an API Key.\" thrown in mem0ai/mem0.","triggerScenarios":"Thrown at mem0/client/main.py:123 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Set the MEM0_API_KEY environment variable or pass api_key to MemoryClient().","Get an API key from the Mem0 platform dashboard."],"exampleFix":null,"handlingStrategy":null,"validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"001c235229be8795e3834520467bd0d661ed8f34","analyzedAt":"2026-08-15T01:55:42.685Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}