项目文件夹

文件
wehub-resource-sync 555e282cc4
pi-agent-plugin checks / lint (push) Has been cancelled
pi-agent-plugin checks / test (20) (push) Has been cancelled
pi-agent-plugin checks / test (22) (push) Has been cancelled
pi-agent-plugin checks / build (push) Has been cancelled
TypeScript SDK CI / check_changes (push) Has been cancelled
TypeScript SDK CI / changelog_check (push) Has been cancelled
ci / changelog_check (push) Has been cancelled
ci / check_changes (push) Has been cancelled
ci / build_mem0 (3.10) (push) Has been cancelled
ci / build_mem0 (3.11) (push) Has been cancelled
ci / build_mem0 (3.12) (push) Has been cancelled
CLI Node CI / lint (push) Has been cancelled
CLI Node CI / test (20) (push) Has been cancelled
CLI Node CI / test (22) (push) Has been cancelled
CLI Node CI / build (push) Has been cancelled
CLI Python CI / lint (push) Has been cancelled
CLI Python CI / test (3.10) (push) Has been cancelled
CLI Python CI / test (3.11) (push) Has been cancelled
CLI Python CI / test (3.12) (push) Has been cancelled
CLI Python CI / build (push) Has been cancelled
openclaw checks / lint (push) Has been cancelled
openclaw checks / test (20) (push) Has been cancelled
openclaw checks / test (22) (push) Has been cancelled
openclaw checks / build (push) Has been cancelled
opencode-plugin checks / build (push) Has been cancelled
TypeScript SDK CI / build_ts_sdk (20) (push) Has been cancelled
TypeScript SDK CI / build_ts_sdk (22) (push) Has been cancelled
TypeScript SDK CI / integration_ts_sdk (20) (push) Has been cancelled
TypeScript SDK CI / integration_ts_sdk (22) (push) Has been cancelled
chore: import upstream snapshot with attribution
2026-07-13 13:03:45 +08:00

4.9 KiB

Python vs TypeScript SDK Differences

Quick-reference cheatsheet for developers working across both Mem0 SDKs.

Constructor

Aspect Python TypeScript
Import (Platform) from mem0 import MemoryClient import MemoryClient from 'mem0ai'
Import (OSS) from mem0 import Memory import { Memory } from 'mem0ai/oss'
Constructor MemoryClient(api_key="m0-xxx") new MemoryClient({ apiKey: 'm0-xxx' })
Required param api_key (positional or kwarg) apiKey (in options object)

Both read from MEM0_API_KEY env var if no key provided.

Method Naming

Operation Python TypeScript
Add add() add()
Search search() search()
Get get() get()
Get all get_all() getAll()
Update update() update()
Delete delete() delete()
Delete all delete_all() deleteAll()
History history() history()
Batch update batch_update() batchUpdate()
Batch delete batch_delete() batchDelete()
List users users() users()
Delete users delete_users() deleteUsers()
Get project project.get() getProject()
Update project project.update() updateProject()
Create webhook create_webhook() createWebhook()
Get webhooks get_webhooks() getWebhooks()
Update webhook update_webhook() updateWebhook()
Delete webhook delete_webhook() deleteWebhook()
Create export create_memory_export() createMemoryExport()
Get export get_memory_export() getMemoryExport()
Feedback feedback() feedback()

Rule: Python uses snake_case, TypeScript uses camelCase for method names.

Parameter Passing

# Python: kwargs
client.add(messages, user_id="alice", metadata={"source": "chat"})
client.search("query", filters={"user_id": "alice"}, top_k=5, rerank=True)
// TypeScript: options object with camelCase for top-level params, snake_case for filter keys
await client.add(messages, { userId: 'alice', metadata: { source: 'chat' } });
await client.search('query', { filters: { user_id: 'alice' }, topK: 5, rerank: true });

v3: Python uses snake_case everywhere. TypeScript uses camelCase for top-level params (userId, topK) but snake_case for filter keys (user_id, agent_id).

Architectural Differences

Aspect Python TypeScript
HTTP library httpx axios
Default timeout 300s 60s
Sync support Yes (MemoryClient) No (all async)
Async support Yes (AsyncMemoryClient) All methods are async
Project management client.project.* (separate class) client.getProject() / client.updateProject()
Context manager async with AsyncMemoryClient() Not supported

Platform Features: Python-only

These methods exist in Python but not TypeScript:

Method Description
get_summary(filters) Get summary of memories
reset() Delete ALL data (users + memories)
project.create(name) Create a new project
project.delete() Delete current project
project.get_members() List project members
project.add_member(email, role) Add member to project
project.update_member(email, role) Change member role
project.remove_member(email) Remove member

Platform Features: TypeScript-only

Method Description
deleteUser(data) Convenience method for single entity deletion
ping() Health check endpoint

OSS Config Naming

Python config key TypeScript config key
vector_store vectorStore
history_db_path historyDbPath
custom_instructions customInstructions

OSS Scope Parameter Naming

Python TypeScript
user_id="alice" userId: 'alice'
agent_id="bot" agentId: 'bot'
run_id="session" runId: 'session'

Entity ID Passing (v3)

Method Python TypeScript
add() Top-level: user_id="alice" Top-level: { userId: 'alice' }
search() In filters: filters={"user_id": "alice"} In filters: { filters: { user_id: 'alice' } }
get_all() In filters: filters={"user_id": "alice"} In filters: { filters: { user_id: 'alice' } }

Common Gotcha

When searching/filtering, both Python and TypeScript use snake_case for filter keys. TypeScript only uses camelCase for top-level method parameters:

# Python - snake_case in filters
results = client.search("query", filters={"user_id": "alice"})
// TypeScript - snake_case in filters, camelCase for top-level params
const results = await client.search('query', { filters: { user_id: 'alice' }, topK: 20 });