SDK
JavaScript SDK
The same client, plain JavaScript — CommonJS and ESM.
The SDK ships both ESM and CommonJS builds. Type annotations are included either way, so editors still offer autocomplete in plain .js files.
CommonJS
const { OpenLink } = require("@openlink/sdk");
const client = new OpenLink({ apiKey: process.env.OPENLINK_API_KEY });
(async () => {
const response = await client.chat({
messages: [{ role: "user", content: "Hi from CommonJS" }],
});
console.log(response.choices[0].message.content);
})();ESM
import { OpenLink } from "@openlink/sdk";
const client = new OpenLink({ apiKey: process.env.OPENLINK_API_KEY });
const response = await client.chat({
messages: [{ role: "user", content: "Hi from ESM" }],
});
console.log(response.choices[0].message.content);Browser usage
Keep keys out of browsers
The SDK works in Node and edge runtimes. Use it in a browser only behind your own proxy — an exposed OPENLINK_API_KEY is a spending liability.