Table of Contents

Class AirBuilder

Namespace
CivitaiSharp.Sdk.Air
Assembly
CivitaiSharp.Sdk.dll

Immutable, thread-safe builder for constructing AirIdentifier instances with validation. Each fluent method returns a new builder instance, allowing safe reuse and caching of base configurations.

public sealed record AirBuilder : IEquatable<AirBuilder>
Inheritance
AirBuilder
Implements
Inherited Members

Examples

var air = new AirBuilder()
    .WithEcosystem(AirEcosystem.StableDiffusionXl)
    .WithAssetType(AirAssetType.Lora)
    .WithModelId(328553)
    .WithVersionId(368189)
    .Build();

Console.WriteLine(air.ToString());
// Output: urn:air:sdxl:lora:civitai:328553@368189

Remarks

This builder simplifies the construction of AIR (Artificial Intelligence Resource) identifiers by providing a clear, step-by-step fluent interface. Use this when you want to construct AIR identifiers programmatically with compile-time guidance and runtime validation.

This builder follows the same immutable pattern as RequestBuilder in CivitaiSharp.Core. Each method returns a new instance, making it inherently thread-safe.

Constructors

AirBuilder()

Initializes a new instance of the AirBuilder record with default values.

public AirBuilder()

Methods

Build()

Builds the AirIdentifier with the configured values.

public AirIdentifier Build()

Returns

AirIdentifier

A new AirIdentifier instance.

Exceptions

InvalidOperationException

Thrown when required properties (Ecosystem, AssetType, ModelId, VersionId) have not been set.

TryBuild(out AirIdentifier)

Attempts to build the AirIdentifier with the configured values.

public bool TryBuild(out AirIdentifier result)

Parameters

result AirIdentifier

When this method returns true, contains the built AirIdentifier; otherwise, contains the default value.

Returns

bool

true if all required properties were set and the identifier was built successfully; otherwise, false.

Remarks

Use this method when you prefer to handle missing required properties without exceptions. All properties (Ecosystem, AssetType, ModelId, VersionId) must be set for the build to succeed.

WithAssetType(AirAssetType)

Sets the asset type (e.g., Checkpoint, LoRA, Embedding).

public AirBuilder WithAssetType(AirAssetType assetType)

Parameters

assetType AirAssetType

The asset type.

Returns

AirBuilder

A new builder instance with the asset type set.

WithEcosystem(AirEcosystem)

Sets the ecosystem (e.g., Stable Diffusion XL, FLUX.1).

public AirBuilder WithEcosystem(AirEcosystem ecosystem)

Parameters

ecosystem AirEcosystem

The model ecosystem.

Returns

AirBuilder

A new builder instance with the ecosystem set.

WithModelId(long)

Sets the model ID.

public AirBuilder WithModelId(long modelId)

Parameters

modelId long

The model ID. Must be greater than 0.

Returns

AirBuilder

A new builder instance with the model ID set.

Exceptions

ArgumentOutOfRangeException

Thrown when modelId is less than 1.

WithSource(AirSource)

Sets the source platform for the resource.

public AirBuilder WithSource(AirSource source)

Parameters

source AirSource

The source platform. Defaults to Civitai if not specified.

Returns

AirBuilder

A new builder instance with the source set.

WithVersionId(long)

Sets the version ID.

public AirBuilder WithVersionId(long versionId)

Parameters

versionId long

The version ID. Must be greater than 0.

Returns

AirBuilder

A new builder instance with the version ID set.

Exceptions

ArgumentOutOfRangeException

Thrown when versionId is less than 1.