diff --git a/internal/gateway/discover.go b/internal/gateway/discover.go index 279d576..ea0c277 100644 --- a/internal/gateway/discover.go +++ b/internal/gateway/discover.go @@ -285,18 +285,22 @@ func composeEndpoint(modelsPath, persistedBase, typedBase string) string { // // base "https://h" + "/v1/images/generations" → correct // base "https://h/v1" + "/v1/images/generations" → "/v1/v1/…" 404 +// base "https://h/v1" + "/images/generations" → "/v1/images/generations" correct // -// Emitting "" when the base already ends in a version is wrong for a different -// reason: the vendor's catalog path is not proof that its image path carries -// the same prefix. Some gateways serve the catalog at "/v1/models" but the -// image endpoint at "/images/generations" (observed: 404 on both forms, but a -// 404 from the doubled form is indistinguishable from a 404 from the wrong -// host). Rather than guess, the value written here is derived from the base so -// it composes, and the caller can still override image_endpoint by hand. +// The second row is not a theoretical guess. Measured against the real +// amr-link endpoint with base_url "https://amr-link.open-design.ai/v1": +// +// …/v1/images/generations → 200 (the image is then generated; that call +// takes minutes, which is the upstream's own +// latency and not a routing problem) +// …/v1/v1/images/generations → 404 +// …/images/generations → 404 +// +// Leaving the default in place when the base already ends in a version is +// therefore always wrong for such an upstream, and the version-relative form +// is the one that composes. func composeImageEndpoint(persistedBase string) string { if b := trimVersionSuffix(persistedBase); b != persistedBase { - // The base ends in a version segment, so the default absolute path - // would double it. Use the version-relative form instead. return "/images/generations" } return ""