Launch Week Day 2: Introducing Reports: An Extensible Reporting Framework for Socket Data.Learn More
Socket
Book a DemoSign in
Socket

semanticbridge

Package Overview
Dependencies
Maintainers
1
Versions
17
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

semanticbridge

A TypeScript/JavaScript SDK for interacting with the SemanticBridge API. This SDK makes it easy to call the `/api/v1/chat/completions` endpoint with type safety and a modern developer experience.

latest
npmnpm
Version
1.3.0
Version published
Maintainers
1
Created
Source

SemanticBridge SDK

A TypeScript/JavaScript SDK for interacting with the SemanticBridge API. This SDK makes it easy to call the /api/v1/chat/completions endpoint with type safety and a modern developer experience.

Installation

npm install semanticbridge

Usage

Standard (no documents)

import { SemanticBridge } from "semanticbridge";

// The base URL is hardcoded to http://localhost:3030/api
const bridge = new SemanticBridge({
  apiKey: "sk-...",
});

const response = await bridge.ask({
  query: "What are the latest trends in AI?",
  models: ["gpt-4o-mini", "gemini-1.5-flash"],
});

console.log(response.best_response);

With Documents (non-streaming)

const response = await bridge.ask({
  query: "Summarize this document.",
  models: ["gpt-4o-mini", "gemini-1.5-flash"],
  documents: [{ url: "https://example.com/file.pdf" }],
});
console.log(response.best_response);

Streaming with Documents

for await (const token of bridge.askStream({
  query: "Summarize this document.",
  models: ["gpt-4o-mini", "gemini-1.5-flash"],
  documents: [{ url: "https://example.com/file.pdf" }],
  stream: true,
})) {
  console.log("Token:", token.token);
}

Middleware

You can add middleware to intercept or modify requests and responses:

bridge.use(async (req, next) => {
  console.log("Request:", req);
  const res = await next(req);
  console.log("Response:", res);
  return res;
});

Features

  • TypeScript-first, fully typed
  • Easy to use and extend
  • Middleware system for advanced use cases
  • Streaming support for real-time tokens
  • Document upload support via public URLs
  • Fixed API endpoint - Base URL is hardcoded to http://localhost:3030/api

API

  • ask(params) — Query the orchestrated LLM endpoint (with or without documents)
  • askStream(params, onToken?) — Stream tokens in real time (callback or async iterator)
  • use(middleware) — Add a middleware function

License

MIT

FAQs

Package last updated on 15 May 2025

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts