Skip to documentation
Documentation navigation

Documentation navigation

Documentation / guides

Model identity

Keep stable provider and model identity separate from endpoints and codecs.

developer

ModelKey is the stable identity of a resolved model. It contains only the provider namespace and provider model ID, so changing a base URL or API format does not silently change the model’s identity.

API surface

type ProviderName string

type ModelKey struct {
	Provider ProviderName
	Model    string
}

func (k ModelKey) Validate() error

Model.Key() returns ModelKey{Provider: m.Provider, Model: m.Name}. Validation returns *ModelKeyValidationError with Field set to ModelKeyFieldProvider or ModelKeyFieldModel and Reason set to ModelKeyValidationReasonEmpty.

descriptor := model.CustomModel(
	model.ProviderName("acme"), model.APIFormatOpenAI,
	"https://api.example.test", "chat-1",
)
key := descriptor.Key()
if err := key.Validate(); err != nil {
	panic(err)
}

ProviderName is opaque and has no provider policy. An empty provider is a wildcard in the descriptor, but a fully resolved ModelKey must validate both fields.

Proof

Related: Model, Resolved model.

← back to documentation