Skip to main content

Tresor

Switch LLM Providers for Any Apps with One Click. β€” a single Go binary that sits between your applications and LLM providers, intercepting API calls, routing them to different backends, and transforming request/response formats on the fly.

At a Glance​

Tresor has two faces in one binary:

ModeWhat It Does
DaemonπŸ–₯️ Long-running HTTP gateway + admin REST API + embedded web UI
CLIπŸ’» Command-line client for managing rules, downstreams, and aliases
β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β” β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β” β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚ Your App │────>β”‚ Tresor │────>β”‚ LLM Providerβ”‚
β”‚ β”‚ β”‚ (gateway) β”‚ β”‚ (OpenAI, β”‚
β”‚ β”‚<────│ β”‚<────│ Anthropic..)β”‚
β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜ β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜ β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
β”‚
β”œβ”€β”€ Admin REST API
β”œβ”€β”€ Embedded Web UI
└── CLI Commands

πŸ€” 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 Web UI

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

The Provider Switching Problem

Imagine you have agents on three machines, all calling OpenAI. You want to switch them to Anthropic. Tresor sits in the middle so you only change one thing.

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

✨ Core Features​

  • πŸ”„ Protocol Translation β€” Convert between OpenAI and Anthropic API formats transparently. Send an OpenAI request, receive it from an Anthropic backend, without changing a line of application code.
  • ⚑ Auto-Translation β€” When a downstream declares its API format (e.g., api_formats: [anthropic]), Tresor automatically inserts the appropriate format converter into the pipeline, even without an explicit rule.
  • πŸ›€οΈ Per-Path Routing β€” Route different API paths (and models) to different downstream providers based on configurable rules.
  • 🏷️ Model Aliasing β€” Map one model name to another at the gateway layer. Your app sends gpt-4o, Tresor forwards as claude-sonnet-4. Hot-switch between backends without restarting. Supports regex patterns (e.g., ^claude-.*) to match entire families of models. Groups can be reordered via drag-and-drop in the web UI.
  • πŸ”Œ Plugin Pipeline β€” Chain multiple transformation plugins per rule (header injection, format conversion, image extraction, and more).
  • πŸ“‹ Aggregated Model List β€” Tresor exposes /v1/models that aggregates all known models from downstreams and exact-match aliases (regex aliases excluded), so OpenAI-compatible clients can discover available models.
  • πŸ“Š Request Logging β€” Real-time gateway request logs via Server-Sent Events (SSE), displayed newest-first with a text filter for searching. Configurable log verbosity (debug, info, warn, error).
  • 🌐 Embedded Web UI β€” Manage everything from a browser-based dashboard served by the daemon itself. Features include a login screen, dark/light theme toggle, visual pipeline editor, request log viewer, and an About panel. No separate frontend needed.
  • πŸ“ Single Config File β€” All downstreams, rules, aliases, and settings live in one portable YAML file. Changes via API or UI write back automatically.
  • πŸͺΆ Zero External Dependencies β€” Pure Go SQLite (no CGO), no external web framework, single compiled binary.

πŸ”„ How It Works​

When a request hits Tresor:

  1. πŸ” Auth Check β€” Validate proxy API key if configured
  2. πŸ” Model Extract β€” Extract the model name from the request body
  3. 🏷️ Alias Check β€” Look for an active exact alias matching the model; if not found, try active regex aliases. If found, use its downstream and rewrite the model name
  4. 🎯 Direct Routing β€” If no alias, find which downstream can handle this model via output_model_ids
  5. πŸ“ Rule Matching β€” Collect all matching rules for pipeline transforms (rules never override the resolved downstream; multiple rules can match and their pipelines are concatenated)
  6. ⚑ Auto-Translation β€” If the request format doesn't match the downstream's declared format, automatically insert a format converter
  7. βš™οΈ Transform & Forward β€” Run request through configured transformers, then forward to the resolved downstream
  8. ↩️ Transform Response β€” Run the downstream's response through response transformers before returning to the client

πŸ—οΈ Key Design Decisions​

  • πŸ“ Single YAML config β€” all settings in one portable file
  • πŸ’Ύ SQLite (modernc.org/sqlite) β€” pure Go, no CGO dependency
  • πŸ”„ Upsert on startup β€” YAML data merges into SQLite; DB-only rows preserved
  • 🚫 No external web framework β€” uses net/http ServeMux directly
  • πŸ“¦ Single binary β€” daemon and CLI dispatched by subcommand
  • 🌐 Web UI embedded at compile time β€” via Go's embed.FS

Next: πŸ“¦ Installation β€” Get Tresor running on your machine.