Metadata-Version: 2.3
Name: py-civitai-api
Version: 0.1.0
Summary: Unofficial Python client for the CivitAI API (sync + async)
Keywords: civitai,api,sdk,stable-diffusion,ai,image-generation
License: MIT
Classifier: Intended Audience :: Developers
Classifier: License :: OSI Approved :: MIT License
Classifier: Programming Language :: Python :: 3.12
Classifier: Typing :: Typed
Requires-Dist: httpx>=0.28
Requires-Dist: pydantic>=2.13
Requires-Dist: typing-extensions>=4.15
Requires-Dist: typer>=0.26.7 ; extra == 'cli'
Requires-Dist: rich>=15 ; extra == 'cli'
Requires-Dist: jmespath>=1.1 ; extra == 'cli'
Requires-Dist: pytest>=9 ; extra == 'dev'
Requires-Dist: pytest-asyncio>=1.4 ; extra == 'dev'
Requires-Dist: pytest-cov>=7.1.0 ; extra == 'dev'
Requires-Dist: respx>=0.23 ; extra == 'dev'
Requires-Dist: ruff>=0.15.15 ; extra == 'dev'
Requires-Dist: poethepoet>=0.46 ; extra == 'dev'
Requires-Dist: mypy>=2.1.0 ; extra == 'dev'
Requires-Dist: types-jmespath>=1.1 ; extra == 'dev'
Requires-Dist: typer>=0.26.7 ; extra == 'dev'
Requires-Dist: jmespath>=1.1 ; extra == 'dev'
Requires-Dist: sphinx>=8 ; extra == 'docs'
Requires-Dist: furo>=2024 ; extra == 'docs'
Requires-Dist: myst-parser>=4 ; extra == 'docs'
Requires-Python: >=3.12
Project-URL: Homepage, https://github.com/mcriley821/civitai-api
Project-URL: Repository, https://github.com/mcriley821/civitai-api
Project-URL: Bug Tracker, https://github.com/mcriley821/civitai-api/issues
Provides-Extra: cli
Provides-Extra: dev
Provides-Extra: docs
Description-Content-Type: text/markdown

# civitai-api

[![build](https://github.com/mcriley821/civitai-api/actions/workflows/ci.yml/badge.svg)](https://github.com/mcriley821/civitai-api/actions/workflows/ci.yml)

[![codecov](https://codecov.io/gh/mcriley821/civitai-api/graph/badge.svg?token=FKOX46HFKF)](https://codecov.io/gh/mcriley821/civitai-api)

Unofficial Python client for the [CivitAI API](https://developer.civitai.com/site/) — sync and async.

## Install

```bash
pip install py-civitai-api

# with CLI
pip install "py-civitai-api[cli]"
```

## Quick start

```python
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

```python
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

```bash
civitai auth login
civitai models list --query dreamshaper --limit 5
civitai models get 12345
civitai images list --model-id 12345
```

## Development

```bash
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](https://claude.ai), Anthropic). All code is reviewed by the author.
Not affiliated with or endorsed by CivitAI.
