Custom Node.js Agents + Govyn — Govern Any Node.js Agent

Node.js agents built with the OpenAI SDK, Vercel AI SDK, or plain fetch calls have no built-in cost controls. In production, a misbehaving agent can make thousands of API calls before you detect the issue — and there's no way to enforce budgets or audit trails at the runtime level.

How it works

Node.js
Your agents
HTTPS
Govyn Proxy
Policy · Budget · Logs
API
Any Provider API
LLM provider

Step-by-step setup

1

Start the Govyn proxy

bash
npx govyn start --config govyn.yaml
2

Point the OpenAI SDK at Govyn

typescript
import OpenAI from 'openai';

const client = new OpenAI({
  baseURL: 'http://localhost:4111/v1',
  apiKey: 'gvn_agent_node_01',
});

const response = await client.chat.completions.create({
  model: 'gpt-4o',
  messages: [{ role: 'user', content: 'Hello' }],
});
3

Or use fetch directly

typescript
const response = await fetch('http://localhost:4111/v1/chat/completions', {
  method: 'POST',
  headers: {
    'Content-Type': 'application/json',
    'Authorization': 'Bearer gvn_agent_node_01',
  },
  body: JSON.stringify({
    model: 'gpt-4o',
    messages: [{ role: 'user', content: 'Hello' }],
  }),
});

Example policy

Define governance rules for your Node.js agents in a simple YAML file.

govyn.yaml
agents:
  node_01:
    budget:
      daily: $5.00
      monthly: $100.00
    models:
      allow: [gpt-4o, gpt-4o-mini]
    rate_limit:
      requests_per_minute: 40
    logging:
      replay: true
      log_headers: false

Why use Govyn with Node.js?

Works with any Node.js HTTP client or SDK
Compatible with Vercel AI SDK and OpenAI SDK
Streaming response support
Budget caps and rate limiting
Full request/response replay
TypeScript-friendly — no type issues

Get started in 5 minutes

Add governance to your Node.js agents with a single config change. No code rewrites.

Read the docs

Frequently asked questions

Does Govyn support streaming responses in Node.js?
Yes. Govyn transparently proxies Server-Sent Events (SSE) streaming from OpenAI and Anthropic. Your Node.js agent receives the stream exactly as it would from the provider, while Govyn logs and enforces policies on each chunk.
Can I use Govyn with the Vercel AI SDK?
Yes. The Vercel AI SDK lets you configure a custom base URL for OpenAI-compatible providers. Point it at your Govyn proxy and all your AI SDK calls are automatically governed — no other changes needed.
Does Govyn work with serverless Node.js functions?
Yes. Deploy the Govyn proxy as a persistent service and point your serverless functions at it. Each function invocation routes through the proxy, so budgets and policies are enforced even across ephemeral compute environments.

Related integrations

Explore more