Docs/Configuration

Configuration

Environment variables, API key formats, provider configuration, and SDK options.

Environment Variables

VariableRequiredDescription
INVARIANCE_API_KEYYesAPI key for authentication. Formats: inv_*, dev_*, org_*
INVARIANCE_API_URLNoAPI endpoint. Default: https://api.useinvariance.com
INVARIANCE_PRIVATE_KEYNoEd25519 private key (64 hex chars) for signing receipts
ANTHROPIC_API_KEYNoUsed for narrative synthesis (LLM-summarized run views)

API Key Formats

Invariance uses tiered API keys with different permission levels:

PrefixTypeScope
dev_*DeveloperFull access to developer resources
org_*OrganizationAccess scoped to organization resources
inv_*Scoped API KeyPer-function access control via api_keys table
(agent key)AgentPer-agent auth, scoped to agent resources

SDK Configuration

Full configuration object for Invariance.init():

InvarianceConfigtypescript
interface InvarianceConfig {
  apiKey: string;                    // Required. API key for authentication
  apiUrl?: string;                   // Default: "https://api.useinvariance.com"
  privateKey?: string;               // Ed25519 private key (64 hex chars)
  policies?: PolicyRule[];           // Local policy rules
  flushIntervalMs?: number;          // Batch flush interval (default: 5000ms)
  maxBatchSize?: number;             // Max batch size (default: 50)
  maxQueueSize?: number;             // Max queue size (default: 1000)
  onError?: (err: InvarianceError) => void;  // Error callback
  mode?: 'DEV' | 'PROD';            // Observability mode (default: 'PROD')
  sampleRate?: number;               // Trace sampling rate in PROD mode
  devOutput?: 'ui' | 'console' | 'both';    // DEV mode output
  onMonitorTrigger?: (event: MonitorTriggerEvent) => void;  // Monitor callback
  monitorPollIntervalMs?: number;    // Monitor poll interval
}

Example .env File

.envbash
# ── Invariance Core ──
INVARIANCE_API_KEY=inv_8417fb46c0f79dec84eb91ccf08e2ca20a0932ea9e4bdc7ec11cedff22914ffd
INVARIANCE_API_URL=https://api.useinvariance.com
INVARIANCE_PRIVATE_KEY=28fb14d95e2ac3126d23b82497b0d4e8e4b04473a46015d939e9979fd84fce8e

# ── LLM Providers (for judge evals) ──
ANTHROPIC_API_KEY=sk-ant-api03-...
OPENAI_API_KEY=sk-...

# ── Testing ──
# EVAL_JUDGE_MOCK=true
On this page
Environment VariablesAPI Key FormatsSDK ConfigurationExample .env File