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

@corbits/embedding

v0.2.0

Published

Embedding client for OpenAI-compatible /v1/embeddings endpoints, built on the Interchange inference primitives

Readme

@corbits/embedding

Batched text embeddings over any OpenAI-compatible /v1/embeddings endpoint, built on @intx/inference retries and error classification. A retrieval building block for Corbits and Interchange agents that also works standalone.

Why @corbits/embedding?

  1. One client for every provider. OpenAI, Ollama, TEI, vLLM and Jina all speak the same wire format. Switching models is a config change.
  2. Order-safe batching. Inputs are split into batches, and vectors come back in input order, placed by the index each response echoes. Short or duplicate replies throw instead of misaligning results.
  3. Interchange retry semantics. Requests run through @intx/inference, so a 429 backs off and a 401 fails the same way it does for inference calls. Failures throw a typed EmbeddingRequestError.

It does not store or search vectors. For that, pair it with @corbits/memory.

Install

bun add @corbits/embedding @intx/inference@^0.4.0 @intx/types@^0.4.0

Runs on Bun >= 1.2 or Node >= 24.

Quickstart

Needs a local Ollama with nomic-embed-text pulled.

import { embedTexts } from "@corbits/embedding";

const vectors = await embedTexts(["a", "b"], {
  baseURL: "http://localhost:11434/v1",
  model: "nomic-embed-text",
});
console.log(vectors.length, vectors[0]?.length); // 2 768

Where it fits

Interchange runs AI agents as principals (accounts that hold their own identity, permissions and credentials). Corbits packages add what an agent product needs around it.

  • Runs in: any process: the Interchange hub (the multi-tenant control plane), an agent sidecar (the runtime next to each agent), or a plain script. No hub is required.
  • Plugs into: @intx/inference for transport, retries and error classification, and @intx/types.
  • Pairs with: @corbits/reranking to reorder results and @corbits/memory to store and search vectors.

Reference

| Export | Description | | -------------------------------------------- | ----------------------------------------------------------- | | embedTexts(texts, config, options?) | Embeds the texts and returns one vector per text, in order. | | probeEmbedDims(config, options?) | Embeds one probe string and returns the vector dimension. | | EmbedConfigSchema, EmbedConfig | Schema and type for config. | | EmbedOptions | Type for options. | | EmbeddingRequestError | Thrown when a request fails. | | RequestDependencies, RetryAfterExtractor | Types for options.deps and options.extractRetryAfterMs. |

Config

| Field | Type | Description | | ---------------- | ---------------------- | ------------------------------------------------------------------------------------------------ | | baseURL | string | Server root with its version path, such as http://host:11434/v1. Trailing slashes are ignored. | | model | string | Model name. | | apiKey | string? | Sent as a bearer token. | | dimensions | number? | Requested output dimension. Sent only when set; a reply of any other dimension is rejected. | | encodingFormat | "float" \| "base64"? | Wire format. Defaults to float. Results are always number[]. | | batchSize | number? | Texts per request. Defaults to 32. | | timeoutMs | number? | Per-attempt timeout; a timed-out attempt is retried. Defaults to 30000. |

Options

| Field | Description | | --------------------- | ---------------------------------------------------------------------------------------- | | deps | { fetch, scheduler }. Defaults to global fetch and Interchange's scheduler. | | retryPolicy | Retry policy. Defaults to Interchange's policy. | | extractRetryAfterMs | Reads the server's retry delay. Defaults to parsing Retry-After, capped at 60 seconds. | | signal | Aborts all pending requests. |

Errors

A failed request throws EmbeddingRequestError with a classified reason and the request url. An invalid config throws before any request is sent.

Dimensions

Each model has a fixed output dimension: 768 for nomic-embed-text, 1536 for OpenAI text-embedding-3-small. If you store vectors, call probeEmbedDims at startup. Changing models changes the dimension, so treat it as a schema migration. Every vector from one call has the same non-zero dimension, or the call throws EmbeddingRequestError with protocol_mismatch.

Using with Interchange

@intx/inference and @intx/types are peer dependencies, so your host's Interchange version supplies them.

To share your host's retry scheduler, pass it as options.deps.scheduler along with fetch.

Upgrading from 0.1

  • Install @intx/inference and @intx/types (^0.4.0) yourself. They are now peer dependencies.
  • ModelRequestError is renamed to EmbeddingRequestError.
  • runJSONRequest, extractRetryAfterMs and RunRequestOptions are no longer exported. To change how retry waits are read, pass options.extractRetryAfterMs.
  • Config and returned vectors are unchanged.

License

LGPL-2.1-only