ModelPreferences class final

The server's preferences for model selection, requested of the client during sampling.

Because LLMs can vary along multiple dimensions, choosing the "best" model is rarely straightforward. Different models excel in different areas—some are faster but less capable, others are more capable but more expensive, and so on. This interface allows servers to express their priorities across multiple dimensions to help clients make an appropriate selection for their use case.

These preferences are always advisory. The client MAY ignore them. It is also up to the client to decide how to interpret these preferences and how to balance them against other considerations.

Revisions: 2024-11-05, 2025-03-26, 2025-06-18, 2025-11-25, 2026-07-28, ext-tasks/2026-07-28.

Inheritance

Constructors

ModelPreferences({num? costPriority, List<ModelHint>? hints, num? intelligencePriority, num? speedPriority, Map<String, Object?>? extra})
ModelPreferences.fromJson(Map<String, Object?> json)
Wraps json as received; nothing is dropped.

Properties

costPriority → num?
How much to prioritize cost when selecting a model. A value of 0 means cost is not important, while a value of 1 means cost is the most important factor.
no setter
extra → Map<String, Object?>
Keys outside the schema (newer revisions, extensions, applications).
no setterinherited
hashCode → int
The hash code for this object.
no setterinherited
hints → List<ModelHint>?
Optional hints to use for model selection.
no setter
intelligencePriority → num?
How much to prioritize intelligence and capabilities when selecting a model. A value of 0 means intelligence is not important, while a value of 1 means intelligence is the most important factor.
no setter
runtimeType → Type
A representation of the runtime type of the object.
no setterinherited
schemaKeys → Set<String>
Property names the schema defines for this type.
no setteroverride
speedPriority → num?
How much to prioritize sampling speed (latency) when selecting a model. A value of 0 means speed is not important, while a value of 1 means speed is the most important factor.
no setter

Methods

$optional<T>(String key, T? read(Object? value, String path)) → T?
Optional property key, converted by read; null when absent or null.
inherited
$required<T>(String key, T read(Object? value, String path)) → T
Required property key, converted by read.
inherited
check() → List<String>
Reads every property this type defines and returns what could not be read (missing required properties, wrong types), nested types included. Empty = the JSON matches the schema's shape for this type.
override
copyWith({num? costPriority, List<ModelHint>? hints, num? intelligencePriority, num? speedPriority}) → ModelPreferences
A copy with the given properties replaced; everything else, unknown keys included, is kept.
has(String key) → bool
Whether key is present (a null value counts as present).
inherited
noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
toJson() → Map<String, Object?>
The JSON form of this value.
inherited
toString() → String
A string representation of this object.
inherited

Operators

operator ==(Object other) → bool
Equal when the JSON is equal; key order does not matter.
inherited
operator [](String key) → Object?
The raw JSON value of key.
inherited

Constants

keys → const Set<String>