feat: multi-backend proxy with auto rate-limit jailing
Refactor from monolithic proxy to multi-backend architecture (Backend interface: OpenCode Zen + Kilo gateway). - Add auto rate-limit jailing: models returning HTTP 429 are hidden from /v1/models immediately and re-probed every 30 min - Backend interface supports model aliases, custom headers, and per-backend routing - Full Anthropic Messages API support with OpenAI format conversion - 9 free models across two backends with Claude name aliases
This commit is contained in:
@@ -0,0 +1,27 @@
|
||||
package proxy
|
||||
|
||||
// Backend represents one upstream free-model provider (opencode zen, kilo, mimo, ...).
|
||||
//
|
||||
// Each backend knows its own model catalogue, how to resolve a requested model
|
||||
// name to the upstream ID, and the URL + headers required to forward a chat
|
||||
// completion request to it. The Proxy holds an ordered list of backends and
|
||||
// routes each request to the first one that recognises the model.
|
||||
type Backend interface {
|
||||
// Name is a short stable identifier ("opencode", "kilo").
|
||||
Name() string
|
||||
|
||||
// Models returns the free models this backend exposes, for /v1/models listing.
|
||||
Models() []ModelInfo
|
||||
|
||||
// Resolve maps a client-requested model name to the upstream model ID.
|
||||
// Returns ok=false when this backend does not recognise the model, so the
|
||||
// router can try the next backend (or fall back to pass-through).
|
||||
Resolve(model string) (resolved string, ok bool)
|
||||
|
||||
// ChatURL is the full upstream chat completions URL.
|
||||
ChatURL() string
|
||||
|
||||
// Headers returns the headers required to authenticate/identify the
|
||||
// request to the upstream (auth, client-id, request/session tracking, etc.).
|
||||
Headers(requestID, sessionID string) map[string]string
|
||||
}
|
||||
Reference in New Issue
Block a user