JuliusBrussee/caveman · error

azure legacy inference path %q is not supported

Error message

azure legacy inference path %q is not supported

What it means

Any Azure request whose path is neither a Foundry v1 inference route (/openai/v1/chat/completions, /openai/v1/responses) nor the legacy deployment route (/openai/deployments/<name>/chat/completions with a syntactically valid deployment name) is rejected with this error echoing the offending path. The proxy only forwards the two known-good Azure surfaces, closing the door on typos, unsupported previews, and path-injection attempts.

Source

Thrown at proxy/providers/azureopenai/azure_routing.go:50

	if err := validateAzureRequest(req.URL); err != nil {
		return nil, err
	}
	return a.Base.ResolveUpstreamURL(ctx, req, route)
}

func validateAzureRequest(u *url.URL) error {
	if foundryV1InferenceRoute(u.Path) {
		versions := u.Query()["api-version"]
		if len(versions) > 1 {
			return fmt.Errorf("azure request has duplicate api-version values")
		}
		if len(versions) == 1 && versions[0] != "v1" && versions[0] != "preview" {
			return fmt.Errorf("azure Foundry api-version %q is not supported", versions[0])
		}
		return nil
	}
	if !legacyChatCompletionsRoute(u.Path) {
		return fmt.Errorf("azure legacy inference path %q is not supported", u.Path)
	}
	versions := u.Query()["api-version"]
	if len(versions) > 1 {
		return fmt.Errorf("azure request has duplicate api-version values")
	}
	version := ""
	if len(versions) == 1 {
		version = versions[0]
	}
	if version == "" {
		return fmt.Errorf("azure request missing api-version")
	}
	if !apiVersionAllowed(version) {
		return fmt.Errorf("azure api-version %q is not on the allowlist", version)
	}
	return nil
}

View on GitHub (pinned to 27d5a3981a)

Solutions

  1. Use one of the two supported shapes: /azure/openai/v1/chat/completions (Foundry, api-version=v1) or /azure/openai/deployments/<deployment>/chat/completions?api-version=<date>.
  2. Fix the path typo — compare segment by segment against the working shapes above.
  3. If you need embeddings/other endpoints, route them directly to Azure; this proxy surface is chat/completions-only by design.

Example fix

# before
curl "$PROXY/azure/openai/deployments/gpt-4o/completions?api-version=2024-10-21"

# after
curl "$PROXY/azure/openai/deployments/gpt-4o/chat/completions?api-version=2024-10-21"
Defensive patterns

Strategy: validation

Validate before calling

p := strings.TrimPrefix(u.Path, "/azure")
foundry := p == "/openai/v1/chat/completions" || p == "/openai/v1/responses"
parts := strings.Split(strings.Trim(p, "/"), "/")
legacy := len(parts) == 5 && parts[0] == "openai" && parts[1] == "deployments" &&
    parts[3] == "chat" && parts[4] == "completions" &&
    validDeploymentName(parts[2])
if !foundry && !legacy {
    return fmt.Errorf("unsupported Azure path %q; use /openai/v1/... or /openai/deployments/<name>/chat/completions", u.Path)
}

Type guard

func isSupportedAzurePath(path string) bool {
    p := strings.TrimPrefix(path, "/azure")
    if p == "/openai/v1/chat/completions" || p == "/openai/v1/responses" {
        return true
    }
    parts := strings.Split(strings.Trim(p, "/"), "/")
    return len(parts) == 5 && parts[0] == "openai" && parts[1] == "deployments" &&
        parts[3] == "chat" && parts[4] == "completions"
}

Try / catch

if err := validateAzureRequest(req.URL); err != nil {
    if strings.Contains(err.Error(), "legacy inference path") {
        http.Error(w, "unsupported Azure route; see /openai/v1/chat/completions and /openai/deployments/<dep>/chat/completions", http.StatusNotFound)
        return
    }
    http.Error(w, err.Error(), http.StatusBadRequest)
}

Prevention

When it happens

Trigger: Calling /azure/openai/deployments/my-dep/completions (missing 'chat' segment), /azure/openai/embeddings, a five-segment path whose deployment contains illegal characters, or a v1 route with a typo like /openai/v1/chat/completion.

Common situations: Pointing a generic OpenAI SDK at the /azure prefix so paths like /v1/models or /embeddings arrive; typo'd route; expecting embeddings or other Azure features that this surface does not proxy; deployment names with spaces or slashes.

Related errors


AI-assisted analysis of JuliusBrussee/caveman@27d5a3981a (2026-08-15). Data as JSON: /api/errors/36fe5742ced5470c. Report an issue: GitHub.