Table of Contents

Class ModelDownloadOptions

Namespace
CivitaiSharp.Tools.Downloads.Options
Assembly
CivitaiSharp.Tools.dll

Configuration options for model file download operations.

public sealed class ModelDownloadOptions
Inheritance
ModelDownloadOptions
Inherited Members

Remarks

Bind this class from configuration using the section path "CivitaiDownloads:Models".

Path patterns support the following tokens when downloading a ModelFile:

TokenDescription
{FileId}The unique file identifier
{FileName}The original file name (required)
{FileType}The file type (e.g., "Model", "Training Data")
{Format}The model format (e.g., "SafeTensor")
{Size}The model size specification (e.g., "full", "pruned")
{Precision}The floating point precision (e.g., "fp16", "fp32")

When a ModelVersion is provided, additional tokens are available:

TokenDescription
{VersionId}The model version identifier
{VersionName}The version name
{BaseModel}The base model (e.g., "SDXL 1.0")
{ModelId}The parent model identifier
{ModelName}The parent model name
{ModelType}The model type (e.g., "Checkpoint", "LORA")

Properties

BaseDirectory

Gets or sets the base directory where downloaded model files will be saved.

public string BaseDirectory { get; set; }

Property Value

string

Remarks

Defaults to the system temporary directory. The directory will be created if it does not exist.

HashAlgorithm

Gets or sets the hash algorithm to use for verification.

public HashAlgorithm HashAlgorithm { get; set; }

Property Value

HashAlgorithm

Remarks

Defaults to Sha256 which is the most commonly available hash in Civitai model metadata. BLAKE3 is also available for many models.

OverwriteExisting

Gets or sets whether existing files should be overwritten.

public bool OverwriteExisting { get; set; }

Property Value

bool

Remarks

When true (default), existing files will be replaced. When false, downloads will fail if the destination file already exists.

PathPattern

Gets or sets the path pattern for generating file names.

public string PathPattern { get; set; }

Property Value

string

Remarks

The pattern supports tokens that are replaced with values from the model file metadata. Tokens are case-sensitive and must be enclosed in curly braces.

Examples:

  • "{FileName}" produces "myModel_v1.safetensors"
  • "{ModelType}/{FileName}" produces "Checkpoint/myModel_v1.safetensors"
  • "{Creator}/{ModelName}/{VersionName}/{FileName}" produces "CreatorName/Amazing Model/v1.0/myModel_v1.safetensors"

VerifyHash

Gets or sets whether to verify the downloaded file's hash against the expected hash from Civitai.

public bool VerifyHash { get; set; }

Property Value

bool

Remarks

When true (default), the downloaded file's hash will be computed and compared against the hash provided by Civitai in the model file metadata. If the hashes do not match, the download is considered failed and the file may be deleted.