Beta docs: the shipped API is POST /api/v1/generate for gemini and sarvam. Some pages below describe planned features. See the shipped quick start.

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

terminal
npm install @openlink/sdk
lib/openlink.ts
import { OpenLink } from "@openlink/sdk";

export const client = new OpenLink({
  apiKey: process.env.OPENLINK_API_KEY!,
});

Types that follow you

types.ts
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

OptionTypeDefaultNotes
apiKeystringrequiredKey or process.env.OPENLINK_API_KEY.
baseURLstringhttps://openlink-1.onrender.comUseful for local testing of the gateway.
timeoutnumber (ms)60000Overrides the default request timeout.
maxRetriesnumber3Client-side retry count. Keep low — see Retries.

Working with errors

errors.ts
import { OpenLinkError } from "@openlink/sdk";

try {
  await client.chat({ messages });
} catch (err) {
  if (err instanceof OpenLinkError) {
    console.log(err.status, err.code, err.provider);
  }
}