llms  by musistudio

LLM API middleware for cross-provider compatibility

Created 6 months ago
280 stars

Top 93.0% on SourcePulse

GitHubView on GitHub
Project Summary

Summary

The musistudio/llms repository offers a universal LLM API transformation server designed to act as middleware. It standardizes requests and responses across diverse LLM providers (e.g., Anthropic, Gemini, Deepseek), significantly simplifying integration for developers and enabling a consistent interface regardless of the underlying LLM service.

How It Works

This project leverages a modular transformer system to achieve API standardization. Each supported LLM provider is integrated via a dedicated transformer class. These classes implement methods to convert provider-specific request and response formats into a common, unified format (UnifiedChatRequest, UnifiedChatResponse) and back again. This abstraction layer is advantageous as it decouples the application logic from the intricacies of individual LLM APIs, allowing for easier switching between providers and centralized management of API interactions, including robust handling of real-time streaming responses.

Quick Start & Requirements

  • Installation: Run npm install or pnpm install.
  • Development: Use npm run dev for hot-reloading via nodemon and tsx.
  • Build: Execute npm run build to generate distributable files in dist/cjs and dist/esm.
  • Testing: Run npm test to execute tests.
  • Configuration: Supports environment variables via .env files and config.json.
  • Path Alias: @ is mapped to the src directory for cleaner imports.
  • Documentation: A "Contributing Guide" is available.

Highlighted Details

  • Streaming Support: Handles real-time streaming responses, converting provider-specific chunked data into a standardized format.
  • Provider Transformers: Includes specific implementations for Anthropic (OpenAI-style to Anthropic-style messages), Gemini (adjusting tool definitions and parameter formats), and Deepseek (enforcing token limits and handling reasoning content in streams).
  • Unified Data Models: Employs UnifiedChatRequest and UnifiedChatResponse types to ensure consistent data structures across all integrated LLM providers.

Maintenance & Community

  • The repository provides a "Contributing Guide" for potential contributors. No specific community channels (like Discord or Slack), official roadmap, or notable sponsors/contributors are detailed in the README.

Licensing & Compatibility

  • The license under which this project is distributed is not specified in the provided README.

Limitations & Caveats

  • The project was "initially developed for the claude-code-router," which may indicate a specific initial use case or focus. Support for new LLM providers requires the development and integration of new transformer classes.
Health Check
Last Commit

4 days ago

Responsiveness

Inactive

Pull Requests (30d)
1
Issues (30d)
2
Star History
21 stars in the last 30 days

Explore Similar Projects

Starred by Chip Huyen Chip Huyen(Author of "AI Engineering", "Designing Machine Learning Systems") and David Cramer David Cramer(Cofounder of Sentry).

llmgateway by theopenco

1.6%
791
LLM API gateway for unified provider access
Created 9 months ago
Updated 1 day ago
Starred by Chip Huyen Chip Huyen(Author of "AI Engineering", "Designing Machine Learning Systems"), Luis Capelo Luis Capelo(Cofounder of Lightning AI), and
1 more.

any-llm by mozilla-ai

1.2%
2k
Unified interface for LLM providers
Created 6 months ago
Updated 2 days ago
Feedback? Help us improve.