mem0ai/mem0 · error · ValueError
org_id must be set to create a project
Error message
org_id must be set to create a project
What it means
The synchronous project create() posts to /api/v1/orgs/organizations/{org_id}/projects/, which requires an org_id in the URL. If the client config has no org_id, it raises ValueError before making the request. This is the sync twin of the async guard at project.py:700.
Source
Thrown at mem0/client/project.py:376
"""
Create a new project within the organization.
Args:
name: Name of the project to be created
description: Optional description for the project
Returns:
Dictionary containing the created project details.
Raises:
ValidationError: If the input data is invalid.
AuthenticationError: If authentication fails.
RateLimitError: If rate limits are exceeded.
NetworkError: If network connectivity issues occur.
ValueError: If org_id is not set.
"""
if not self.config.org_id:
raise ValueError("org_id must be set to create a project")
payload = {"name": name}
if description is not None:
payload["description"] = description
response = self._client.post(
f"/api/v1/orgs/organizations/{self.config.org_id}/projects/",
json=payload,
)
response.raise_for_status()
capture_client_event(
"client.project.create",
self,
{"name": name, "description": description, "sync_type": "sync"},
)
return response.json()
@api_error_handlerView on GitHub (pinned to 001c235229)
Solutions
- Construct the client with org_id before calling projects.create()
- Verify the org_id value is a non-empty string (None or "" both fail)
- Fetch the org ID from the Mem0 dashboard and add it to your config/env
Example fix
# before client = MemoryClient(api_key=API_KEY) client.projects.create(name="demo") # after client = MemoryClient(api_key=API_KEY, org_id="my-org") client.projects.create(name="demo")
Defensive patterns
Strategy: validation
Validate before calling
if not (org_id and org_id.strip()):
raise ConfigError("projects.create requires a non-empty org_id")
client = MemoryClient(api_key=API_KEY, org_id=org_id) Type guard
def has_org_id(client) -> bool:
return bool(getattr(getattr(client, "config", None), "org_id", None)) Try / catch
try:
client.projects.create(name=name)
except ValueError as e:
if "org_id must be set to create" in str(e):
raise ConfigError("configure org_id before provisioning projects") from e
raise Prevention
- Provision org context before any project-creation flow
- Treat empty-string org_id as missing in your config loader
When it happens
Trigger: Calling `client.projects.create(name=...)` (sync) on a client constructed without org_id. The check is `if not self.config.org_id`, so an empty string also triggers it.
Common situations: Onboarding scripts that try to create the first project before any org context is configured; org_id loaded from a settings file that silently returns None; mixing memory-scope and project-scope client usage in one app.
Related errors
- org_id and project_id must be set to access project operatio
- Please provide both org_id and project_id
- At least one parameter must be provided for update: custom_i
- projectId must be set to access webhooks
- projectId must be set to create a webhook
AI-assisted analysis of mem0ai/mem0@001c235229 (2026-08-15).
Data as JSON: /api/errors/f84ff552008261c4.
Report an issue: GitHub.