SemiLayerDocs

Environments

An Environment is a deployment stage within a Project. Each environment is fully isolated — its own sources, lenses, API keys, and ingest jobs. This lets you develop and test schema changes without touching production data or indexes.


Default Setup

When you create a project, a development environment is created automatically. A typical setup adds staging and production as you ship:

my-app (Project)
  ├── development   ← local dev, experimentation
  ├── staging       ← pre-production verification
  └── production    ← live traffic

Create an Environment

Console: Project page → EnvironmentsNew environment.

CLI:

semilayer envs create
# prompts for name and slug

Each environment gets its own sk_ / pk_ / ik_ API keys created automatically.


Switch Environments

CLI — update your context:

semilayer config --set-env production

Or run semilayer init again to select a different environment interactively.

Console: Use the environment selector in the top navigation to switch between environments in the same project.


API Keys Per Environment

Keys are scoped to the environment in which they were created. A sk_live_ key for your production environment cannot access staging.

semilayer keys list                    # keys in current environment
semilayer keys create --type service   # new sk_ in current environment

Promoting Config Between Environments

To promote a lens config from staging to production:

Console: Open the Multi-environment comparison view from the environment selector → select the source environment → click Promote.

CLI — export then push:

# Export production config
semilayer config --set-env production
semilayer export config        # writes to sl.config.ts

# Review the diff, then push to production
semilayer push --resume-ingest

Or copy manually: the lens config is just the object in sl.config.ts. Promote by editing the file and pushing to the target environment.


Environment Variables

In your application, inject the right key and base URL per environment:

# .env.development
SEMILAYER_API_KEY=sk_dev_...
SEMILAYER_BASE_URL=https://api.semilayer.com

# .env.production
SEMILAYER_API_KEY=sk_live_...
SEMILAYER_BASE_URL=https://api.semilayer.com
const beam = createBeam({
  baseUrl: process.env.SEMILAYER_BASE_URL!,
  apiKey: process.env.SEMILAYER_API_KEY!,
})

Isolating Ingest

Each environment runs its own ingest independently. You can have production running continuous incremental syncs while staging is paused, or run a --rebuild on staging without affecting production.

# Rebuild staging without touching production
semilayer config --set-env staging
semilayer push --rebuild

# Production continues unaffected
semilayer config --set-env production
semilayer status

Delete an Environment

Console: Settings → EnvironmentsDelete (admin role required).

Deleting an environment permanently removes all its lenses, indexed data, sources, and API keys. This cannot be undone.