Skip to main content
Environments are Memic’s tenancy boundary. Every file, every vector, every search query is scoped to exactly one environment, and there is no way to query across environments from a single API key. If you take one thing away from this guide: environments are the unit of isolation. Whatever you need to keep separate, put it in different environments.

Common patterns

Staging vs production

The simplest use: two environments, two keys, same codebase.
import os
from memic import Memic

client = Memic(api_key=os.environ["MEMIC_API_KEY"])
# dev
export MEMIC_API_KEY="mk_live_staging_..."

# prod
export MEMIC_API_KEY="mk_live_prod_..."

Per-customer isolation

If you’re building a multi-tenant SaaS where each customer has their own knowledge base, create one environment per customer. Your provisioning flow:
  1. Customer signs up
  2. Your backend creates a new environment in Memic (via the dashboard or admin API)
  3. Your backend creates an API key scoped to that environment
  4. You store the key in your database, associated with the customer
Every time you handle a request from that customer, you load their specific API key and instantiate a Memic client. Customer data is never visible to other customers because the key cannot access other environments. See the Per-customer isolation recipe for a full walkthrough.

Feature branches

If you’re running many feature-branch deploys on a staging server, create a short-lived environment per branch. Delete it when the branch merges.

What’s inside an environment

Every environment has:
  • Its own file namespace — files are not shared across environments
  • Its own vector index — search never crosses environment boundaries
  • Its own prompts — prompt names are scoped per environment
  • Its own folders — folder names are scoped per environment
  • Its own connectors — if you have connector-backed structured search
Organizations, projects, and users are shared across environments — they sit above environments in the hierarchy.

Switching environments in code

Because environments are key-scoped, switching is just swapping the key:
staging_client = Memic(api_key=STAGING_KEY)
prod_client = Memic(api_key=PROD_KEY)
You cannot switch environments mid-request. One client, one environment.

Creating and managing environments

Environments are created and managed from the Memic dashboard. Navigate to your project → Environments → Create.

Core concepts

The full hierarchy explained.

Recipe: Per-customer isolation

Multi-tenant SaaS pattern.