AiConfig class
Everything needed to talk to a model.
Resolution order, most specific first: command line flags, the ai: section
of distribution.yaml, the machine-wide store, then the environment.
The API key is deliberately not expected in distribution.yaml: that file
belongs in version control. It lives in the machine-wide store written by
distribute ai setup, in an environment variable, or in the config as a
${{VAR}} placeholder that resolves at run time.
Constructors
- AiConfig({required AiProviderKind provider, required String baseUrl, required String model, required String apiKey, AiPermission permission = AiPermission.manual, int maxTokens = 2048, AiSource baseUrlSource = AiSource.none, AiSource apiKeySource = AiSource.none, bool permissionDemoted = false})
-
Creates a resolved configuration.
const
Properties
- apiKey → String
-
Credential for the endpoint. Empty when none could be resolved.
final
- apiKeySource → AiSource
-
Where apiKey was resolved from.
final
- baseUrl → String
-
Endpoint root, without the operation path.
final
- baseUrlSource → AiSource
-
Where baseUrl was resolved from.
final
- hasApiKey → bool
-
Whether a credential is available.
no setter
- hashCode → int
-
The hash code for this object.
no setterinherited
- maxTokens → int
-
Ceiling on the model's response length.
final
- model → String
-
Model identifier passed through verbatim.
final
- permission → AiPermission
-
How much the assistant may do on its own.
final
- permissionDemoted → bool
-
Whether
permission: autofrom the project file was reduced tomanual.final - provider → AiProviderKind
-
Wire protocol of the endpoint.
final
- redirectsForeignKey → bool
-
Whether the project file is redirecting a credential it did not supply.
no setter
- runtimeType → Type
-
A representation of the runtime type of the object.
no setterinherited
Methods
-
noSuchMethod(
Invocation invocation) → dynamic -
Invoked when a nonexistent method or property is accessed.
inherited
-
toString(
) → String -
A string representation of this object.
inherited
-
toYamlSection(
{String? apiKey}) → Map< String, dynamic> -
Renders the configuration as the
ai:section ofdistribution.yaml.
Operators
-
operator ==(
Object other) → bool -
The equality operator.
inherited
Static Properties
- globalStore → File
-
The machine-wide store, shared by every project on this machine.
no setter
Static Methods
-
looksLikeLiteralSecret(
String? value) → bool -
Whether
valueis a literal secret rather than a${{VAR}}placeholder. -
readGlobalStore(
) → Map< String, dynamic> ? -
Reads the machine-wide store, or
nullwhen it is absent or unreadable. -
resolve(
{Map< String, dynamic> ? yaml, Map<String, String?> overrides = const {}, Map<String, dynamic> ? global, Map<String, String> ? environment}) → AiConfig - Builds a configuration from the layered sources.
-
writeGlobalStore(
Map< String, dynamic> values) → String? -
Writes
valuesto the machine-wide store with owner-only permissions.