Skip to content

SDK Installation

The official OG Engine SDK provides a typed TypeScript client for all API endpoints. It handles authentication, retry logic on 5xx errors, and returns typed responses.

Choose your package manager:

Terminal window
# npm
npm install @atypical-consulting/og-engine-sdk
# bun
bun add @atypical-consulting/og-engine-sdk
# pnpm
pnpm add @atypical-consulting/og-engine-sdk

The SDK ships with TypeScript types included — no separate @types package needed.

Import OGEngine and pass your API key:

import { OGEngine } from '@atypical-consulting/og-engine-sdk'
const og = new OGEngine('oge_sk_YOUR_KEY')

Never hard-code your API key in source code. Store it as an environment variable:

.env
OG_ENGINE_KEY=oge_sk_YOUR_KEY
import { OGEngine } from '@atypical-consulting/og-engine-sdk'
const og = new OGEngine(process.env.OG_ENGINE_KEY!)

If OG_ENGINE_KEY is not set, the SDK throws an OGEngineConfigError at initialization time — so you catch missing credentials immediately, not mid-render.

lib/og.ts
import { OGEngine } from '@atypical-consulting/og-engine-sdk'
// This module is server-only — do not import in client components
export const og = new OGEngine(process.env.OG_ENGINE_KEY!)

Add OG_ENGINE_KEY to your .env.local (and to Vercel’s environment variables in the dashboard).

src/lib/og.ts
import { OGEngine } from '@atypical-consulting/og-engine-sdk'
export const og = new OGEngine(import.meta.env.OG_ENGINE_KEY)

Add OG_ENGINE_KEY to your .env file. Astro exposes server-only variables without the PUBLIC_ prefix to server-side code.

export default {
async fetch(request: Request, env: Env) {
const { OGEngine } = await import('@atypical-consulting/og-engine-sdk')
const og = new OGEngine(env.OG_ENGINE_KEY)
// ...
}
}

Bind OG_ENGINE_KEY as a secret in your wrangler.toml or via the Cloudflare dashboard.

The OGEngine constructor accepts an optional second argument for advanced configuration:

const og = new OGEngine(process.env.OG_ENGINE_KEY!, {
baseUrl: 'https://og-engine.com', // Override for self-hosted instances
timeout: 10000, // Request timeout in ms (default: 10000)
retries: 3, // Retry count for 5xx errors (default: 3)
})
const { status, fonts } = await og.health()
console.log(status) // 'ok'
console.log(fonts) // ['Outfit', 'Inter', ...]