Skip to documentation
Documentation navigation

Documentation navigation

Documentation / guides

Counting errors

Inspect typed count, model, encoding, capability, and compatibility failures.

developer

Count failures preserve bounded classifications without retaining request bytes. Inspect them with errors.As and errors.Is.

Types

ErrorMeaning
EstimatorStateErrornil estimator or nil context
ModelIdentityErrorinvalid model key or identity
UnsupportedAPIFormatErrorno bundled estimator encoder
RequestEncodingErrorselected codec rejected the request
ContextCountErrorcallback missing, canceled, model/quality mismatch, or wrapped cause
CapabilityValidationErrormalformed capability metadata
CounterCompatibilityErrorcounter weakens inference trust posture

ContextCountError.Unwrap exposes the safe cause. The errors do not include raw request bodies or provider response content.

Inspection

var unsupported *contextcount.UnsupportedAPIFormatError
var encoding *contextcount.RequestEncodingError
switch {
case errors.As(err, &unsupported):
	// choose an exact provider counter or reject admission
case errors.As(err, &encoding):
	// fix the request or use a dialect that represents it
}

Source and proof

Run go test ./contextcount.

← back to documentation