Skip to documentation
Documentation navigation

Documentation navigation

Documentation / guides

Model validation

Apply structural model validation and inspect typed failures safely.

developer

Model.Validate is the structural boundary before a descriptor enters a client. It returns typed errors and intentionally leaves provider policy to the consumer that owns a catalogue or codec registry.

Validation rules

RuleFailure
Name is non-empty*ValidationError{Field: "Name"}
StructuredOutputWithTools implies Tools and StructuredOutput*ValidationError{Field: "Caps.StructuredOutputWithTools"}
Known max input/output limits do not exceed WindowTokens*ContextLimitsValidationError
Non-empty base URL has a host and no userinfo*ValidationError{Field: "BaseURL"}
Scheme is HTTPS, or loopback HTTP*ValidationError{Field: "BaseURL"}

Unknown ProviderName and APIFormat values pass. OriginCustom and OriginCatalog validate identically; origin changes downstream trust and gating, not the structural rules.

descriptor := model.Model{BaseURL: "http://example.test", Name: "chat"}
err := descriptor.Validate()
var validation *model.ValidationError
if errors.As(err, &validation) {
	fmt.Println(validation.Field, validation.Reason)
}

Always use errors.As instead of matching the human-readable error string. A caller that needs a fully resolved identity should also call descriptor.Key().Validate().

Proof

Related: Custom models, Model identity.

← back to documentation