Overview

VibeKit Proxy seamlessly integrates with the Vercel AI SDK, providing automatic data redaction and security for your AI-powered applications without changing your existing code.

Installation

First, install both the Vercel AI SDK and VibeKit Proxy:
npm install ai @vibe-kit/proxy

Start the Proxy

Start the VibeKit proxy server:
npx @vibe-kit/proxy start --port 8080

Configuration

Update your AI provider configuration to use the VibeKit proxy:

OpenAI Integration

Before:
import { openai } from '@ai-sdk/openai';

const model = openai('gpt-4');
After:
import { openai } from '@ai-sdk/openai';

const model = openai('gpt-4', {
  baseURL: 'http://localhost:8080/v1'
});

Anthropic Integration

Before:
import { anthropic } from '@ai-sdk/anthropic';

const model = anthropic('claude-3-sonnet-20240229');
After:
import { anthropic } from '@ai-sdk/anthropic';

const model = anthropic('claude-3-sonnet-20240229', {
  baseURL: 'http://localhost:8080'
});

Usage Examples

Chat Completion with Automatic Redaction

import { generateText } from 'ai';
import { openai } from '@ai-sdk/openai';

const model = openai('gpt-4', {
  baseURL: 'http://localhost:8080/v1'
});

const result = await generateText({
  model,
  prompt: 'My email is john@example.com and my SSN is 123-45-6789. Help me with privacy best practices.',
});

console.log(result.text);
// Sensitive data will be automatically redacted in both request and response

Streaming with Security

import { streamText } from 'ai';
import { anthropic } from '@ai-sdk/anthropic';

const model = anthropic('claude-3-sonnet-20240229', {
  baseURL: 'http://localhost:8080'
});

const result = await streamText({
  model,
  prompt: 'Analyze this customer data: Name: John Doe, Phone: (555) 123-4567, Account: 1234567890',
});

for await (const textPart of result.textStream) {
  process.stdout.write(textPart);
  // All streaming content is automatically redacted
}