llm-bridge  by supermemoryai

LLM API translation layer

Created 1 year ago
296 stars

Top 89.4% on SourcePulse

GitHubView on GitHub
Project Summary

LLM Bridge is a TypeScript library designed to solve the interoperability challenges between different Large Language Model (LLM) providers. It offers a universal translation layer, enabling seamless communication and data exchange between APIs like OpenAI, Anthropic, and Google Gemini. Developers benefit from a unified format that preserves all request details, supports multimodal inputs, translates tool calls, and standardizes error handling, significantly simplifying the development of multi-LLM applications.

How It Works

The library operates by defining a universal intermediate format that acts as a common language for LLM requests. It provides functions to convert provider-specific request formats (e.g., OpenAI's JSON structure) into this universal format and vice-versa. This approach ensures zero data loss and allows for perfect reconstruction of original requests, while also facilitating the translation of complex features like multimodal content (images, documents) and function/tool calls between disparate provider APIs.

Quick Start & Requirements

Installation is straightforward using package managers:

npm install llm-bridge
# or
yarn add llm-bridge
# or
pnpm add llm-bridge

The library requires a TypeScript environment. No specific hardware, operating system, or non-default software prerequisites are mentioned in the README.

Highlighted Details

  • Universal Format Translation: Seamlessly converts requests between OpenAI, Anthropic, Google, and custom formats via an intermediate universal representation.
  • Multimodal Content Support: Handles and translates image and document inputs across different LLM providers.
  • Function/Tool Calling Translation: Enables cross-provider compatibility for function calling mechanisms.
  • Unified Error Handling: Provides standardized error types and translates provider-specific errors into a common format.
  • Provider Detection: Automatically identifies the LLM provider based on the request format.
  • Zero Data Loss & Perfect Reconstruction: Guarantees that all request fields are preserved through round-trip conversions.
  • Advanced Features: Includes utilities for cost optimization, token counting, observability data generation, and examples for middleware patterns, load balancing, and fallbacks.

Maintenance & Community

The project is developed by "team supermemory." Links are provided for official documentation, issue reporting, and community discussions. No specific community channels like Discord or Slack are listed.

Licensing & Compatibility

LLM Bridge is released under the MIT License, which is highly permissive and generally suitable for commercial use and integration into closed-source projects.

Limitations & Caveats

The README does not explicitly detail limitations, alpha status, or known bugs. While it supports OpenAI, Anthropic, and Google, the maturity and completeness of translation for other or custom providers may vary. The effectiveness of advanced features like cost optimization relies on the accuracy of the getModelCosts and countUniversalTokens utilities.

Health Check
Last Commit

1 month ago

Responsiveness

Inactive

Pull Requests (30d)
0
Issues (30d)
0
Star History
3 stars in the last 30 days

Explore Similar Projects

Feedback? Help us improve.