regent-sdk
v0.1.10
Published
Regent SDK — LLM proxy patching for OpenAI and Anthropic clients
Readme
Regent SDK (JavaScript / TypeScript)
npm install regent-sdkUsage
import regent from 'regent-sdk'
regent.init({ apiKey: process.env.REGENT_API_KEY! })
// All OpenAI/Anthropic clients instantiated after this call
// will automatically route through Regent's proxy.
import OpenAI from 'openai'
const client = new OpenAI() // automatically proxiedCall regent.init() at the very top of your app's entry point, before any OpenAI or Anthropic imports are instantiated.
Local development
regent.init({
apiKey: process.env.REGENT_API_KEY!,
proxyUrl: 'http://localhost:8000',
})What gets proxied
Only clients instantiated without an explicit apiKey are routed through Regent:
new OpenAI() // proxied — Regent injects baseURL + apiKey
new OpenAI({ apiKey: 'sk-...' }) // not proxied — your key, your endpoint
new Anthropic() // proxied
new Anthropic({ apiKey: 'sk-...' }) // not proxiedPrivacy
Regent only proxies traffic from your test runs (GitHub Actions / CI). In production, leave REGENT_ENABLED unset — regent.init() becomes a no-op and nothing is patched.
Requirements
- Node.js 18+
- TypeScript projects compiled to CommonJS (default
tscoutput) openai≥ 4.0.0 and/or@anthropic-ai/sdk≥ 0.20.0 (optional peer deps — install whichever you use)
Publishing to npm
# First time setup
npm login # log in with your npm account
# Build and publish
cd sdk/js
npm run build
npm publish
# Bump version for subsequent releases — edit version in package.json, then:
npm publish