Skip to content

bug(client): MemoryClient ignores MEM0_HOST / MEM0_API_URL env vars #6622

Description

@Bartok9

Which SDK / package

Python SDK (mem0ai) — MemoryClient / AsyncMemoryClient

Describe the bug

MemoryClient.__init__ only accepts an explicit host= argument or hardcodes https://api.mem0.ai. It does not read MEM0_HOST or MEM0_API_URL, so proxy / private-gateway deployments must patch code or always pass host= in every process.

The OpenCode plugin request in #6498 documents the same need. Python host-path should honor the same env fallback used by many API clients:

host argument > MEM0_HOST > MEM0_API_URL > default https://api.mem0.ai

(Custom header injection can stay out of scope for this issue.)

Reproduction

import os
from unittest.mock import patch

os.environ["MEM0_HOST"] = "https://mem0-proxy.example.com"
os.environ["MEM0_API_KEY"] = "m0sk_test"

# Illustrative: after fix, MemoryClient().host should be the proxy URL

Expected behavior

When host is omitted, construct the client against MEM0_HOST or MEM0_API_URL if set.

Metadata

Metadata

Assignees

No one assigned

    Labels

    integrationsAgent and editor integrationspluginEditor and agent plugins (Claude Code, Cursor, Codex, OpenClaw, Pi Agent)sdk-pythonPython SDK specific

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions