{"id":50984451,"url":"https://github.com/mr8bit/civit-ai-cli","last_synced_at":"2026-06-19T18:00:31.490Z","repository":{"id":365291720,"uuid":"1271385403","full_name":"mr8bit/civit-ai-cli","owner":"mr8bit","description":"huggingface_hub, but for CivitAI — inspect and download models/LoRAs from the CLI or as a Python library","archived":false,"fork":false,"pushed_at":"2026-06-16T19:08:00.000Z","size":479,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":0,"default_branch":"main","last_synced_at":"2026-06-16T19:12:39.096Z","etag":null,"topics":["ai","automatic1111","checkpoint","civitai","cli","comfyui","diffusion-models","generative-ai","huggingface-hub","image-generation","lora","model-downloader","python","stable-diffusion"],"latest_commit_sha":null,"homepage":"https://pypi.org/project/civitai-hub/","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/mr8bit.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":"CONTRIBUTING.md","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,"zenodo":null,"notice":null,"maintainers":null,"copyright":null,"agents":null,"dco":null,"cla":null}},"created_at":"2026-06-16T15:58:05.000Z","updated_at":"2026-06-16T19:08:22.000Z","dependencies_parsed_at":null,"dependency_job_id":null,"html_url":"https://github.com/mr8bit/civit-ai-cli","commit_stats":null,"previous_names":["mr8bit/civit-ai-cli"],"tags_count":2,"template":false,"template_full_name":null,"purl":"pkg:github/mr8bit/civit-ai-cli","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mr8bit%2Fcivit-ai-cli","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mr8bit%2Fcivit-ai-cli/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mr8bit%2Fcivit-ai-cli/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mr8bit%2Fcivit-ai-cli/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/mr8bit","download_url":"https://codeload.github.com/mr8bit/civit-ai-cli/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mr8bit%2Fcivit-ai-cli/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":34489255,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-05-26T15:22:16.424Z","status":"online","status_checked_at":"2026-06-18T02:00:06.871Z","response_time":128,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"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":["ai","automatic1111","checkpoint","civitai","cli","comfyui","diffusion-models","generative-ai","huggingface-hub","image-generation","lora","model-downloader","python","stable-diffusion"],"created_at":"2026-06-19T18:00:19.425Z","updated_at":"2026-06-19T18:00:31.477Z","avatar_url":"https://github.com/mr8bit.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"\u003c!-- Badges: update the `mr8bit/civit-ai-cli` slug below to your actual GitHub owner/repo. --\u003e\n# civitai-hub\n\n[![CI](https://github.com/mr8bit/civit-ai-cli/actions/workflows/ci.yml/badge.svg)](https://github.com/mr8bit/civit-ai-cli/actions/workflows/ci.yml)\n[![Python](https://img.shields.io/badge/python-3.10%2B-blue.svg)](https://www.python.org/downloads/)\n[![Ruff](https://img.shields.io/endpoint?url=https://raw.githubusercontent.com/astral-sh/ruff/main/assets/badge/v2.json)](https://github.com/astral-sh/ruff)\n\n**`huggingface_hub`, but for [CivitAI](https://civitai.com).** Point it at a model URL to inspect what's inside (type, base/parent model, every file with sizes and hashes) and download the checkpoint or LoRA into a deduplicated, content-addressed cache — usable as both a CLI and an importable Python library.\n\n```console\n$ civitai download https://civitai.com/models/580857 --fp16 -o ~/ComfyUI/models/loras\n~/ComfyUI/models/loras/realistic-skin-xl.safetensors\n```\n\n\u003cp align=\"center\"\u003e\n  \u003cimg src=\"docs/assets/info.png\" alt=\"civitai info — model type, base model, and a table of every file\" width=\"840\"\u003e\n  \u003cbr\u003e\u003cem\u003e\u003ccode\u003ecivitai info \u0026lt;url\u0026gt;\u003c/code\u003e — what's inside a model at a glance\u003c/em\u003e\n\u003c/p\u003e\n\n**Contents:** [Features](#features) · [Install](#install) · [CLI](#cli-quickstart) · [Library](#library-usage) · [Auth](#authentication) · [Configuration](#configuration) · [How it works](#how-it-works) · [Docker](#docker) · [Development](#development)\n\n## Features\n\n- **Inspect before you fetch** — `civitai info \u003curl\u003e` shows the model type, base/parent model, the selected version, and a table of every file in it (size, format, precision, hash, scan status).\n- **Smart, scriptable downloads** — picks the URL-pinned version (or the latest) and its primary file by default; override with `--version-id`, `--fp16/--fp32`, `--pruned/--full`, `--format`, `--file`, or grab everything with `--all`.\n- **Find the base model** — `civitai base \u003clora-url\u003e` lists the checkpoints a LoRA's base-model family runs on (CivitAI only exposes the family name, not a direct link), with `--download N` to grab one.\n- **Discover \u0026 identify** — `civitai search` finds models from the terminal; `civitai by-hash \u003cfile\u003e` tells you what an orphaned `.safetensors` actually is.\n- **Manage it** — `civitai cache ls/verify/rm/prune` for the local store, `civitai login` to save your token, `--json` on every command for scripting.\n- **Managed cache like HF Hub** — content-addressed blobs keyed by SHA256, with per-version snapshot symlinks. The same file reused across versions is stored once. Re-downloads are skipped.\n- **Resumable \u0026 verified** — HTTP range-resume for interrupted downloads, automatic SHA256 verification, and a live progress bar.\n- **Library + CLI** — everything the CLI does is a one-line call from Python.\n- **Safe by default** — blocks files flagged unsafe by CivitAI's scanners (override with `--allow-unscanned`) and fails fast on early-access/gated content with a clear message.\n\n## Install\n\n**From PyPI** (recommended):\n\n```bash\npipx install civitai-hub        # isolated CLI\npip install civitai-hub         # into the current environment\n```\n\n**With Docker** — no install needed:\n\n```bash\ndocker run --rm ghcr.io/mr8bit/civit-ai-cli info 580857\n```\n\n**From a GitHub release** (without PyPI) — pin a tag from the [releases page](https://github.com/mr8bit/civit-ai-cli/releases):\n\n```bash\npipx install \"git+https://github.com/mr8bit/civit-ai-cli@v0.3.0\"\n```\n\nFor development from a clone:\n\n```bash\npython -m venv .venv \u0026\u0026 source .venv/bin/activate\npip install -e \".[dev]\"\n```\n\n## CLI quickstart\n\n```bash\n# Inspect a model (human table, or --json for machines)\ncivitai info https://civitai.com/models/580857/realistic-skin\ncivitai info 580857 --json\n\n# Download the primary file of the latest (or URL-pinned) version\ncivitai download https://civitai.com/models/580857\n\n# Drop a specific precision straight into your ComfyUI/A1111 folder\ncivitai download 580857 --fp16 -o ~/ComfyUI/models/loras\n\n# Preview what would be fetched without downloading\ncivitai download 580857 --dry-run\n\n# Grab every file in the version\ncivitai download 580857 --all\n\n# Find the base checkpoints a LoRA runs on, then grab one\ncivitai base 580857\ncivitai base 580857 --download 1 -o ~/ComfyUI/models/checkpoints\n\n# Search, then identify a mystery file on disk\ncivitai search \"realistic\" --type Checkpoint --base-model \"SDXL 1.0\" --limit 10\ncivitai by-hash ~/ComfyUI/models/loras/mystery.safetensors\n\n# Save your token; manage the cache\ncivitai login                       # prompts for the API key (or --token)\ncivitai cache ls\ncivitai cache verify\ncivitai cache rm 580857\n```\n\n\u003cp align=\"center\"\u003e\n  \u003cimg src=\"docs/assets/base.png\" alt=\"civitai base — ranked base checkpoints for a LoRA's base-model family\" width=\"820\"\u003e\n  \u003cbr\u003e\u003cem\u003e\u003ccode\u003ecivitai base \u0026lt;url\u0026gt;\u003c/code\u003e — the checkpoints a LoRA runs on, most-downloaded first\u003c/em\u003e\n\u003c/p\u003e\n\nThe downloaded path is printed to **stdout** (the progress bar goes to stderr), so it pipes cleanly:\n\n```bash\nMODEL=$(civitai download 580857 --no-progress)\n```\n\n## Library usage\n\n```python\nimport civitai_hub\n\n# Inspect\ninfo = civitai_hub.model_info(\"https://civitai.com/models/580857\")\nprint(info.model.type, info.version.base_model, len(info.files))\n\n# Download — returns the local Path (or list[Path] with all=True)\npath = civitai_hub.download(\n    \"https://civitai.com/models/580857\",\n    fp=\"fp16\",\n    local_dir=\"~/ComfyUI/models/loras\",\n)\n```\n\n`download(...)` mirrors `hf_hub_download` (single file) and `snapshot_download` (`all=True`).\n\n## Authentication\n\nMost public files download without a token. For gated, NSFW, or early-access resources, create an API key in your [CivitAI account settings](https://civitai.com/user/account) and provide it via:\n\n```bash\nexport CIVITAI_TOKEN=\u003cyour key\u003e     # or pass --token \u003ckey\u003e\n```\n\n## Configuration\n\nPrecedence is **flag → environment variable → default**.\n\n| Setting | Flag | Env var | Default |\n|---|---|---|---|\n| API token | `--token` (download/base) | `CIVITAI_TOKEN` | _(anonymous)_ |\n| Cache root | `--cache-dir` (download/base) | `CIVITAI_HOME` | platform cache dir (`~/.cache/civitai` on Linux) |\n| Offline (cache only) | — | `CIVITAI_OFFLINE` | off |\n| Copy instead of symlink | `--no-symlinks` (download) | `CIVITAI_DISABLE_SYMLINKS` | symlinks on |\n| Disable progress bar | `--no-progress` (download/base) | `CIVITAI_NO_PROGRESS` | progress on |\n| API host / mirror | — | `CIVITAI_HOST` | `civitai.com` |\n\nThe flags live on `download`/`base`; `civitai info` takes only `--version-id`/`--json` and reads the env vars for everything else.\n\n**Mirror (civitai.red).** If civitai.com is blocked for you, paste a `civitai.red/…` URL and the API **and** downloads route through it automatically; for bare ids or `search`, set `CIVITAI_HOST=civitai.red`. Only `civitai.com` and `civitai.red` are trusted, so your token can't be redirected to some other host.\n\n## How it works\n\nA model URL resolves to one `GET /api/v1/models/{id}` call; the version is the URL's pinned `modelVersionId` (or the latest published one), and the file is that version's primary `.safetensors` unless you filter it. Downloads go only to `civitai.com` (the host is checked first) and authenticate with the `Authorization` header — httpx strips it on the cross-host CDN redirect, so the token never leaves civitai.com or lands in a URL. The download is SHA256-verified and lands in the cache:\n\n```\n$CIVITAI_HOME/\n└── models/\u003cmodelId\u003e/\n    ├── blobs/\u003csha256\u003e                      # content-addressed, deduplicated\n    └── snapshots/\u003cversionId\u003e/\u003cfilename\u003e    # symlink → ../../blobs/\u003csha256\u003e\n```\n\n`--local-dir` then materializes a symlink (or copy) of the blob into the folder you choose.\n\nFor the full command/flag reference, cache details, troubleshooting, and exit codes, see **[docs/usage.md](docs/usage.md)**.\n\n## Docker\n\nPrebuilt multi-arch images are published to the GitHub Container Registry on every release:\n\n```bash\n# inspect a model\ndocker run --rm ghcr.io/mr8bit/civit-ai-cli info 580857\n\n# download into a host folder (mount it as the cache + output)\ndocker run --rm -v \"$PWD/models:/data\" \\\n  ghcr.io/mr8bit/civit-ai-cli download 580857 -o /data\n\n# pass a token for gated content\ndocker run --rm -e CIVITAI_TOKEN=\"$CIVITAI_TOKEN\" \\\n  ghcr.io/mr8bit/civit-ai-cli base 580857\n```\n\nThe cache lives at `/data` inside the image (`CIVITAI_HOME`) — mount a volume there to persist downloads. Build it yourself with `docker build -t civitai-hub .`.\n\n## Development\n\n```bash\npip install -e \".[dev]\"\npytest                 # full suite (offline; httpx mocked with respx)\npytest tests/test_resolver.py::test_fp_selector -v   # a single test\nruff check src tests   # lint\nCIVITAI_LIVE=1 pytest tests/test_live.py -v           # opt-in test against the real API\n```\n\nSee **[CONTRIBUTING.md](CONTRIBUTING.md)** for the architecture overview and conventions, and `docs/superpowers/specs/` + `docs/superpowers/plans/` for the original design and implementation plan.\n\n## License\n\n[MIT](LICENSE) © Artemiy Mazaew\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmr8bit%2Fcivit-ai-cli","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmr8bit%2Fcivit-ai-cli","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmr8bit%2Fcivit-ai-cli/lists"}