{"id":27398253,"url":"https://github.com/ryanontheinside/civitai-api","last_synced_at":"2025-10-27T22:06:33.038Z","repository":{"id":247666277,"uuid":"826487845","full_name":"ryanontheinside/civitai-api","owner":"ryanontheinside","description":"A python wrapper for the civit rest api","archived":false,"fork":false,"pushed_at":"2024-07-22T14:15:39.000Z","size":15,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"main","last_synced_at":"2024-07-22T17:08:46.764Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/ryanontheinside.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2024-07-09T19:57:56.000Z","updated_at":"2024-07-22T14:15:42.000Z","dependencies_parsed_at":"2024-07-16T00:04:37.592Z","dependency_job_id":null,"html_url":"https://github.com/ryanontheinside/civitai-api","commit_stats":null,"previous_names":["ryanontheinside/civitai-api"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ryanontheinside%2Fcivitai-api","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ryanontheinside%2Fcivitai-api/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ryanontheinside%2Fcivitai-api/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ryanontheinside%2Fcivitai-api/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/ryanontheinside","download_url":"https://codeload.github.com/ryanontheinside/civitai-api/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248807232,"owners_count":21164650,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2025-04-14T01:30:18.509Z","updated_at":"2025-10-27T22:06:28.021Z","avatar_url":"https://github.com/ryanontheinside.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"\n# Civitai API Wrapper\n\nA Python wrapper for the Civitai REST API, providing easy access to models, images, creators, tags, and more.\n\n## Features\n\n- List and search models with various filters\n- Retrieve detailed information about specific models\n- List and search images waith various filters\n- List and search creators\n- List and search tags\n- Retrieve specific model versions\n\n## Installation\n\nClone this repo and install the required dependencies using `pip`:\n\n```bash\npip install -r requirements.txt\n```\n\n## Usage\n\n### Initialization\n\nImport what you need and initialize the `Civitai` client with your API key:\n\n```python\nfrom civitai_api import Civitai\nfrom civitai_api.models import BaseModel, ModelType\nfrom civitai_api.api.models import ModelSort, ModelPeriod\n\ncivitai = Civitai(api_key=\"nice try, fed\")\n```\n\n### Listing Models\n\nList models with various filters:\n\n```python\n#get top 5 loras created by RalFinger this year for sd15 with 'style' in the name\nmodels = civitai.models.list_models(\n        types=[ModelType.LORA],\n        sort=ModelSort.HIGHEST_RATED,\n        username='RalFinger',\n        base_models=[BaseModel.SD_1_5, BaseModel.SD_1_5_LCM],\n        query='style',\n        page=1,\n        period=ModelPeriod.YEAR,\n        limit=5\n    )\n\nprint(\"models:\")\nfor model in models:\n    print(model.name)\n```\n\n\n### Getting Model Details\n\nRetrieve detailed information about a specific model:\n\n```python\nmodel = civitai.models.get_model(model_id=1102)\nprint(model.nsfw)\n```\n\n### Getting Images, Creators, ModelVersions, Tags\n\nRetrieve information about images\n\n```python\n#get 4 images related to model 1102\nimages = civitai.images.list_images(model_id=1102, limit=4)\nprint(\"images:\")\nfor image in images:\n    print(image.url)\n\n#get a model version\nversion = civitai.model_versions.get_model_version(version_id=1302)\nprint(version.name)\n\n#query creators\ncreators = civitai.creators.list_creators(query='RalFinger')\nfor creator in creators:\n    print(creator.modelCount)\n\n#query tags\ntags = civitai.tags.list_tags(query='celebrity')\nfor tag in tags:\n    print(tag.name, tag.modelCount)\n```\n## License\n\nThis project is licensed under the MIT License. See the [LICENSE](LICENSE) file for details.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fryanontheinside%2Fcivitai-api","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fryanontheinside%2Fcivitai-api","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fryanontheinside%2Fcivitai-api/lists"}