JuliusBrussee/caveman · error

vertex model is not on the allowlist

Error message

vertex model %q is not on the allowlist

What it means

The Vertex adapter matches the requested model id against a prefix allowlist — by default ['gemini-','claude-'] (routing.go:24,46-47,176-178) — so versioned ids like gemini-2.5-pro or claude-sonnet-4-5@20250929 are covered. A model that matches no entry is rejected, unless it is the special Anthropic count-tokens literal path. This keeps clients from invoking models the gateway cannot price or meter.

Solutions

  1. Use a model id starting with an allowlisted prefix (gemini-... under publishers/google, claude-... under publishers/anthropic).
  2. Check the id for typos against the vendor's published model list (e.g. gemini-2.5-pro, claude-sonnet-4-5@20250929).
  3. If the model is intended, extend CAVE_VERTEX_MODEL_ALLOWLIST with the appropriate prefix (comma-separated) — the default list matches as prefixes, so 'gemini-' covers all versions.

Example fix

# before
CAVE_VERTEX_MODEL_ALLOWLIST=gemini-
# after
CAVE_VERTEX_MODEL_ALLOWLIST=gemini-,claude-
Defensive patterns

Strategy: validation

Validate before calling

if !modelAllowed(model) && !(publisher == "anthropic" && model == "count-tokens" && method == "rawPredict") {
    return fmt.Errorf("model %q not allowlisted; default prefixes gemini-,claude-; override with CAVE_VERTEX_MODEL_ALLOWLIST", model)
}

Type guard

func isAllowlistedModel(model string) bool {
    return modelAllowed(model)
}

Try / catch

if err != nil && strings.Contains(err.Error(), "model") && strings.Contains(err.Error(), "allowlist") {
    return httpError(403, "model not allowlisted; verify the id or extend CAVE_VERTEX_MODEL_ALLOWLIST")
}

Prevention

When it happens

Trigger: Request '/vertex/.../publishers/google/models/llama-4-maverick:generateContent', a typo'd id like 'gemini2.5-pro' (no hyphen), or an unpublished model id not starting with gemini-/claude- while CAVE_VERTEX_MODEL_ALLOWLIST is unset/overridden.

Common situations: Routing partner (non-gemini/claude) models; a narrowed CAVE_VERTEX_MODEL_ALLOWLIST that dropped a prefix you now use; brand-new model families released after the default list was written.

Understand the failure class

Background: Invalid enum value errors: "Unknown type", "Invalid scope", "must be one of" — when a string is not on the library's allowed list — this error's family across 23 libraries.

Related errors


AI-assisted analysis of JuliusBrussee/caveman@3ee70a1026 (2026-09-20). Data as JSON: /api/errors/6d56f40b3ba12153. Report an issue: GitHub.

Appendix: source

Thrown at proxy/providers/vertex/routing.go:47

// 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)

	// SSRF/host validation on the resolved endpoint. Active in managed (prod)
	// mode; local/self-hosted (stub) endpoints are permitted so the dry-run and
	// examples can target the provider-stub.
	if env.IsProduction() {
		if err := providers.ValidateUpstreamEndpoint(ctx, base, ssrf.ManagedConfig()); err != nil {

View on GitHub (pinned to 3ee70a1026)