JuliusBrussee/caveman · error
vertex method is not allowed for publisher
Error message
vertex method %q is not allowed for publisher %q
What it means
The Vertex adapter enforces a per-publisher method allowlist in methodAllowed (routing.go:40-41,75-89). Google-publisher models accept only generateContent/streamGenerateContent; Anthropic-publisher models accept only rawPredict/streamRawPredict; countTokens is allowed for both. A method/publisher combination outside that matrix is rejected before the request is routed upstream.
Solutions
- Match the method to the publisher: use :generateContent/:streamGenerateContent for publisher 'google', :rawPredict/:streamRawPredict for publisher 'anthropic'.
- Change the publisher segment in the path if the model actually belongs to the other family (e.g. gemini-* under publishers/google, claude-* under publishers/anthropic).
- For token counting either family works: use :countTokens (google/anthropic) or the Anthropic SDK's count-tokens:rawPredict path.
Example fix
// before POST /vertex/v1/projects/p/locations/l/publishers/google/models/claude-sonnet-4-5:generateContent // after POST /vertex/v1/projects/p/locations/l/publishers/anthropic/models/claude-sonnet-4-5@20250929:rawPredict
Defensive patterns
Strategy: validation
Validate before calling
if !methodAllowed(publisher, method) {
return fmt.Errorf("method %s invalid for publisher %s: google→generateContent|streamGenerateContent, anthropic→rawPredict|streamRawPredict", method, publisher)
} Type guard
func isCompatiblePair(publisher, method string) bool {
return methodAllowed(publisher, method)
} Try / catch
if err != nil && strings.Contains(err.Error(), "is not allowed for publisher") {
return httpError(400, "method/publisher mismatch — match the method to the model family")
} Prevention
- Keep a mental map: gemini-* models → publishers/google + :generateContent; claude-* → publishers/anthropic + :rawPredict.
- Never swap only the model id in a copied curl example; check the publisher too.
- For token counting use :countTokens, allowed for both publishers.
When it happens
Trigger: Call '/vertex/.../publishers/google/models/gemini-2.5-pro:rawPredict' (OpenAI-style method on a Google model) or '/vertex/.../publishers/anthropic/models/claude-sonnet-4-5:generateContent' (Gemini-style method on a Claude model).
Common situations: Pointing an Anthropic-format client at a google-publisher model or vice versa; copying a curl example for one model family and swapping only the model id; SDK defaults that assume the other publisher's method.
Understand the failure class
Background: UnsupportedOperationException and "is not supported" errors: when a library deliberately refuses a call — this error's family across 30 libraries.
Related errors
- vertex model is not on the allowlist
- vertex publisher is not on the allowlist
- vertex request path does not name a publisher, model, and…
- compat route does not match default /compat/ mount
- compat route does not match prefix
AI-assisted analysis of JuliusBrussee/caveman@3ee70a1026 (2026-09-20).
Data as JSON: /api/errors/b891b3610198d5f5.
Report an issue: GitHub.
Appendix: source
Thrown at proxy/providers/vertex/routing.go:41
// Operators override it with CAVE_VERTEX_MODEL_ALLOWLIST.
var defaultModelPrefixes = []string{"gemini-", "claude-"}
// ResolveUpstreamURL validates the Vertex request shape (publisher + model on
// the allowlist), enforces SSRF/host constraints against the aiplatform
// endpoint, and resolves the upstream URL. The /vertex prefix is stripped so the
// upstream path is the native aiplatform path
// (/v1/projects/{p}/locations/{l}/publishers/{pub}/models/{model}:{method}). The
// non-authentication query bytes (e.g. ?alt=sse) are preserved unchanged.
func (a Adapter) ResolveUpstreamURL(ctx context.Context, req *http.Request, route providers.RouteContext) (*url.URL, error) {
if _, err := providers.GoogleRequestAPIKey(req); err != nil {
return nil, err
}
publisher, model, method := parsePredictPath(req.URL.Path)
if publisher == "" || model == "" || method == "" {
return nil, fmt.Errorf("vertex request path %q does not name a publisher, model, and method", req.URL.Path)
}
if !methodAllowed(publisher, method) {
return nil, fmt.Errorf("vertex method %q is not allowed for publisher %q", method, publisher)
}
if !publisherAllowed(publisher) {
return nil, fmt.Errorf("vertex publisher %q is not on the allowlist", publisher)
}
if !modelAllowed(model) && !anthropicCountTokensPath(publisher, model, method) {
return nil, fmt.Errorf("vertex model %q is not on the allowlist", model)
}
baseURL := a.BaseURL
if route.BaseURL != "" {
baseURL = route.BaseURL
}
base, err := url.Parse(baseURL)
if err != nil {
return nil, fmt.Errorf("vertex base url invalid: %w", err)
}
base.Path = strings.TrimRight(base.Path, "/") + strings.TrimPrefix(req.URL.Path, "/vertex")
base.RawQuery = providers.WithoutGoogleAPIKeyQuery(req.URL.RawQuery)View on GitHub (pinned to 3ee70a1026)