
Research
Supply Chain Attack on Axios Pulls Malicious Dependency from npm
A supply chain attack on Axios introduced a malicious dependency, plain-crypto-js@4.2.1, published minutes earlier and absent from the project’s GitHub releases.
context-interceptor-sdk
Advanced tools
RAG-based context injection SDK for OpenAI-compatible providers and Vercel AI SDK
Production-ready RAG SDK for OpenAI and Vercel AI SDK with automatic context injection in 1-2 lines of code.
npm install @context-interceptor/sdk
# or
pnpm add @context-interceptor/sdk
# or
yarn add @context-interceptor/sdk
import OpenAI from 'openai';
import { initContextInterceptor, getOpenAIFetch } from '@context-interceptor/sdk';
// 1. Initialize once (at app startup)
initContextInterceptor({
openaiApiKey: process.env.OPENAI_API_KEY!,
upstashVectorUrl: process.env.UPSTASH_VECTOR_URL!,
upstashVectorToken: process.env.UPSTASH_VECTOR_TOKEN!,
upstashRedisUrl: process.env.UPSTASH_REDIS_URL!,
upstashRedisToken: process.env.UPSTASH_REDIS_TOKEN!,
});
// 2. Add fetch parameter - THAT'S IT!
const openai = new OpenAI({
apiKey: process.env.OPENAI_API_KEY,
fetch: getOpenAIFetch(), // <- Just this line!
});
// Use normally - context injected automatically! 🎉
const response = await openai.chat.completions.create({
model: 'gpt-4o',
messages: [{ role: 'user', content: 'Your question here' }],
});
import { openai } from '@ai-sdk/openai';
import { generateText } from 'ai';
import { initContextInterceptor, getAISDKMiddleware } from '@context-interceptor/sdk';
// 1. Initialize once
initContextInterceptor({
openaiApiKey: process.env.OPENAI_API_KEY!,
upstashVectorUrl: process.env.UPSTASH_VECTOR_URL!,
upstashVectorToken: process.env.UPSTASH_VECTOR_TOKEN!,
upstashRedisUrl: process.env.UPSTASH_REDIS_URL!,
upstashRedisToken: process.env.UPSTASH_REDIS_TOKEN!,
});
// 2. Spread the middleware - THAT'S IT!
const result = await generateText({
model: openai('gpt-4o'),
messages: [{ role: 'user', content: 'Your question' }],
...getAISDKMiddleware(), // <- Just this line!
});
import { indexDocs } from '@context-interceptor/sdk';
await indexDocs([
{
id: 'doc1',
content: 'Your documentation content here...',
metadata: { category: 'api', tags: ['auth', 'rest'] },
},
{
id: 'doc2',
content: 'More documentation...',
},
]);
Create a .env file:
OPENAI_API_KEY=sk-...
UPSTASH_VECTOR_URL=https://...
UPSTASH_VECTOR_TOKEN=...
UPSTASH_REDIS_URL=https://...
UPSTASH_REDIS_TOKEN=...
// Different contexts for different users
const user1 = new OpenAI({
apiKey: process.env.OPENAI_API_KEY,
fetch: getOpenAIFetch({ conversationId: 'user-123' }),
});
const user2 = new OpenAI({
apiKey: process.env.OPENAI_API_KEY,
fetch: getOpenAIFetch({ conversationId: 'user-456' }),
});
const openai = new OpenAI({
apiKey: process.env.OPENAI_API_KEY,
fetch: getOpenAIFetch({
systemPrompt: 'You are a helpful coding assistant specializing in TypeScript.',
}),
});
The SDK automatically:
import { getInterceptor } from '@context-interceptor/sdk';
const interceptor = getInterceptor();
const context = await interceptor.query('How to use React hooks?', {
topK: 5,
conversationId: 'user-123',
});
const stats = interceptor.getPatternStats();
console.log('Total patterns:', stats.totalPatterns);
console.log('Processing:', stats.isProcessing);
interceptor.clearPatternCache();
// Update document
await interceptor.updateDocument('doc1', 'Updated content...');
// Delete document
await interceptor.deleteDocument('doc1');
// Get vector store info
const info = await interceptor.getVectorStoreInfo();
// Stop background processing
interceptor.shutdown();
// app/page.tsx
import OpenAI from 'openai';
import { initContextInterceptor, getOpenAIFetch } from '@context-interceptor/sdk';
initContextInterceptor({
openaiApiKey: process.env.OPENAI_API_KEY!,
upstashVectorUrl: process.env.UPSTASH_VECTOR_URL!,
upstashVectorToken: process.env.UPSTASH_VECTOR_TOKEN!,
upstashRedisUrl: process.env.UPSTASH_REDIS_URL!,
upstashRedisToken: process.env.UPSTASH_REDIS_TOKEN!,
});
export default async function Page() {
const openai = new OpenAI({
apiKey: process.env.OPENAI_API_KEY,
fetch: getOpenAIFetch(),
});
const response = await openai.chat.completions.create({
model: 'gpt-4o',
messages: [{ role: 'user', content: 'Your question' }],
});
return <div>{response.choices[0].message.content}</div>;
}
// app/api/chat/route.ts
import { openai } from '@ai-sdk/openai';
import { streamText } from 'ai';
import { initContextInterceptor, getAISDKMiddleware } from '@context-interceptor/sdk';
initContextInterceptor({
openaiApiKey: process.env.OPENAI_API_KEY!,
upstashVectorUrl: process.env.UPSTASH_VECTOR_URL!,
upstashVectorToken: process.env.UPSTASH_VECTOR_TOKEN!,
upstashRedisUrl: process.env.UPSTASH_REDIS_URL!,
upstashRedisToken: process.env.UPSTASH_REDIS_TOKEN!,
});
export async function POST(req: Request) {
const { messages } = await req.json();
const result = await streamText({
model: openai('gpt-4o'),
messages,
...getAISDKMiddleware(),
});
return result.toAIStreamResponse();
}
Contributions are welcome! Please read our Contributing Guide.
MIT © [Your Name]
Built with:
Made with ❤️ for developers who want RAG without the complexity
FAQs
RAG-based context injection SDK for OpenAI-compatible providers and Vercel AI SDK
We found that context-interceptor-sdk demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?

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.

Research
A supply chain attack on Axios introduced a malicious dependency, plain-crypto-js@4.2.1, published minutes earlier and absent from the project’s GitHub releases.

Research
Malicious versions of the Telnyx Python SDK on PyPI delivered credential-stealing malware via a multi-stage supply chain attack.

Security News
TeamPCP is partnering with ransomware group Vect to turn open source supply chain attacks on tools like Trivy and LiteLLM into large-scale ransomware operations.