Big News: Socket raises $60M Series C at a $1B valuation to secure software supply chains for AI-driven development.Announcement
Sign In

@ragpipe/plugin-openai

Package Overview
Dependencies
Maintainers
1
Versions
2
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@ragpipe/plugin-openai

OpenAI embedding and generation plugin for ragpipe

latest
Source
npmnpm
Version
0.1.0
Version published
Maintainers
1
Created
Source

@ragpipe/plugin-openai

OpenAI embedding and generation plugin for ragpipe.

Install

pnpm add ragpipe @ragpipe/plugin-openai

Usage

import { defineConfig } from "ragpipe";
import { openaiEmbedding, openaiGeneration } from "@ragpipe/plugin-openai";

export default defineConfig({
  embedding: openaiEmbedding({
    apiKey: process.env.OPENAI_API_KEY ?? "",
    model: "text-embedding-3-small",
  }),
  generation: openaiGeneration({
    apiKey: process.env.OPENAI_API_KEY ?? "",
    model: "gpt-4o-mini",
    systemPrompt: "Answer based on the provided context.",
  }),
  // ... vectorStore
});

API

openaiEmbedding(options)

Returns an EmbeddingPlugin that calls the OpenAI Embeddings API.

OptionTypeDefaultDescription
apiKeystringOpenAI API key (required)
modelstring"text-embedding-3-small"Embedding model name
dimensionsnumbermodel default (1536 / 3072)Output dimensions (text-embedding-3-* only)
baseUrlstring"https://api.openai.com/v1"API base URL
  • Rate limit: 200ms between calls (built-in)
  • Batch support: embedMany() sends array input in a single API call
  • Dimension reduction: text-embedding-3-small/large support custom dimensions to reduce output size
  • Compatible APIs: Set baseUrl to use OpenRouter, Azure OpenAI, or other OpenAI-compatible endpoints

openaiGeneration(options)

Returns a GenerationPlugin that calls the OpenAI Chat Completions API.

OptionTypeDefaultDescription
apiKeystringOpenAI API key (required)
modelstring"gpt-4o-mini"Chat model name
systemPromptstring"Answer based on the provided context."Default system instruction
baseUrlstring"https://api.openai.com/v1"API base URL
  • Streaming: generateStream() returns an AsyncIterable<string> via SSE
  • History: Pass { history } to include conversation context
  • Per-call override: Pass { systemPrompt } at call time to override the default
  • Compatible APIs: Set baseUrl to use OpenRouter, Azure OpenAI, or other OpenAI-compatible endpoints

Supported Models

Embedding

ModelDimensionsNotes
text-embedding-3-small1536Default, cost-efficient
text-embedding-3-large3072High precision
text-embedding-ada-0021536Legacy

Generation

ModelNotes
gpt-4o-miniDefault, cost-efficient
gpt-4oFlagship
o1Reasoning
o3-miniReasoning (lightweight)

Get an API Key

  • Go to OpenAI Platform
  • Create an API key
  • Set it as OPENAI_API_KEY in your environment

License

MIT

Keywords

ragpipe

FAQs

Package last updated on 10 Apr 2026

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