Skip to main content
Last updated on

Configuration

The Mastra SDK can be configured through environment variables or explicit options passed to withOpenBox() and parseOpenBoxConfig().

Configuration Precedence

Configuration is resolved in this order:

  1. Explicit options passed in code
  2. Environment variables
  3. SDK defaults for optional fields

apiUrl and apiKey are always required from either code or environment.

Environment Variables

VariableRequiredDefaultPurpose
OPENBOX_URLYes-OpenBox Core base URL
OPENBOX_API_KEYYes-OpenBox API key
OPENBOX_VALIDATENotrueValidate the API key at startup
OPENBOX_GOVERNANCE_POLICYNofail_openBehavior when OpenBox is unavailable
OPENBOX_GOVERNANCE_TIMEOUTNo30Timeout in seconds for evaluate and approval calls
OPENBOX_HITL_ENABLEDNotrueEnable approval suspension or polling
OPENBOX_HTTP_CAPTURENotrueCapture text HTTP bodies and headers
OPENBOX_INSTRUMENT_DATABASESNotrueEnable supported database instrumentation
OPENBOX_INSTRUMENT_FILE_IONofalseEnable file operation capture
OPENBOX_SEND_START_EVENTNotrueEmit WorkflowStarted
OPENBOX_SEND_ACTIVITY_START_EVENTNotrueEmit ActivityStarted
OPENBOX_SKIP_ACTIVITY_TYPESNosend_governance_eventSkip matching activity types
OPENBOX_SKIP_SIGNALSNoemptySkip matching signal names
OPENBOX_SKIP_WORKFLOW_TYPESNoemptySkip matching workflow or agent workflow types
OPENBOX_DEBUGNofalseEnable summarized debug logging

Core Runtime Options

OptionDefaultUse it to
apiUrlrequiredPoint the SDK at OpenBox Core
apiKeyrequiredAuthenticate evaluate and approval calls
validatetrueFail fast on invalid credentials or insecure URLs
onApiError"fail_open"Choose availability versus strict enforcement during outages
governanceTimeout30Set the API timeout in seconds
hitlEnabledtrueEnable approval handling
httpCapturetrueCapture text HTTP payloads and headers
instrumentDatabasestrueEnable supported DB instrumentation
instrumentFileIofalseEnable file operation telemetry
sendStartEventtrueEmit WorkflowStarted
sendActivityStartEventtrueEmit ActivityStarted
SettingRecommended valueWhy
validatetrueCatch bad credentials or insecure URLs during startup
onApiErrorexplicit per environmentAvoid accidental fail-open or fail-closed behavior
httpCapturetrue unless payload sensitivity blocks itPreserve request context for policy and troubleshooting
instrumentDatabasestrueLow-friction visibility into data access
instrumentFileIofalse until neededReduce noise and sensitive-path exposure
skipSignalsDo not skip agent_output by defaultThat signal carries agent output and model telemetry

Example

import { withOpenBox } from "@openbox-ai/openbox-mastra-sdk";

await withOpenBox(mastra, {
apiKey: process.env.OPENBOX_API_KEY,
apiUrl: process.env.OPENBOX_URL,
validate: true,
onApiError: "fail_open",
governanceTimeout: 30,
hitlEnabled: true,
httpCapture: true,
instrumentDatabases: true,
instrumentFileIo: false,
sendStartEvent: true,
sendActivityStartEvent: true,
skipActivityTypes: ["send_governance_event"],
skipSignals: [],
skipWorkflowTypes: []
});

Important Behavioral Notes

Validation

Startup validation checks:

  • API key format
  • OpenBox URL format
  • live API key validation unless validate: false

Use validate: false only for tests, local mocks, or fixture servers.

Failure Policy

fail_open keeps the application running if OpenBox is unreachable. fail_closed stops governed execution when OpenBox cannot be reached after retries. Choose this intentionally before deployment.

Skip Lists

Skip lists suppress emission of matching workflow, activity, or signal events. This is useful for reducing noise, but it can also hide telemetry you later expect in the UI.

Next Steps