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

@memofs/adapter-openai

v1.2.0-beta.2

Published

OpenAI embeddings adapter for MemoFS.

Readme

@memofs/adapter-openai

OpenAI embeddings adapter for MemoFS.

What is this?

OpenAI Embedder adapter for MemoFS. Provides first-class integration with OpenAI's embedding models (text-embedding-3-small, text-embedding-3-large, text-embedding-ada-002) through MemoFS's provider-neutral embedder contract.

Installation

npm install @memofs/adapter-openai

Requires Node.js >= 22.

You also need an OpenAI API key from platform.openai.com.

Quick Start

import { createOpenAIEmbedder } from "@memofs/adapter-openai";

const embedder = createOpenAIEmbedder({
 apiKey: process.env.OPENAI_API_KEY!,
 model: "text-embedding-3-large",
});

// Embed a batch of texts
const result = await embedder.embed([
 "MemoFS provides unified memory runtime for AI agents",
 "OpenAI offers state-of-the-art embedding models",
]);

console.log(result.embeddings); // number[][]
console.log(result.usage); // { promptTokens, totalTokens }

Configuration

Embedder Options

| Option | Type | Default | Description | |--------|------|---------|-------------| | apiKey | string | required | OpenAI API key | | model | string | "text-embedding-3-large" | Embedding model to use | | dimensions | number | model default | Output dimensions (for text-embedding-3 models) | | encodingFormat | "float" \| "base64" | "float" | Output format for embeddings | | timeout | number | 30000 | Request timeout in milliseconds | | maxRetries | number | 3 | Maximum retry attempts | | batchSize | number | 100 | Maximum texts per batch request | | organization | string | — | OpenAI organization ID (optional) |

Supported Models

| Model | Dimensions | Max Tokens | Use Case | |-------|------------|------------|----------| | text-embedding-3-large | 3072 (configurable) | 8191 | Highest quality | | text-embedding-3-small | 1536 (configurable) | 8191 | Balanced quality/speed | | text-embedding-ada-002 | 1536 | 8191 | Legacy, cost-effective |

Integration with MemoFS Core

import { MemoFS } from "@memofs/core";
import { createNodeFsMemoryStore } from "@memofs/core/node-fs";
import { createOpenAIEmbedder } from "@memofs/adapter-openai";

const store = createNodeFsMemoryStore({ rootDir: "." });

const memo = new MemoFS({
  store,
  projectId: "my-app",
  embedder: createOpenAIEmbedder({
    apiKey: process.env.OPENAI_API_KEY!,
    model: "text-embedding-3-large",
    dimensions: 1536, // Optional: reduce dimensions for speed
  }),
});

// The embedder powers hybrid recall; embeddings persist to
// `.memofs/indexes/embeddings.jsonl` via the file-backed recall store.

Advanced: Custom Client

import { OpenAI } from "openai";
import { createOpenAIEmbedder } from "@memofs/adapter-openai";

const customClient = new OpenAI({
 apiKey: process.env.OPENAI_API_KEY!,
 baseURL: "https://custom-proxy.example.com/v1", // For proxies, Azure, etc.
 defaultHeaders: { "x-custom-header": "value" },
});

const embedder = createOpenAIEmbedder({
 client: customClient,
 model: "text-embedding-3-large",
});

Testing

The package exports fake implementations for testing:

import { createFakeOpenAIClient } from "@memofs/adapter-openai/testing";

const fakeClient = createFakeOpenAIClient({
 embeddings: [[0.1, 0.2, 0.3], [0.4, 0.5, 0.6]],
 usage: { promptTokens: 10, totalTokens: 10 },
});

Boundary

This package owns the OpenAI embedder adapter implementation. It does not own the MemoFS core contracts, other provider adapters, or the OpenAI service itself.

Contributing

See our central Contributing Guide and development scripts for details on formatting, linting, and testing within the monorepo.

License

MIT