moon-bridge  by ZhiYi-R

LLM API protocol conversion and routing proxy

Created 1 month ago
391 stars

Top 73.2% on SourcePulse

GitHubView on GitHub
Project Summary

A Go-based proxy that unifies access to multiple Large Language Model (LLM) providers, Moon Bridge exposes a consistent OpenAI Responses API endpoint while internally supporting and translating requests for Anthropic Messages, Google Gemini, and OpenAI Chat Completions. This enables clients to use a single API interface, automatically routing requests to different upstream providers based on configured model aliases, simplifying multi-model LLM integration for developers.

How It Works

The core architecture centers on protocol conversion and intelligent model routing. Moon Bridge intercepts incoming requests, performs necessary protocol transformations (e.g., OpenAI Responses to Anthropic Messages), and routes them to the specified upstream LLM provider using configured aliases. It supports three primary modes: 'Transform' (default, performs conversion), 'CaptureAnthropic' (transparently forwards to Anthropic), and 'CaptureResponse' (transparently forwards to OpenAI). Extensibility is provided via a CorePluginHooks interface for custom request/response processing and stream interception.

Quick Start & Requirements

  • Installation: Requires Go 1.25+. Clone the repository, copy config.example.yml to config.yml, edit API keys, and run go run ./cmd/moonbridge -config config.yml. Docker deployment is also supported.
  • Prerequisites: Go 1.25+ toolchain, upstream LLM provider API keys.
  • Resources: Configuration file (config.yml), upstream API keys.
  • Documentation: Detailed setup and usage guides are available in CookBook.md, CONFIGURATION.md, and API.md.

Highlighted Details

  • Protocol Conversion: Seamlessly translates between OpenAI Responses, Anthropic Messages, Google Gemini, and OpenAI Chat Completions.
  • Model Routing: Dynamically maps client-specified model aliases to various upstream provider models via routes configuration.
  • Plugin Extensibility: Supports custom logic through the CorePluginHooks interface for pre/post-processing and stream handling.
  • Request Tracing: Provides full, step-by-step logging of request/response chains for debugging.
  • Usage Statistics: Aggregates token consumption and estimated costs per session.
  • Web Search Injection: Integrates with Tavily and Firecrawl for automatic or injected web search capabilities.
  • Prompt Caching: Offers explicit, automatic, and hybrid caching strategies.

Maintenance & Community

  • Community: An official QQ group is available at 1103798316. No other community or maintenance signals were explicitly detailed in the provided text.

Licensing & Compatibility

  • License: GPL v3.
  • Compatibility: The GPL v3 license imposes copyleft restrictions, requiring derivative works to also be open-sourced under GPL v3. This may impact integration with closed-source commercial applications.

Limitations & Caveats

Requires a relatively recent Go version (1.25+). The GPL v3 license necessitates careful consideration for commercial use or integration into proprietary software. Advanced features like web search injection and prompt caching may require specific upstream provider support or complex configuration.

Health Check
Last Commit

4 days ago

Responsiveness

Inactive

Pull Requests (30d)
43
Issues (30d)
15
Star History
395 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.2%
1k
LLM API gateway for unified provider access
Created 1 year ago
Updated 10 hours ago
Feedback? Help us improve.