SDK
TypeScript SDK
The typed wrapper around the OpenLink API. One client, full autocomplete.
@openlink/sdk is fully typed and follows the API 1:1 — the options object is the request body, the return value is the normalized response.
Install and initialize
npm install @openlink/sdkimport { OpenLink } from "@openlink/sdk";
export const client = new OpenLink({
apiKey: process.env.OPENLINK_API_KEY!,
});Types that follow you
import type { ChatCompletion } from "@openlink/sdk";
async function summarize(text: string): Promise<ChatCompletion> {
const response = await client.chat({
messages: [
{ role: "system", content: "Summarize in one sentence." },
{ role: "user", content: text },
],
});
return response;
}
const completion: ChatCompletion = await summarize("long email copy…");Client options
| Option | Type | Default | Notes |
|---|---|---|---|
| apiKey | string | required | Key or process.env.OPENLINK_API_KEY. |
| baseURL | string | https://openlink-1.onrender.com | Useful for local testing of the gateway. |
| timeout | number (ms) | 60000 | Overrides the default request timeout. |
| maxRetries | number | 3 | Client-side retry count. Keep low — see Retries. |
Working with errors
import { OpenLinkError } from "@openlink/sdk";
try {
await client.chat({ messages });
} catch (err) {
if (err instanceof OpenLinkError) {
console.log(err.status, err.code, err.provider);
}
}