New:Introducing Socket Scanning for VS Code Marketplace Extensions.Learn more →
Get Started

bridge-ai

Package Overview
Dependencies
Maintainers
1
Versions
5
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

bridge-ai

Unified AI SDK for OpenAI, Gemini, Claude, Perplexity, and DeepSeek. Designed like AWS SDK v3.

Source
npmnpm
Version
1.2.0
Version published
Weekly downloads
26
136.36%
Maintainers
1
Weekly downloads
 
Created
Source

🌉 Bridge AI SDK

npm version License: MIT

Bridge AI is a unified, type-safe SDK for interacting with multiple AI providers (OpenAI, Gemini, Claude, Perplexity, and DeepSeek). Designed with the elegance and modularity of AWS SDK v3, it provides a seamless interface whether you're building a simple bot or a complex multi-model application.

✨ Features

  • 🎯 Unified Interface: One SDK to rule them all. Switch providers by changing a single config line.
  • 🏗️ AWS SDK v3 Inspired: Familiar Client-Command pattern for modularity.
  • 🛡️ Type-Safe: Written in TypeScript with full type definitions.
  • 🚀 Environment Conscious: Automatically picks up API keys from environment variables.
  • ⚙️ Configurable: Define pre-instructions (system prompts) at the client level or per request.
  • 📦 Lightweight: Zero-dependency core (using official SDKs under the hood for reliability).

🚀 Installation

npm install bridge-ai

🛠️ Quick Start

1. Set up your Environment Variables

Add your API keys to your .env file:

OPENAI_API_KEY=sk-...
GEMINI_API_KEY=...
ANTHROPIC_API_KEY=...
PERPLEXITY_API_KEY=...
DEEPSEEK_API_KEY=...

2. Basic Usage (TS/JS)

import { BridgeAIClient, ChatCommand } from 'bridge-ai';

// Initialize the client
const client = new BridgeAIClient({
  provider: 'openai', // or 'gemini', 'claude', 'perplexity', 'deepseek'
  preInstructions: 'You are a helpful coding assistant.'
});

// Use the Command Pattern (AWS SDK v3 Style)
const command = new ChatCommand({
  prompt: 'How do I use Bridge AI?'
});

const response = await client.send(command);
console.log(response.text);

const response = await client.chat({ prompt: 'Write a story', temperature: 0.7, maxTokens: 500 });


## 🧠 Agentic & Enterprise Features

### 🔄 Automatic Fallbacks
Ensure high availability by defining fallback providers. If the primary provider fails, Bridge AI automatically tries the next one.

```typescript
const client = new BridgeAIClient({
  provider: 'openai',
  fallbackProviders: ['gemini', 'claude']
});

🔐 Prompt Hashing & Persistence

Automatically hash prompts for caching or auditing. Use the onResponse hook to save results to your database.

const client = new BridgeAIClient({
  provider: 'openai',
  onResponse: async ({ prompt, response, hash }) => {
    // Save to your DB
    console.log(`Saving prompt with hash: ${hash}`);
    await db.logs.create({ prompt, responseText: response.text, hash });
  }
});

🛠️ Agentic Tools (Function Calling)

Pass tools to the model and handle structured responses across different providers.

const response = await client.chat({
  prompt: 'What is the weather in London?',
  tools: [{
    name: 'getWeather',
    description: 'Get current weather',
    parameters: {
      type: 'object',
      properties: { location: { type: 'string' } }
    }
  }]
});

if (response.toolCalls) {
  // Handle your tool logic here
}

💾 Smart Memory

Maintain conversation state automatically.

await client.chat({ prompt: 'My name is Alice', memory: true });
const res = await client.chat({ prompt: 'What is my name?', memory: true });
console.log(res.text); // "Your name is Alice"

🤝 Supported Providers

ProviderConfig NameDefault ModelEnv Variable
OpenAIopenaigpt-4-turbo-previewOPENAI_API_KEY
Google Geminigeminigemini-1.5-flashGEMINI_API_KEY
Anthropic Claudeclaudeclaude-3-5-sonnet-20240620ANTHROPIC_API_KEY
Perplexityperplexityllama-3-sonar-large-32k-onlinePERPLEXITY_API_KEY
DeepSeekdeepseekdeepseek-chatDEEPSEEK_API_KEY

📖 Documentation

For full documentation and advanced examples, visit our GitHub Pages.

📄 License

MIT © Himanshu Mamgain

Keywords

ai

FAQs

Package last updated on 28 Dec 2025

Related posts