Node.js OpenAI SDK
The official OpenAI Node SDK accepts a custom baseURL, so you can route every call through Corveil with two lines of config.
Mode
Direct mode only.
1. Install
bash
npm install openai2. Minimal example
typescript
import OpenAI from "openai";
const client = new OpenAI({
baseURL: "https://your-corveil-host/v1",
apiKey: "sk-citadel-your-key-here",
});
const resp = await client.chat.completions.create({
model: "or-claude-haiku-4.5",
messages: [{ role: "user", content: "Hello from Corveil" }],
});
console.log(resp.choices[0].message.content);Troubleshooting
- CORS errors in the browser: Don't call Corveil directly from a browser context — route through your own server
- Network errors with self-signed certs: Configure Node's
NODE_EXTRA_CA_CERTSto include your CA bundle