Self-hosted open-source AI gateway with OpenAI-compatible APIs, Ollama upstream support, routing, fallback, and observability-friendly data sharing.
Docs | API Reference | Examples | Website
Important
LunarGate is under active development. The core gateway is already usable today, but interfaces and configuration may still evolve.
LunarGate is a Go-based AI gateway that lets you expose one stable endpoint to your applications while routing requests to different upstream model providers behind the scenes.
What LunarGate does
- Exposes an OpenAI-compatible API for client apps
- Routes requests across providers and models with weighted or conditional rules
- Adds retries, fallbacks, and circuit breakers at the gateway layer
- Supports streaming and tool-calling flows
- Keeps a small footprint: the standalone binary is typically around 10-12 MB depending on platform, and the container image is around 12 MB
- Keeps data local by default, with optional prompt/response sharing for observability
- Works with providers such as OpenAI, Anthropic, Ollama, and other OpenAI-compatible local backends
Supported endpoints
POST /v1/chat/completionsPOST /v1/responsesPOST /v1/embeddingsGET /v1/models
Provider support
LunarGate exposes an OpenAI-compatible client-facing API, but it can route to multiple upstream provider types behind the scenes, including:
- OpenAI
- Anthropic
- Ollama
- other OpenAI-compatible backends
That means your app can keep one stable client integration while the gateway talks to the upstream provider in the format it expects.
Documentation
Full documentation lives at docs.lunargate.ai.
Useful starting points:
Quick start
Choose one install path:
Homebrew (macOS)
brew tap lunargate-ai/tap brew install lunargate
Install script (Linux)
curl -fsSL https://get.lunargate.ai/install.sh | shBuild from source
make build
Minimal configuration
Create config.yaml:
providers: openai: api_key: "${OPENAI_API_KEY}" base_url: "https://api.openai.com/v1" default_model: "gpt-5.2" routing: routes: - name: "default" targets: - provider: openai model: "gpt-5.2"
If you use environment placeholders such as ${OPENAI_API_KEY}, either export them in your shell or place them in a local .env file:
OPENAI_API_KEY=sk-xxxxxxxxx
Then start the gateway:
lunargate --config ./config.yaml
If you omit --config, LunarGate will look for config.yaml in the current directory.
Call the gateway
Point your OpenAI-compatible client at:
http://localhost:8080/v1
For a runnable client example, see gateway-examples/.
Observability
By default, LunarGate does not forward prompts or responses outside your infrastructure.
If you want to connect the gateway to LunarGate observability, create a gateway in the Gateways section of app.lunargate.ai and add the generated gateway API key to your environment:
LUNARGATE_GATEWAY_API_KEY=lgw_your_gateway_api_key
Then enable data_sharing in config.yaml:
data_sharing: enabled: true share_prompts: true share_responses: true remote_control: true api_key: "${LUNARGATE_GATEWAY_API_KEY}"
You can keep share_prompts and share_responses off if you want metrics-only forwarding.
Security
Basic inbound API-key authentication is available via the security section in config.yaml.
For now, treat that as a solid first layer for trusted internal clients, not as a finished public multi-tenant edge. If the gateway is internet-facing, keep an auth-enforcing proxy, API gateway, or service mesh in front of it.
License
MIT



























