npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

@superlinked/sie-sdk

v0.8.2

Published

Official TypeScript SDK for SIE (Search Inference Engine)

Readme

@superlinked/sie-sdk

Official TypeScript SDK for SIE (Search Inference Engine). Async-only, built on native fetch, works in Node.js (>= 22) and the browser.

Installation

npm install @superlinked/sie-sdk

Creating a client

import { SIEClient } from "@superlinked/sie-sdk";

// Local server
const client = new SIEClient("http://localhost:8080");

// Managed SIE gateway: pass the gateway URL and your API key
// (sent as a Bearer token). Server-side code only — see below.
const managed = new SIEClient("https://your-gateway.example.com", {
  apiKey: "YOUR_API_KEY",
});

Warning: only pass apiKey in server-side code. Shipping it in a browser bundle exposes the bearer key to anyone who loads the page. For browser apps, route requests through a backend proxy that holds the key.

Cold-start continuations: non-streaming requests through a managed gateway may receive a bounded Modal result continuation. Consuming it safely requires a server-side Fetch runtime (Node.js >= 22) that exposes the status and Location of a redirect: "manual" response. Browser Fetch exposes an opaque redirect instead, so the SDK fails closed; route these browser calls through a backend proxy as well.

Encoding

// Single item — result.dense is a Float32Array
const result = await client.encode("BAAI/bge-m3", { text: "Hello world" });
console.log(result.dense?.length); // 1024

// Batch — results come back in input order
const results = await client.encode("BAAI/bge-m3", [
  { text: "First document" },
  { text: "Second document" },
]);

Scoring (reranking)

const scored = await client.score(
  "BAAI/bge-reranker-v2-m3",
  { text: "What is machine learning?" },
  [
    { id: "doc-1", text: "Machine learning is a subfield of AI." },
    { id: "doc-2", text: "Python is a programming language." },
  ],
);
// Sorted by relevance (rank 0 = most relevant)
console.log(scored.scores[0].itemId, scored.scores[0].score);

Generation

Text-only generate and streamGenerate prompts are raw continuation input: the worker preserves them without rendering a chat template or applying enable_thinking / guardian_config. Native requests with images render one user turn. For chat, instruction-based structured output (responseFormat), and guard checks, use chatCompletions or streamChatCompletions with messages so the worker applies the served template settings. Operator settings take precedence over request template kwargs.

Granite Guardian's shipped risk dimension is harm; requesting another dimension in prompt text does not change it. Valid thresholded verdicts are Yes (unsafe) and No (safe); missing or invalid verdicts fail with invalid_guard_verdict. Never interpret an error or empty output as safe. Reasoning remains private; a budget exhausted without usable output fails with empty_model_output.

// Aggregated result
const gen = await client.generate(
  "Qwen/Qwen3-4B-Instruct-2507",
  "Write a haiku about the sea.",
  { maxNewTokens: 64, temperature: 0.7 },
);
console.log(gen.text, gen.finishReason, gen.usage);

// Streaming (SSE) — chunks as they arrive (Node.js example;
// process.stdout is not available in the browser)
for await (const chunk of client.streamGenerate(
  "Qwen/Qwen3-4B-Instruct-2507",
  "Write a haiku about the sea.",
  { maxNewTokens: 64 },
)) {
  process.stdout.write(chunk.text_delta);
  if (chunk.done && chunk.ttft_ms !== undefined) {
    console.log(`\nTTFT: ${chunk.ttft_ms}ms`);
  }
}

Error handling

All errors extend SIEError and are exported from the package root. Server-reported errors carry .code and .statusCode, plus .requestId (the gateway x-sie-request-id) when the gateway included one in the response — check it before using it.

import {
  ModelLoadingError,
  RequestError,
  ResourceExhaustedError,
  ServerError,
  SIEStreamError,
} from "@superlinked/sie-sdk";

try {
  const res = await client.encode("BAAI/bge-m3", { text: "Hello" });
} catch (error) {
  if (error instanceof RequestError) {
    console.error(`Bad request (${error.code}):`, error.message);
  } else if (error instanceof ServerError) {
    const correlation = error.requestId ? ` [request ${error.requestId}]` : "";
    console.error(`Server error (${error.code})${correlation}:`, error.message);
  }
}

Retry semantics for transient 503 codes:

  • PROVISIONING — the cluster is scaling capacity from zero. Retried automatically while waitForCapacity: true (the default); with waitForCapacity: false it throws ProvisioningError immediately.
  • MODEL_LOADING — the worker is cold-loading the model. The SDK retries automatically until provisionTimeout (default 900000 ms), then throws ModelLoadingError.
  • LORA_LOADING — the requested LoRA adapter is still loading. Retried a bounded number of times, then throws LoraLoadingError.
  • RESOURCE_EXHAUSTED — server-side GPU OOM. Retried with bounded exponential backoff; throws ResourceExhaustedError (a ServerError subclass) when retries run out.

Streaming calls throw SIEStreamError for mid-stream error chunks — the HTTP connection was healthy but the worker or gateway emitted an error envelope partway through. Branch on error.code (for example empty_model_output, a terminal generation that produced no visible text) and, when error.requestId is present, use it to correlate with gateway logs. For a validated RESOURCE_EXHAUSTED terminal, error.retryAfter carries the operator hint in milliseconds; its presence does not make retrying generation safe after output has already arrived.

License

MIT