### Install Dependencies Source: https://github.com/ryanontheinside/civitai-api/blob/main/README.md Install the required dependencies for the Civitai API Wrapper by running this command. ```bash pip install -r requirements.txt ``` -------------------------------- ### Retrieve Images, Model Versions, Creators, and Tags Source: https://github.com/ryanontheinside/civitai-api/blob/main/README.md This snippet demonstrates how to retrieve images related to a model, get a specific model version, query creators by name, and search for tags. It shows how to iterate through results and access specific properties. ```python #get 4 images related to model 1102 images = civitai.images.list_images(model_id=1102, limit=4) print("images:") for image in images: print(image.url) #get a model version version = civitai.model_versions.get_model_version(version_id=1302) print(version.name) #query creators creators = civitai.creators.list_creators(query='RalFinger') for creator in creators: print(creator.modelCount) #query tags tags = civitai.tags.list_tags(query='celebrity') for tag in tags: print(tag.name, tag.modelCount) ``` -------------------------------- ### Get Model Details Source: https://github.com/ryanontheinside/civitai-api/blob/main/README.md Retrieve detailed information about a specific model using its ID. This snippet shows how to access model properties like 'nsfw'. ```python model = civitai.models.get_model(model_id=1102) print(model.nsfw) ``` -------------------------------- ### List Models with Filters Source: https://github.com/ryanontheinside/civitai-api/blob/main/README.md List models using various filters such as type, sort order, username, base model, query, page, period, and limit. This example retrieves top-rated LoRAs for SD 1.5 created by a specific user this year. ```python #get top 5 loras created by RalFinger this year for sd15 with 'style' in the name models = civitai.models.list_models( types=[ModelType.LORA], sort=ModelSort.HIGHEST_RATED, username='RalFinger', base_models=[BaseModel.SD_1_5, BaseModel.SD_1_5_LCM], query='style', page=1, period=ModelPeriod.YEAR, limit=5 ) print("models:") for model in models: print(model.name) ``` -------------------------------- ### Initialize Civitai Client Source: https://github.com/ryanontheinside/civitai-api/blob/main/README.md Initialize the Civitai client with your API key. Ensure you have the necessary imports. ```python from civitai_api import Civitai from civitai_api.models import BaseModel, ModelType from civitai_api.api.models import ModelSort, ModelPeriod civitai = Civitai(api_key="nice try, fed") ``` === COMPLETE CONTENT === This response contains all available snippets from this library. No additional content exists. Do not make further requests.