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.
Install
Section titled “Install”Choose your package manager:
# npmnpm install @atypical-consulting/og-engine-sdk
# bunbun add @atypical-consulting/og-engine-sdk
# pnpmpnpm add @atypical-consulting/og-engine-sdkThe SDK ships with TypeScript types included — no separate @types package needed.
Initialize the Client
Section titled “Initialize the Client”Import OGEngine and pass your API key:
import { OGEngine } from '@atypical-consulting/og-engine-sdk'
const og = new OGEngine('oge_sk_YOUR_KEY')Using Environment Variables
Section titled “Using Environment Variables”Never hard-code your API key in source code. Store it as an environment variable:
OG_ENGINE_KEY=oge_sk_YOUR_KEYimport { 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.
Next.js
Section titled “Next.js”import { OGEngine } from '@atypical-consulting/og-engine-sdk'
// This module is server-only — do not import in client componentsexport 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).
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.
Cloudflare Workers
Section titled “Cloudflare Workers”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.
Configuration Options
Section titled “Configuration Options”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)})Verifying the Installation
Section titled “Verifying the Installation”const { status, fonts } = await og.health()console.log(status) // 'ok'console.log(fonts) // ['Outfit', 'Inter', ...]Next Steps
Section titled “Next Steps”- SDK Reference — all methods, TypeScript signatures, and framework examples
- Quick Start — generate your first image in 2 minutes
- API Reference Overview — underlying REST API documentation