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 Chat Completions, Anthropic Messages, or OpenAI Responses 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​

  • ⚑ 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.
  • 🎭 Auto-Translation β€” Automatically convert between OpenAI, Anthropic, OpenAI Responses, and Google Gemini formats. Your app sends an OpenAI request; Tresor forwards it to an Anthropic, Gemini, or any other downstream and converts the response back β€” no rule configuration needed.
  • πŸ” Traffic Inspection (off by default) β€” Inspect raw incoming requests and downstream LLM responses, by clicking the log entries. Curious about what your LLM Apps are actually sending to LLMs? Then this is for you! Works similar to claude-tap.
  • 🌐 Embedded Web UI β€” Manage everything from a browser dashboard. No separate frontend deployment.
  • πŸ”Œ Plugin Pipeline β€” Chain transformation plugins per rule (header injection, image fix, format conversion, and more). Fourteen built-in plugins cover all common format combinations.
  • πŸ“ Single Config File β€” All settings in one portable YAML file. Changes via the web UI write back automatically.
  • πŸ”‘ Proxy Authentication β€” Require clients to authenticate via Authorization: Bearer or x-api-key headers (supports Anthropic-format clients like Claude Office plugin).
  • πŸ”„ Retry on Empty Response β€” Automatically retry downstream requests that return HTTP 200 but produce no content (e.g., thinking-only responses, empty completions). Up to 3 retries with exponential backoff. Transparent to the client.
  • πŸͺΆ 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 (OpenAI Chat Completions, Anthropic Messages, or OpenAI Responses API) doesn't match the downstream's declared format, automatically insert the appropriate format converter (e.g., openai2responses, responses2anthropic)
  7. βš™οΈ Transform & Forward β€” Run request through configured transformers, then forward to the resolved downstream
  8. πŸ”„ Retry on Empty Response β€” (if enabled) If the downstream returns HTTP 200 but produces no content, retry up to 3 times with exponential backoff. Retries are transparent to the client.
  9. ↩️ 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