An open API service indexing awesome lists of open source software.

https://github.com/ladbaby/tresor

⚑A single-binary LLM gateway for switching providers with one click. One gateway, One config, One click.
https://github.com/ladbaby/tresor

agent ai-gateway cc-switch claude-code codex deepseek gemini-cli litellm llm opencode

Last synced: 15 days ago
JSON representation

⚑A single-binary LLM gateway for switching providers with one click. One gateway, One config, One click.

Awesome Lists containing this project

README

          

# Tresor

> **Switch LLM Providers for Any Apps with One Click**

**One binary, One click, Any App**

[![Go Version](https://img.shields.io/badge/Go-1.26-violet)](https://go.dev/)
[![License](https://img.shields.io/badge/License-MIT-blue)](LICENSE)

![](images/screenshot.png)

## πŸ€” Why Tresor?

- **One binary**: No need to install on every PC/server where LLM apps live in.
- **One click**: LLM provider switch via alias buttons in web UI.
- **Any Apps**: All LLM apps using OpenAI/Anthropic API do not need to reconfigure their LLM providers.
> For apps that do not support customizable endpoint, a possible workaround is to modify DNS records and point the IP address to Tresor.

||Tresor (Ours)|[cc-switch](https://github.com/farion1231/cc-switch)|[LiteLLM](https://github.com/BerriAI/litellm)
|---|---|---|---|
|One binary|βœ…|❌(install on every PC)|❌(tons of dependencies)|
|One click|βœ…|βœ…|❌(retype model name)|
|Any App|βœ…|❌(limited apps)|βœ…|

### πŸ”„ The Problem: Switching Providers at Scale

Imagine you have agents on three machines, all calling OpenAI. You want to switch them to Anthropic.

![](images/comparison.png)

⚠ DISCLAIMER: Tresor is intended for personal use rather than LLM transfer stations, so it only have one administrative account. We are not planning to support commercial-purpose multi-user login.

## ⚑ What Tresor Does

Tresor is a single binary with two modes:

| Mode | What It Does |
|------|-------------|
| **Daemon** | πŸ–₯️ Long-running HTTP gateway + admin REST API + embedded web UI |
| **CLI** | πŸ’» Command-line client for managing the daemon |

```
β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β” β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β” β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚ Your App │────>β”‚ Tresor │────>β”‚ LLM Providerβ”‚
β”‚ β”‚ β”‚ (gateway) β”‚ β”‚ (OpenAI, β”‚
β”‚ β”‚<────│ β”‚<────│ Anthropic..) β”‚
β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜ β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜ β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
β”‚
β”œβ”€β”€ Admin REST API
β”œβ”€β”€ Embedded Web UI
└── CLI Commands
```

### Key Capabilities

- ⚑ **Hot-Switch Models** β€” Map one model name to any backend model and switch on the fly. Your app requests `gpt-4o`; Tresor can route it to Claude Sonnet, Opus, or keep it on GPT-4o β€” all without restarting.
- πŸ”„ **Protocol Translation** β€” Convert between OpenAI and Anthropic API formats transparently. Your app sends an OpenAI request; Tresor forwards it to Anthropic and converts the response back. No code changes needed.
- πŸ”Œ **Plugin Pipeline** β€” Chain transformation plugins per rule (header injection, compatibility fix, format conversion, and more).
- πŸ›€οΈ **Per-Path Routing** β€” Route different API paths (and models) to different providers based on configurable rules.
- 🌐 **Embedded Web UI** β€” Manage everything from a browser dashboard. No separate frontend deployment.
- πŸ“ **Single Config File** β€” All settings in one portable YAML file. Changes via the web UI write back automatically.

## πŸš€ Getting Started

> Warning: the program is heavily vibe-coded, but the author has tried the best to follow software engineering practices to ensure its quality. Use with caution.

### Install

**Linux / macOS** β€” download the latest release with one command:

```bash
curl -fsSL https://raw.githubusercontent.com/Ladbaby/Tresor/main/setup.sh | bash
```

This installs the binary to `~/.local/bin/tresor` and creates a config skeleton at `~/.config/tresor/config.yaml`.

**Windows** β€” download a release binary manually from [GitHub Releases](https://github.com/Ladbaby/Tresor/releases).

### Configure

- Option 1: Configure later via web UI.
- Option 2: Edit `~/.config/tresor/config.yaml`.

> Change bind_addr to 0.0.0.0:11510 if you want the server to be publicly available.

### Start

```bash
# Start the daemon
tresor run --config ~/.config/tresor/config.yaml

# Point your LLM apps to: http://127.0.0.1:11510
# Open the web UI: http://127.0.0.1:11510 in your browser
```

### Run as Systemd Service (Linux)

Run Tresor as a user-level systemd service β€” no `sudo` needed, auto-starts on login:

```bash
# 1. Create the user service unit
mkdir -p ~/.config/systemd/user
cat > ~/.config/systemd/user/tresor.service << EOF
[Unit]
Description=Tresor LLM Gateway

[Service]
Type=simple
ExecStart=$HOME/.local/bin/tresor run --config $HOME/.config/tresor/config.yaml
WorkingDirectory=$HOME/.config/tresor
Restart=on-failure
RestartSec=5

# Environment (uncomment as needed)
# Environment=HTTP_PROXY=http://proxy.example.com:8080
# Environment=HTTPS_PROXY=http://proxy.example.com:8080

[Install]
WantedBy=default.target
EOF

# 2. Enable and start the service
# (--user creates a service under your user session)
systemctl --user daemon-reload
systemctl --user enable --now tresor.service

# 3. Check status
systemctl --user status tresor

# View logs
journalctl --user -u tresor -f
```

> **Note:** If you installed Tresor to a different path, update `ExecStart` and `WorkingDirectory` accordingly.

### Build from Source

For developers or unsupported platforms (requires Go 1.26+):

```bash
go build -o tresor .
```

See the [Installation](https://ladbaby.github.io/Tresor-docs/docs/user/getting-started/installation) docs for full instructions.

## πŸ“š Documentation

Full documentation is available at **[ladbaby.github.io/Tresor-docs/](https://ladbaby.github.io/Tresor-docs/)**:

### πŸ‘€ For Users
- [🏠 Introduction](https://ladbaby.github.io/Tresor-docs/docs/user/intro) β€” overview and architecture
- [πŸ“¦ Installation & Quick Start](https://ladbaby.github.io/Tresor-docs/docs/user/getting-started/installation) β€” install from release or source, configure, run
- [βš™οΈ Configuration Basics](https://ladbaby.github.io/Tresor-docs/docs/user/configuration/basics) β€” YAML config file reference
- [πŸ”— Downstreams](https://ladbaby.github.io/Tresor-docs/docs/user/configuration/downstreams) β€” configure LLM provider endpoints
- [πŸ“ Rules](https://ladbaby.github.io/Tresor-docs/docs/user/configuration/rules) β€” define routing rules with transform pipelines
- [🏷️ Model Aliases](https://ladbaby.github.io/Tresor-docs/docs/user/configuration/aliases) β€” map model names and hot-switch backends
- [🌐 Proxy Modes](https://ladbaby.github.io/Tresor-docs/docs/user/configuration/proxy-modes) β€” outbound proxy configuration
- [πŸ–₯️ Web UI Guide](https://ladbaby.github.io/Tresor-docs/docs/user/web-ui) β€” manage everything from the browser
- [πŸ’» CLI Reference](https://ladbaby.github.io/Tresor-docs/docs/user/cli-reference) β€” all command-line commands

### πŸ’‘ Use Cases
- [πŸ”„ Transparent Provider Switching](https://ladbaby.github.io/Tresor-docs/docs/user/use-cases/provider-switching) β€” route OpenAI-format traffic to Anthropic
- [πŸŽ›οΈ Model Aliasing](https://ladbaby.github.io/Tresor-docs/docs/user/use-cases/model-aliasing) β€” hot-switch between backends
- [βš–οΈ A/B Testing Backends](https://ladbaby.github.io/Tresor-docs/docs/user/use-cases/ab-testing) β€” compare providers side by side

### πŸ› οΈ For Developers
- [πŸ—οΈ Architecture](https://ladbaby.github.io/Tresor-docs/docs/dev/architecture) β€” codebase structure, request flow, data layer
- [πŸ”Œ Plugin System](https://ladbaby.github.io/Tresor-docs/docs/dev/plugin-system) β€” building custom transformers
- [πŸ§ͺ Testing](https://ladbaby.github.io/Tresor-docs/docs/dev/testing) β€” test strategy and coverage
- [🀝 Contributing](https://ladbaby.github.io/Tresor-docs/docs/dev/contributing) β€” how to contribute to Tresor

## πŸ“œ Acknowledgement

- [llama.cpp](https://github.com/ggml-org/llama.cpp): Memory saving LLM inference.
- [Qwen & Unsloth](https://huggingface.co/unsloth/Qwen3.6-27B-MTP-GGUF): High quality local LLM.
- [Google Gemini](https://gemini.google.com/): Icon creation.
- [OpenAI ChatGPT](https://chatgpt.com/): Comparison figures.