Skip to main content

Installation

npm install @operark/sdk
# or: pnpm add @operark/sdk  /  yarn add @operark/sdk

Initialize

import { Operark } from '@operark/sdk';

const client = new Operark({
  apiKey: process.env.OPERARK_API_KEY,
});

Ask an executive

const response = await client.executives.CEO.ask({
  question: "What's our strategy for Q2?",
});

console.log(response.answer);

Request a governed decision

const decision = await client.executives.CRO.decide({
  question: "Approve a new vendor without ISO 27001?",
});

console.log(decision.outcome, decision.rationale);

Error handling

Wrap calls and inspect the typed error for the machine-readable code:
import { Operark, OperarkError } from '@operark/sdk';

try {
  await client.executives.CFO.ask({ question: "Q2 burn rate?" });
} catch (err) {
  if (err instanceof OperarkError) {
    console.error(err.code, err.message);
  }
}

API Reference

Full endpoint reference, generated from OpenAPI.