civitai-api
Unofficial Python client for the CivitAI API — sync and async.
Install
pip install py-civitai-api
# with CLI
pip install "py-civitai-api[cli]"
Quick start
from civitai_api import CivitAI
# api key or CIVITAI_API_KEY env var
with CivitAI(api_key="...") as client:
for model in client.models.list(query="dreamshaper", limit=5).auto_paging_iter():
print(model.name, model.id)
Async
import asyncio
from civitai_api import AsyncCivitAI
async def main():
async with AsyncCivitAI() as client:
version = await client.model_versions.retrieve(12345)
print(version.name)
asyncio.run(main())
CLI
civitai auth login
civitai models list --query dreamshaper --limit 5
civitai models get 12345
civitai images list --model-id 12345
Development
git clone https://github.com/mcriley821/civitai-api
cd civitai-api
uv sync --extra dev
uv run poe install-hooks # install pre-commit hook (runs lint + typecheck + test)
uv run poe check # lint + typecheck + test
Note
Built with AI assistance (Claude, Anthropic). All code is reviewed by the author. Not affiliated with or endorsed by CivitAI.
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
py_civitai_api-0.1.0.tar.gz
(22.6 kB
view details)
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file py_civitai_api-0.1.0.tar.gz.
File metadata
- Download URL: py_civitai_api-0.1.0.tar.gz
- Upload date:
- Size: 22.6 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: uv/0.11.19 {"installer":{"name":"uv","version":"0.11.19","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
d362c7f11b851ab278014e807c71a7f87eaf3c89f0b74d4234fb31d1de7b4d6b
|
|
| MD5 |
621433d26fb41c188a0659ded8662e7e
|
|
| BLAKE2b-256 |
f18a6b291aab36483062bb13831a21514cf651e5588c2aa254f83ab67708a825
|
File details
Details for the file py_civitai_api-0.1.0-py3-none-any.whl.
File metadata
- Download URL: py_civitai_api-0.1.0-py3-none-any.whl
- Upload date:
- Size: 35.0 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: uv/0.11.19 {"installer":{"name":"uv","version":"0.11.19","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
4fa0d25d3ac3ba9fd62c2b7f0b9569d7be283c174bd629931a905fdcb1554a9d
|
|
| MD5 |
659a2a15806a372befb0fae32e1756fd
|
|
| BLAKE2b-256 |
7151e1b4735746b4b42e534bd79ab47ab1ac45c1d434bd3934e3746db4572d44
|