pycivitai.client.resource

list_models_by_name

pycivitai.client.resource.list_models_by_name(model_name: str, creator: Optional[str] = None, strict: bool = False) List[dict][source]

Retrieve model information from the CiviTAI API based on the given model name.

Parameters:
  • model_name (str) – The name of the model to retrieve information for.

  • creator (Optional[str]) – Name of creator. None means anyone.

  • strict (bool) – Strict filter all the results or not. Default is False.

Returns:

The list of dictionaries containing the searched model information.

Return type:

dict

find_model_by_name

pycivitai.client.resource.find_model_by_name(model_name: str, creator: Optional[str] = None) dict[source]

Retrieve model information from the CiviTAI API based on the given model name.

Parameters:
  • model_name (str) – The name of the model to retrieve information for.

  • creator (Optional[str]) – Name of creator. None means anyone.

Returns:

The dictionary containing the model information.

Return type:

dict

Raises:

find_model_by_id

pycivitai.client.resource.find_model_by_id(model_id) dict[source]

Retrieve model information from the CiviTAI API based on the given model ID.

Parameters:

model_id (int) – The ID of the model to retrieve information for.

Returns:

The dictionary containing the model information.

Return type:

dict

Raises:

ModelNotFound – If the model with the given ID is not found.

find_model

pycivitai.client.resource.find_model(model_name_or_id: Union[int, str], creator: Optional[str] = None) dict[source]

Find model information from the CiviTAI API based on the given model name or ID.

Parameters:
  • model_name_or_id (Union[int, str]) – The name or ID of the model to retrieve information for.

  • creator (Optional[str]) – Name of creator. None means anyone.

Returns:

The dictionary containing the model information.

Return type:

dict

Raises:

TypeError – If the model name or ID is not a valid integer or string.

find_version

pycivitai.client.resource.find_version(model_data: dict, version: Optional[Union[int, str]] = None)[source]

Find the specified version from the model data.

Parameters:
  • model_data (dict) – The model data containing version information.

  • version (Union[int, str, None]) – The version ID or name to find. If None, the first version will be chosen.

Returns:

The dictionary containing the selected version information.

Return type:

dict

Raises:

find_resource

pycivitai.client.resource.find_resource(model_data: dict, version_data: dict, pattern: Optional[str] = None)[source]

Find the specified resource from the model and version data.

Parameters:
  • model_data (dict) – The model data containing version information.

  • version_data (dict) – The version data containing resource information.

  • pattern (str) – The pattern to match the resource filename. If None, the primary resource will be chosen.

Returns:

The resource information.

Return type:

Resource

Raises:
  • TypeError – If the pattern of the resource is not a valid string.

  • ResourceNotFound – If the specified resource is not found.

  • ResourceDuplicated – If multiple resources with the same name are found.

Model

class pycivitai.client.resource.Model(data)[source]

Resource

class pycivitai.client.resource.Resource(model_name: str, model_id: int, creator: str, version_name: str, version_id: int, filename: str, is_primary: bool, url: str, sha256: str, crc32: str, hashes: dict, size: int, tags: List[str])[source]

Data class for resource.

ResourceNotFound

exception pycivitai.client.resource.ResourceNotFound[source]

ModelNotFound

exception pycivitai.client.resource.ModelNotFound[source]

ModelVersionNotFound

exception pycivitai.client.resource.ModelVersionNotFound[source]

ResourceDuplicated

exception pycivitai.client.resource.ResourceDuplicated[source]

ModelVersionDuplicated

exception pycivitai.client.resource.ModelVersionDuplicated[source]

ModelFoundDuplicated

exception pycivitai.client.resource.ModelFoundDuplicated[source]