Skip to main content
Configure the Moru SDK and CLI using environment variables.

SDK Configuration

MORU_API_KEY

Your Moru API key for authentication.
export MORU_API_KEY=moru_abc123...
Get your API key from the dashboard.
# Automatically used
from moru import Sandbox
sandbox = Sandbox.create()

# Or override
sandbox = Sandbox.create(api_key="different_key")

MORU_ACCESS_TOKEN

Access token for CLI authentication (typically set by moru auth login).
export MORU_ACCESS_TOKEN=eyJ...

MORU_DEBUG

Enable debug logging.
export MORU_DEBUG=true

MORU_API_URL

Full API URL (advanced usage).
export MORU_API_URL=https://api.moru.io

Sandbox Environment Variables

Set environment variables inside sandboxes:
sandbox = Sandbox.create(
    envs={
        "API_KEY": "secret",
        "NODE_ENV": "production",
        "DATABASE_URL": "postgres://..."
    }
)

# Access in commands
result = sandbox.commands.run("echo $API_KEY")

Per-Command Environment Variables

Set environment variables for specific commands:
result = sandbox.commands.run(
    "python script.py",
    envs={
        "DEBUG": "true",
        "LOG_LEVEL": "debug"
    }
)

Template Environment Variables

Set default environment variables in templates:
template = (
    Template()
    .from_python_image()
    .set_envs({
        "PYTHONUNBUFFERED": "1",
        "NODE_ENV": "production"
    })
)

Priority Order

Environment variables are resolved in this order (highest priority first):
  1. Per-command envs option
  2. Sandbox creation envs option
  3. Template default environment variables
  4. System environment variables in the base image

CI/CD Examples

GitHub Actions

name: Build and Test
on: push

jobs:
  test:
    runs-on: ubuntu-latest
    env:
      MORU_API_KEY: ${{ secrets.MORU_API_KEY }}
    steps:
      - uses: actions/checkout@v3
      - name: Run tests in sandbox
        run: |
          pip install moru
          python test_in_sandbox.py

GitLab CI

test:
  variables:
    MORU_API_KEY: $MORU_API_KEY
  script:
    - pip install moru
    - python test_in_sandbox.py

CircleCI

version: 2.1
jobs:
  test:
    docker:
      - image: python:3.11
    environment:
      MORU_API_KEY: ${MORU_API_KEY}
    steps:
      - checkout
      - run: pip install moru
      - run: python test_in_sandbox.py

Next Steps