feat(provider): per-model and per-path upstreams (#8)

Add modelBaseUrls and pathBaseUrls to openai-type providers.
This commit is contained in:
2026-11-08 07:26:14 +00:00
committed by GitHub
parent aa9a925d49
commit a4fda5f9cb
10 changed files with 512 additions and 9 deletions
+16 -1
View File
@@ -1291,7 +1291,22 @@ func (g *Gateway) handlePassthrough(w http.ResponseWriter, r *http.Request, u *u
}
}
upstreamURL := adapter.base() + "/" + rest
upstreamBase := adapter.base()
if oa, isOpenAI := adapter.(*openaiAdapter); isOpenAI && oa.hasUpstreamOverrides() {
var model string
if len(oa.modelBases) > 0 {
m, hasModel, truncated, peekErr := peekPassthroughModel(r)
if peekErr != nil {
writeOAIError(w, http.StatusBadRequest, "invalid_request_error", "cannot read request body")
return
}
if hasModel && !truncated {
model = m
}
}
upstreamBase = oa.passthroughBase(model, "/"+rest)
}
upstreamURL := upstreamBase + "/" + rest
if r.URL.RawQuery != "" {
upstreamURL += "?" + r.URL.RawQuery
}