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_AGENT_DIDYes, unless disabled-DID assigned to this OpenBox agent
OPENBOX_AGENT_PRIVATE_KEYYes, unless disabled-Base64 raw Ed25519 seed returned during identity provision or rotation
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
agentDidunsetIdentify the agent for DID-signed OpenBox requests
agentPrivateKeyunsetSign OpenBox requests when the registered agent requires signing
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
OPENBOX_AGENT_PRIVATE_KEYSecret manager only when signing is requiredPrevents agent identity material from being shared or committed

Example

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

await withOpenBox(mastra, {
apiKey: process.env.OPENBOX_API_KEY,
apiUrl: process.env.OPENBOX_URL,
agentDid: process.env.OPENBOX_AGENT_DID,
agentPrivateKey: process.env.OPENBOX_AGENT_PRIVATE_KEY,
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

Agent DID Identity

Newly created OpenBox agents require cryptographic DID signing by default. When Require signing is enabled for the registered agent, the Mastra SDK signs validation, governance evaluation, and approval requests with the agent's DID identity.

Set both values together:

.env
OPENBOX_AGENT_DID=did:aip:550e8400-e29b-41d4-a716-446655440000
OPENBOX_AGENT_PRIVATE_KEY=base64_raw_ed25519_seed

Rules:

  • OPENBOX_AGENT_DID must use the did:aip:<uuid> format.
  • OPENBOX_AGENT_PRIVATE_KEY must be the base64 raw 32-byte Ed25519 seed returned by OpenBox.
  • Setting only one of the two values fails SDK configuration parsing.
  • The SDK never logs the private key.

The private key is returned only when the agent identity is provisioned or rotated. Store it as a per-agent secret and rotate it from OpenBox if it is exposed.

If Require signing is disabled for the agent, omit both DID values and authenticate with OPENBOX_API_KEY only.

Validation

Startup validation checks:

  • API key format
  • OpenBox URL format
  • DID identity pair consistency when DID signing values are present
  • 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