# AbstractVision — llms-full

> Single-file, agent-oriented context bundle generated from this repository’s docs and metadata.

How to use:
- If you only need a map of where to look, use `llms.txt`.
- If you need an all-in-one context bundle (for offline models or constrained retrieval), use this file.

Notes:
- This is a **convention** (many projects publish an `llms-full.txt`). It is not part of the core `llms.txt` spec.
- Relative links inside each file section are authored for that file’s original location. Use the `FILE: …` marker to interpret link paths.
- If you change docs or packaging metadata, regenerate this file by running:
  - `python scripts/generate_llms_full.py`

Included files:
- `llms.txt`
- `README.md`
- `docs/README.md`
- `docs/getting-started.md`
- `docs/mlx-gen-local-examples.md`
- `docs/api.md`
- `docs/architecture.md`
- `docs/faq.md`
- `docs/troubleshooting.md`
- `docs/reference/backends.md`
- `docs/reference/configuration.md`
- `docs/reference/capabilities-registry.md`
- `docs/adr/README.md`
- `docs/adr/0005_curated_capability_registry_and_download_catalog.md`
- `docs/adr/0006_operator_control_configuration_precedence_and_explicit_network_use.md`
- `docs/reference/artifacts.md`
- `docs/reference/abstractcore-integration.md`
- `playground/README.md`
- `CONTRIBUTING.md`
- `SECURITY.md`
- `ACKNOWLEDGMENTS.md`
- `CHANGELOG.md`
- `pyproject.toml`

--- 8< --- FILE: llms.txt --- 8< ---
# AbstractVision

> Model-agnostic generative vision API (images, optional video) with packaged model/adapter capability registries, artifact-ref outputs, and backends for OpenAI-compatible HTTP, Diffusers, stable-diffusion.cpp, and MLX-Gen.

This repository’s current source of truth is the code under `src/abstractvision/` (docs in `docs/`).

Format note: this file follows the `llms.txt` Markdown spec (H1 + optional summary/details + H2 “file list” sections; the `## Optional` section can be skipped when you need a shorter context). Spec: https://llmstxt.org/#format

Maintenance tips:
- Keep link descriptions concise and unambiguous; avoid unexplained jargon.
- Regenerate `llms-full.txt` after doc/packaging changes: `python scripts/generate_llms_full.py`.

Agent quickstart (choose the path that matches your goal):
- **Install in one line**: `curl -LsSf https://abstractframework.ai/vision/install.sh | sh` (macOS/Linux) or `powershell -ExecutionPolicy ByPass -c "irm https://abstractframework.ai/vision/install.ps1 | iex"` (Windows), or `pip install "abstractvision[apple]"` / `"abstractvision[gpu]"`; the script detects the platform (Apple Silicon -> apple, NVIDIA/ROCm -> gpu, else light) and installs an isolated user tool; see `docs/getting-started.md#one-line-install`. On Linux with an NVIDIA card the Diffusers backend runs in float16 (bfloat16 only on Ampere or newer); on a processor-only Linux host install `torch torchvision` from the CPU index first.
- **Use the library (Python / CLI)**: start with `README.md` → `docs/getting-started.md` → `docs/api.md` → `docs/reference/backends.md`; shell commands are `abstractvision t2i` / `abstractvision i2i` / `abstractvision upscale` / `abstractvision t2v` / `abstractvision i2v`, and the interactive path is `abstractvision cli` (legacy alias `abstractvision repl`) with `/t2i` / `/i2i` / `/t2v` / `/i2v`.
- **Integrate with AbstractCore/Runtime**: read `docs/reference/abstractcore-integration.md` and `docs/reference/artifacts.md` (includes local model residency control for in-process backends).
- **Inspect provider model catalogs**: use `abstractvision provider-models`, `VisionManager.list_provider_models(...)`, or `llm.vision.list_provider_models(...)`; catalog listing is explicit and does not select the active model.
- **Inspect local model/task metadata**: use `abstractvision catalog`, `abstractvision show-model`, or `GET /v1/vision/models`; runtime-backed local surfaces only expose tasks that the selected backend currently enables.
- **Need the model/adapter curation policy**: read `docs/reference/capabilities-registry.md`, `docs/adr/0005_curated_capability_registry_and_download_catalog.md`, and `docs/adr/0006_operator_control_configuration_precedence_and_explicit_network_use.md`.
- **Need a single file**: open `llms-full.txt` (generated bundle of the core docs).
- **Need local Diffusers**: install `abstractvision[diffusers]`, set `ABSTRACTVISION_BACKEND=diffusers`, pre-download `runwayml/stable-diffusion-v1-5`, or set `ABSTRACTVISION_DIFFUSERS_ALLOW_DOWNLOAD=1`.
- **Need local MLX-Gen**: install `abstractvision[mlx-gen]`. MLX-Gen is validated on Apple Silicon; the extra also installs on Linux, where it is not validated yet, and the NVIDIA/Linux `gpu` / `all-gpu` profiles do not include it. Choose exact published model ids such as `AbstractFramework/qwen-image-2512-4bit` for `t2i`, `AbstractFramework/qwen-image-edit-2511-4bit` or `briaai/Fibo-Edit` for `i2i`, `AbstractFramework/seedvr2-3b-8bit` / `AbstractFramework/seedvr2-7b-8bit` for SeedVR2 `upscale`, and `AbstractFramework/wan2.2-t2v-a14b-diffusers-8bit` / `AbstractFramework/wan2.2-i2v-a14b-diffusers-8bit` for Wan A14B `t2v`/`i2v`; use typed `guidance_2` / CLI `--guidance-2` for the A14B second-stage guidance control, and `mask` for validated Qwen/FIBO/FLUX.2 klein/Z-Image Turbo masked-edit routes (`control_image` / `--control-image` runs on `AbstractFramework/qwen-image-8bit` only); pre-download with `abstractvision download ... --provider mlx-gen`.
- **Need LoRA adapters**: prefer the shared typed contract `lora_adapters=[LoRAAdapterSpec(...)]` in Python and repeated `--lora` / `--lora-scale` / `--lora-target-role` flags in the CLI. Use provider/model discovery to inspect `supports_lora`, `lora_status`, `lora_target_roles`, and `lora_validation_profile` before long runs.

Reality checks (current shipped behavior, anchored in code):
- Built-in backends implement `text_to_image`, `image_to_image`, `image_upscale`, and backend-dependent `text_to_video` / `image_to_video`.
- Local MLX-Gen supports curated q4/q8 image presets, official FIBO image snapshots, FLUX.2/Qwen multi-reference image edits, latent image-to-image, outpaint and reframe, Qwen/FIBO/FLUX.2 klein/Z-Image Turbo masked edits, a structured control image on `AbstractFramework/qwen-image-8bit` only, canonical SeedVR2 q8/q4 image upscaling packages and SeedVR2 video restoration (`video_upscale`), shared LoRA adapters, and Wan 2.2 TI2V plus task-specific Wan 2.2 A14B `text_to_video` / first-frame `image_to_video`, with `video_to_video` on Wan 2.2 T2V-A14B and Wan 2.1 VACE 1.3B.
- Wan video defaults live in one per-model table (`WAN_VIDEO_DEFAULT_CANVASES` in `backends/mflux.py`): 832x480 for TI2V-5B (121 frames, 24 fps, 50 steps) and the A14B models (81 frames, 16 fps, 40 steps); explicit `width`/`height`/`num_frames`/`fps`/`steps` override them. The VAE decode is tiled by default (`extra={"vae_tiling": False}` / `--no-vae-tiling` to disable); measured memory per size is in `docs/faq.md`.
- Every generation request takes `memory_mode` (`default`, `low`, `lowest`; CLI `--memory-mode`; AbstractCore keyword or `extra`; process default `ABSTRACTVISION_MEMORY_MODE`, which degrades to the closest mode a backend can honour, while a request value is refused; `make_vision_tools(..., memory_mode=...)` fixes it for all tool calls). MLX-Gen: `low` = its low-RAM mode per route, `lowest` = low-RAM plus block streaming, accepted where routes stream transformer blocks: MiniMax-H3, and no other current catalog model. Diffusers on CUDA: `low`/`lowest` = model/sequential CPU offload (the request only raises the configured `cpu_offload`). stable-diffusion.cpp: `low` = CPU offload of parameters. OpenAI-compatible: the modes the remote lists for the model in `GET /vision/models` (AbstractCore's server), sent with `quantize` and the soundtrack fields; `default` only for a plain OpenAI endpoint. Every backend refuses a mode it cannot honour with `CapabilityNotSupportedError`, also when called directly. Discovery: `get_capabilities().memory_modes`, MLX-Gen catalog `parameter_constraints["memory_mode"]` (also over HTTP), plugin `available_providers()` details (also read by AbstractCore's server).
- MiniMax-H3 (`MiniMaxAI/MiniMax-H3`, packages `AbstractFramework/minimax-h3-8bit|bf16|4bit`, gated, territorial licence, never downloaded during generation; `abstractvision download MiniMaxAI/MiniMax-H3 [--bits 4|16] [--base-model minimax-h3-turbo-544p]` fetches the recommended 8-bit package, or the width named, and the Turbo adapter of that schedule; `--allow-non-8bit` fetches the source repository itself): video with a stereo soundtrack through MLX-Gen; `base_model` picks the schedule (`minimax-h3-turbo-544p`, `minimax-h3-turbo`, `minimax-h3`); typed `soundscape`, `music`, `generate_audio`, `audio_shift` (and `flow_shift` as the video shift); frame grid and defaults from MLX-Gen's capability row; result MP4 with AAC plus `GeneratedAsset.audio`; `memory_mode` low = 1 GB cache + transformer release, lowest = block streaming.
- Downloads and listings: `download` selects one package (the host's target order picks the target; there, a single package is selected, several select the recommended one or stop listing them whatever flags narrowed them, and `--allow-non-8bit` with a repository named exactly selects that repository) and plans from the Hub listings before it writes anything, for every repository it fetches from (the package, a stable-diffusion.cpp bundle's companions, a `--base-model` schedule's adapter): files complete in the cache, files to fetch and their size, one total, and whether they fit on the cache disk (the files to fetch at full size, less what their partial `.incomplete` files hold). It fetches only the files to fetch, from the commit the listing named, and names the page and licence when a gated repository refuses; `--dry-run` prints the same plan. Cache states are `cached`, `incomplete` or `absent`. `catalog`, `show-model` and `models --json` show per download its access (gated/open, from the catalog), its cache state from an offline local look with size on disk, the memory modes this host can run and, for MLX-Gen packages with published measurements, the peak memory per mode and the smallest memory it was tested on (read from mlx-gen at run time).
- Host contract: `cancel_event` on every request (`GenerationCancelledError`, between steps on MLX-Gen), typed load-time `quantize` (`get_capabilities().quantize_bits`), `VisionManager.describe_routes()` for MLX-Gen's schema-17 rows as JSON, engine metadata under `metadata["mlx_gen"]`, progress-callback errors logged without stopping the run.
- Task-specific Wan A14B video declares typed `guidance_2` defaults in `vision_model_capabilities.json` (`3.0` for T2V, `3.5` for I2V); it is not transported through backend `extra`.
- MLX-Gen progress is surfaced through Python/Core `on_progress(event)` callbacks, opt-in one-shot image generation/edit CLI `--progress`, and denoise-step video/upscale progress by default.
- Local Diffusers `text_to_video` remains experimental and is temporarily disabled from the normal local surfaces.
- OpenAI-compatible HTTP can also provide `text_to_video` / `image_to_video` when video endpoints are configured.
- `multi_view_image` exists in the API but no built-in backend implements it yet.
- Provider `/models` catalogs can be listed explicitly, including through the AbstractCore plugin boundary; they are not used for automatic model selection.
- Backend normalization is shared across `VisionManager`, the playground API, and the AbstractCore plugin, so model-specific parameter constraints are enforced once in the backend layer instead of separately in each UI.
- Image dimensions are provider/model-specific. `width`/`height` are optional request overrides; omit them to let the backend use its default or `auto` behavior, and do not assume `512x512` is universally accepted.

## Documentation

- [llms-full.txt](llms-full.txt): single-file bundle of the core docs (for agent ingestion)
- [README.md](README.md): overview, install, quickstart
- [docs/README.md](docs/README.md): docs index (map)
- [docs/getting-started.md](docs/getting-started.md): first image (OpenAI-compatible HTTP / Diffusers / sdcpp) + Playground
- [docs/mlx-gen-local-examples.md](docs/mlx-gen-local-examples.md): current MLX-Gen LoRA route proofs, exact commands, progress logs, and generated outputs
- [docs/troubleshooting.md](docs/troubleshooting.md): symptom-oriented setup/runtime fixes for local backends, playground, and integration issues
- [docs/api.md](docs/api.md): public Python API surface
- [docs/architecture.md](docs/architecture.md): how components fit together (with diagrams)
- [docs/faq.md](docs/faq.md): common questions + troubleshooting
- [docs/reference/backends.md](docs/reference/backends.md): backend support matrix + config notes
- [docs/reference/configuration.md](docs/reference/configuration.md): CLI/REPL commands + `ABSTRACTVISION_*` env vars
- [docs/reference/capabilities-registry.md](docs/reference/capabilities-registry.md): capability registry format + usage
- [docs/adr/README.md](docs/adr/README.md): ADR index for durable engineering policy
- [docs/adr/0005_curated_capability_registry_and_download_catalog.md](docs/adr/0005_curated_capability_registry_and_download_catalog.md): packaged capability registry and cache-backed model catalog policy
- [docs/adr/0006_operator_control_configuration_precedence_and_explicit_network_use.md](docs/adr/0006_operator_control_configuration_precedence_and_explicit_network_use.md): explicit runtime selection, cache-only defaults, and network-use policy
- [docs/reference/artifacts.md](docs/reference/artifacts.md): artifact refs + stores
- [docs/reference/abstractcore-integration.md](docs/reference/abstractcore-integration.md): AbstractCore plugin + tool helpers
- [playground/README.md](playground/README.md): self-contained local web UI/API served by `abstractvision playground`
- [CONTRIBUTING.md](CONTRIBUTING.md): dev setup + tests + contribution guidelines
- [SECURITY.md](SECURITY.md): responsible vulnerability reporting
- [ACKNOWLEDGMENTS.md](ACKNOWLEDGMENTS.md): upstream libraries/projects

## AbstractFramework ecosystem

- [AbstractFramework](https://github.com/lpalbou/AbstractFramework): ecosystem hub (how components fit together)
- [AbstractCore](https://github.com/lpalbou/abstractcore): orchestration + tool calling (AbstractVision integrates via plugin/tools)
- [AbstractRuntime](https://github.com/lpalbou/abstractruntime): runtime services (artifact store integration via adapter)

## Code entry points

- [src/abstractvision/vision_manager.py](src/abstractvision/vision_manager.py): `VisionManager` orchestrator API
- [src/abstractvision/types.py](src/abstractvision/types.py): request/response dataclasses (`ImageGenerationRequest`, `ImageUpscaleRequest`, `GeneratedAsset`, …)
- [src/abstractvision/errors.py](src/abstractvision/errors.py): error types (`CapabilityNotSupportedError`, …)
- [src/abstractvision/backends/base_backend.py](src/abstractvision/backends/base_backend.py): `VisionBackend` contract
- [src/abstractvision/backends/__init__.py](src/abstractvision/backends/__init__.py): lazy imports (keeps `import abstractvision` import-light)
- [src/abstractvision/backends/openai_compatible.py](src/abstractvision/backends/openai_compatible.py): OpenAI-compatible HTTP backend (+ optional video)
- [src/abstractvision/backends/huggingface_diffusers.py](src/abstractvision/backends/huggingface_diffusers.py): local Diffusers backend (local images; experimental local video groundwork)
- [src/abstractvision/backends/stable_diffusion_cpp.py](src/abstractvision/backends/stable_diffusion_cpp.py): stable-diffusion.cpp backend (GGUF via `sd-cli` or python bindings)
- [src/abstractvision/adapter_capabilities.py](src/abstractvision/adapter_capabilities.py): adapter capability registry loader + validator
- [src/abstractvision/model_capabilities.py](src/abstractvision/model_capabilities.py): capability registry loader + validator
- [src/abstractvision/lora_adapters.py](src/abstractvision/lora_adapters.py): shared LoRA parsing, matching, and backend handle helpers
- [src/abstractvision/artifacts.py](src/abstractvision/artifacts.py): artifact refs + stores (`LocalAssetStore`, `RuntimeArtifactStoreAdapter`)
- [src/abstractvision/cli.py](src/abstractvision/cli.py): CLI/REPL (`abstractvision`)
- [src/abstractvision/playground_server.py](src/abstractvision/playground_server.py): self-contained playground server and `/v1/vision/*` jobs
- [src/abstractvision/playground/vision_playground.html](src/abstractvision/playground/vision_playground.html): packaged playground UI asset
- [src/abstractvision/integrations/abstractcore_plugin.py](src/abstractvision/integrations/abstractcore_plugin.py): AbstractCore capability plugin entry point and provider catalog shim
- [src/abstractvision/integrations/abstractcore.py](src/abstractvision/integrations/abstractcore.py): AbstractCore tool helpers (`make_vision_tools`)

## Testing

- [Test suite](tests/): run `python -m unittest discover -s tests -p "test_*.py" -q`
- [Changelog](CHANGELOG.md): release notes
- [pyproject.toml](pyproject.toml): dependencies/extras + entry points
- [scripts/generate_llms_full.py](scripts/generate_llms_full.py): regenerate `llms-full.txt`

## Optional

- [Engineering backlog](docs/backlog/README.md): internal design notes + completion reports
--- >8 --- END FILE: llms.txt --- >8 ---

--- 8< --- FILE: README.md --- 8< ---
# AbstractVision

[![PyPI version](https://img.shields.io/pypi/v/abstractvision.svg)](https://pypi.org/project/abstractvision/)
[![CI](https://github.com/lpalbou/AbstractVision/actions/workflows/ci.yml/badge.svg)](https://github.com/lpalbou/AbstractVision/actions/workflows/ci.yml)
[![Tested Python](https://img.shields.io/badge/dynamic/yaml?url=https%3A%2F%2Fraw.githubusercontent.com%2Flpalbou%2FAbstractVision%2Fmain%2F.github%2Fworkflows%2Fci.yml&query=%24.jobs%5B%22test-base%22%5D.strategy.matrix%5B%22python-version%22%5D&label=tested%20python&color=blue)](https://github.com/lpalbou/AbstractVision/actions/workflows/ci.yml)
[![license](https://img.shields.io/github/license/lpalbou/AbstractVision)](https://github.com/lpalbou/AbstractVision/blob/main/LICENSE)
[![GitHub stars](https://img.shields.io/github/stars/lpalbou/AbstractVision?style=social)](https://github.com/lpalbou/AbstractVision/stargazers)

Model-agnostic generative vision API (images, optional video) for Python and the Abstract* ecosystem.

## What you get

- A small orchestration API: [`VisionManager`](src/abstractvision/vision_manager.py)
- Packaged capability registries for model families and adapter defaults:
  [`VisionModelCapabilitiesRegistry`](src/abstractvision/model_capabilities.py)
  backed by [`vision_model_capabilities.json`](src/abstractvision/assets/vision_model_capabilities.json),
  plus [`VisionAdapterCapabilitiesRegistry`](src/abstractvision/adapter_capabilities.py)
  backed by [`vision_adapter_capabilities.json`](src/abstractvision/assets/vision_adapter_capabilities.json)
- Shared model and adapter metadata that drives local catalog surfacing and backend request normalization across the CLI, playground, and AbstractCore paths
- Optional artifact-ref outputs (small JSON refs): [`LocalAssetStore`](src/abstractvision/artifacts.py) and [`RuntimeArtifactStoreAdapter`](src/abstractvision/artifacts.py)
- Built-in backends (execution engines): [`src/abstractvision/backends/`](src/abstractvision/backends/)
  - OpenAI-compatible HTTP: [`openai_compatible.py`](src/abstractvision/backends/openai_compatible.py)
  - Local Diffusers: [`huggingface_diffusers.py`](src/abstractvision/backends/huggingface_diffusers.py)
  - Local stable-diffusion.cpp / GGUF: [`stable_diffusion_cpp.py`](src/abstractvision/backends/stable_diffusion_cpp.py)
  - Local MLX-Gen backend for curated AbstractFramework MLX presets and Wan video: [`mflux.py`](src/abstractvision/backends/mflux.py)
- CLI for manual testing (`abstractvision cli`, legacy alias: `abstractvision repl`): [`abstractvision`](src/abstractvision/cli.py)
- Self-contained local Playground UI/API: [`playground/vision_playground.html`](playground/vision_playground.html) (docs: [`playground/README.md`](playground/README.md))

## How it fits together (diagram)

```mermaid
flowchart LR
  Caller[Python / CLI / AbstractCore] --> VM[VisionManager]
  VM --> BE[VisionBackend]
  BE --> VM
  VM -->|optional| Store[MediaStore]
  Store --> Ref[Artifact ref dict]
  VM -->|no store| Asset["GeneratedAsset (bytes + mime)"]
```

## Status (current backend support)

- Development status: **Alpha** (0.x). The public API is stable-by-design, but breaking changes may still happen and will be called out in `CHANGELOG.md`.
- What's new in 0.3.38: MLX-Gen latent, masked, multi-reference, outpaint and reframe edits, video-to-video on Wan, and SeedVR2 video restoration; it requires `mlx-gen>=0.40.3,<0.41.0`. See [CHANGELOG.md](CHANGELOG.md#0338---2026-11-27).
- Checked on Linux without a GPU, Linux with an NVIDIA card and Apple silicon; the measured generation times per model are in [docs/benchmark.md](docs/benchmark.md).
- Built-in backends implement images (`text_to_image`, `image_to_image`) plus backend-dependent video (`text_to_video`, `image_to_video`).
- Local MLX-Gen supports `text_to_image` for curated FLUX.2, Qwen Image, Z-Image, ERNIE Image Turbo, FIBO, and Bonsai ternary models; supports `image_to_image` for FLUX.2 klein/base, base Qwen Image, Z-Image, Qwen Image Edit, ERNIE Image Turbo, FIBO, and FIBO Edit models; supports Wan 2.2 TI2V plus task-specific Wan 2.2 A14B packages for local `text_to_video` and first-frame `image_to_video`, and `video_to_video` on Wan 2.2 T2V-A14B and Wan 2.1 VACE 1.3B; supports SeedVR2 video restoration (`video_upscale`, see [docs/api.md](docs/api.md#video-restoration-video_upscale)); and supports MiniMax-H3, video with a synchronized stereo soundtrack (`text_to_video` and first-frame `image_to_video`, with `soundscape` / `music`), from the gated `AbstractFramework/minimax-h3-*` packages. See [docs/api.md](docs/api.md#video-with-sound-minimax-h3).
- Local MLX-Gen `0.40.3+` exposes route-aware masked edit on validated Qwen 2511 edit routes, FLUX.2 klein and Z-Image Turbo through `mask`. It runs structured control (`control_image`) on `AbstractFramework/qwen-image-8bit` only, with the ControlNet side weights in the cache; any other model raises `CapabilityNotSupportedError` (`field="control_image"`).
- Local MLX-Gen exposes a shared `lora_adapters` contract across `text_to_image`, `image_to_image`, `text_to_video`, and `image_to_video`. Route-level LoRA truth stays backend-owned and is surfaced through provider catalogs as `supports_lora`, `lora_status`, `lora_target_roles`, and `lora_validation_profile`.
- Local Diffusers `text_to_video` remains experimental and is temporarily disabled from the normal local runtime surfaces pending [`docs/backlog/planned/0023_local_runtime_capability_quarantine_for_glm_mflux_and_t2v.md`](docs/backlog/planned/0023_local_runtime_capability_quarantine_for_glm_mflux_and_t2v.md).
- Remote `text_to_video` / `image_to_video` are also supported through the OpenAI-compatible backend **when** endpoints are configured.
- `multi_view_image` is part of the public API (`VisionManager.generate_angles`) but no built-in backend implements it yet.

Details: [`docs/reference/backends.md`](docs/reference/backends.md).

## Installation

One line, no admin rights, no Python needed beforehand:

```bash
# macOS / Linux
curl -LsSf https://abstractframework.ai/vision/install.sh | sh
```

```powershell
# Windows
powershell -ExecutionPolicy ByPass -c "irm https://abstractframework.ai/vision/install.ps1 | iex"
```

It installs AbstractVision alone as a uv tool (the `abstractvision` command, Python 3.12
through uv) and picks the profile for the machine: `apple` (Apple Silicon, macOS 14+: MLX-Gen
and Diffusers), `gpu` (NVIDIA or ROCm: Diffusers on PyTorch) or `light` (the CLI and the
OpenAI-compatible backend; no local generation). On Linux without a GPU,
`curl -LsSf https://abstractframework.ai/vision/install.sh | sh -s -- --profile gpu` generates
locally on the processor. Prebuilt wheels only: on Apple Silicon `stable-diffusion-cpp-python` is
left out (PyPI has only its source build); GGUF models run through stable-diffusion.cpp's
`sd-cli`, which AbstractVision downloads itself at the first GGUF generation. Run the line again
to upgrade. Profiles, options and what is left out:
[One-line install](docs/getting-started.md#one-line-install).

Or with pip, in your own environment:

```bash
pip install abstractvision            # light: no dependency
pip install "abstractvision[apple]"   # Apple Silicon
pip install "abstractvision[gpu]"     # NVIDIA / Linux
```

The MLX-Gen extras (`mlx-gen`, `mflux`, `apple`, `all`, `all-apple`) install `mlx-gen>=0.40.3,<0.41.0` and,
on macOS, `mlx>=0.32.4`. Upgrade with the extra (`pip install -U "abstractvision[apple]"`): an upgrade without it
keeps the installed mlx-gen and MLX, and the MLX-Gen backend then refuses them at the first model load
([Troubleshooting](docs/troubleshooting.md#mlx-gen-refuses-the-installed-mlx-gen-or-mlx-version)).

The base install is lightweight. It includes the shared API, capability
registry, artifact helpers, CLI, AbstractCore plugin entry point, and the
stdlib OpenAI-compatible HTTP backend. Local inference runtimes are explicit
extras.

Optional extras:

| Extra | Use |
|---|---|
| `abstractvision[openai]` | Official OpenAI provider intent marker; no SDK dependency today. |
| `abstractvision[openai-compatible]` | Generic local/remote OpenAI-shaped endpoint intent marker; stdlib-only today. |
| `abstractvision[models]` | Curated Hugging Face download helpers for cache-backed local quantized vision model presets. |
| `abstractvision[diffusers]` | Install Torch/Diffusers and related packages for local Diffusers generation. |
| `abstractvision[huggingface]` | Compatibility alias for callers that still request the historical Diffusers extra. |
| `abstractvision[sdcpp]` | Install `stable-diffusion-cpp-python` for the pip binding fallback. |
| `abstractvision[mlx-gen]` | Install the optional MLX-Gen image/video runtime, validated on Apple Silicon. The extra also installs on Linux, where it is not validated yet (see [backlog 030](docs/backlog/planned/030_gpu_parity_with_mlx_gen.md)). |
| `abstractvision[mflux]` | Compatibility alias for the MLX-Gen runtime. |
| `abstractvision[local]` | Convenience for the Diffusers + `sdcpp` local runtime stack. Add `abstractvision[mlx-gen]` or use `abstractvision[all]` / `abstractvision[all-apple]` when you also want MLX-Gen. |
| `abstractvision[all]` | All runtime backend dependencies, without contributor tooling. |
| `abstractvision[apple]` / `abstractvision[all-apple]` | Native macOS Python profile: Diffusers/Torch MPS, stable-diffusion.cpp bindings, and MLX-Gen. |
| `abstractvision[gpu]` | NVIDIA/Linux local profile: Diffusers/Torch, no MLX. Install a CUDA/ROCm-enabled PyTorch wheel when needed. |
| `abstractvision[all-gpu]` | Full NVIDIA local profile: Diffusers/Torch and stable-diffusion.cpp bindings (not on Windows, where PyPI has only its source build), no MLX. Add `abstractvision[mlx-gen]` explicitly if you want to try MLX-Gen on Linux. |
| `abstractvision[abstractcore]` | Compatibility marker only; AbstractCore is still supplied by the host application. |

`stable-diffusion-cpp-python` is currently constrained below `0.4.6` because
that release's source distribution is missing vendored CMake files required by
native Linux builds.

Contributor-only extras:

| Extra | Use |
|---|---|
| `abstractvision[diffusers-dev]` / `abstractvision[huggingface-dev]` | Looser dependency pins for newer/unreleased Diffusers pipelines; install Diffusers `main` separately if needed. |
| `abstractvision[test]` | Local test dependencies. |
| `abstractvision[docs]` | Documentation build tooling. |
| `abstractvision[dev]` | Full contributor workflow: tests, docs, build, lint, formatting, and pre-commit. Do not use this as an application runtime profile. |

Note (CUDA): on Windows, `pip install "abstractvision[diffusers]"` installs PyPI's CPU-only PyTorch build; for an NVIDIA GPU, install a CUDA-enabled PyTorch build first (see <https://pytorch.org/get-started/locally/>; the one-line installer picks it for the driver). On Linux, PyPI's PyTorch is the CUDA 13 build (NVIDIA driver 580 or newer, compute capability 7.5 or newer). Verify `torch.cuda.is_available()` is `True`.

AbstractCore is not installed by AbstractVision. When an AbstractCore application
has AbstractVision installed in the same environment, AbstractCore can discover
the plugin entry point and use the integration modules lazily.

If you hit “missing pipeline class” errors for newer model families, see [`docs/getting-started.md`](docs/getting-started.md). In that case you may need Diffusers from source (`main`):

```bash
pip install -U "abstractvision[diffusers-dev]"
pip install -U "git+https://github.com/huggingface/diffusers@main"
```

For local development from a repo checkout:

```bash
pip install -e ".[dev]"
```

## Usage

Start here:
- Getting started: [`docs/getting-started.md`](docs/getting-started.md)
- FAQ: [`docs/faq.md`](docs/faq.md)
- Troubleshooting: [`docs/troubleshooting.md`](docs/troubleshooting.md)
- API reference: [`docs/api.md`](docs/api.md)
- Architecture: [`docs/architecture.md`](docs/architecture.md)
- Capability registry + catalog policy: [`docs/reference/capabilities-registry.md`](docs/reference/capabilities-registry.md), [`docs/adr/README.md`](docs/adr/README.md)
- Docs index: [`docs/README.md`](docs/README.md)

### First Apple-local MLX model

For Apple-first local MLX-Gen image generation, prefer the AbstractFramework
MLX-Gen q4 presets first. They are published in the
[AbstractFramework/mlx-gen Hugging Face collection](https://huggingface.co/collections/AbstractFramework/mlx-gen/)
and are the default recommendation for local memory efficiency. q8 variants are
also listed as separate model repos and should be selected explicitly when quality is more important
than memory footprint. Qwen and ERNIE q4 prepared folders can mix q4 and q8
components, but they remain the default prepared choice.

The downloader stores curated presets in the Hugging Face cache and imports
older `~/models/<preset>` trees into it on first use. Generation stays
cache-only unless you explicitly enable runtime downloads. `catalog` and
`show-model` give each download's access (whether its repository is gated),
its cache state as a local look sees it (with its size on disk) and the memory
modes this machine can run; for MLX-Gen packages with published measurements,
`show-model` adds the peak memory of each mode. `download` plans from the
Hugging Face listings before it writes anything, for every repository it
fetches from (the package, a GGUF bundle's text encoder and VAE, the adapter of
a `--base-model` schedule): how many files are already complete in the cache,
how many are to fetch and their size, and whether they fit on the cache disk
(a partial file's bytes count as already there). It then fetches only the files
to fetch, from the commit the listing named; after an interruption the same
command fetches the rest. `--dry-run` prints the plan without downloading. See
[Downloads](docs/reference/configuration.md#downloads).

```bash
pip install "abstractvision[models,mlx-gen]"
abstractvision model-presets
abstractvision catalog --provider mlx-gen
abstractvision show-model AbstractFramework/qwen-image-edit-2511-8bit
abstractvision show-model AbstractFramework/wan2.2-ti2v-5b-diffusers-8bit
abstractvision adapters --provider mlx-gen --model AbstractFramework/qwen-image-edit-2509-8bit --task image_to_image
# Tip: `--provider mlx-gen` implies `--target mlx` (you usually set one or the other).
# Use `catalog` to browse available downloadable models, then `show-model` for the exact route
# contract, defaults, tasks, and LoRA support truth of one selected model.
# Use `adapters` to inspect locally cached overlays for one model/task route.
abstractvision download AbstractFramework/flux.2-klein-4b-4bit --provider mlx-gen
abstractvision download AbstractFramework/qwen-image-2512-4bit --provider mlx-gen
abstractvision download AbstractFramework/qwen-image-edit-2511-4bit --provider mlx-gen
abstractvision download AbstractFramework/z-image-turbo-4bit --provider mlx-gen
abstractvision download AbstractFramework/ernie-image-turbo-8bit --provider mlx-gen
abstractvision download briaai/FIBO --provider mlx-gen
abstractvision download briaai/Fibo-lite --provider mlx-gen
abstractvision download briaai/Fibo-Edit --provider mlx-gen
abstractvision download prism-ml/bonsai-image-ternary-4B-mlx-2bit --provider mlx-gen
abstractvision download Wan-AI/Wan2.2-TI2V-5B-Diffusers --provider mlx-gen
abstractvision download AbstractFramework/wan2.2-ti2v-5b-diffusers-8bit --provider mlx-gen
abstractvision download AbstractFramework/wan2.2-t2v-a14b-diffusers-8bit --provider mlx-gen
abstractvision download AbstractFramework/wan2.2-i2v-a14b-diffusers-8bit --provider mlx-gen
abstractvision download AbstractFramework/seedvr2-3b-8bit --provider mlx-gen
# MiniMax-H3 (video with sound): gated, accept the licence on the package page first.
# The model id fetches the recommended 8-bit package; --base-model also caches the Turbo adapter.
# `--allow-non-8bit` fetches the MiniMaxAI/MiniMax-H3 source repository itself instead.
abstractvision show-model MiniMaxAI/MiniMax-H3
abstractvision download MiniMaxAI/MiniMax-H3 --base-model minimax-h3-turbo-544p --dry-run
abstractvision download MiniMaxAI/MiniMax-H3 --base-model minimax-h3-turbo-544p
abstractvision t2i --provider mlx-gen --model AbstractFramework/flux.2-klein-4b-4bit "a product photo of a matte black espresso machine" --steps 4 --guidance-scale 1.0
abstractvision t2i --provider mlx-gen --model AbstractFramework/flux.2-klein-4b-8bit "a product photo of a matte black espresso machine" --steps 4 --guidance-scale 1.0
abstractvision i2i --provider mlx-gen --model AbstractFramework/qwen-image-edit-2511-4bit --image ./input.png "replace the background with a clean white studio setup" --steps 20 --guidance-scale 2.5 --strength 0.75
abstractvision i2i --provider mlx-gen --model AbstractFramework/qwen-image-edit-2511-4bit --image ./input.png --reference-image ./style.png "apply the style reference while preserving the subject" --progress
abstractvision t2i --provider mlx-gen --model briaai/FIBO "a studio product photo of a white ceramic mug with the AbstractFramework logo" --steps 50 --guidance-scale 4.0
abstractvision t2i --provider mlx-gen --model prism-ml/bonsai-image-ternary-4B-mlx-2bit "a bonsai tree in a quiet ceramic studio" --steps 4 --guidance-scale 1.0
abstractvision i2i --provider mlx-gen --model briaai/Fibo-Edit --image ./input.png "remove the background and keep the object edges clean" --steps 20 --guidance-scale 4.0
abstractvision upscale --provider mlx-gen --model AbstractFramework/seedvr2-3b-8bit --image ./input.png --resolution 2x --softness 0.25 --open
abstractvision t2v --provider mlx-gen --model AbstractFramework/wan2.2-t2v-a14b-diffusers-8bit "a red fox walking through a snowy forest, cinematic" --width 480 --height 240 --frames 41 --fps 10 --steps 20 --guidance-scale 4.0 --guidance-2 3.0
abstractvision i2v --provider mlx-gen --model AbstractFramework/wan2.2-i2v-a14b-diffusers-8bit --image ./first-frame.png "slow camera push-in" --width 480 --height 240 --frames 41 --fps 10 --steps 20 --guidance-scale 3.5 --guidance-2 3.5
```

For a complete local MLX-Gen gallery with copy-paste commands and bundled
generated outputs, see [MLX-Gen local examples](docs/mlx-gen-local-examples.md).

Select q4 or q8 by using the exact published model id, for example
`AbstractFramework/flux.2-klein-4b-4bit` or
`AbstractFramework/flux.2-klein-4b-8bit`. Quantization is metadata of the
published model folder, not a generation-time override.

The shipped MLX-Gen backend currently supports curated q4/q8 prepared folders
for `flux2-klein-4b`, `flux2-klein-9b`, `flux2-klein-base-4b`,
`flux2-klein-base-9b`, `qwen-image`, `qwen-image-edit`, `z-image`, and
`z-image-turbo` families, plus the q4/q8 `ernie-image-turbo` prepared folders.
MLX-Gen `0.40.3+` also runs official runtime snapshots such as `briaai/FIBO`,
`briaai/Fibo-lite`, `briaai/Fibo-Edit`, `briaai/Fibo-Edit-RMBG`,
`prism-ml/bonsai-image-ternary-4B-mlx-2bit`, and
`Wan-AI/Wan2.2-TI2V-5B-Diffusers`, the prepared TI2V package
`AbstractFramework/wan2.2-ti2v-5b-diffusers-8bit`, and prepared Wan 2.2 A14B video packages
such as `AbstractFramework/wan2.2-t2v-a14b-diffusers-8bit` and
`AbstractFramework/wan2.2-i2v-a14b-diffusers-8bit`. It also supports SeedVR2
single-image upscaling through the official `ByteDance-Seed/SeedVR2-3B` and
`ByteDance-Seed/SeedVR2-7B` bases plus the canonical
`AbstractFramework/seedvr2-{3b,7b}-{8bit,4bit}` prepared packages. Use
`AbstractFramework/seedvr2-3b-8bit` by default, `AbstractFramework/seedvr2-7b-8bit`
when memory allows, and q4 variants only when memory is tight. The default
upscale request uses `--resolution 2x` and `--softness 0.25`; pass an integer
`--resolution` for a target shortest edge. `--scale` remains accepted as a
friendly scale-factor alias when `--resolution` is omitted. `--quantize` is only
needed for official/source weights. Bonsai is a pre-packed
ternary 2-bit checkpoint, not a q4/q8 prepared folder; use its exact repo id
and keep guidance at 1.0. The binary 1-bit Bonsai checkpoint is not surfaced
because stock MLX cannot run it yet. `image_to_image` is implemented for FLUX.2
klein/base, base Qwen Image and Z-Image (latent, at strength 0.4 unless set;
Z-Image Turbo also takes a mask), Qwen Image Edit, ERNIE Image Turbo, FIBO, and
FIBO Edit models; Python
`image_strength=` selects FLUX.2's latent route.
FLUX.2 klein and Qwen Image Edit outpaint and reframe with `outpaint_padding=` /
`reframe_padding=` (see [docs/api.md](docs/api.md#outpaint-and-reframe)).
FLUX.2 and Qwen Image Edit 2509/2511 can accept additional references with
`--reference-image` (or Python `reference_images=[...]`) for
multi-reference edits. FIBO Edit snapshots support mask inputs where the runtime
supports them, and `AbstractFramework/qwen-image-edit-2511-8bit` and FLUX.2
klein support route-aware masked edits. Edit inputs fail closed when the selected route
does not advertise the matching runtime capability, and a structured control
image (`--control-image`, Python `control_image=`) runs on
`AbstractFramework/qwen-image-8bit` only. Edit strength is passed as
`strength` and normalized to MLX-Gen's `image_strength` parameter where the
runtime supports it. For video,
prefer the prepared TI2V-5B or task-specific Wan 2.2 A14B packages when memory
allows. TI2V-5B should be run at `832x480` / `480x832` or above in practice;
the bundled proof page validates the route at `832x480` with `flow_shift=3.0`.
Wan A14B dimensions must be multiples of 16 and can still be smoke-tested at
`480x240`. Wan A14B uses two guidance stages: `guidance_scale` is the primary/high-noise guidance,
and `guidance_2` (`--guidance-2`) is the second-stage/low-noise guidance.
Registry defaults are `4.0` + `3.0` for T2V and `3.5` + `3.5` for I2V; omit
`guidance_2` for single-stage video models.

### Wan video sizes and memory

Each Wan video model has its own default generation size, chosen for speed and
memory. Every request can override `width`, `height`, `num_frames`, `fps` and
`steps` (CLI `--width/--height/--frames/--fps/--steps`, Python keyword
arguments, or the AbstractCore/Gateway video options):

| Model | Default size | Frames @ fps | Steps | Peak memory at the default (measured) |
|---|---|---|---|---|
| Wan 2.2 TI2V-5B (`AbstractFramework/wan2.2-ti2v-5b-diffusers-8bit`) | 832x480 | 121 @ 24 (5 s) | 50 | 16.6 GiB |
| Wan 2.2 T2V-A14B (`AbstractFramework/wan2.2-t2v-a14b-diffusers-8bit`) | 832x480 | 81 @ 16 (5 s) | 40 | 38.3 GiB |
| Wan 2.2 I2V-A14B (`AbstractFramework/wan2.2-i2v-a14b-diffusers-8bit`) | 832x480 | 81 @ 16 (5 s) | 40 | 38.4 GiB |

The MLX-Gen backend decodes Wan video in overlapping spatial tiles, which keeps
the VAE decode below the denoising peak; pass `extra={"vae_tiling": False}`
(CLI `--no-vae-tiling`) to decode whole frames at once. Figures are MLX
allocator peaks measured with AbstractVision/mlx-gen 0.38 on Apple silicon;
see [docs/faq.md](docs/faq.md#how-much-memory-does-wan-video-need) for other
sizes.

Every generation request also takes `memory_mode` (CLI `--memory-mode`,
process default `ABSTRACTVISION_MEMORY_MODE`): `"low"` runs MLX-Gen in its
low-RAM mode, Diffusers on CUDA with model CPU offload and stable-diffusion.cpp
with CPU offload of its parameters; `"lowest"` runs MLX-Gen with block
streaming (MiniMax-H3) and Diffusers on CUDA with sequential CPU offload. A mode
the provider cannot honour is refused. See
[docs/api.md](docs/api.md#memory-modes-memory_mode).

### Shared LoRA adapters

AbstractVision exposes one shared LoRA adapter request shape across Python,
CLI, and the AbstractCore plugin:

- Python: `lora_adapters=[LoRAAdapterSpec(...)]`
- CLI: repeated `--lora`, `--lora-scale`, `--lora-weight-name`,
  `--lora-subfolder`, `--lora-adapter-name`, and `--lora-target-role`
- Zero adapters means a base-model run; repeated flags let you stack one or more adapters in order
- Provider catalogs: `supports_lora`, `lora_status`, `lora_target_roles`,
  `lora_validation_profile`

Example CLI commands:

```bash
abstractvision t2i \
  --provider mlx-gen \
  --model AbstractFramework/qwen-image-2512-8bit \
  --lora prithivMLmods/Qwen-Image-2512-Pixel-Art-LoRA:Qwen-Image-2512-Master-Pixel-Art-LoRA.safetensors \
  --lora-scale 1.0 \
  --steps 20 \
  --guidance-scale 5.0 \
  --progress \
  "Pixel art astronaut floating above Earth"

abstractvision t2v \
  --provider mlx-gen \
  --model AbstractFramework/wan2.2-ti2v-5b-diffusers-8bit \
  --lora AlekseyCalvin/HSToric_Color_Wan2.2_5B_LoRA_BySilverAgePoets:HSToric_color_Wan22_5b_LoRA.safetensors \
  --lora-scale 0.8 \
  --lora-target-role transformer \
  --width 832 \
  --height 480 \
  --frames 17 \
  --fps 16 \
  --steps 20 \
  --flow-shift 3.0 \
  --progress \
  "HST style HD film, early 1900s, autochrome, analog cinema. A horse-drawn carriage crossing a snowy town square at dusk, pedestrians in wool coats, historical street lamps glowing, gentle cinematic motion."

abstractvision i2i \
  --provider mlx-gen \
  --model AbstractFramework/qwen-image-edit-2509-8bit \
  --image ./input.png \
  --lora lightx2v/Qwen-Image-Lightning:Qwen-Image-Edit-2509/Qwen-Image-Edit-2509-Lightning-8steps-V1.0-bf16.safetensors \
  --lora dx8152/Qwen-Edit-2509-Multiple-angles:镜头转换.safetensors \
  --lora-scale 1.0 \
  --lora-scale 0.9 \
  --steps 8 \
  --guidance-scale 1.0 \
  --progress \
  "Use the source starfighter as the same object. Re-render it from behind and slightly above, banking left over the snowy canyon, keeping the same vehicle identity and environment."
```

Wan LoRA routes may require explicit target roles. TI2V-5B uses one role,
`transformer`. A14B routes use two roles,
`high_noise_transformer` and `low_noise_transformer`. AbstractVision passes the
roles through unchanged instead of guessing.

Quantization guidance for Lightning LoRAs:

- The upstream LightX2V Qwen Lightning docs warn against pairing a BF16-trained
  Lightning LoRA with the raw unscaled FP8 Qwen base
  (`qwen_image_fp8_e4m3fn.safetensors`); that mix can produce grid artifacts.
  Use the fp8-trained Lightning LoRA variant on that raw FP8 base, or use a
  scaled FP8/BF16-compatible base with the BF16-trained Lightning LoRA instead.
  See:
  <https://github.com/ModelTC/LightX2V-Qwen-Image-Lightning#-using-lightning-loras-with-fp8-models>
- AbstractVision does not currently surface that raw unscaled Qwen FP8 base as
  a first-class local route. For local LoRA-heavy Qwen and Wan runs through the
  MLX-Gen backend, prefer the curated `...-8bit` prepared model routes when
  memory allows. q4 routes remain available for tighter memory budgets.

Diffusers still accepts legacy `extra["loras"]`, `extra["loras_json"]`,
`extra["lora"]`, and `extra["lora_json"]` payloads for compatibility, but new
callers should use the typed shared contract.

Inspect one exact route before long LoRA runs:

```bash
abstractvision show-model AbstractFramework/wan2.2-ti2v-5b-diffusers-8bit
abstractvision adapters --provider mlx-gen --model AbstractFramework/wan2.2-ti2v-5b-diffusers-8bit --task text_to_video --json
```

### Batch generation

AbstractVision also exposes a public batch surface above the exact single-run
requests:

- Python: `generate_image_batch(...)`, `edit_image_batch(...)`,
  `generate_video_batch(...)`, `image_to_video_batch(...)`
- CLI: `--count` plus optional explicit `--seeds`

Examples:

```bash
abstractvision t2i \
  --provider mlx-gen \
  --model AbstractFramework/qwen-image-2512-8bit \
  --count 2 \
  --seeds 2512,2513 \
  --lora prithivMLmods/Qwen-Image-2512-Pixel-Art-LoRA:Qwen-Image-2512-Master-Pixel-Art-LoRA.safetensors \
  --lora-scale 1.0 \
  --width 768 \
  --height 768 \
  --steps 20 \
  --guidance-scale 5.0 \
  --progress \
  "Pixel art isometric research outpost on an icy exoplanet at blue hour, tiny service drones, crisp tiles, retro RPG palette"

abstractvision t2v \
  --provider mlx-gen \
  --model AbstractFramework/wan2.2-ti2v-5b-diffusers-8bit \
  --count 2 \
  --seeds 6201,6202 \
  --width 832 \
  --height 480 \
  --frames 9 \
  --fps 8 \
  --steps 4 \
  --guidance-scale 4.0 \
  --flow-shift 3.0 \
  --progress \
  "A paper lantern drifting across a quiet snowy street, slow stable camera, soft evening light"
```

SeedVR2 model selection:

| Model id | Use when |
| --- | --- |
| `AbstractFramework/seedvr2-3b-8bit` | Default upscaler: lowest-friction q8 package. |
| `AbstractFramework/seedvr2-7b-8bit` | Higher-quality 7B upscaling when memory allows. |
| `AbstractFramework/seedvr2-3b-4bit` | Lower-memory 3B package. |
| `AbstractFramework/seedvr2-7b-4bit` | Lower-memory 7B package. |
| `ByteDance-Seed/SeedVR2-3B` / `ByteDance-Seed/SeedVR2-7B` | Official source weights; pass `--quantize 8` or `--quantize 4` when runtime quantization is needed. |

If you already have a prepared MLX-Gen folder, pass the folder directly as the
model. AbstractVision infers the SeedVR2 base from names such as
`seedvr2-7b-8bit`:

```bash
abstractvision upscale \
  --provider mlx-gen \
  --model /path/to/seedvr2-7b-8bit \
  --image ./input.png \
  --resolution 2x \
  --softness 0.25 \
  --open
```

One-shot `t2i`, `i2i`, `t2v`, and `i2v` commands store results in the local
asset store and print an artifact ref followed by the local content path. Use
`--open` when you want the generated output opened after storage, or
`--store-dir <dir>` to choose the asset store directory.
Image dimensions are provider/model-specific. `width`/`height` are optional
request overrides; when omitted, AbstractVision lets the selected backend use
its own default or `auto` behavior. Do not treat `512x512` as a universal
default: some older/local models accept it, while newer OpenAI-compatible image
models may only accept larger provider-declared sizes such as `1024x1024`,
`1024x1536`, `1536x1024`, or `auto`. If you pass `--width`/`--height`, the
backend may reject unsupported combinations.
MLX-Gen video and upscale commands report denoise-step progress on stderr by
default; video progress also includes frame context. Pass `--no-progress` when
you need quiet output. MLX-Gen image generation/edit commands are quiet by
default and accept `--progress` for step progress.

Stable Diffusion does not currently have a curated MLX-Gen q4/q8 preset in
AbstractVision, so full Diffusers downloads remain explicit.

Install the Diffusers runtime extra, download a Diffusers snapshot, then select
the Diffusers backend explicitly:

```bash
pip install "abstractvision[models,diffusers]"
abstractvision catalog --provider diffusers
# Tip: `--provider diffusers` implies `--target diffusers` (you usually set one or the other).
abstractvision download stable-diffusion --provider diffusers
abstractvision download sd1.4 --provider diffusers
abstractvision download sd1.5-inpaint --provider diffusers
abstractvision download sdxl-base --provider diffusers
abstractvision download sdxl-inpaint --provider diffusers
abstractvision download sd3-medium --provider diffusers
abstractvision download sd3.5-large --provider diffusers
abstractvision download ernie-image --provider diffusers
abstractvision download qwen-image-edit-2511 --provider diffusers
abstractvision download flux2-dev --provider diffusers
export ABSTRACTVISION_BACKEND=diffusers
export ABSTRACTVISION_MODEL_ID=runwayml/stable-diffusion-v1-5
export ABSTRACTVISION_DIFFUSERS_DEVICE=auto
abstractvision cli
```

Notes:
- `abstractvision download qwen-image-edit-2511 --provider diffusers` downloads the curated official 16-bit Diffusers snapshot.
- `GLM-Image` remains in the packaged registry, but local Diffusers `GLM-Image` is temporarily disabled pending the follow-up tracked in [`docs/backlog/planned/0023_local_runtime_capability_quarantine_for_glm_mflux_and_t2v.md`](docs/backlog/planned/0023_local_runtime_capability_quarantine_for_glm_mflux_and_t2v.md).
- `CogVideoX-2b` downloads are still available for experimentation, but local `text_to_video` is currently marked experimental and disabled from the normal product surfaces.

For a fresh cache, you can also permit the interactive CLI to download missing files:

```bash
ABSTRACTVISION_DIFFUSERS_ALLOW_DOWNLOAD=1 abstractvision cli
```

More recommendations by VRAM: [`docs/getting-started.md`](docs/getting-started.md).

### Capability-driven model selection

```python
from abstractvision import VisionModelCapabilitiesRegistry

reg = VisionModelCapabilitiesRegistry()
assert reg.supports("runwayml/stable-diffusion-v1-5", "text_to_image")
assert reg.supports("Qwen/Qwen-Image-Edit-2511", "image_to_image")

print(reg.list_tasks())
print(reg.models_for_task("text_to_image"))
print(reg.models_for_task("image_to_image"))
```

### Backend wiring + generation (artifact outputs)

The base install is import-light and does not install Torch/Diffusers. Heavy
local backend modules are imported lazily (see [`src/abstractvision/backends/__init__.py`](src/abstractvision/backends/__init__.py)).
Install `abstractvision[diffusers]` for local Diffusers, or
`abstractvision[sdcpp]` for the optional stable-diffusion.cpp python binding
fallback.

```python
from abstractvision import LocalAssetStore, VisionManager, VisionModelCapabilitiesRegistry, is_artifact_ref
from abstractvision.backends import OpenAICompatibleBackendConfig, OpenAICompatibleVisionBackend

reg = VisionModelCapabilitiesRegistry()

backend = OpenAICompatibleVisionBackend(
    config=OpenAICompatibleBackendConfig(
        base_url="http://localhost:1234/v1",
        api_key="YOUR_KEY",      # optional for local servers
        model_id="REMOTE_MODEL", # optional (server-dependent)
    )
)

vm = VisionManager(
    backend=backend,
    store=LocalAssetStore(),         # enables artifact-ref outputs
    model_id="Qwen/Qwen-Image-Edit-2511",  # optional: capability gating
    registry=reg,                   # optional: reuse loaded registry
)

out = vm.generate_image("a cinematic photo of a red fox in snow")
assert is_artifact_ref(out)
print(out)  # {"$artifact": "...", "content_type": "...", ...}

png_bytes = vm.store.load_bytes(out["$artifact"])  # type: ignore[union-attr]
```

When installed next to AbstractCore, AbstractVision is also discovered as a
`llm.vision` capability plugin. The plugin defaults to the official OpenAI
image endpoint (`https://api.openai.com/v1`) and reads `OPENAI_API_KEY`.
Set `OPENAI_BASE_URL` when you need a local or remote compatible `/v1` server,
and use the same `OPENAI_API_KEY` bearer token if that endpoint requires auth.
Set `ABSTRACTVISION_BACKEND=openai-compatible` when you want to force
compatible-endpoint semantics. Set `ABSTRACTVISION_MODEL_ID`,
`OPENAI_IMAGE_MODEL_ID`, or `OPENAI_IMAGE_MODEL` when you need an explicit
image model (static default OpenAI model: `gpt-image-1`). AbstractVision does
not query provider `/models` catalogs to discover or select image models
automatically, but you can inspect them explicitly with
`abstractvision provider-models`, `VisionManager.list_provider_models(...)`,
or the AbstractCore plugin method `llm.vision.list_provider_models(...)`.
After inspection, set the model env var explicitly for newer provider models
when available to your account. Set `ABSTRACTVISION_BACKEND=mlx-gen`,
`ABSTRACTVISION_BACKEND=diffusers`, or `ABSTRACTVISION_BACKEND=sdcpp` when you
want AbstractCore to launch local AbstractVision generation directly. For
MLX-Gen, set `ABSTRACTVISION_MFLUX_MODEL=AbstractFramework/flux.2-klein-4b-4bit`
or use routed model ids such as
`mlx-gen/AbstractFramework/flux.2-klein-4b-4bit`. Legacy `mflux` provider values
remain accepted as compatibility aliases.

### Interactive testing (CLI)

```bash
abstractvision models
abstractvision provider-models --openai --task text_to_image
abstractvision provider-models --base-url http://localhost:1234/v1 --task text_to_image
abstractvision tasks
abstractvision show-model runwayml/stable-diffusion-v1-5

abstractvision cli
```

Inside the interactive CLI:

```text
/t2i "a watercolor painting of a lighthouse" --width 512 --height 512 --steps 10 --open
/i2i --image ./input.png "make it watercolor" --steps 20 --guidance-scale 6.5 --open
```

For a newer but still relatively small local model, try `black-forest-labs/FLUX.2-klein-4B` after installing Diffusers
from source (see [`docs/getting-started.md`](docs/getting-started.md)):

```text
/backend diffusers black-forest-labs/FLUX.2-klein-4B mps float16
/t2i "a product photo of a matte black espresso machine" --steps 4 --guidance-scale 1.0 --open
```

Local Diffusers `text_to_video` remains experimental and is temporarily
disabled from the normal bundled local surfaces. Use MLX-Gen Wan 2.2 A14B for
local Apple Silicon `text_to_video` / `image_to_video`, or use the
OpenAI-compatible backend for remote video endpoints.

For local MLX-Gen generation (Apple-first validation):

```text
/backend mlx-gen AbstractFramework/flux.2-klein-4b-4bit
/t2i "a product photo of a matte black espresso machine" --steps 4 --guidance-scale 1.0 --open
/backend mlx-gen prism-ml/bonsai-image-ternary-4B-mlx-2bit
/t2i "a bonsai tree in a quiet ceramic studio" --steps 4 --guidance-scale 1.0 --open
/backend mlx-gen AbstractFramework/qwen-image-edit-2511-4bit
/i2i --image ./input.png "replace the background with a clean white studio setup" --steps 20 --guidance-scale 2.5 --strength 0.75 --open
/backend mlx-gen AbstractFramework/wan2.2-t2v-a14b-diffusers-8bit
/t2v "a red fox walking through a snowy forest, cinematic" --width 432 --height 240 --frames 41 --fps 10 --steps 20 --guidance-scale 4.0 --guidance-2 3.0 --open
/backend mlx-gen AbstractFramework/wan2.2-i2v-a14b-diffusers-8bit
/i2v --image ./first-frame.png "slow camera push-in" --width 432 --height 240 --frames 41 --fps 10 --steps 20 --guidance-scale 3.5 --guidance-2 3.5 --open
```

`/t2v` and `/i2v` show MLX-Gen denoise-step video progress by default; add
`--no-progress` to suppress progress output in scripts.

OpenAI-compatible server example:

```text
/backend openai http://localhost:1234/v1
/t2i "a watercolor painting of a lighthouse" --width 512 --height 512 --steps 10 --open
```

The CLI/REPL can also be configured via `ABSTRACTVISION_*` env vars; see [`docs/reference/configuration.md`](docs/reference/configuration.md).

### Local web playground

The playground is owned by AbstractVision and runs without AbstractCore. It is
a local/dev testing surface; use AbstractCore/Gateway for production routing,
authentication, and browser-origin policy.

```bash
abstractvision playground --port 8091
```

Open `http://127.0.0.1:8091/vision_playground.html`. The page and the API are served by the same process.

Current behavior:
- The UI is split into task tabs (`Text→Image`, `Image→Image`, `Text→Video`, and a placeholder `Image→Video` tab for later work).
- Each active task tab has its own model selector and unload button. Switching models in a tab unloads the current active backend first to free memory before loading the replacement.
- The Image→Image tab is enabled only for models that both advertise `image_to_image` in the packaged capability registry and remain enabled by the selected backend.
- MLX-Gen FLUX.2 klein/base, Qwen Image Edit, ERNIE Image Turbo, FIBO, and FIBO Edit models are surfaced for `Image→Image` edits when cached.
- The Text→Video tab is experimental in the playground UI. Use shell/REPL or AbstractCore for the most complete MLX-Gen Wan video controls.
- Model-specific request normalization happens at the API/backend layer, not just in the page.
- Local video export packages generated frames into MP4 via an external `ffmpeg` binary on `PATH`.
- Response logs intentionally show only a shortened `b64_json` preview instead of the full base64 image payload.

One-shot commands pick this machine's local engine and FLUX.2 [klein] 4B when you give no provider, model or base
URL: MLX-Gen with the 8-bit package `AbstractFramework/flux.2-klein-4b-8bit` on Apple silicon, stable-diffusion.cpp
with the Q8_0 (8-bit) GGUF of `black-forest-labs/FLUX.2-klein-4B` on an NVIDIA card, Diffusers with that model's
16-bit pipeline (run in float32 on the processor) on a processor-only host. The command prints its choice and the
`abstractvision download` command that fetches it. A configured
`--base-url` (or `$OPENAI_BASE_URL`) selects the OpenAI-compatible HTTP backend instead, and `--provider` always wins:

```bash
abstractvision t2i --base-url http://localhost:1234/v1 "a studio photo of an espresso machine"
abstractvision i2i --base-url http://localhost:1234/v1 --image ./input.png "make it watercolor"
abstractvision t2i --provider diffusers --model qwen-image "a studio photo of an espresso machine"
```

#### Local GGUF via stable-diffusion.cpp

If you want to run GGUF diffusion models locally, use the stable-diffusion.cpp backend (`sdcpp`). Start with a
single-file Stable Diffusion model when possible; Qwen Image and FLUX GGUF component sets are heavier.

Recommended:
- `abstractvision` auto-installs `sd-cli` into `~/.abstractvision/bin` on first use (set `ABSTRACTVISION_SDCPP_AUTO_INSTALL=0` to disable).
- If you prefer python bindings: install `abstractvision[sdcpp]` (uses `stable-diffusion-cpp-python`).

Alternative (external executable): install `sd-cli` from <https://github.com/leejet/stable-diffusion.cpp/releases>.

In the REPL:

```text
/backend sdcpp /path/to/sd-v1-5.gguf /path/to/sd-cli
/t2i "a watercolor painting of a lighthouse" --width 512 --height 512 --steps 10 --open
```

Curated FLUX/Qwen GGUF bundle example:

```bash
abstractvision download flux2-klein-base-4b --provider sdcpp
abstractvision download qwen-image-edit-2511-gguf --provider sdcpp
```

```text
/backend sdcpp flux2-klein-base-4b /path/to/sd-cli
/t2i "a product photo of a matte black espresso machine" --steps 4 --guidance-scale 1.0 --sampling-method euler --diffusion-fa --offload-to-cpu --open
```

The package resolves the required VAE and text-encoder companions from the cache automatically for curated `sdcpp`
model keys. Manual component wiring remains available for advanced cases.

Extra flags are forwarded via `request.extra`. In CLI mode they are forwarded to `sd-cli`; in python bindings mode, keys are mapped to python binding kwargs when supported and unsupported keys are ignored.

### AbstractCore tool integration (artifact refs)

If you’re using AbstractCore tool calling, AbstractVision can expose vision tasks as tools:

```python
from abstractvision.integrations.abstractcore import make_vision_tools

tools = make_vision_tools(vision_manager=vm, model_id="Qwen/Qwen-Image-Edit-2511")
```

Install `abstractcore` in the host application environment when you use these helpers; it is not pulled in by AbstractVision.

## AbstractFramework ecosystem

AbstractVision is part of the **AbstractFramework** ecosystem and is designed to compose with:

- **AbstractFramework** (project hub): <https://github.com/lpalbou/AbstractFramework>
- **AbstractCore** (orchestration + tool calling): <https://github.com/lpalbou/abstractcore>
- **AbstractRuntime** (runtime services, including artifact storage): <https://github.com/lpalbou/abstractruntime>

In practice:
- AbstractVision standardizes *generative vision outputs* (image/video) behind `VisionManager`.
- AbstractCore can discover and use AbstractVision via the capability plugin (`src/abstractvision/integrations/abstractcore_plugin.py`) or you can expose vision tasks as tools (`src/abstractvision/integrations/abstractcore.py`).
- Artifact refs returned by AbstractVision are designed to travel across processes; `RuntimeArtifactStoreAdapter` bridges to an AbstractRuntime-style artifact store (`src/abstractvision/artifacts.py`).

## Project

- Release notes: [`CHANGELOG.md`](CHANGELOG.md)
- Contributing: [`CONTRIBUTING.md`](CONTRIBUTING.md)
- Security: [`SECURITY.md`](SECURITY.md)
- Acknowledgments: [`ACKNOWLEDGMENTS.md`](ACKNOWLEDGMENTS.md)
- Agent docs: [`llms.txt`](llms.txt) and [`llms-full.txt`](llms-full.txt)

## Requirements

- Python >= 3.9

## License

MIT License - see LICENSE file for details.

## Author

Laurent-Philippe Albou

## Contact

contact@abstractcore.ai
--- >8 --- END FILE: README.md --- >8 ---

--- 8< --- FILE: docs/README.md --- 8< ---
# AbstractVision documentation

This folder contains the user-facing documentation for `abstractvision`.

## Start here (new users)

1) [Project overview + quickstart](../README.md)  
2) [Getting started](getting-started.md) ([one-line install](getting-started.md#one-line-install); shell and interactive `t2i`/`i2i`; then Diffusers, MLX-Gen, GGUF, OpenAI-compatible HTTP, Playground)
3) [Architecture](architecture.md) (how the pieces fit together)

## Quick reference

- [FAQ](faq.md)
- [Platform check (measured speed on Linux processor, Linux NVIDIA, Apple silicon)](benchmark.md)
- [Troubleshooting](troubleshooting.md)
- [API reference](api.md)
- [Architecture decisions](adr/README.md)
- [Backends](reference/backends.md)
- [MLX-Gen local examples](mlx-gen-local-examples.md) (current LoRA route proofs, progress logs, and generated assets)
- [Configuration (CLI/REPL env vars + flags)](reference/configuration.md)
- [Capability registries (models + adapters)](reference/capabilities-registry.md)
- [Artifacts (artifact refs + stores)](reference/artifacts.md)
- [AbstractCore integration (capability plugin + tools)](reference/abstractcore-integration.md)
- Agent-oriented docs: [`../llms.txt`](../llms.txt) and [`../llms-full.txt`](../llms-full.txt)

## AbstractFramework ecosystem

AbstractVision is part of the **AbstractFramework** ecosystem and is designed to compose with:

- **AbstractFramework** (project hub): <https://github.com/lpalbou/AbstractFramework>
- **AbstractCore** (orchestration + tool calling): <https://github.com/lpalbou/abstractcore>
- **AbstractRuntime** (runtime services, including artifact storage): <https://github.com/lpalbou/abstractruntime>

## Current implementation status (as shipped)

Public API surface: [`VisionManager`](../src/abstractvision/vision_manager.py) exposes:
- `generate_image` (`text_to_image`), `edit_image` (`image_to_image`)
- `generate_image_batch`, `edit_image_batch` (repeatable orchestration with explicit seed planning)
- `generate_video` (`text_to_video`), `image_to_video` (`image_to_video`) (backend-dependent)
- `generate_video_batch`, `image_to_video_batch` (repeatable orchestration with explicit seed planning)
- `generate_angles` (`multi_view_image`) (API exists; no built-in backend implements it yet)

Built-in backends implement:
- **Images**: Diffusers, stable-diffusion.cpp, MLX-Gen, OpenAI-compatible HTTP ([`../src/abstractvision/backends/`](../src/abstractvision/backends/))
- **Current local policy**: MLX-Gen supports curated q4/q8 image presets, Qwen/FIBO/FLUX.2 klein/Z-Image Turbo masked edits, a structured control image on `AbstractFramework/qwen-image-8bit` only, official FIBO image snapshots, SeedVR2 image upscaling and video restoration, shared LoRA adapters, and Wan 2.2 TI2V/A14B video (with `video_to_video` on T2V-A14B and Wan 2.1 VACE 1.3B). MLX-Gen is validated on Apple Silicon; the explicit `mlx-gen` extra also installs on Linux, where it is not validated yet (see [backlog 030](backlog/planned/030_gpu_parity_with_mlx_gen.md)), and the NVIDIA/Linux `gpu` / `all-gpu` profiles do not include it. Local Diffusers `text_to_video` is experimental and temporarily disabled from normal local surfaces.
- **Video**:
  - MLX-Gen for Wan 2.2 local `text_to_video` and first-frame `image_to_video`
  - OpenAI-compatible HTTP for optional `text_to_video` / `image_to_video` when endpoints are configured ([`openai_compatible.py`](../src/abstractvision/backends/openai_compatible.py))

If you’re looking for “what can model X do?” or “which adapter defaults/compatibilities are packaged?”, the packaged registries are the source of truth:
[`../src/abstractvision/assets/vision_model_capabilities.json`](../src/abstractvision/assets/vision_model_capabilities.json) (loaded by `VisionModelCapabilitiesRegistry` in [`../src/abstractvision/model_capabilities.py`](../src/abstractvision/model_capabilities.py)) and
[`../src/abstractvision/assets/vision_adapter_capabilities.json`](../src/abstractvision/assets/vision_adapter_capabilities.json) (loaded by `VisionAdapterCapabilitiesRegistry` in [`../src/abstractvision/adapter_capabilities.py`](../src/abstractvision/adapter_capabilities.py)).
Exact runtime route truth still comes from the selected backend.
The curation and cross-platform support policy for those registries is governed by
[ADR 0005](adr/0005_curated_capability_registry_and_download_catalog.md).

## Internal engineering notes

[`docs/adr/`](adr/) contains durable engineering policy.

[`docs/backlog/`](backlog/) is an internal log (planned work + completion reports). It is not the normative user documentation surface.

## Project

- Release notes: [`CHANGELOG.md`](../CHANGELOG.md)
- Contributing: [`CONTRIBUTING.md`](../CONTRIBUTING.md)
- Security: [`SECURITY.md`](../SECURITY.md)
- License: [`LICENSE`](../LICENSE)
- Acknowledgments: [`ACKNOWLEDGMENTS.md`](../ACKNOWLEDGMENTS.md)
--- >8 --- END FILE: docs/README.md --- >8 ---

--- 8< --- FILE: docs/getting-started.md --- 8< ---
# Getting Started

This guide helps you generate your first image using AbstractVision with the built-in backends:

- **OpenAI-compatible HTTP**: call a local/remote server that exposes OpenAI-shaped image endpoints
- **Diffusers (local Python)**: Stable Diffusion / Qwen Image / FLUX 2 / other supported Diffusers pipelines
- **MLX-Gen (local, Apple-first)**: q4/q8 AbstractFramework MLX-optimized image generation via the optional MLX-Gen runtime, official FIBO image models, canonical SeedVR2 image upscaling packages, shared LoRA adapters, and Wan 2.2 TI2V/A14B video routes. AbstractVision validates MLX-Gen on Apple Silicon; the `mlx-gen` extra also installs on Linux, where it is not validated yet (see [backlog 030](backlog/planned/030_gpu_parity_with_mlx_gen.md)).
- **stable-diffusion.cpp (local GGUF)**: GGUF diffusion models via `sd-cli` (recommended for GPU backends like **Metal**/**CUDA**) or via pip-installable python bindings (often **CPU-only** fallback)
- **Playground (web, optional)**: self-contained AbstractVision UI/API for local model loading and jobs (`/v1/vision/*`)

See also:
- Docs index: [docs/README.md](README.md)
- FAQ: [docs/faq.md](faq.md)
- Troubleshooting: [docs/troubleshooting.md](troubleshooting.md)
- API reference: [docs/api.md](api.md)
- Architecture: [docs/architecture.md](architecture.md)
- Backends: [docs/reference/backends.md](reference/backends.md)
- Configuration (CLI/REPL env vars): [docs/reference/configuration.md](reference/configuration.md)
- Capability registries: [docs/reference/capabilities-registry.md](reference/capabilities-registry.md)
- Artifacts: [docs/reference/artifacts.md](reference/artifacts.md)
- AbstractCore integration: [docs/reference/abstractcore-integration.md](reference/abstractcore-integration.md)

---

## One-line install

One line, no admin rights, no Python needed beforehand. It installs AbstractVision alone (the
`abstractvision` command; no gateway, no services) as a uv tool: an isolated, user-scoped
environment with Python 3.12 managed by [uv](https://docs.astral.sh/uv), which it installs into
`~/.local/bin` when missing.

```bash
# macOS / Linux
curl -LsSf https://abstractframework.ai/vision/install.sh | sh
curl -LsSf https://abstractframework.ai/vision/install.sh | sh -s -- --profile gpu   # with options
```

```powershell
# Windows 10/11 (PowerShell 5.1 or 7)
powershell -ExecutionPolicy ByPass -c "irm https://abstractframework.ai/vision/install.ps1 | iex"
& ([scriptblock]::Create((irm https://abstractframework.ai/vision/install.ps1))) -Profile gpu   # with options
```

Without the installer, in an environment of your own:

```bash
pip install abstractvision            # light
pip install "abstractvision[apple]"   # Apple Silicon
pip install "abstractvision[gpu]"     # NVIDIA / Linux
```

The installer runs `uv tool install --python 3.12 "abstractvision[<profile>]==<version>"`, where
the version is the release the script ships with. Every step prints its command; `--print`
(`-Print` on Windows) shows the plan and changes nothing. After an `apple` or `gpu` install
(not `light`, which has no PyTorch), it checks which device PyTorch runs on (`torch` and
`torchvision` import, then CUDA or MPS) and says so.
AbstractFramework's own installer (`https://abstractframework.ai/install.sh`) already includes
AbstractVision: where it is installed, its gateway tool owns the `abstractvision` command and this
installer stops with a sentence, changing nothing (upgrade the framework instead).

| Profile | Picked when | Installs | Local generation |
|---|---|---|---|
| `apple` | Apple Silicon, macOS 14 or later | `abstractvision[apple]`: MLX-Gen, Diffusers on PyTorch | Apple GPU (MLX, MPS) |
| `gpu` | Linux with NVIDIA (`nvidia-smi -L`) or ROCm (`rocminfo`); Windows with `nvidia-smi` | `abstractvision[gpu]`: Diffusers on PyTorch | CUDA when the card works, else the processor |
| `light` | anything else | `abstractvision`, no dependency at all: the CLI, the catalog, the OpenAI-compatible backend | none (OpenAI or any `/v1/images` server) |

PyTorch for the `gpu` profile: on Linux, PyPI's PyTorch is the CUDA 13 build (NVIDIA driver 580
or newer, compute capability 7.5 or newer). On Windows, the installer adds `--torch-backend cu130`
(driver 580+ and compute capability 7.5+) or `cu126` (driver 525+), so torch and torchvision come
from the same PyTorch index; otherwise PyPI's CPU build. An AMD GPU (ROCm) gets PyPI's CUDA build,
which runs on the processor; the device check says so. Windows on ARM gets `light` only: PyTorch
publishes no Windows ARM64 wheels.

### Linux without a GPU

- `light` (what `auto` picks) has no local generation: it talks to OpenAI-compatible image
  servers only.
- `--profile gpu` is the way to generate locally on the processor (Diffusers on PyTorch). It
  installs PyPI's PyTorch, the CUDA build, which runs on the processor: the environment is about
  5.5 GB (measured on Ubuntu 24.04 x86_64).
- For a smaller footprint, install PyTorch's CPU build afterwards (the installer's summary prints
  this line with its version):

  ```bash
  uv tool install --python 3.12 --torch-backend cpu --reinstall "abstractvision[gpu]==<version>"
  ```

  It takes torch and torchvision from PyTorch's CPU index and removes the NVIDIA libraries: the
  environment drops to about 1.1 GB. Both must come from the same index: a CPU torch next to the
  CUDA torchvision breaks torchvision (its operators no longer load). Measured with uv 0.13.7: uv's
  receipt does not record `--torch-backend`, and uv keeps an installed torch that still satisfies,
  so a re-run of the installer, an upgrade through it (0.3.33 to 0.3.34) and `uv tool upgrade`
  kept the CPU build. A reinstall re-resolves torch from PyPI and brings the CUDA build back:
  `uv tool upgrade --reinstall abstractvision` did, and so does
  `uv tool install --python 3.12 --reinstall "abstractvision[gpu]==<version>"` (the way to get it
  back on purpose). After an upgrade, check the summary's `PyTorch:` line: when it names a CUDA
  build again, run the `--torch-backend cpu` line again.

### Options

| macOS / Linux | Windows | Environment | Meaning |
|---|---|---|---|
| `--profile auto\|light\|apple\|gpu` | `-Profile auto\|light\|gpu` | `AVIS_PROFILE` | install profile (default `auto`: the first that fits) |
| `--pin VERSION\|latest` | `-Pin VERSION\|latest` | `AVIS_PIN` | the AbstractVision version (default: the release the script ships with; `latest` = the newest on PyPI) |
| `--from PATH` | `-From PATH` | `AVIS_FROM` | install from a checkout, sdist or wheel (testing) |
| `--no-modify-path` | `-NoModifyPath` | | do not run `uv tool update-shell` |
| `--print`, `--dry-run`, `-n` | `-Print`, `-DryRun` | | show the plan and the commands; change nothing |
| `-v`, `--verbose` | `-Verbose` | | show the full output of every command |
| `-h`, `--help` | `Get-Help .\install.ps1` | | the help |

### Upgrade and removal

Run the same line again: it says `AbstractVision <old> found: upgrading to <new>` (or `already up
to date`, after checking that the command starts and reinstalling it when it does not). The
previous profile is kept (read from uv's receipt) unless `--profile` says otherwise; `--pin`
goes back to an older release. When the command folder is not on `PATH`, `uv tool update-shell`
adds it to your shell profile once. Remove with `uv tool uninstall abstractvision`.

### What is left out

The installer uses prebuilt wheels only, so it never starts a C compiler (a fresh Mac never sees
the Xcode tools dialog). Checked against PyPI for Python 3.12:

- `apple`: `stable-diffusion-cpp-python`, the Python binding of stable-diffusion.cpp, is left out
  (an overrides file plus `--no-build-package`): PyPI has only its source build, for every
  version. Every other package has a macOS 14 arm64 wheel. To add the binding with a C compiler
  and CMake: `uv pip install --python "$(uv tool dir)/abstractvision/bin/python" "stable-diffusion-cpp-python>=0.4.2,<0.4.6"`.
- `gpu`: nothing (every package has a Linux x86_64/aarch64 and a Windows x64 wheel).
- `light`: nothing (no dependency).
- GGUF models: the installer does not install stable-diffusion.cpp's `sd-cli`. The
  stable-diffusion.cpp backend prefers it and downloads it itself into `~/.abstractvision/bin` at
  the first GGUF generation (the macOS arm64 build on Apple Silicon; on Linux a Vulkan build when
  NVIDIA is present; a CUDA build on Windows); `ABSTRACTVISION_SDCPP_AUTO_INSTALL=0` turns that off.

---

## 0) Install

From PyPI:

```bash
pip install abstractvision
```

AbstractVision’s base install is lightweight. It includes the shared API, packaged capability registries, artifact helpers, CLI, AbstractCore plugin entry point, and stdlib OpenAI-compatible HTTP backend. Local inference runtimes are explicit extras: install `abstractvision[diffusers]` for Torch/Diffusers, `abstractvision[sdcpp]` for the stable-diffusion.cpp python binding fallback, `abstractvision[mlx-gen]` for MLX-Gen, or `abstractvision[all-apple]` for the full native macOS stack. `abstractvision[mflux]` remains available as a compatibility alias for older install instructions.

If you see “missing pipeline class” errors for newer model families, install the `diffusers-dev` extra (or compatibility alias `huggingface-dev`) to get compatible dependencies, then install Diffusers from source (`main`).

For that newer-pipeline workflow from a **repo checkout**, install the `diffusers-dev` extra (compatible deps; does not include Diffusers `main`):

```bash
pip install -e ".[diffusers-dev]"
```

If you're installing **AbstractVision from PyPI**, you can install the extra directly:

```bash
pip install -U "abstractvision[diffusers-dev]"
```

Or install Diffusers from source directly:

```bash
pip install -U "git+https://github.com/huggingface/diffusers@main"
```

Sanity check:

```bash
python -c "import diffusers; print(diffusers.__version__)"
python -c "import diffusers; print('GlmImagePipeline', hasattr(diffusers, 'GlmImagePipeline')); print('Flux2KleinPipeline', hasattr(diffusers, 'Flux2KleinPipeline'))"
```

Offline alternative (if you already have a local Diffusers checkout):

```bash
pip install -U -e /path/to/diffusers
```

Or, from a repo checkout (run in the repo root):

```bash
pip install -e .
```

For contributor tooling from a repo checkout, use:

```bash
pip install -e ".[dev]"
```

For local Diffusers generation, install `abstractvision[diffusers]` before selecting the `diffusers` backend. Use `diffusers-dev` only when you need newer Diffusers-compatible dependency pins, and use `sdcpp` only when you want the optional stable-diffusion.cpp python binding fallback.

Optional extras:

| Extra | Use |
|---|---|
| `openai` | Empty official OpenAI provider intent marker; the HTTP backend is stdlib-only today. |
| `openai-compatible` | Empty local/remote OpenAI-shaped endpoint intent marker; the HTTP backend is stdlib-only today. |
| `diffusers` | Installs Torch/Diffusers and related packages for local Diffusers generation. |
| `sdcpp` | Installs `stable-diffusion-cpp-python` for the stable-diffusion.cpp pip binding fallback. |
| `mlx-gen` | Installs the optional MLX-Gen runtime, validated on Apple Silicon. The extra also installs on Linux, where it is not validated yet (see [backlog 030](backlog/planned/030_gpu_parity_with_mlx_gen.md)). |
| `mflux` | Compatibility alias for the MLX-Gen runtime. |
| `apple` | Native macOS profile: Diffusers/Torch MPS, stable-diffusion.cpp bindings, and MLX-Gen. |
| `gpu` | NVIDIA/Linux profile: Diffusers/Torch, no MLX. |
| `huggingface` | Compatibility alias for the historical Diffusers backend dependency set. |
| `local` | Convenience extra for the Diffusers + `sdcpp` local runtime stack. Add `mlx-gen` separately, or use `all` / `all-apple`, when you also want MLX-Gen. |
| `all` | All runtime backend dependencies, without contributor tooling. |
| `all-apple` | Aggregate native macOS profile: Diffusers/Torch MPS, stable-diffusion.cpp, and MLX-Gen. |
| `all-gpu` | Aggregate NVIDIA profile: Diffusers/Torch + stable-diffusion.cpp bindings (left out on Windows: PyPI has only its source build, which needs MSVC), no MLX. |
| `abstractcore` | Empty compatibility marker; install AbstractCore in the host application environment. |

Contributor-only extras:

| Extra | Use |
|---|---|
| `diffusers-dev` / `huggingface-dev` | Looser dependency pins for newer/unreleased Diffusers pipelines. Install Diffusers `main` separately when a pipeline is not in the latest release. |
| `test` | Local test dependencies. |
| `docs` | Documentation build tooling. |
| `dev` | Full contributor workflow: tests, docs, packaging, formatting, release checks, and pre-commit. Do not use this as an application runtime profile. |

Optional (recommended): pre-download heavyweight model sets (so first-run doesn’t do surprise multi‑GB downloads):

```bash
python scripts/download_model_sets.py --list
python scripts/download_model_sets.py --plan --set sd15_diffusers
python scripts/download_model_sets.py --plan --set flux2_klein_4b_gguf
python scripts/download_model_sets.py --set sd15_diffusers
```

### 0.1 Hardware quickstart (macOS Metal vs NVIDIA CUDA vs CPU)

AbstractVision can run “locally” via three main routes:

- **Diffusers backend**: uses Torch device selection (`cuda` / `mps` / `cpu`).
- **MLX-Gen backend (`mlx-gen`)**: Apple-first MLX generation through the optional MLX-Gen runtime. q4 AbstractFramework model repos are the default recommendation; q8 variants are separate exact model ids for quality-focused runs.
- **stable-diffusion.cpp backend (`sdcpp`)**: runs GGUF diffusion models using:
  - `sd-cli` (**recommended** when you want GPU backends like **Metal** or **CUDA**)
  - or `stable-diffusion-cpp-python` (convenient, but often **CPU-only**, especially on macOS)

#### macOS (Apple Silicon, Metal)

- **Diffusers**: start with Stable Diffusion 1.5, then move up:
  - `/backend diffusers runwayml/stable-diffusion-v1-5 mps float16`
  - `/backend diffusers black-forest-labs/FLUX.2-klein-4B mps float16` (requires Diffusers `main` today)
- **GGUF (`sdcpp`)**: install `sd-cli` from stable-diffusion.cpp releases and use **CLI mode** for Metal speed:
  - Download: <https://github.com/leejet/stable-diffusion.cpp/releases>
  - Pick the Darwin arm64 zip (example asset name: `sd-…-bin-Darwin-macOS-…-arm64.zip`)
  - If macOS blocks execution, clear quarantine: `xattr -dr com.apple.quarantine /path/to/sd-cli`
  - In the REPL, pass the full path as the last arg to `/backend sdcpp …` (see section **6)**).

If you see `Using CPU backend` in logs, you’re on CPU (it will work, but can be extremely slow for large models).

#### NVIDIA (CUDA)

- Install a CUDA-enabled PyTorch wheel first (see <https://pytorch.org/get-started/locally/>).
- Use Diffusers with `cuda` + `float16`:
  - `/backend diffusers runwayml/stable-diffusion-v1-5 cuda float16`
- For GGUF (`sdcpp`) on NVIDIA, use an `sd-cli` build compiled with CUDA (stable-diffusion.cpp releases provide multiple assets depending on tag).

#### CPU-only

- Expect slow inference. Prefer smaller models and lower resolutions/steps.
- `sdcpp` via python bindings is the simplest “no external binary” option, but it will use whatever backend the wheel was compiled with (often CPU).

---

## Recommended default models (VRAM guide)

If you run **locally** (Diffusers backend) and want a reliable starting point, here are practical model picks from the packaged capability registry (`src/abstractvision/assets/vision_model_capabilities.json`).

Notes:
- VRAM needs vary with resolution, dtype, and pipeline implementation. Treat this as a starting point.
- Some models are **gated** on Hugging Face and require accepting terms + setting `HF_TOKEN`.
- If you want a non-gated modern image model, try `black-forest-labs/FLUX.2-klein-4B` (but it currently requires installing Diffusers from source; see the FLUX section below).

| GPU VRAM | Recommended model id | Why | Install / quickstart |
|---:|---|---|---|
| ≤ 16 GB | `runwayml/stable-diffusion-v1-5` | Small, stable, and widely compatible (Windows/Linux CUDA, macOS MPS) | `pip install "abstractvision[diffusers]"` then run the REPL using the snippet below |
| 24-32 GB | `black-forest-labs/FLUX.2-klein-4B` | Newer non-gated model, much smaller than FLUX.2-dev | Install Diffusers `main`, then use the FLUX.2 klein section below |
| 32 GB | `stabilityai/stable-diffusion-3.5-large-turbo` | High-quality still images with low step counts (gated) | Accept model terms on HF, set `HF_TOKEN`, then use the SD3.5 section below |
| 64 GB | `Qwen/Qwen-Image-2512` | Strong prompt following and text rendering (large model) | Same as Diffusers setup; if pipeline import fails, use Diffusers `main` (see install section above) |
| 128 GB | `black-forest-labs/FLUX.2-dev` | Very high quality (very large; non-commercial license; gated) | Accept model terms on HF, set `HF_TOKEN`, then use the FLUX section below |

macOS Metal (Apple Silicon) quick picks:

- If you want **local quantized FLUX.2** on Metal: start with `AbstractFramework/flux.2-klein-4b-4bit`, then use `AbstractFramework/flux.2-klein-4b-8bit` when quality is more important than memory.
- If you want a fast local FLUX.2 for iteration: `AbstractFramework/flux.2-klein-4b-4bit` through MLX-Gen is usually the most practical Apple Silicon starting point.
- If you want strong prompt following + text rendering: use exact MLX-Gen ids such as `AbstractFramework/qwen-image-2512-4bit` or `AbstractFramework/ernie-image-turbo-4bit`, select the matching `-8bit` repo when quality is more important than memory, or use `Qwen/Qwen-Image-2512` / `baidu/ERNIE-Image-Turbo` through Diffusers on `mps` when you want the full Diffusers path.

Recommended default (local, cross-platform) — Stable Diffusion 1.5:

```bash
pip install "abstractvision[diffusers]"
abstractvision download stable-diffusion --provider diffusers
export ABSTRACTVISION_BACKEND=diffusers
export ABSTRACTVISION_MODEL_ID=runwayml/stable-diffusion-v1-5
export ABSTRACTVISION_DIFFUSERS_DEVICE=auto
abstractvision cli
```

Then type a prompt (plain text runs `/t2i`), or use `/t2i "..." --open`.

Jump to detailed recipes:
- Stable Diffusion 1.5: section **1) First local image (Diffusers)**
- FLUX.2-klein-4B: section **2) Next small model (FLUX.2-klein-4B)**
- OpenAI-compatible HTTP: section **2.1) OpenAI-compatible HTTP**
- Apple Silicon MLX-Gen: section **2.2) Apple Silicon MLX-Gen (q4 first)**
- Qwen Image: section **3) Qwen Image (Diffusers)**
- FLUX 2 details: section **4) FLUX 2 (Diffusers)**
- SD3.5: section **5) Stable Diffusion 3.5 (Diffusers, gated)**

---

## 1) First local image (Diffusers)

The REPL is cache-only by default, so it will not download model weights. Download the model separately first:

```bash
abstractvision download stable-diffusion --provider diffusers
```

```bash
# Required for this local Diffusers recipe.
export ABSTRACTVISION_BACKEND=diffusers
export ABSTRACTVISION_MODEL_ID=runwayml/stable-diffusion-v1-5
export ABSTRACTVISION_DIFFUSERS_DEVICE=auto
# auto prefers cuda, then mps, then cpu. You can also set cuda/mps/cpu explicitly.
# Optional: override dtype (auto defaults to float16 on MPS for broad compatibility).
# - `float16` is usually the best speed/compatibility tradeoff on Apple Silicon
# - `bfloat16` can work for some models, but can trigger dtype-mismatch errors in some pipelines
# - `float32` is the most stable, but can require much more memory
# export ABSTRACTVISION_DIFFUSERS_TORCH_DTYPE=bfloat16
# export ABSTRACTVISION_DIFFUSERS_TORCH_DTYPE=float16
# export ABSTRACTVISION_DIFFUSERS_TORCH_DTYPE=float32
```

Quick sanity check (device):

```bash
python -c "import torch; print('mps', torch.backends.mps.is_available(), 'cuda', torch.cuda.is_available())"
```

If you have an NVIDIA GPU but `cuda` is `False`, you likely installed a CPU-only PyTorch build. Follow the PyTorch install guide to install a CUDA-enabled wheel, then re-run the sanity check: <https://pytorch.org/get-started/locally/>.

Start the interactive CLI (`abstractvision repl` remains an alias):

```bash
abstractvision cli
```

With `ABSTRACTVISION_BACKEND=diffusers` and `ABSTRACTVISION_MODEL_ID` set above, the REPL uses `runwayml/stable-diffusion-v1-5`:

```text
/set guidance_scale 7
/set seed 42
/t2i "a cinematic photo of a red fox in snow" --width 512 --height 512 --steps 10 --open
```

Change settings by changing `/set …` values, or pass flags per request:

```text
/t2i "a watercolor painting of a lighthouse" --width 512 --height 512 --steps 20 --seed 123 --guidance-scale 6.5 --open
```

---

## 2) Next small model (FLUX.2-klein-4B)

After Stable Diffusion 1.5 works, `black-forest-labs/FLUX.2-klein-4B` is the next recommended local test. It is
non-gated and much smaller than FLUX.2-dev, but it currently needs Diffusers from source because released Diffusers
may not include `Flux2KleinPipeline`.

```bash
pip install -U "abstractvision[diffusers-dev]"
pip install -U "git+https://github.com/huggingface/diffusers@main"
```

Quick REPL test:

```text
/backend diffusers black-forest-labs/FLUX.2-klein-4B mps float16
/t2i "a product photo of a matte black espresso machine" --width 1024 --height 1024 --steps 4 --guidance-scale 1.0 --open
```

Use `cuda float16` on NVIDIA, or `auto` if you want AbstractVision/Torch to pick the device.

---

## 2.1) OpenAI-compatible HTTP

Use this path if you already have a server that exposes OpenAI-shaped image endpoints (e.g. a local model server).

For unknown or local OpenAI-compatible servers, AbstractVision forwards local extension fields such as `steps`, `seed`, `guidance_scale`, `width`, and `height`. For the real OpenAI API and known GPT image models, it suppresses unsupported local-only fields and sends the narrower OpenAI request shape.

List provider-advertised models explicitly:

```bash
abstractvision provider-models --openai --task text_to_image
abstractvision provider-models --base-url http://localhost:1234/v1 --task text_to_image
```

One-shot (stores output via `LocalAssetStore` and prints an artifact ref + file path):

```bash
abstractvision t2i --base-url http://localhost:1234/v1 "a watercolor painting of a lighthouse" --width 512 --height 512 --steps 10 --open
```

Interactive CLI/REPL:

```bash
abstractvision cli
```

```text
/backend openai http://localhost:1234/v1
/t2i "a watercolor painting of a lighthouse" --width 512 --height 512 --steps 10 --open
```

If your server also supports video endpoints, configure them via `ABSTRACTVISION_TEXT_TO_VIDEO_PATH` / `ABSTRACTVISION_IMAGE_TO_VIDEO_PATH` (see [docs/reference/configuration.md](reference/configuration.md)).

---

## 2.2) MLX-Gen local (q4 first)

Use this path when you want local MLX-optimized image/video models without
running a separate server. AbstractVision validates MLX-Gen on Apple Silicon.
The `abstractvision[mlx-gen]` extra also installs on Linux, where it is not
validated yet (see [backlog 030](backlog/planned/030_gpu_parity_with_mlx_gen.md)); the `gpu` and `all-gpu` profiles do not
include it. AbstractVision uses the
`mlx-gen` Python API in-process and expects prepared model folders to exist in
the Hugging Face cache. It does not silently download weights during
generation.

```bash
pip install "abstractvision[models,mlx-gen]"
abstractvision catalog --provider mlx-gen
abstractvision download AbstractFramework/flux.2-klein-4b-4bit --provider mlx-gen
abstractvision download AbstractFramework/qwen-image-2512-4bit --provider mlx-gen
abstractvision download AbstractFramework/qwen-image-edit-2511-4bit --provider mlx-gen
abstractvision download AbstractFramework/ernie-image-turbo-4bit --provider mlx-gen
abstractvision download AbstractFramework/ernie-image-turbo-8bit --provider mlx-gen
abstractvision download briaai/FIBO --provider mlx-gen
abstractvision download briaai/Fibo-lite --provider mlx-gen
abstractvision download briaai/Fibo-Edit --provider mlx-gen
abstractvision download prism-ml/bonsai-image-ternary-4B-mlx-2bit --provider mlx-gen
abstractvision download Wan-AI/Wan2.2-TI2V-5B-Diffusers --provider mlx-gen
abstractvision download AbstractFramework/wan2.2-t2v-a14b-diffusers-8bit --provider mlx-gen
abstractvision download AbstractFramework/wan2.2-i2v-a14b-diffusers-8bit --provider mlx-gen
abstractvision download AbstractFramework/seedvr2-3b-8bit --provider mlx-gen
```

The default prepared choices are q4 repos from the
[AbstractFramework/mlx-gen Hugging Face collection](https://huggingface.co/collections/AbstractFramework/mlx-gen/).
Select q8 variants by passing the exact `AbstractFramework/...-8bit` model id
when quality is paramount and memory permits it. Quantization is part of the
published model folder, not a generation-time parameter.
Qwen and ERNIE q4 folders can mix q4 and q8 components, but remain the default
prepared choice.
Bonsai ternary is different: `prism-ml/bonsai-image-ternary-4B-mlx-2bit` is a
pre-packed MLX checkpoint consumed directly by MLX-Gen. Use the exact repo id,
keep guidance at 1.0, and do not use it for image-to-image.
SeedVR2 uses the official `ByteDance-Seed/SeedVR2-3B` and
`ByteDance-Seed/SeedVR2-7B` bases plus canonical prepared packages:
`AbstractFramework/seedvr2-3b-8bit` is the default upscaler,
`AbstractFramework/seedvr2-7b-8bit` is the larger q8 variant, and q4 variants
are available for tighter memory. The default upscale request uses
`--resolution 2x` and `--softness 0.25`; pass `--resolution <pixels>` for a
target short edge. `--scale 2x` remains accepted when `--resolution` is omitted.
Runtime `--quantize` is only needed for official/source weights.

One-shot shell commands store the output in the local asset store and print the
artifact ref followed by the local content path. Add `--open` to open the output
after generation, or `--store-dir <dir>` to select the store directory.

Text-to-image from the shell:

```bash
abstractvision t2i --provider mlx-gen --model AbstractFramework/qwen-image-2512-4bit "a studio product photo of a white ceramic mug with the AbstractFramework logo" --steps 20 --guidance-scale 1.0 --open
abstractvision t2i --provider mlx-gen --model prism-ml/bonsai-image-ternary-4B-mlx-2bit "a bonsai tree in a quiet ceramic studio" --steps 4 --guidance-scale 1.0 --open
```

Image-to-image/edit from the shell:

```bash
abstractvision i2i --provider mlx-gen --model AbstractFramework/qwen-image-edit-2511-4bit --image ./input.png "replace the background with a clean white studio setup" --steps 20 --guidance-scale 2.5 --strength 0.75 --open
abstractvision i2i --provider mlx-gen --model briaai/Fibo-Edit --image ./input.png "remove the background and keep the object edges clean" --steps 20 --guidance-scale 4.0 --open
```

Masked edit from the shell:

```bash
abstractvision i2i --provider mlx-gen --model AbstractFramework/qwen-image-edit-2511-8bit --image ./input.png --mask ./mask.png "replace only the masked region with a brushed steel panel" --steps 20 --guidance-scale 4.0 --open
```

Image upscaling from the shell:

```bash
abstractvision upscale --provider mlx-gen --model AbstractFramework/seedvr2-3b-8bit --image ./input.png --resolution 2x --softness 0.25 --open
```

Text-to-video and first-frame image-to-video from the shell:

```bash
abstractvision t2v --provider mlx-gen --model AbstractFramework/wan2.2-t2v-a14b-diffusers-8bit "a red fox walking through a snowy forest, cinematic" --width 480 --height 240 --frames 41 --fps 10 --steps 20 --guidance-scale 4.0 --guidance-2 3.0 --open
abstractvision i2v --provider mlx-gen --model AbstractFramework/wan2.2-i2v-a14b-diffusers-8bit --image ./first-frame.png "slow camera push-in" --width 480 --height 240 --frames 41 --fps 10 --steps 20 --guidance-scale 3.5 --guidance-2 3.5 --open
```

Wan 2.2 A14B uses 16px width/height multiples; `480x240` is valid for low-cost
local checks, while larger native sizes are more appropriate for quality review.
Leave out `--width/--height/--frames/--fps/--steps` to use each model's default
(832x480 for every Wan model; 121 frames at 24 fps for TI2V-5B, 81 frames at
16 fps for A14B). The measured memory per size is in
[docs/faq.md](faq.md#how-much-memory-does-wan-video-need).
`--control-image` on `t2i` runs on MLX-Gen's `AbstractFramework/qwen-image-8bit`
only; every other model and backend refuses it. For masked edits, use the validated Qwen edit route
`AbstractFramework/qwen-image-edit-2511-8bit` (or FIBO Edit, FLUX.2 klein, Z-Image Turbo) and pass
`--mask`.

Shared LoRA adapters:

```bash
abstractvision t2i \
  --provider mlx-gen \
  --model AbstractFramework/qwen-image-2512-8bit \
  --lora prithivMLmods/Qwen-Image-2512-Pixel-Art-LoRA:Qwen-Image-2512-Master-Pixel-Art-LoRA.safetensors \
  --lora-scale 1.0 \
  --steps 20 \
  --guidance-scale 5.0 \
  --progress \
  "Pixel art astronaut floating above Earth"

abstractvision i2i \
  --provider mlx-gen \
  --model AbstractFramework/qwen-image-edit-2511-8bit \
  --image ./input.png \
  --lora fal/Qwen-Image-Edit-2511-Multiple-Angles-LoRA:qwen-image-edit-2511-multiple-angles-lora.safetensors \
  --lora-scale 0.9 \
  --steps 6 \
  --guidance-scale 4.0 \
  --progress \
  "Use the source subject as the same object. <sks> back view low-angle shot wide shot."

abstractvision t2v \
  --provider mlx-gen \
  --model AbstractFramework/wan2.2-ti2v-5b-diffusers-8bit \
  --lora AlekseyCalvin/HSToric_Color_Wan2.2_5B_LoRA_BySilverAgePoets:HSToric_color_Wan22_5b_LoRA.safetensors \
  --lora-scale 0.8 \
  --lora-target-role transformer \
  --width 832 \
  --height 480 \
  --frames 17 \
  --fps 16 \
  --steps 20 \
  --flow-shift 3.0 \
  --progress \
  "HST style HD film, early 1900s, autochrome, analog cinema. A horse-drawn carriage crossing a snowy town square at dusk, pedestrians in wool coats, historical street lamps glowing, gentle cinematic motion."
```

Use provider/model discovery to check the route before a long LoRA run.
Use `abstractvision catalog --provider mlx-gen` to browse downloadable models,
then `abstractvision show-model <model-id>` for the exact runtime route
contract. Use `abstractvision adapters --provider mlx-gen --model <model-id> --task <task>`
to list locally cached overlays for one route. MLX-Gen route rows surface
`supports_lora`, `lora_status`, `lora_target_roles`, and
`lora_validation_profile`.

Batch generation:

```bash
abstractvision t2i \
  --provider mlx-gen \
  --model AbstractFramework/qwen-image-2512-8bit \
  --count 2 \
  --seeds 2512,2513 \
  --lora prithivMLmods/Qwen-Image-2512-Pixel-Art-LoRA:Qwen-Image-2512-Master-Pixel-Art-LoRA.safetensors \
  --lora-scale 1.0 \
  --width 768 \
  --height 768 \
  --steps 20 \
  --guidance-scale 5.0 \
  --progress \
  "Pixel art isometric research outpost on an icy exoplanet at blue hour, tiny service drones, crisp tiles, retro RPG palette"
```

Video examples (5s MP4):

<div class="af_media_carousel" aria-label="AbstractVision text-to-video examples">
  <button class="af_media_carousel__btn af_media_carousel__btn--prev" type="button" aria-label="Previous video">‹</button>
  <div class="af_media_carousel__track" tabindex="0">
    <figure class="af_media_carousel__item">
      <video class="af_media_carousel__video" controls muted playsinline loop preload="metadata">
        <source src="../assets/videos/video-river.mp4" type="video/mp4" />
      </video>
      <figcaption class="af_media_carousel__caption"><strong>River</strong> — smooth, clean motion (5s)</figcaption>
    </figure>
    <figure class="af_media_carousel__item">
      <video class="af_media_carousel__video" controls muted playsinline loop preload="metadata">
        <source src="../assets/videos/video-space.mp4" type="video/mp4" />
      </video>
      <figcaption class="af_media_carousel__caption"><strong>Space</strong> — cinematic scene (5s)</figcaption>
    </figure>
    <figure class="af_media_carousel__item">
      <video class="af_media_carousel__video" controls muted playsinline loop preload="metadata">
        <source src="../assets/videos/t2v-example.mp4" type="video/mp4" />
      </video>
      <figcaption class="af_media_carousel__caption"><strong>T2V example</strong> — prior sample (5s)</figcaption>
    </figure>
  </div>
  <button class="af_media_carousel__btn af_media_carousel__btn--next" type="button" aria-label="Next video">›</button>
</div>

MLX-Gen image generation/edit commands accept `--progress` for step progress.
MLX-Gen upscale and video commands print denoise-step progress by default;
video events also include frame context while the video is running. Use
`--no-progress` for quiet video or upscaling scripts. A complete local example
gallery with commands and bundled outputs is available in
[MLX-Gen local examples](mlx-gen-local-examples.md).

Interactive CLI/REPL (`abstractvision cli`; `abstractvision repl` remains an
alias) uses the same backend and request normalization:

```text
/backend mlx-gen AbstractFramework/flux.2-klein-4b-4bit
/t2i "a product photo of a matte black espresso machine" --steps 4 --guidance-scale 1.0 --open

/backend mlx-gen AbstractFramework/qwen-image-edit-2511-4bit
/i2i --image ./input.png "make it watercolor" --steps 20 --guidance-scale 2.5 --open

/backend mlx-gen briaai/FIBO
/t2i "a studio product photo of a white ceramic mug with the AbstractFramework logo" --steps 50 --guidance-scale 4.0 --open

/backend mlx-gen prism-ml/bonsai-image-ternary-4B-mlx-2bit
/t2i "a bonsai tree in a quiet ceramic studio" --steps 4 --guidance-scale 1.0 --open

/backend mlx-gen AbstractFramework/wan2.2-t2v-a14b-diffusers-8bit
/t2v "a red fox walking through a snowy forest, cinematic" --width 432 --height 240 --frames 41 --fps 10 --steps 20 --guidance-scale 4.0 --guidance-2 3.0 --open
/backend mlx-gen AbstractFramework/wan2.2-i2v-a14b-diffusers-8bit
/i2v --image ./first-frame.png "slow camera push-in" --width 432 --height 240 --frames 41 --fps 10 --steps 20 --guidance-scale 3.5 --guidance-2 3.5 --open
```

Interactive `/t2v` and `/i2v` use the same default progress display; add
`--no-progress` to suppress it.

Legacy `mflux` provider names and routed ids still work as aliases, but new
configuration should use `mlx-gen`.

---

## 3) Qwen Image (Diffusers)

Qwen Image models in the registry:

- `Qwen/Qwen-Image` (older)
- `Qwen/Qwen-Image-2512` (newer)

Use the same Diffusers flow:

```text
/backend diffusers Qwen/Qwen-Image-2512 mps float16
/t2i "a poster with the word 'ABSTRACT' rendered perfectly in bold typography" --width 512 --height 512 --steps 10 --guidance-scale 2.5 --open
```

Notes:
- Qwen Image models are **large**.
- For best results, prefer the model card’s recommended sizes (e.g. 1328x1328 for 1:1). For quick tests, 512x512 is fine.
- On Apple Silicon (MPS), start with fp16 (default; best compatibility):
  - `ABSTRACTVISION_DIFFUSERS_TORCH_DTYPE=float16` (or in the REPL: `/backend diffusers Qwen/Qwen-Image-2512 mps float16`)
- If you get NaNs/black images, try fp32 (this can require **very** large peak memory during load):
  - `ABSTRACTVISION_DIFFUSERS_TORCH_DTYPE=float32` (or in the REPL: `/backend diffusers Qwen/Qwen-Image-2512 mps float32`)
- On Apple Silicon (MPS), AbstractVision upcasts the VAE to fp32 when using fp16 to avoid common “black image” issues.
- Automatic fp32 retry on all-black output is enabled by default on MPS (can increase peak memory):
  - disable with `ABSTRACTVISION_DIFFUSERS_AUTO_RETRY_FP32=0`
- In AbstractVision, `--guidance-scale` is mapped to Qwen’s `true_cfg_scale` when using Qwen pipelines (CFG). If you set `--guidance-scale` but don’t provide a `negative_prompt`, AbstractVision passes a placeholder negative prompt (`" "`) so CFG is actually enabled.

Tip: keep `guidance_scale` relatively low for some modern DiT models.

---

## 3.1) LoRA + Rapid-AIO (Diffusers)

AbstractVision can apply LoRA adapters (Diffusers adapter system) and optionally swap in a distilled “Rapid-AIO”
transformer for faster Qwen Image Edit inference.

These features follow the Diffusers download setting. The REPL is cache-only by default, so pre-download adapters or
Rapid-AIO weights separately before using repo ids here. If you intentionally want runtime downloads, set:

```bash
export ABSTRACTVISION_DIFFUSERS_ALLOW_DOWNLOAD=1
```

Tip: Qwen Image Edit pipelines often default to a ~1MP output resolution when `width`/`height` are omitted. AbstractVision
defaults to the input image size for image-to-image edits to avoid unexpected memory spikes. To request a specific output
resolution, pass `--width`/`--height` flags in the REPL (forwarded via `request.extra`) or set them in the playground
Extra JSON field.

LoRA example (REPL; prefer the shared adapter flags):

```text
/backend diffusers Qwen/Qwen-Image-Edit-2511 mps bfloat16
/i2i --image ./input.png "make it watercolor" --steps 8 --guidance-scale 1 --lora lightx2v/Qwen-Image-Edit-2511-Lightning --lora-scale 1.0 --open
```

Rapid-AIO example (distilled transformer override; Qwen Image Edit):

```text
/backend diffusers Qwen/Qwen-Image-Edit-2511 mps bfloat16
/i2i --image ./input.png "make it watercolor" --steps 4 --guidance-scale 1 --rapid_aio_repo linoyts/Qwen-Image-Edit-Rapid-AIO --open
```

---

## 4) FLUX 2 (Diffusers)

FLUX 2 models in the registry:

- `black-forest-labs/FLUX.2-klein-4B` (Apache-2.0, not gated)
- `black-forest-labs/FLUX.2-klein-9B` (non-commercial license, gated on Hugging Face)
- `black-forest-labs/FLUX.2-dev` (non-commercial license, gated on Hugging Face)

Sanity check:

```bash
python -c "import diffusers; print(diffusers.__version__)"
```

Notes:
- `FLUX.2-dev` uses Diffusers `Flux2Pipeline` and works on released Diffusers (0.36+).
- `FLUX.2-klein-4B` and `FLUX.2-klein-9B` use `Flux2KleinPipeline`, which is not available in the released Diffusers (0.36.0). It currently
  requires installing Diffusers from source (with the `diffusers-dev` extra for compatible dependency pins):
  - `pip install -U "abstractvision[diffusers-dev]"`
  - `pip install -U "git+https://github.com/huggingface/diffusers@main"`

Recommended first FLUX example (`FLUX.2-klein-4B`, not gated):

```text
/backend diffusers black-forest-labs/FLUX.2-klein-4B mps float16
/t2i "a product photo of a matte black espresso machine" --width 1024 --height 1024 --steps 4 --guidance-scale 1.0 --seed 0 --open
```

Example (`FLUX.2-klein-9B`, gated; requires Diffusers `main` and HF access):

```text
/backend diffusers black-forest-labs/FLUX.2-klein-9B mps float16
/t2i "a minimalist product photo of a matte black espresso machine, studio lighting" --width 1024 --height 1024 --steps 4 --guidance-scale 1.0 --seed 0 --open
```

Example (`FLUX.2-dev`, gated; you must pre-download it into your HF cache first):

```text
/backend diffusers black-forest-labs/FLUX.2-dev mps
/t2i "a minimalist product photo of a matte black espresso machine, studio lighting" --width 1024 --height 1024 --steps 4 --guidance-scale 1.0 --seed 0 --open
```

If you use gated models (like `FLUX.2-dev`), you typically must accept the model’s terms on Hugging Face and set `HF_TOKEN` in your environment.

---

## 5) Stable Diffusion 3.5 (Diffusers, gated)

SD3.5 models (all gated on Hugging Face):

- `stabilityai/stable-diffusion-3.5-large-turbo`
- `stabilityai/stable-diffusion-3.5-large`
- `stabilityai/stable-diffusion-3.5-medium`

1) Accept the model terms on Hugging Face (in your browser).  
2) Export a token:

```bash
export HF_TOKEN=...   # your Hugging Face access token
```

Then in the REPL:

```text
/backend diffusers stabilityai/stable-diffusion-3.5-large-turbo mps
/t2i "a modern product photo of a watch, studio lighting" --width 1024 --height 1024 --steps 6 --guidance-scale 4 --seed 42 --open
```

Turbo models are usually best with low step counts (e.g. ~4–8).

---

## 6) GGUF diffusion models (stable-diffusion.cpp)

If you downloaded a GGUF diffusion model (like Qwen Image GGUF or FLUX.2 GGUF), Diffusers cannot load it. Use the stable-diffusion.cpp backend instead (either via pip-installed python bindings or `sd-cli`).

### 6.1 Install stable-diffusion.cpp runtime

The base `pip install abstractvision` path does not install local inference runtimes. Use one of these explicit stable-diffusion.cpp runtime choices:

```bash
pip install "abstractvision[sdcpp]"
```

This pip binding path is convenient, but it may require a native build or run **CPU-only** depending on how the wheel was built.

Alternative (external executable):

- Download `sd-cli` from: <https://github.com/leejet/stable-diffusion.cpp/releases>
- Ensure `sd-cli` is in your `PATH` (or pass a full path as the last arg to `/backend sdcpp …`).

On macOS (Apple Silicon), **`sd-cli` is the recommended path** to get **Metal** acceleration. If you see `Using CPU backend`,
install `sd-cli` and re-run in CLI mode.

### 6.2 Single-file Stable Diffusion model

This is the lowest-friction `sdcpp` shape: one model file plus an optional `sd-cli` path. Use it for Stable Diffusion
1.x/2.x/SDXL checkpoints or GGUF conversions that stable-diffusion.cpp can load as `--model`.

```bash
abstractvision cli
```

```text
/backend sdcpp /path/to/sd-v1-5.gguf /path/to/sd-cli
/t2i "a watercolor painting of a lighthouse" --width 512 --height 512 --steps 10 --open
```

If `sd-cli` is already in your `PATH`, you can omit the final `/path/to/sd-cli` argument. If it is not available,
AbstractVision falls back to `stable-diffusion-cpp-python` when that package is installed, for example through `pip install "abstractvision[sdcpp]"`.

### 6.3 Curated `sdcpp` bundles

For Qwen Image and FLUX GGUF, external users should not have to manually locate a VAE or text encoder.
Download the curated bundle once, then use the model key everywhere:

```bash
abstractvision download qwen-image --provider sdcpp
abstractvision download flux2-klein-base-4b --provider sdcpp
```

AbstractVision resolves the required side artifacts from the Hugging Face cache automatically:

- CLI one-shot: `abstractvision t2i --provider sdcpp --model flux2-klein-base-4b "..."`
- REPL: `/backend sdcpp flux2-klein-base-4b /path/to/sd-cli`
- Playground / AbstractCore plugin: set the model key and let the package resolve the cached bundle

If a required companion file is missing, the package now fails early with a precise `download ... --provider sdcpp`
hint instead of starting generation and then failing deep in the runtime.

### 6.4 Run Qwen Image with `sdcpp`

```bash
abstractvision cli
```

Then:

```text
/backend sdcpp qwen-image /path/to/sd-cli
/set width 1024
/set height 1024
/t2i "a cinematic photo of a red fox in snow" --sampling-method euler --offload-to-cpu --diffusion-fa --flow-shift 3 --open
```

Any extra `--flag` you pass (like `--sampling-method euler`) is forwarded to the backend as `extra`.
- CLI mode: forwarded to `sd-cli`
- Python bindings mode: keys are mapped to python binding kwargs when supported; unsupported keys are ignored (see [`../src/abstractvision/backends/stable_diffusion_cpp.py`](../src/abstractvision/backends/stable_diffusion_cpp.py))
- Diffusers backend: only forwards kwargs that the pipeline `__call__` accepts; unknown keys are ignored (see [`../src/abstractvision/backends/huggingface_diffusers.py`](../src/abstractvision/backends/huggingface_diffusers.py))

### 6.5 FLUX.2-klein-4B / FLUX.2-klein-base-4B (GGUF) example

The curated `sdcpp` presets now download the main GGUF plus the required companion artifacts and let you refer to the
model by key afterward.

Example:

```text
/backend sdcpp flux2-klein-base-4b /path/to/sd-cli
/t2i "a product photo of a matte black espresso machine" --steps 4 --guidance-scale 1.0 --sampling-method euler --diffusion-fa --offload-to-cpu --open
```

Advanced/manual mode is still supported if you want to wire explicit component paths yourself:

```text
/backend sdcpp /path/to/flux-2-klein-base-4b-Q8_0.gguf /path/to/vae/diffusion_pytorch_model.safetensors /path/to/Qwen3-4B-Q4_K_M.gguf /path/to/sd-cli
```

FLUX.2-dev and Qwen Image GGUF are still heavier follow-ups, but the single-file Stable Diffusion path or the curated
klein bundle above should be the first local test on a fresh machine.

---

## 7) Web UI testing (optional): Playground

This repo includes a self-contained web UI and local API server. It is owned by
AbstractVision and does not require AbstractCore. Treat it as a local/dev
testing surface; use AbstractCore/Gateway for production routing,
authentication, and browser-origin policy.

### 7.1 Start the playground

```bash
abstractvision playground --port 8091
```

Open:

- `http://127.0.0.1:8091/vision_playground.html`

In the UI:
- The API Base URL defaults to the same process that serves the page
- Each task tab has its own model selector and unload button
- Switching models in a tab unloads the previously active backend first to free memory before the replacement model is loaded
- Generate (T2I), upload an input image (I2I), or inspect video-capable backend status. The Playground is still a dev surface; prefer the shell/REPL or AbstractCore for MLX-Gen Wan video smoke tests.

For the endpoint list, see `playground/README.md`.

### 7.2 Local text→video status

The packaged local Diffusers `text_to_video` groundwork remains experimental and
is currently disabled from the normal local surfaces. The practical local Apple
Silicon video path is MLX-Gen Wan 2.2, preferably the task-specific A14B
packages when memory allows.

Current policy:
- use `abstractvision t2v --provider mlx-gen --model AbstractFramework/wan2.2-t2v-a14b-diffusers-8bit` and `abstractvision i2v --provider mlx-gen --model AbstractFramework/wan2.2-i2v-a14b-diffusers-8bit` for local Apple Silicon Wan A14B video;
- use the OpenAI-compatible backend when video is served remotely; and
- keep Diffusers local video behind the experimental follow-up in [`docs/backlog/planned/0023_local_runtime_capability_quarantine_for_glm_mflux_and_t2v.md`](backlog/planned/0023_local_runtime_capability_quarantine_for_glm_mflux_and_t2v.md).
--- >8 --- END FILE: docs/getting-started.md --- >8 ---

--- 8< --- FILE: docs/mlx-gen-local-examples.md --- 8< ---
# MLX-Gen local examples

This page records the current bundled proof runs for the MLX-Gen backend in
AbstractVision.

All assets referenced here were generated through AbstractVision with
`mlx-gen 0.18.19` and copied into
[`docs/assets/mlx-gen-lora-examples/`](assets/mlx-gen-lora-examples/).

## What this page validates

- AbstractVision uses one shared LoRA adapter contract across
  `text_to_image`, `image_to_image`, `text_to_video`, and `image_to_video`:
  `LoRAAdapterSpec(...)` / `lora_adapters=[...]`.
- The same surface supports base runs, single-adapter runs, and stacked-adapter
  runs.
- AbstractVision exposes a simple public batch surface above the exact
  single-request dataclasses:
  `generate_image_batch(...)`, `edit_image_batch(...)`,
  `generate_video_batch(...)`, and `image_to_video_batch(...)`, plus CLI
  `--count` / `--seeds`.
- Provider-model discovery surfaces route truth through `supports_lora`,
  `lora_status`, `lora_target_roles`, and `lora_validation_profile`.
- Installed adapter discovery is backend-owned and lists optional overlays only;
  full-model component files are excluded from the adapter inventory.
- The MLX-Gen surface exposes route-aware Qwen masked edit through a typed
  request field instead of an `extra`-only escape hatch; it runs a structured
  control image (`control_image`) on `AbstractFramework/qwen-image-8bit` only.
- The public TI2V-5B visual proofs in this bundle use `832x480`.
- The public task-specific Wan A14B proofs in this bundle use `480x240`.
- The LoRA-heavy proof runs on this page use curated 8-bit MLX-Gen routes. For
  local Qwen and Wan Lightning work, q8 is the preferred prepared route when
  memory allows; q4 remains available for tighter memory budgets.
- The current AbstractVision MLX runtime floor is
  `mlx-gen>=0.40.3,<0.41.0`, with `mlx>=0.32.4` on macOS.

MLX-Gen is validated on Apple Silicon, and the proof assets on this page are
Apple validations. The explicit `mlx-gen` extra also installs on Linux (upstream
pulls `mlx[cuda13]` there), where it is not validated yet (see
[backlog 030](backlog/planned/030_gpu_parity_with_mlx_gen.md)). The NVIDIA/Linux `gpu` and `all-gpu` profiles do not
include MLX-Gen.

## Install and discovery

Install the MLX-Gen extra:

```bash
pip install "abstractvision[mlx-gen]"
```

Inspect the local MLX-Gen catalog before long runs:

```bash
abstractvision catalog --provider mlx-gen
abstractvision show-model AbstractFramework/qwen-image-edit-2509-8bit
abstractvision show-model AbstractFramework/wan2.2-ti2v-5b-diffusers-8bit
abstractvision show-model AbstractFramework/wan2.2-t2v-a14b-diffusers-8bit
abstractvision adapters --provider mlx-gen --model AbstractFramework/qwen-image-edit-2509-8bit --task image_to_image
abstractvision adapters --provider mlx-gen --model AbstractFramework/flux.2-klein-9b-8bit --task image_to_image
abstractvision adapters --provider mlx-gen --model AbstractFramework/wan2.2-ti2v-5b-diffusers-8bit --task text_to_video
abstractvision adapters --provider mlx-gen --model AbstractFramework/wan2.2-i2v-a14b-diffusers-8bit --task image_to_video
```

Use `catalog` to browse downloadable models. Use `show-model` when you need
the exact runtime route contract, including default parameters such as
`flow_shift`. Use `adapters` when you need locally cached overlays that match
one route.

If you manually experiment outside the curated AbstractVision routes, note the
upstream LightX2V Qwen Lightning guidance: do not pair a BF16-trained Qwen
Lightning LoRA with the raw unscaled FP8 Qwen base
(`qwen_image_fp8_e4m3fn.safetensors`). That upstream mix can produce grid
artifacts. Reference:
<https://github.com/ModelTC/LightX2V-Qwen-Image-Lightning#-using-lightning-loras-with-fp8-models>

Bundled discovery artifacts:

- [provider_adapters_qwen2512_t2i.json](assets/mlx-gen-lora-examples/provider_adapters_qwen2512_t2i.json)
- [provider_adapters_qwen2509_i2i.json](assets/mlx-gen-lora-examples/provider_adapters_qwen2509_i2i.json)
- [provider_adapters_wan_ti2v_t2v.json](assets/mlx-gen-lora-examples/provider_adapters_wan_ti2v_t2v.json)
- [provider_adapters_wan_a14b_t2v.json](assets/mlx-gen-lora-examples/provider_adapters_wan_a14b_t2v.json)
- [provider_adapters_wan_a14b_i2v.json](assets/mlx-gen-lora-examples/provider_adapters_wan_a14b_i2v.json)
- [show_model_wan_ti2v_5b.txt](assets/mlx-gen-lora-examples/show_model_wan_ti2v_5b.txt)
- [show_model_wan_a14b_t2v.txt](assets/mlx-gen-lora-examples/show_model_wan_a14b_t2v.txt)
- [summary.json](assets/mlx-gen-lora-examples/summary.json)

## Route-aware Qwen extras

The public request surface exposes the validated Qwen MLX-Gen masked edit
directly:

- masked edit:
  `abstractvision i2i --provider mlx-gen --model AbstractFramework/qwen-image-edit-2511-8bit --image ./input.png --mask ./mask.png "repair the marked area"`

A mask fails closed when the selected route does not advertise the matching
runtime capability. A structured control image (`--control-image`) runs on
`AbstractFramework/qwen-image-8bit` only and is refused on every other model.

## Shared adapter contract

In Python, use the typed request surface:

```python
from abstractvision import LoRAAdapterSpec, VisionManager
from abstractvision.backends import MLXGenBackendConfig, MLXGenVisionBackend

backend = MLXGenVisionBackend(
    config=MLXGenBackendConfig(model="AbstractFramework/qwen-image-2512-8bit")
)
t2i = VisionManager(backend=backend, model_id="AbstractFramework/qwen-image-2512-8bit")
assets = t2i.generate_image_batch(
    "Pixel art isometric research outpost on an icy exoplanet at blue hour",
    count=2,
    seeds=[2512, 2513],
    width=768,
    height=768,
    steps=20,
    guidance_scale=5.0,
    lora_adapters=[
        LoRAAdapterSpec(
            source="prithivMLmods/Qwen-Image-2512-Pixel-Art-LoRA:Qwen-Image-2512-Master-Pixel-Art-LoRA.safetensors",
            scale=1.0,
        )
    ],
)

edit_backend = MLXGenVisionBackend(
    config=MLXGenBackendConfig(model="AbstractFramework/qwen-image-edit-2509-8bit")
)
i2i = VisionManager(backend=edit_backend, model_id="AbstractFramework/qwen-image-edit-2509-8bit")
edited = i2i.edit_image(
    "Re-render the same vehicle from behind and slightly above.",
    image=open("./input.png", "rb").read(),
    steps=8,
    guidance_scale=1.0,
    lora_adapters=[
        LoRAAdapterSpec(
            source="lightx2v/Qwen-Image-Lightning:Qwen-Image-Edit-2509/Qwen-Image-Edit-2509-Lightning-8steps-V1.0-bf16.safetensors",
            scale=1.0,
        ),
        LoRAAdapterSpec(
            source="dx8152/Qwen-Edit-2509-Multiple-angles:镜头转换.safetensors",
            scale=0.9,
        ),
    ],
)
```

In the CLI, the equivalent surface is repeated `--lora*` flags. Passing no
LoRA flags keeps the base-model route. Passing one or more adapter flags stacks
them in order.

## FLUX.2 klein 9B edit with the consistency LoRA

[`dx8152/Flux2-Klein-9B-Consistency`](https://huggingface.co/dx8152/Flux2-Klein-9B-Consistency)
is an image-to-image LoRA for FLUX.2 klein 9B that improves the consistency of
edits (apache-2.0, no trigger word). Use its V2 file, the one the author
recommends; MLX-Gen validated it on `AbstractFramework/flux.2-klein-9b-8bit`'s
edit route (`flux2.edit`). The author gives no scale, so the examples leave the
default. Fetch it (the whole repository, both files, into the Hugging Face
cache) and check that the model lists it:

```bash
abstractvision download dx8152/Flux2-Klein-9B-Consistency
abstractvision adapters --provider mlx-gen --model AbstractFramework/flux.2-klein-9b-8bit --task image_to_image
```

```bash
abstractvision i2i \
  --provider mlx-gen \
  --model AbstractFramework/flux.2-klein-9b-8bit \
  --image ./cat.png \
  --lora dx8152/Flux2-Klein-9B-Consistency:Flux2-Klein-9B-consistency-V2.safetensors \
  "Turn this cat into a dog."
```

```python
from pathlib import Path

from abstractvision import LoRAAdapterSpec, VisionManager
from abstractvision.backends import MLXGenBackendConfig, MLXGenVisionBackend

klein = MLXGenVisionBackend(config=MLXGenBackendConfig(model="AbstractFramework/flux.2-klein-9b-8bit"))
edited = VisionManager(backend=klein).edit_image(
    "Turn this cat into a dog.",
    image=Path("./cat.png").read_bytes(),
    lora_adapters=[
        LoRAAdapterSpec(source="dx8152/Flux2-Klein-9B-Consistency:Flux2-Klein-9B-consistency-V2.safetensors")
    ],
)
```

A plain edit runs the `flux2.edit` route. The adapter also attaches to the other
routes whose rows take a LoRA (multi-reference, masked edit, outpaint); the
latent route (`image_strength`) and reframe take none and refuse it.

## Proof bundle

The proof manifest for the runs below is
[summary.json](assets/mlx-gen-lora-examples/summary.json).

![MLX-Gen proof table](assets/mlx-gen-lora-examples/proof_table.png)

| Proof | Model | Feature exercised | Output |
| --- | --- | --- | --- |
| Batch T2I x2 | `AbstractFramework/qwen-image-2512-8bit` | `--count 2`, explicit seeds, one LoRA | [contact sheet](assets/mlx-gen-lora-examples/t2i_qwen2512_pixel_art_batch_contact_sheet.png) |
| Stacked I2I | `AbstractFramework/qwen-image-edit-2509-8bit` | two LoRAs stacked on one edit run | [input](assets/mlx-gen-lora-examples/i2i_qwen2509_stacked_loras_input.png) / [PNG](assets/mlx-gen-lora-examples/i2i_qwen2509_stacked_loras.png) |
| TI2V visual proof | `AbstractFramework/wan2.2-ti2v-5b-diffusers-8bit` | validated `832x480` TI2V LoRA route | [MP4](assets/mlx-gen-lora-examples/t2v_wan_ti2v5b_hstoric_832x480.mp4) / [contact sheet](assets/mlx-gen-lora-examples/t2v_wan_ti2v5b_hstoric_832x480_contact_sheet.png) |
| Batch T2V x2 | `AbstractFramework/wan2.2-ti2v-5b-diffusers-8bit` | `--count 2`, explicit seeds, zero LoRAs | [contact sheet](assets/mlx-gen-lora-examples/t2v_batch_wan_ti2v5b_832x480_contact_sheet.png) |
| A14B T2V | `AbstractFramework/wan2.2-t2v-a14b-diffusers-8bit` | task-specific route, paired Lightning LoRAs | [MP4](assets/mlx-gen-lora-examples/t2v_wan_a14b_lightning_480x240.mp4) / [contact sheet](assets/mlx-gen-lora-examples/t2v_wan_a14b_lightning_480x240_contact_sheet.png) |
| A14B I2V | `AbstractFramework/wan2.2-i2v-a14b-diffusers-8bit` | task-specific route, paired Lightning LoRAs | [input](assets/mlx-gen-lora-examples/i2v_wan_a14b_lightning_480x240_input.png) / [MP4](assets/mlx-gen-lora-examples/i2v_wan_a14b_lightning_480x240.mp4) |

The public first-frame `image_to_video` proof in this bundle uses the
task-specific Wan A14B route. TI2V-5B `image_to_video` remains supported
through the same runtime surface, but the bundle keeps only the validated
public proofs that held up visually at the supported sizes.

## Exact commands used

### Batch text to image: Qwen Image 2512 + pixel-art LoRA

```bash
PYTHONPATH=src python -m abstractvision.cli t2i \
  --provider mlx-gen \
  --model AbstractFramework/qwen-image-2512-8bit \
  --store-dir <store> \
  --width 768 \
  --height 768 \
  --steps 20 \
  --guidance-scale 5.0 \
  --count 2 \
  --seeds 2512,2513 \
  --lora prithivMLmods/Qwen-Image-2512-Pixel-Art-LoRA:Qwen-Image-2512-Master-Pixel-Art-LoRA.safetensors \
  --lora-scale 1.0 \
  --progress \
  "Pixel art isometric research outpost on an icy exoplanet at blue hour, tiny service drones, crisp tiles, retro RPG palette"
```

Outputs:

- [seed 2512](assets/mlx-gen-lora-examples/t2i_qwen2512_pixel_art_batch_seed2512.png)
- [seed 2513](assets/mlx-gen-lora-examples/t2i_qwen2512_pixel_art_batch_seed2513.png)
- [progress log](assets/mlx-gen-lora-examples/t2i_batch_qwen2512_pixel_art.progress.log)

### Image to image: Qwen Image Edit 2509 + stacked LoRAs

```bash
PYTHONPATH=src python -m abstractvision.cli i2i \
  --provider mlx-gen \
  --model AbstractFramework/qwen-image-edit-2509-8bit \
  --store-dir <store> \
  --image ./input.png \
  --steps 8 \
  --guidance-scale 1.0 \
  --seed 9701 \
  --lora lightx2v/Qwen-Image-Lightning:Qwen-Image-Edit-2509/Qwen-Image-Edit-2509-Lightning-8steps-V1.0-bf16.safetensors \
  --lora dx8152/Qwen-Edit-2509-Multiple-angles:镜头转换.safetensors \
  --lora-scale 1.0 \
  --lora-scale 0.9 \
  --progress \
  "Use the source starfighter as the same object. Re-render it from behind and slightly above, banking left over the snowy canyon, keeping the same vehicle identity and environment."
```

Artifacts:

- [input image](assets/mlx-gen-lora-examples/i2i_qwen2509_stacked_loras_input.png)
- [edited image](assets/mlx-gen-lora-examples/i2i_qwen2509_stacked_loras.png)
- [metadata](assets/mlx-gen-lora-examples/i2i_qwen2509_stacked_loras.meta.json)
- [progress log](assets/mlx-gen-lora-examples/i2i_qwen2509_stacked_loras.progress.log)

### Text to video: TI2V-5B + HSToric LoRA at 832x480

```bash
HF_HUB_OFFLINE=1 PYTHONPATH=src python -m abstractvision.cli t2v \
  --provider mlx-gen \
  --model AbstractFramework/wan2.2-ti2v-5b-diffusers-8bit \
  --store-dir <store> \
  --width 832 \
  --height 480 \
  --frames 17 \
  --steps 20 \
  --guidance-scale 4.0 \
  --flow-shift 3.0 \
  --fps 16 \
  --seed 6301 \
  --lora AlekseyCalvin/HSToric_Color_Wan2.2_5B_LoRA_BySilverAgePoets:HSToric_color_Wan22_5b_LoRA.safetensors \
  --lora-target-role transformer \
  --lora-scale 0.8 \
  --progress \
  "HST style HD film, early 1900s, autochrome, analog cinema. A horse-drawn carriage crossing a snowy town square at dusk, pedestrians in wool coats, historical street lamps glowing, gentle cinematic motion."
```

<video controls muted playsinline preload="metadata" style="max-width: 100%; border-radius: 8px;">
  <source src="assets/mlx-gen-lora-examples/t2v_wan_ti2v5b_hstoric_832x480.mp4" type="video/mp4" />
</video>

![TI2V-5B 832x480 contact sheet](assets/mlx-gen-lora-examples/t2v_wan_ti2v5b_hstoric_832x480_contact_sheet.png)

Progress proof:
[t2v_wan_ti2v5b_hstoric_832x480.progress.log](assets/mlx-gen-lora-examples/t2v_wan_ti2v5b_hstoric_832x480.progress.log)

### Batch text to video: TI2V-5B x2

```bash
HF_HUB_OFFLINE=1 PYTHONPATH=src python -m abstractvision.cli t2v \
  --provider mlx-gen \
  --model AbstractFramework/wan2.2-ti2v-5b-diffusers-8bit \
  --store-dir <store> \
  --width 832 \
  --height 480 \
  --frames 9 \
  --steps 8 \
  --guidance-scale 4.0 \
  --flow-shift 3.0 \
  --fps 8 \
  --count 2 \
  --seeds 6251,6252 \
  --progress \
  "A compact silver spaceship rests in a frozen canyon at dawn. Blue engines begin to glow, loose snow drifts across the landing pad, and the camera holds a stable wide composition with gentle atmospheric motion."
```

Artifacts:

- [seed 6251 MP4](assets/mlx-gen-lora-examples/t2v_batch_wan_ti2v5b_832x480_seed6251.mp4)
- [seed 6252 MP4](assets/mlx-gen-lora-examples/t2v_batch_wan_ti2v5b_832x480_seed6252.mp4)
- [contact sheet](assets/mlx-gen-lora-examples/t2v_batch_wan_ti2v5b_832x480_contact_sheet.png)
- [progress log](assets/mlx-gen-lora-examples/t2v_batch_wan_ti2v5b_832x480.progress.log)

### Text to video: task-specific Wan A14B + Lightning pair at 480x240

```bash
HF_HUB_OFFLINE=1 PYTHONPATH=src python -m abstractvision.cli t2v \
  --provider mlx-gen \
  --model AbstractFramework/wan2.2-t2v-a14b-diffusers-8bit \
  --store-dir <store> \
  --negative "oversaturated colors, overexposed, static shot, blurry details, subtitles, text, watermark, painting, illustration, ugly, deformed, broken anatomy, extra limbs, cluttered background, frozen frame, low quality, jpeg artifacts" \
  --width 480 \
  --height 240 \
  --frames 41 \
  --steps 4 \
  --guidance-scale 1 \
  --guidance-2 1 \
  --flow-shift 5 \
  --fps 20 \
  --seed 8401 \
  --lora lightx2v/Wan2.2-Lightning:Wan2.2-T2V-A14B-4steps-lora-rank64-Seko-V1.1/high_noise_model.safetensors \
  --lora lightx2v/Wan2.2-Lightning:Wan2.2-T2V-A14B-4steps-lora-rank64-Seko-V1.1/low_noise_model.safetensors \
  --lora-target-role high_noise_transformer \
  --lora-target-role low_noise_transformer \
  --lora-scale 1 \
  --lora-scale 1 \
  --progress \
  "A cinematic wide-angle movie shot of a massive futuristic starship taking off from a frozen tundra. The ship features sleek dark metallic armor. Two massive warp nacelles pulse with bright blue plasma. Violent snow squalls whip around the hull. The camera slowly tilts up as the thrusters ignite and massive clouds of snow blast away from the launch pad. Photorealistic, highly detailed, dramatic lighting."
```

<video controls muted playsinline preload="metadata" style="max-width: 100%; border-radius: 8px;">
  <source src="assets/mlx-gen-lora-examples/t2v_wan_a14b_lightning_480x240.mp4" type="video/mp4" />
</video>

![Wan A14B T2V 480x240 contact sheet](assets/mlx-gen-lora-examples/t2v_wan_a14b_lightning_480x240_contact_sheet.png)

Progress proof:
[t2v_wan_a14b_lightning_480x240.progress.log](assets/mlx-gen-lora-examples/t2v_wan_a14b_lightning_480x240.progress.log)

### Image to video: task-specific Wan A14B + Lightning pair at 480x240

```bash
HF_HUB_OFFLINE=1 PYTHONPATH=src python -m abstractvision.cli i2v \
  --provider mlx-gen \
  --model AbstractFramework/wan2.2-i2v-a14b-diffusers-8bit \
  --store-dir <store> \
  --image ./input.png \
  --negative "oversaturated colors, overexposed, static shot, blurry details, subtitles, text, watermark, painting, illustration, ugly, deformed, broken anatomy, extra limbs, cluttered background, frozen frame, low quality, jpeg artifacts" \
  --width 480 \
  --height 240 \
  --frames 41 \
  --steps 4 \
  --guidance-scale 1 \
  --guidance-2 1 \
  --flow-shift 5 \
  --fps 20 \
  --seed 8402 \
  --lora lightx2v/Wan2.2-Lightning:Wan2.2-I2V-A14B-4steps-lora-rank64-Seko-V1/high_noise_model.safetensors \
  --lora lightx2v/Wan2.2-Lightning:Wan2.2-I2V-A14B-4steps-lora-rank64-Seko-V1/low_noise_model.safetensors \
  --lora-target-role high_noise_transformer \
  --lora-target-role low_noise_transformer \
  --lora-scale 1 \
  --lora-scale 1 \
  --progress \
  "Starting from the input image, the silver spaceship powers up and lifts off from the frozen ground. Blue engines brighten, snow blasts outward, vapor rolls under the hull, and the camera holds the same wide icy canyon framing while the ship rises smoothly."
```

Source image:

![Wan A14B I2V source image](assets/mlx-gen-lora-examples/i2v_wan_a14b_lightning_480x240_input.png)

<video controls muted playsinline preload="metadata" style="max-width: 100%; border-radius: 8px;">
  <source src="assets/mlx-gen-lora-examples/i2v_wan_a14b_lightning_480x240.mp4" type="video/mp4" />
</video>

![Wan A14B I2V 480x240 contact sheet](assets/mlx-gen-lora-examples/i2v_wan_a14b_lightning_480x240_contact_sheet.png)

Progress proof:
[i2v_wan_a14b_lightning_480x240.progress.log](assets/mlx-gen-lora-examples/i2v_wan_a14b_lightning_480x240.progress.log)

## Progress semantics

The bundled logs show the normalized MLX-Gen semantics that AbstractVision
preserves:

- image generation and image edit report denoise-step progress (`0/20`,
  `1/20`, ..., `20/20`, `complete`);
- video generation reports denoise-step progress while keeping frame counts as
  context (`1/20 denoise frame 0/17`, ..., `20/20 decode`, `convert`,
  `generated`).

That is the progress contract AbstractVision forwards to Python callers, the
AbstractCore plugin, and higher-level runtime and gateway consumers.
--- >8 --- END FILE: docs/mlx-gen-local-examples.md --- >8 ---

--- 8< --- FILE: docs/api.md --- 8< ---
# API reference

This document describes the **public** Python API surface of `abstractvision` (0.x / Alpha) and points to the implementation.

See also:
- Getting started (end-to-end examples): [docs/getting-started.md](getting-started.md)
- Architecture (how the pieces fit): [docs/architecture.md](architecture.md)
- Backends reference (support matrix): [docs/reference/backends.md](reference/backends.md)
- FAQ (common questions): [docs/faq.md](faq.md)

## Public exports

The package exports the following symbols from `abstractvision` (see [`../src/abstractvision/__init__.py`](../src/abstractvision/__init__.py)):

- `VisionManager`
- `ProviderAdapterInfo`
- `ProviderModelInfo`
- `VisionAdapterCapabilitiesRegistry`
- `VisionModelCapabilitiesRegistry`
- `LocalAssetStore`
- `RuntimeArtifactStoreAdapter`
- `LoRAAdapterSpec`
- `is_artifact_ref`
- `__version__`

## Core concepts

### Tasks

`VisionManager` exposes one method per task (implementation: [`../src/abstractvision/vision_manager.py`](../src/abstractvision/vision_manager.py)):

- `generate_image(...)` → `text_to_image`
- `generate_image_batch(...)` → repeated `text_to_image` orchestration with explicit seed planning
- `edit_image(...)` → `image_to_image`
- `edit_image_batch(...)` → repeated `image_to_image` orchestration with explicit seed planning
- `upscale_image(...)` → `image_upscale`
- `generate_video(...)` → `text_to_video` (backend-dependent)
- `generate_video_batch(...)` → repeated `text_to_video` orchestration with explicit seed planning
- `image_to_video(...)` → `image_to_video` (backend-dependent)
- `image_to_video_batch(...)` → repeated `image_to_video` orchestration with explicit seed planning
- `video_to_video(...)` → `video_to_video` (backend-dependent)
- `upscale_video(...)` → `video_upscale` (backend-dependent)
- `generate_angles(...)` → `multi_view_image` (API exists; no built-in backend implements it yet)

Task names are also used by the capability registry ([`../src/abstractvision/assets/vision_model_capabilities.json`](../src/abstractvision/assets/vision_model_capabilities.json)).

### Backends

Backends are execution engines that implement the `VisionBackend` interface ([`../src/abstractvision/backends/base_backend.py`](../src/abstractvision/backends/base_backend.py)).

Built-in backends live in [`../src/abstractvision/backends/`](../src/abstractvision/backends/):
- `OpenAICompatibleVisionBackend` (HTTP)
- `HuggingFaceDiffusersVisionBackend` (local Diffusers images; local Diffusers `text_to_video` groundwork is currently quarantined)
- `StableDiffusionCppVisionBackend` (local stable-diffusion.cpp / GGUF)
- `MLXGenVisionBackend` / compatibility alias `MFluxVisionBackend` (local Apple-first MLX-Gen bridge for curated AbstractFramework q4/q8 MLX presets, official FIBO snapshots, shared LoRA adapters, and Wan video)

Backend config classes are re-exported from `abstractvision.backends` via lazy imports (see [`../src/abstractvision/backends/__init__.py`](../src/abstractvision/backends/__init__.py)).

Provider catalog listing is exposed as a backend contract:

```python
from abstractvision.backends import OpenAICompatibleBackendConfig, OpenAICompatibleVisionBackend

backend = OpenAICompatibleVisionBackend(
    config=OpenAICompatibleBackendConfig(base_url="http://localhost:1234/v1")
)
for model in backend.list_provider_models(task="text_to_image"):
    print(model.id)
```

For official OpenAI, use `base_url="https://api.openai.com/v1"` and an API key. Catalog listing is explicit and does not change the configured generation model.

When AbstractVision is loaded as an AbstractCore capability plugin, the plugin shim exposes the
same explicit catalog surface as `llm.vision.list_provider_models(task="text_to_image")`. It
returns JSON-safe dictionaries so Core/Gateway route code can avoid private backend reach-throughs.

Adapter inventory is exposed through the same explicit pattern:

```python
for adapter in backend.list_provider_adapters(
    model="AbstractFramework/qwen-image-edit-2509-8bit",
    task="image_to_image",
):
    print(adapter.id)
```

`ProviderAdapterInfo` rows are explicit discovery outputs. They do not mutate
the configured generation route.

### Outputs: bytes vs artifact refs

`VisionManager` returns:

- `GeneratedAsset` (bytes) when no store is configured ([`../src/abstractvision/types.py`](../src/abstractvision/types.py))
- an artifact ref `dict` when `VisionManager.store` is configured (via `MediaStore.store_bytes(...)`)

Artifact helpers and stores are defined in [`../src/abstractvision/artifacts.py`](../src/abstractvision/artifacts.py).

Image sizes are backend/model-specific. `width` and `height` arguments are
optional request overrides; omitting them lets the backend use its default or
`auto` behavior. Passing an unsupported size is expected to fail at the selected
provider/backend boundary rather than being silently rewritten by
AbstractVision.

## VisionManager (orchestrator)

`VisionManager` is intentionally thin: it validates/gates best-effort and delegates to the configured backend.

Signature (see [`../src/abstractvision/vision_manager.py`](../src/abstractvision/vision_manager.py)):
- `backend`: a `VisionBackend` implementation (required to run anything)
- `store`: optional `MediaStore` to enable artifact-ref outputs
- `model_id`: optional capability-gating model id (must exist in the registry)
- `registry`: optional `VisionModelCapabilitiesRegistry` instance (reused when gating is enabled)

### Minimal example (OpenAI-compatible backend + artifact refs)

```python
from abstractvision import LocalAssetStore, VisionManager, is_artifact_ref
from abstractvision.backends import OpenAICompatibleBackendConfig, OpenAICompatibleVisionBackend

backend = OpenAICompatibleVisionBackend(
    config=OpenAICompatibleBackendConfig(base_url="http://localhost:1234/v1")
)
store = LocalAssetStore()
vm = VisionManager(backend=backend, store=store)

ref = vm.generate_image("a studio photo of an espresso machine", width=768, height=768, steps=20)
assert is_artifact_ref(ref)
png_bytes = store.load_bytes(ref["$artifact"])
```

### Local example (Diffusers backend)

Install `abstractvision[diffusers]` before using this backend.

```python
from abstractvision import LoRAAdapterSpec, VisionManager
from abstractvision.backends import HuggingFaceDiffusersBackendConfig, HuggingFaceDiffusersVisionBackend

backend = HuggingFaceDiffusersVisionBackend(
    config=HuggingFaceDiffusersBackendConfig(
        model_id="runwayml/stable-diffusion-v1-5",
        device="auto",
        allow_download=False,
    )
)
vm = VisionManager(backend=backend)
asset = vm.generate_image("a watercolor painting of a lighthouse", width=512, height=512, steps=10)
```

Note: `allow_download=False` is the default. Pre-download model weights separately, or set `allow_download=True` only when you want runtime downloads.

`upscale_image(...)`, `generate_video(...)`, and `image_to_video(...)` are part
of the public API. MLX-Gen `0.40.3+` supports SeedVR2 `image_upscale`, Wan
`text_to_video`, and first-frame `image_to_video`, including A14B task-specific
checkpoints. Local Diffusers video remains experimental and disabled from the
normal local surfaces. Generated MP4 outputs still require an `ffmpeg`
executable on `PATH` whenever a backend returns frame sequences for local
packaging.

`ImageGenerationRequest` includes typed `control_image` and `control_strength`
fields: a structure guide such as edges, sketch, or pose, not a source-image edit
input. MLX-Gen applies them on `AbstractFramework/qwen-image-8bit` (see
[Control image](#control-image-control_image)) and refuses a `control_image` on
any other model (`field="control_image"`) and a `control_strength` given alone
(`field="control_strength"`); the other built-in backends refuse a `control_image`
and do not use `control_strength`.

### Local example (MLX-Gen backend)

Install `abstractvision[mlx-gen]` and pre-download the exact model repo first,
for example `abstractvision download AbstractFramework/wan2.2-t2v-a14b-diffusers-8bit --provider mlx-gen`.

```python
from pathlib import Path

from abstractvision import LoRAAdapterSpec, VisionManager
from abstractvision.backends import MLXGenBackendConfig, MLXGenVisionBackend

def on_progress(event):
    if event.total_frames:
        print(f"{event.phase}: frame {event.frame}/{event.total_frames}")
    else:
        print(f"{event.phase}: step {event.step}/{event.total_steps}")

image_backend = MLXGenVisionBackend(
    config=MLXGenBackendConfig(model="AbstractFramework/flux.2-klein-9b-8bit")
)
image_vm = VisionManager(backend=image_backend)

image_asset = image_vm.generate_image(
    "a studio product photo of a red toy race car",
    width=768,
    height=512,
    steps=12,
    guidance_scale=1.0,
    on_progress=on_progress,
)

# A plain edit runs FLUX.2's edit route, on which MLX-Gen validated this LoRA on the 8-bit package.
edit_asset = image_vm.edit_image(
    "Turn this cat into a dog.",
    image=Path("./cat.png").read_bytes(),
    lora_adapters=[
        LoRAAdapterSpec(source="dx8152/Flux2-Klein-9B-Consistency:Flux2-Klein-9B-consistency-V2.safetensors")
    ],
    on_progress=on_progress,
)

reference_asset = image_vm.edit_image(
    "compose the subject using the second image as a style and layout reference",
    image=Path("./subject.png").read_bytes(),
    steps=12,
    guidance_scale=1.0,
    on_progress=on_progress,
    reference_images=[Path("./style-reference.png").read_bytes()],
)

upscale_backend = MLXGenVisionBackend(config=MLXGenBackendConfig(model="AbstractFramework/seedvr2-3b-8bit"))
upscale_vm = VisionManager(backend=upscale_backend)

upscaled_asset = upscale_vm.upscale_image(
    image=Path("./subject.png").read_bytes(),
    resolution="2x",
    softness=0.25,
    seed=2405,
    on_progress=on_progress,
)

ti2v_backend = MLXGenVisionBackend(
    config=MLXGenBackendConfig(model="AbstractFramework/wan2.2-ti2v-5b-diffusers-8bit")
)
ti2v_vm = VisionManager(backend=ti2v_backend)

# TI2V-5B has one transformer: its adapters take target_role="transformer".
styled_asset = ti2v_vm.generate_video(
    "HST style HD film, early 1900s, autochrome, analog cinema. A horse-drawn carriage crossing a snowy town square at dusk",
    width=832,
    height=480,
    num_frames=17,
    fps=16,
    steps=20,
    guidance_scale=4.0,
    flow_shift=3.0,
    lora_adapters=[
        LoRAAdapterSpec(
            source="AlekseyCalvin/HSToric_Color_Wan2.2_5B_LoRA_BySilverAgePoets:HSToric_color_Wan22_5b_LoRA.safetensors",
            scale=0.8,
            target_role="transformer",
        )
    ],
    on_progress=on_progress,
)

t2v_backend = MLXGenVisionBackend(
    config=MLXGenBackendConfig(model="AbstractFramework/wan2.2-t2v-a14b-diffusers-8bit")
)
t2v_vm = VisionManager(backend=t2v_backend)

# A14B has two denoisers: each adapter names the one it targets (here the Wan 2.2 Lightning pair).
asset = t2v_vm.generate_video(
    "a red fox walking through a snowy forest, cinematic",
    width=480,
    height=240,
    num_frames=41,
    fps=20,
    steps=4,
    guidance_scale=1.0,
    guidance_2=1.0,
    flow_shift=5.0,
    lora_adapters=[
        LoRAAdapterSpec(
            source="lightx2v/Wan2.2-Lightning:Wan2.2-T2V-A14B-4steps-lora-rank64-Seko-V1.1/high_noise_model.safetensors",
            scale=1.0,
            target_role="high_noise_transformer",
        ),
        LoRAAdapterSpec(
            source="lightx2v/Wan2.2-Lightning:Wan2.2-T2V-A14B-4steps-lora-rank64-Seko-V1.1/low_noise_model.safetensors",
            scale=1.0,
            target_role="low_noise_transformer",
        ),
    ],
    on_progress=on_progress,
)

i2v_backend = MLXGenVisionBackend(
    config=MLXGenBackendConfig(model="AbstractFramework/wan2.2-i2v-a14b-diffusers-8bit")
)
i2v_vm = VisionManager(backend=i2v_backend)

first_frame_asset = i2v_vm.image_to_video(
    image=Path("./first-frame.png").read_bytes(),
    prompt="slow camera push-in",
    width=480,
    height=240,
    num_frames=41,
    fps=20,
    steps=4,
    guidance_scale=1.0,
    guidance_2=1.0,
    flow_shift=5.0,
    lora_adapters=[
        LoRAAdapterSpec(
            source="lightx2v/Wan2.2-Lightning:Wan2.2-I2V-A14B-4steps-lora-rank64-Seko-V1/high_noise_model.safetensors",
            scale=1.0,
            target_role="high_noise_transformer",
        ),
        LoRAAdapterSpec(
            source="lightx2v/Wan2.2-Lightning:Wan2.2-I2V-A14B-4steps-lora-rank64-Seko-V1/low_noise_model.safetensors",
            scale=1.0,
            target_role="low_noise_transformer",
        ),
    ],
    on_progress=on_progress,
)
```

### Control image (`control_image`)

On `AbstractFramework/qwen-image-8bit`, the only model whose MLX-Gen rows have a
control route (`qwen.control`), `generate_image(..., control_image=...)` runs
`QwenImageControlNet` with the row's ControlNet
(`InstantX/Qwen-Image-ControlNet-Union:diffusion_pytorch_model.safetensors`);
`control_strength` is a finite number (unset: the engine CLI's 0.4). The
ControlNet's side weights are looked up in the Hugging Face cache before any
weights load and never downloaded during a generation: when they are missing the
request is refused (`field="control_image"`) with the command that fetches them,
`abstractvision download InstantX/Qwen-Image-ControlNet-Union`.
`get_capabilities().supports_control_image` is true on that model only. `i2i`
refuses `control_image` and `control_strength` (`field=`).

### Video-to-video (`video_to_video`)

`VisionManager.video_to_video(prompt, video, **kwargs)` (`VideoToVideoRequest`;
the plugin's `v2v(prompt, video, ...)`) edits a source clip. `video` is its bytes,
written once to the run's directory, or a local file `Path` the engine reads in
place (the plugin takes a file path, bytes or an artifact ref). On MLX-Gen it
runs Wan 2.2 T2V-A14B's video-to-video route (`Wan2_2_TI2V`) with the A14B
defaults and memory plan of text-to-video:

- Guidance as the engine CLI sets it on this route: unset, 4.0 and `guidance_2`
  3.0; a `guidance_scale` set alone leaves `guidance_2` to the engine, which then
  uses the same value (text-to-video and image-to-video keep `guidance_2` at the
  model's default).
- `video_strength` in `(0, 1]` (unset: the engine's 0.8) and an optional `mask`
  (one image, white is the region to change; one with no white pixel raises
  `ValueError`). A negative prompt is passed only when set, so the model's own
  default applies.
- Before any weights load, the clip is probed by the engine's rule: one too short
  for `num_frames` at `fps` is refused (`field="num_frames"`); `extra` takes the
  progress callbacks, `max_sequence_length` and `vae_tiling` (as on the other Wan
  routes), and any other key is refused naming it.
- The result is the engine's MP4 (the source's audio is not carried; the engine
  records whether there was one) and `num_frames` is the engine's count, snapped
  down to `4n+1`.

Wan 2.1 VACE 1.3B (`Wan-AI/Wan2.1-VACE-1.3B-diffusers`, `WanVace`; defaults
832x480, 81 frames at 16 fps, 30 steps, guidance 5.0) runs the same task with
other controls: `reference_images` (images in order, no published maximum),
`masked_region_mode` (`"generate"` or `"repaint"` the region the `mask` marks;
it needs a mask) and `conditioning_scale` (a finite number, default 1.0). It
takes no `video_strength` and no `guidance_2` (one transformer), and refuses
them by name; T2V-A14B refuses the three VACE fields the same way. A VACE
preload loads `WanVace` and runs no warm-up generation; in `"default"` it reads
the transformer and the VAE ahead, as the other Wan preloads do.

TI2V-5B and I2V-A14B have no video-to-video route and refuse the task, as do the
other backends.

### Video restoration (`video_upscale`)

`VisionManager.upscale_video(video, **kwargs)` (`VideoUpscaleRequest`; the
plugin's `upscale_video(video, ...)`) restores a clip on SeedVR2 3B or 7B
(MLX-Gen 0.40.2 and later). `video` is handled as for video-to-video. The options are
`resolution` (unset: 1x), `softness` (`[0, 1]`, unset: 0.0), `start_seconds`
(unset: the clip's start), `max_frames` (unset: to its end), `seed`, `quantize`
(as for `upscale_image`) and `drop_audio` (True: the result is always silent,
MLX-Gen does not copy the source's soundtrack; unset or False: MLX-Gen copies it,
and fails the run after the restoration when it cannot). Before any weights load,
MLX-Gen's own plan (`SeedVR2VideoRestorePlan.for_video`, the one `mlxgen upscale
--video-path` uses) probes the clip and decides the chunking and the memory
profile, counting the model's weights as loaded when this backend already holds
the instance the run reuses:

- a scale above 1x is refused (`CapabilityNotSupportedError`,
  `field="resolution"`, `supported=None`), and a clip beyond the safe memory
  profile or below its temporal quality floor is refused (`field=None`), each with
  MLX-Gen's message (on the safe profile's 48 GB budget a frame of up to about
  1.4 megapixels fits, 1280x720 included; a larger one is refused with the
  largest size that fits); MLX-Gen's argument errors (`start_seconds` below 0,
  `max_frames` below 1) stay `ValueError`, as does a clip it cannot decode
  ("video is not a readable clip"); an `extra` key other than the progress
  callbacks is refused naming it (`vae_tiling` included).
- The run applies the plan as the CLI does: MLX-Gen's low-RAM saver keeping the
  transformer, in `memory_mode="default"` and `"low"` alike (`"lowest"` is
  refused); metadata reports the mode asked and `low_ram: true`. The MLX cache
  limit is one value from before the model loads to the end of the run: the
  plan's (8 GB, what MLX-Gen's CLI runs with on any Mac, above its default cap
  where that is lower), except that a limit the host set (by MLX-Gen's own rule:
  one at or below half of physical memory found before its default applied) is
  never raised, so the smaller of the two applies; the limit in force before the
  run is restored after it. The run drops the model at its end, so a later image
  upscale loads a fresh one.
- The result is an MP4 whatever the source's container (as MLX-Gen writes it:
  H.264, and AAC for the source's audio, which MLX-Gen copies);
  `metadata["mlx_gen"]` is its sidecar.
  Progress is per chunk; a cancel removes the partial output.

Wan 2.2 A14B has two guidance controls. Use `guidance_scale` for the
primary/high-noise stage and `guidance_2` for the second/low-noise stage. The
registry default is `guidance_2=3.0` for text-to-video A14B and `3.5` for
image-to-video A14B. Other video models should omit `guidance_2` unless their
registry task declares it.

For TI2V-5B, use `flow_shift` directly when you need to override the route
default. The bundled visual proof uses `832x480` with `flow_shift=3.0`.

Wan video defaults come from one per-model table,
`WAN_VIDEO_DEFAULT_CANVASES` in
[`../src/abstractvision/backends/mflux.py`](../src/abstractvision/backends/mflux.py):
832x480 for every Wan model, 121 frames at 24 fps and 50 steps for TI2V-5B,
81 frames at 16 fps and 40 steps for the A14B models. Any field you pass
(`width`, `height`, `num_frames`, `fps`, `steps`) overrides the default;
`backend.list_provider_models(task="text_to_video")` reports the same values in
each model's `raw["parameter_defaults"]`. The Wan VAE decode runs in overlapping spatial tiles by
default, which bounds its memory; pass `extra={"vae_tiling": False}` to decode
whole frames at once. Generated asset metadata records `vae_tiling`. Measured
memory per size: [docs/faq.md](faq.md#how-much-memory-does-wan-video-need).
MLX-Gen encodes the prompt with its UMT5 text encoder in float32 on the GPU: with mlx-gen 0.40.2 and later a
new prompt is encoded in seconds, a prompt already used is served from MLX-Gen's on-disk cache, and
results for a given prompt and seed differ slightly from those made with mlx-gen 0.40.1; see
MLX-Gen's [Wan prompt encoding](https://github.com/lpalbou/mlx-gen/blob/main/docs/wan-text-encoder.md).

For MLX-Gen, `on_progress` receives an `abstractvision.VideoProgressEvent`.
Image generation/editing/upscaling events carry `phase`, `step`, `total_steps`,
and denoise-step `progress`. Wan video events add `frame`, `total_frames`, and
`frame_progress`. The lower-level `backend.generate_image_with_progress(...)`,
`backend.edit_image_with_progress(...)`, `backend.upscale_image_with_progress(...)`,
`backend.generate_video_with_progress(...)`, and
`backend.image_to_video_with_progress(...)` methods keep the existing
two-argument `(current, total)` callback for backend-agnostic progress bars.
For MLX-Gen, that callback reports denoise step counts; use
`on_progress(event)` when a UI also needs video frame context.

## MLX-Gen image routes

MLX-Gen publishes, per model, the routes it can run (its capability rows,
`backend.describe_routes()`), and `mlxgen generate` picks one with its planner.
The MLX-Gen backend asks the same planner for every `image_to_image` request on
FLUX.2, Z-Image and base Qwen-Image, and for a request on any model that sets an
option only a route applies (`image_strength` below). The route it selects
decides the MLX-Gen class and call; other requests run as in 0.3.37. On a model
the engine publishes no rows for (a local folder whose own name it cannot place),
the model has its 0.3.37 tasks, and an option runs its 0.3.37 branch on the
families 0.3.37 applied it on (`image_strength` on ERNIE-Image-Turbo, reference
images on FLUX.2 and Qwen-Image-Edit, a mask on Qwen-Image-Edit and FIBO-Edit)
and is refused on any other with `field=<option>`, `supported=()`. On every
MLX-Gen image route, text-to-image included, a negative prompt is passed where
the row of the route the request runs takes one (`supports_negative_prompt`) and
dropped silently where it takes none; a model without rows keeps 0.3.37's answer.
`parameter_constraints["negative_prompt"]` in `list_provider_models()` says the same.
A request is refused before any weights load, in `normalize_image_edit_request`
as in `edit_image`:

- with `ValueError` when two of its options contradict each other (`mask` with
  `image_strength`), or a value is not of its type (a picture that fails to
  decode, checked once the route takes it);
- with `CapabilityNotSupportedError(field=<option>, supported=())` when no row of
  the model applies an option it sets, and `field="lora_adapters"` when the
  selected row takes no adapters;
- with `CapabilityNotSupportedError(field=None, supported=None)` and the planner's
  message when no row serves that combination of options.

Those are check point 1, from the request's values and the engine's rows. An
outpaint or a reframe adds check point 2 at the start of `edit_image`, still
before any weights load: the source is written to the run's directory and
MLX-Gen's canvas session is built from it, which refuses a box it cannot apply
and a two-pass outpaint in low-RAM mode. A caller who only calls
`normalize_image_edit_request` sees check point 1 only.

### Latent image-to-image (`image_strength`)

`ImageEditRequest.image_strength` (`edit_image(..., image_strength=0.6)`, the
plugin's `i2i(image_strength=...)`) noises the source before denoising, in
`(0, 1]`; a value outside is refused with `field="image_strength"`. On MLX-Gen,
`extra["image_strength"]` is the same option (both set and different:
`ValueError`); the other backends refuse the typed field and pass `extra` on
unchanged.

- FLUX.2 klein: setting it selects the latent route (`Flux2Klein`); without it
  an edit stays the reference edit (`Flux2KleinEdit`).
- Base Qwen-Image (`AbstractFramework/qwen-image-8bit`, the Qwen-Image-2512
  packages): `image_to_image` runs latent (`QwenImage`), at `image_strength=0.4`
  when the request names none; so do Z-Image and Z-Image-Turbo (`ZImage`).
  ERNIE-Image-Turbo runs latent as before.
- Qwen-Image-Edit, FIBO, Fibo-lite and FIBO-Edit have no latent route and
  refuse it (`field="image_strength", supported=()`).

`list_provider_models()` publishes `parameter_defaults["image_strength"] = 0.4`
and `parameter_constraints["image_strength"] = {"min": 0.0, "min_exclusive":
true, "max": 1.0}` for every model with a latent route.

### FLUX.2 masked edits (`mask`)

On FLUX.2 klein, an edit with a `mask` runs `Flux2KleinInpaint` (route
`flux2.inpaint`): white in the mask is the region to change (MLX-Gen reads its
luminance, resizes it to the canvas and ignores an alpha channel; the bytes are
passed unchanged). The mask is decoded first, and one that is not a picture
raises `ValueError` naming `mask`. An unset `guidance_scale` stays unset, so the
class applies its default (4.0 on the base models, 1.0 on the distilled ones);
the base models take a negative prompt. `get_capabilities().supports_mask` is
true on FLUX.2 klein. A masked edit and a plain edit run on different classes,
so alternating them reloads the model each time (never two instances at once).

On Z-Image-Turbo a `mask` runs its masked edit (route `z-image.inpaint`, the
mask instead of a strength); base Z-Image has no masked route and refuses it.

### Multi-reference edits (`reference_images`)

`ImageEditRequest.reference_images` lists the images after `image`, in order:
bytes, or local file paths the engine reads in place (the plugin's
`i2i(reference_images=...)` and `i2i_batch` take bytes-like values, file paths
(any path-like) and artifact
refs, and pass bytes). On MLX-Gen, `extra["reference_images"]` is the same
option, and the 0.3.37 keys `extra["images"]`, `["additional_images"]` and
`["image_paths"]` keep working but raise `ValueError` with the typed list. The
request runs MLX-Gen's multi-reference route: FLUX.2 klein (`Flux2KleinEdit`)
and Qwen-Image-Edit 2509 and 2511 (`QwenImageEdit`); the first image decides the
canvas, and no maximum count is published or enforced. A model without that
route (plain Qwen-Image-Edit, ERNIE, base Qwen-Image) refuses it
(`field="reference_images"`, `supported=()`), as does a combination with a mask
or a strength (`field=None`); every picture counts there, those of the 0.3.37
`extra` keys included, so none is dropped. An empty list is no reference.
`extra["reference_images"]` is read as 0.3.37 read it (any iterable; `None` and
blank items skipped), and only what that reading keeps counts; the typed field
takes a list of image bytes or paths.

### Outpaint and reframe

`outpaint_padding` grows the canvas by a box in MLX-Gen's syntax
(`"top,right,bottom,left"`, each in pixels or `"N%"`; one to four values) and
fills the new area, keeping the source; `reframe_padding` grows it the same way
and lets the model recompose the whole picture. They run MLX-Gen's own canvas
session (`mflux.outpaint`), which builds the conditioning canvas, plans the
passes and owns the canvas size, so `extra["width"]` / `["height"]` are refused
with them (`field="width"`). FLUX.2 klein runs outpaint with `Flux2KleinOutpaint`
and reframe (distilled weights only) with `Flux2KleinEdit`; Qwen-Image-Edit runs
both with `QwenImageEdit`.

- `outpaint_fill` is one of the route's fill modes (FLUX.2: `auto`, `edge`,
  `neutral`, `solid`, `blur`; unset: `auto`), `outpaint_fill_color` (`"R,G,B"`
  or `"#rrggbb"`) the color of `outpaint_fill="solid"`. Qwen-Image-Edit's fill is
  fixed (`edge`) and refuses both, and either one without an outpaint is refused.
- A box that pads both axes deeply runs as two passes (MLX-Gen's `auto` plan);
  progress counts the steps across both, and `memory_mode="low"` refuses it
  (`field="memory_mode"`, `supported=("default",)`: low-RAM mode frees the
  transformer the second pass needs). An unset `guidance_scale` stays unset, so
  the class applies its default.
- A box outside MLX-Gen's validated envelope runs, as on the engine's CLI;
  `metadata["outpaint_warnings"]` says so, and `metadata["outpaint_notice"]` gives
  the resolved canvas and passes. The engine's geometry fields are under
  `metadata["mlx_gen"]`.

`extra["strength"]` (the CLI's `--strength`, the plugin's `strength=`) is the
0.3.37 cross-backend keyword, not a second spelling of the typed field: on every
route 0.3.37 had it keeps exactly its 0.3.37 meaning (clamped to `[0, 1]`,
dropped when not a number, ignored by the FLUX.2 and Qwen-Image-Edit reference
edits), and on the latent routes new in 0.3.38 it is read as the run's strength
with the same clamp. It never selects a route and is not read on a masked route.
Combined with `image_strength` it raises `ValueError`.

## Memory modes (`memory_mode`)

Every generation request (`generate_image`, `edit_image`, `upscale_image`,
`generate_video`, `image_to_video` and their `_batch` variants) takes
`memory_mode`: `"default"`, `"low"` or `"lowest"` (`MEMORY_MODES` in
[`../src/abstractvision/types.py`](../src/abstractvision/types.py)). The lower
modes trade speed for a lower memory peak. A request that names no mode uses
`$ABSTRACTVISION_MEMORY_MODE`, else `"default"`; a request value always wins.
The environment value is one setting for every backend in the process: a
backend that cannot honour it runs the lowest-memory mode it lists that is not
below it (`"lowest"` becomes `"low"` where `"low"` is listed, else `"default"`)
and logs that once per process, while a mode passed on the request is refused.
On MLX-Gen, every mode starts with the engine's default MLX cache cap, as its CLI
applies it (total RAM / 8, between 1 and 8 GiB, once per process; a limit the
host set at or below half of physical memory is left alone, a higher one is
replaced by the default cap). `"low"` then lowers it to 1 GB for the run.
`backend.preload(memory_mode=None, quantize=None)` loads the model as a request
carrying those values would, so the first such request reuses it: the values
are checked by the same function as a request's, before anything loads, with
the same refusals; `memory_mode=None` is the process default under the same rule.
A backend that takes no load-time quantize refuses `quantize` there. On
MLX-Gen, `preload()` loads the model as the first request with those values
starts it (under the same 1 GB cache hold in `"low"` and `"lowest"`) into the
instance that request reuses, so in a mode whose runs drop the model (`"low"`,
`"lowest"`, and every mode on Wan TI2V-5B, which releases its denoiser before
the decode) the preloaded instance serves one request.
In `"default"` an MLX-Gen preload warms exactly what a run of its task reads, so
the first request reads no weights (MLX-Gen binds them lazily at load): an image
task (text-to-image, image-to-image, upscale) runs one warm-up of that task on
its plain route, its output discarded, with a small ordinary request: a
neutral 256x256 picture or canvas (352 on base Qwen-Image, FIBO and Fibo-lite,
384 on FIBO-Edit, 512 on ERNIE-Image-Turbo and Bonsai, the smallest side MLX-Gen
runs those families at) at 2 steps, or for SeedVR2 a 64x64 picture at 1x; a
backend whose `default_width` / `default_height` are set warms at that canvas
instead. A video task, whose warm-up run would take minutes, reads the first
denoiser and, where the run encodes an input (image-to-video, video-to-video),
the VAE (the Wan A14B second expert is read at the switch, as in a run;
MiniMax-H3 reads its transformer at load). `"low"` and `"lowest"` read nothing
ahead. `preload(..., warm_up=False)` skips all of it: the model is still resolved
(its files found), checked (MLX-Gen version, the task, the
memory mode and `quantize`) and built, so a bad model fails at the preload and not
at the first request, but nothing is run or read ahead, and the first request
reads the weights as a request without a preload does, minus the construction;
`backend.preload_warmed()` says which the held model got.
When anything in a preload fails, the model it loaded is dropped before the error
is raised. A preload refused for its values, or one that fails after reusing the
model already held, leaves that model held. The MLX-Gen backend's `preload` also
takes `task`, the task the host is about to run, as a hint: when the model has
that task, the model is loaded as a request of that task loads it (on FLUX.2
klein, `task="image_to_image"` loads `Flux2KleinEdit`, the class of a plain or
multi-reference edit; a latent, masked or outpaint request then rebuilds its own
class), and when it does not, or `task` is `None`, the preload chooses as before.
`task` is never a reason to refuse; the other backends' `preload` takes no `task`.

```python
asset_or_ref = vm.generate_video(
    "a red fox trots through fresh snow",
    memory_mode="low",
)
```

| Backend | `low` | `lowest` |
| --- | --- | --- |
| MLX-Gen, image and edit routes | MLX-Gen low-RAM mode, as `mlxgen generate --low-ram`: a 1 GB MLX cache from before the model loads to the end of the run, and mlx-gen's `MemorySaver`, which tiles the VAE decode, frees the text encoders before the denoising loop and the transformer after it. | `low` plus transformer block streaming (`--stream-blocks`), on a model whose MLX-Gen routes stream transformer blocks: accepted for MiniMax-H3, refused on every other current catalog model. |
| MLX-Gen, Wan video | As `mlxgen generate --low-ram` on one seed: the 1 GB cache, the MLX cache cleared after every step and transformer block, the denoisers released before the decode and, on the A14B models, the inactive expert released. | Refused on every current Wan route. |
| MLX-Gen, MiniMax-H3 | The 1 GB cache and the transformer freed before the decode (`release_transformer=True`); the next request loads the model again. | `low` plus block streaming (`stream_blocks=True`). Refused with load-time `quantize`, and with an adapter that trains the AdaLN projections. |
| MLX-Gen, SeedVR2 upscale | As `mlxgen upscale --low-ram` on images: the 1 GB cache only. SeedVR2 keeps its own tiling and the loaded model. | Refused (SeedVR2 has no block streaming). |
| Diffusers on CUDA | Model CPU offload. | Sequential CPU offload. |
| Diffusers on CPU or MPS | Refused. | Refused. |
| stable-diffusion.cpp | CPU offload of the model parameters: `--offload-to-cpu` for `sd-cli`, `offload_params_to_cpu` for the Python binding. | Refused. |
| OpenAI-compatible | Sent to a remote that lists the mode for the model in `GET /vision/models` (AbstractCore's server); refused otherwise. | As `low`. |

A mode named on the request that the backend cannot honour for its configured
model and device raises `CapabilityNotSupportedError` before any model loads or
any request is sent,
whether the call comes through `VisionManager`, the AbstractCore plugin or a
direct backend call. `extra={"memory_mode": ...}` is read the same way as the
keyword (on a backend that applies `quantize` or the soundtrack fields, so are
those keys of `extra`; elsewhere they pass through `extra` unchanged); a keyword
and an `extra` value that disagree raise `ValueError`.

Placement is fixed when a model loads, so a request may only raise it. On
Diffusers, the CPU offload that runs is the higher of the configured
`cpu_offload` (or what `"auto"` picks) and the one the request needs; a loaded
pipeline with less offload than a request needs is loaded again, and one with
more offload keeps serving later requests until it is unloaded. stable-diffusion.cpp
keeps an operator's `--offload-to-cpu` and loads the Python binding again
with `offload_params_to_cpu` when a `low` request needs it.

On MLX-Gen, `low` trades residency for memory: image, edit, Wan and MiniMax-H3
runs free parts of the model, so the instance is dropped when the run ends,
whatever its outcome, and the next request loads it again, a preloaded resident
model included; MiniMax-H3 runs in `lowest` are dropped the same way. A batch
(`generate_image_batch`, `generate_video_batch`, ...) is a series of such
requests: each item loads the model, frees it and drops it, so every item peaks
as one `low` run, at the cost of one load per item (building the instance took
1.3 to 3.1 s for MiniMax-H3 8-bit, 0.5 to 2.5 s for FLUX.2 [klein] 9B 8-bit and
1.4 to 2.7 s for Wan 2.2 T2V-A14B 8-bit; the weights are then read during the
run). SeedVR2's `low` is the cache limit alone, and it keeps its instance. `low` and `lowest` hold a 1 GB MLX cache limit for the run, never
above a limit already in force; `default` runs leave the limit to MLX-Gen. MLX-Gen holds one instance at a time: a request
whose model, adapters, `quantize` or block streaming differ from the loaded
instance's releases it, and clears the MLX cache, before the new one loads.

Discovery: `backend.get_capabilities().memory_modes` lists the modes a backend
can honour for its configured model and device; Diffusers with `device="auto"`
lists `"default"` on macOS (no CUDA) without importing torch, and elsewhere
asks torch, importing it once. Each MLX-Gen provider catalog
entry carries `raw["parameter_constraints"]["memory_mode"]` = `{"enum": [...]}`,
where `enum` holds the modes that model can honour. The result metadata records
the mode a run used as `memory_mode`, `"default"` included: Diffusers,
stable-diffusion.cpp and MLX-Gen on every run (MLX-Gen also
records `low_ram` and `stream_blocks`; stable-diffusion.cpp records
`offload_to_cpu`; Diffusers records `cpu_offload`), and the OpenAI-compatible
backend when the remote reports it.

## Video with sound (MiniMax-H3)

The MLX-Gen backend serves MiniMax-H3, which generates a video with a synchronized
stereo soundtrack: `text_to_video`, and `image_to_video` from a first frame. The
catalog entry is `MiniMaxAI/MiniMax-H3`; the published packages are
`AbstractFramework/minimax-h3-8bit` (64.3 GiB, recommended),
`AbstractFramework/minimax-h3-bf16` (115.1 GiB) and the mixed
`AbstractFramework/minimax-h3-4bit` (44.9 GiB). The packages hold the base
weights; `base_model` picks the schedule: `minimax-h3-turbo-544p` (8 steps,
960x544), `minimax-h3-turbo` (8 steps, 1344x768) or `minimax-h3` (50 steps).

```python
from abstractvision import VisionManager
from abstractvision.backends.mflux import MLXGenBackendConfig, MLXGenVisionBackend

backend = MLXGenVisionBackend(config=MLXGenBackendConfig(
    model="AbstractFramework/minimax-h3-8bit", base_model="minimax-h3-turbo-544p"))
clip = VisionManager(backend=backend).generate_video(
    "A red fox trots through fresh snow at dawn.",
    soundscape="Soft crunch of paws in dry snow, faint wind.", music="Sparse piano.",
    width=640, height=352, num_frames=124, seed=42, memory_mode="low")
```

Request fields (on `VideoGenerationRequest` and `ImageToVideoRequest`):

| Field | Meaning |
| --- | --- |
| `prompt` | The visual description, or a complete structured prompt with its section labels. Passed to MLX-Gen unchanged; MLX-Gen composes the structured prompt (and, for a first frame, its picture reference). |
| `soundscape`, `music` | The `overall_soundscape` and `non_diegetic_music` sections. |
| `generate_audio` | `False` writes a silent clip. Default: the soundtrack is generated. A boolean: any other type, the string `"false"` included, is refused. |
| `flow_shift`, `audio_shift` | The video and audio schedule shifts (MLX-Gen `video_shift` / `audio_shift`), positive numbers. |
| `width`, `height` | Given together; positive multiples of the route's `dimension_multiple` (32), with an aspect ratio inside MLX-Gen's window (1:4 to 4:1). Unset: the schedule's canvas, or for a first frame MiniMax-H3's own mapping of the keyframe's aspect ratio, which must then lie in the same window. |
| `num_frames` | Rounded up by MLX-Gen to the next count of its grid (`17n+5` at 24 fps, `124` to `345`): `125` runs as `141`. A count that rounds outside that range (below `108`, or above `345`) is refused before any weights load. |
| `steps`, `seed`, `quantize`, `memory_mode`, `cancel_event` | As for other routes; `steps` is at least 1 and `seed` lies in `[0, 2**64 - 1]` (MLX's random key). `quantize` applies to the source snapshot only (8 or 4, the row's `validated_quantization_bits`). |
| `lora_adapters` | Adapters on the `transformer` role (the row's `lora_target_roles`). As in MLX-Gen, the list replaces the Turbo adapter a Turbo schedule attaches: include the Turbo file to keep the 8-step schedule. |

Values left unset stay unset, so MLX-Gen applies the schedule's own defaults.
Everything is checked before any weights load, against MLX-Gen's capability row
and its own MiniMax-H3 planning code, and a refusal about one field names it
(a refusal about two fields together, such as `lowest` with `quantize`, leaves
`field` None):

- What the route cannot apply, or a value outside what it accepts, raises
  `CapabilityNotSupportedError`: `negative_prompt`, `guidance_scale`,
  `guidance_2`, an `fps` other than 24, an `extra` key other than the progress
  callbacks and `memory_mode`, a canvas off the multiple or outside the aspect
  window, a frame count that rounds outside `124` to `345` (a count inside is
  rounded up to the grid, not refused), `steps` below 1, a shift that is not
  positive.
- A value of the wrong type, or two fields that contradict each other, raises
  `ValueError`: a width that is not an integer, `soundscape` or `music` that is
  not a string, a non-boolean `generate_audio`, a prompt that already carries an
  `overall_soundscape:` (or `non_diegetic_music:`) section together with
  `soundscape=` (or `music=`), which MLX-Gen's own prompt composition refuses.
- A first frame is opened and decoded first: empty or undecodable bytes raise
  `ValueError` naming `image`. Wan routes check their values and keyframes the
  same way, with the same error types.
- `memory_mode="lowest"` with an adapter that trains the transformer's AdaLN
  projections (checked with MLX-Gen's own adapter test) is refused, naming the
  adapter: MLX-Gen must then hold the whole transformer in memory.

Every number the backend checks comes from MLX-Gen (the capability row, its
aspect window); `describe_routes()` returns the row. Wan and the other local
backends refuse `soundscape`, `music`, `generate_audio` and `audio_shift`; the
OpenAI-compatible backend sends them to a remote that advertises them for its
model and refuses them otherwise
([backends](reference/backends.md#openai-compatible-http-backend)).

The result is the MP4 with its AAC soundtrack. `GeneratedAsset.audio` is a
`GeneratedAudioTrack` (`sample_rate`, `channels`, `duration_seconds`, `muxed`,
`codec`); when MLX-Gen could not mux the track, `muxed` is false and `data`
holds it as WAV bytes. `GeneratedAsset.audio_summary()` reports the soundtrack
in the one shape every layer uses (None without one):

```python
{"present": True, "sample_rate": 32000, "channels": 2, "codec": "aac",
 "muxed": True, "duration_seconds": 5.1667}
```

`codec` is the WAV's (`"pcm_s16le"`) when the track is not muxed, and the
summary then adds `"wav"`: the WAV bytes on the asset, the stored WAV's artifact
ref once stored. With a store, `VisionManager` stores such a WAV as an artifact
of its own (tags `modality: audio`) and records the summary as `audio` in the
video's stored metadata and in the returned ref. `metadata` carries `prompt`
(the composed prompt), `seed`, `steps`, `width`, `height`, `num_frames`,
`requested_frames`, `duration_seconds`, the two shifts, and `mlx_gen`: MLX-Gen's
own metadata sidecar (`<clip>.metadata.json`), including its audio mux facts and
`runtime_memory` (the process's memory at the end of the save, peaks included).

Memory modes: `low` sets the 1 GB MLX cache and `release_transformer=True`: the
transformer is freed before the decode, the model is dropped when the run ends,
and the next request, a batch item included, loads it again. Every `low` clip
then peaks the same: 24.7 GiB for a 640x352, 124-frame clip with the 8-bit
package, alone, in sequence or in a batch. `lowest` adds block streaming
(`stream_blocks=True`): each transformer block is read from disk for the length
of its call (10.6 GiB on the same clip), and the next request also loads
the model again. It works from a
prepared package or from the 16-bit source, and is
refused with `quantize`. MLX-Gen's measured peaks for each package and mode are
in the route row's `measured_runs`; `abstractvision show-model MiniMaxAI/MiniMax-H3`
prints them per package, with the smallest memory each mode was tested on. When
MLX-Gen's preflight finds that a run cannot fit, the backend raises
`GpuOutOfMemoryError` naming the `memory_mode` the run used and the lower modes
to try.

The weights are never downloaded during generation, even with
`allow_download=True`: the catalog marks the downloads that only an explicit
download fetches (`explicit_download: true`), today the three AbstractFramework
packages and the source repository `MiniMaxAI/MiniMax-H3`. The packages are gated,
and the MiniMax H3 Community License's grant excludes the European Union, the
United Kingdom, the Republic of Korea and the United States of America (the
source repository is not gated; the same licence applies). Accept the
licence on the package page while logged in to Hugging Face and download
explicitly: `abstractvision download MiniMaxAI/MiniMax-H3` fetches the
recommended 8-bit package (`--bits 4` or `--bits 16` the others), and
`--base-model minimax-h3-turbo-544p` (or `minimax-h3-turbo`) also caches the
Turbo adapter that schedule loads. `minimax-h3` loads no adapter. See
[Downloads](reference/configuration.md#downloads).

## Host integration

What an application embedding `VisionManager` can rely on:

- **Engine metadata.** MLX-Gen results carry the engine's metadata under
  `metadata["mlx_gen"]` (image, edit, upscale and video routes).
- **Cancellation.** Every request takes `cancel_event` (anything with `is_set()`,
  such as `threading.Event`). A set event stops an MLX-Gen run at its next
  progress event, between denoising steps, and raises `GenerationCancelledError`.
  What stays loaded after a cancelled run depends on the family:
  - image, edit, Wan A14B and MiniMax-H3 keep the model in `"default"`, and
    SeedVR2 in every mode;
  - Wan TI2V-5B always drops it (it releases its denoiser before the decode);
  - image, edit, Wan A14B and MiniMax-H3 runs in `"low"` (MiniMax-H3 in
    `"lowest"` too) drop it, a batch item included.

  The `GenerationCancelledError` an MLX-Gen run raises carries no traceback of
  the run, so a caller that keeps it holds none of the run's memory.

  Diffusers and stable-diffusion.cpp check the event before a run starts; the
  OpenAI-compatible backend cancels its remote job on a remote that advertises
  the vision routes for the model, and elsewhere (the OpenAI API, a remote
  without those routes, a model the remote does not list) checks the event only
  before sending. Such a request runs there as a job, which AbstractCore's server refuses
  while another generation runs (a request without `cancel_event` waits instead);
  the backend raises that as a `RuntimeError` saying so.
  `get_capabilities().cancellation` is `"step"` or `"start"`.
- **Load-time quantize.** `quantize` (bits) on generation requests.
  `get_capabilities().quantize_bits` lists the widths the configured model
  accepts: the route's `validated_quantization_bits`, else MLX-Gen's `--quantize`
  choices (for MiniMax-H3, its own 8 and 4). A prepared package (its shards carry
  MLX-Gen's metadata, or the catalog lists it as a prepared or sub-16-bit package)
  lists none and refuses it, as do the other local backends; the OpenAI-compatible
  backend sends it to a remote that advertises it.
- **Metadata without local paths.** MLX-Gen results report the model as its repo
  id (a Hugging Face cache snapshot) or its directory name (another local path),
  and adapters the same way (`org/name:file.safetensors`, or the file name):
  every field of the engine's metadata that holds a path (`model`, `lora_paths`,
  `lora_application_reports`, the file `video_health` checked, the `original_*`
  fields an upscale copies from its input), in `metadata["mlx_gen"]` and its
  top-level copies, and `requested_lora_adapters`; the fields naming the files
  AbstractVision wrote for a run (`image_path`, `image_paths`, `masked_image_path`,
  `video_path`, `audio_sidecar_path`) are left out.
- **Route rows.** `vm.describe_routes(model=None, task=None)` returns MLX-Gen's
  capability rows (schema 17) as JSON: canvas and frame rules, defaults, LoRA,
  audio, memory (`measured_runs`, peaks), quantization. Other
  backends return `[]`.
- **Progress.** `on_progress(event)` receives `VideoProgressEvent` with `phase`,
  `step`, `total_steps` (and `frame`, `total_frames` on video) as MLX-Gen emits
  them. An exception raised in a progress callback is logged once per run and
  does not stop the run; use `cancel_event` to stop one.
- **Embedding.** `import abstractvision` and constructing a `VisionManager` write
  no files, set no environment variables, configure no loggers and import neither
  AbstractCore nor an engine. MLX-Gen is imported at the first capability lookup
  or model load; its own import sets `TOKENIZERS_PARALLELISM=false` when unset.

## Shared LoRA adapters

AbstractVision exposes a typed LoRA contract across Python, CLI, and the
AbstractCore plugin through `LoRAAdapterSpec` plus the request field
`lora_adapters=[...]`.

Each adapter can carry:

- `source`
- `scale`
- `weight_name`
- `subfolder`
- `adapter_name`
- `target_role`

Wan TI2V-5B uses one role, `transformer`. Wan A14B routes require explicit
`high_noise_transformer` / `low_noise_transformer` assignment. Provider catalogs
surface exact-route LoRA truth through `supports_lora`, `lora_status`,
`lora_target_roles`, and `lora_validation_profile`.

## Passing advanced backend parameters (`extra`)

Request dataclasses include an `extra: dict` field ([`../src/abstractvision/types.py`](../src/abstractvision/types.py)). Use it to pass backend-specific parameters in a controlled way:

```python
asset_or_ref = vm.generate_image(
    "a product photo of a matte black espresso machine",
    steps=8,
    guidance_scale=1.0,
    extra={
        # Compatibility-only keys used by older Diffusers flows:
        "rapid_aio_repo": "linoyts/Qwen-Image-Edit-Rapid-AIO",
    },
)
```

Backends may ignore unknown keys; consult the backend implementation and
[docs/reference/backends.md](reference/backends.md). New callers should prefer
the typed shared `lora_adapters` field instead of `extra["loras*"]`. Legacy
Diffusers compatibility payloads such as `loras_json` still work, but they are
no longer the preferred public contract.

## Capability registry (what models can do)

The packaged registry is loaded by `VisionModelCapabilitiesRegistry` ([`../src/abstractvision/model_capabilities.py`](../src/abstractvision/model_capabilities.py)).

```python
from abstractvision import VisionModelCapabilitiesRegistry

reg = VisionModelCapabilitiesRegistry()
print(reg.list_tasks())
print(reg.models_for_task("text_to_image"))

reg.require_support("runwayml/stable-diffusion-v1-5", "text_to_image")
```

Optional gating:
- If you construct `VisionManager(model_id=..., registry=...)`, the manager will fail fast on unsupported tasks before calling a backend ([`../src/abstractvision/vision_manager.py`](../src/abstractvision/vision_manager.py)).

Important: the registry is *not* a guarantee that your configured backend can execute a task at runtime.
Use [docs/reference/backends.md](reference/backends.md) for backend support.

### Downloads and what is cached

The download presets live in
[`../src/abstractvision/model_downloads.py`](../src/abstractvision/model_downloads.py); the state of a
preset on this host in [`../src/abstractvision/model_inventory.py`](../src/abstractvision/model_inventory.py).
The CLI's `download`, `catalog`, `show-model` and `models --json` are built on them.

```python
from abstractvision.model_downloads import download_model_preset, plan_model_preset_download, select_download_preset
from abstractvision.model_inventory import preset_status

preset = select_download_preset("MiniMaxAI/MiniMax-H3")          # the recommended package: AbstractFramework/minimax-h3-8bit
preset = select_download_preset("MiniMaxAI/MiniMax-H3", bits=4)  # AbstractFramework/minimax-h3-4bit
print(preset.gated, preset.license_name, preset.recommended)  # from the catalog
plan = plan_model_preset_download(preset, base_model="minimax-h3-turbo-544p")  # reads the Hub listings; downloads nothing
print(plan.summary_lines(), plan.disk_space_error())  # access, sizes, files complete / to fetch, free disk space
print(preset_status(preset))  # cache / cache_bytes / cache_gaps / snapshot_dir / memory_modes / memory_peaks
snapshot_dir = download_model_preset(preset, base_model="minimax-h3-turbo-544p", report=print)
```

- `select_download_preset(name, *, target, engine, bits, allow_non_8bit)`: the preset `abstractvision
  download` fetches, with its flags. The host's order picks the target, preferring an 8-bit package
  unless `allow_non_8bit` or an MLX-Gen engine or target is named (`target` or `engine` restricts it;
  `bits` keeps one width). Within that target
  a single package is selected, and several select the one the catalog marks `recommended`; with none
  recommended, `ValueError` lists them, whatever the flags narrowed them to. Without the 8-bit preference a
  repository named exactly selects that repository instead of a package made from it, on every host. A
  Hugging Face `owner/name` the catalog does not name is the whole repository (`repository_preset`).
  `find_model_preset(name, *, target, engine, require_8bit, bits, download_rule=False)` is the catalog
  lookup it is built on; without `download_rule` (as the backends resolve a configured model), several
  packages with none recommended resolve by the catalog's own order (`qwen-image` to Qwen-Image-2512).
- `download_command(repo_id, *, engine=None, base_model=None)`: the `abstractvision download` command
  that selects exactly `repo_id` on this host, checked with `select_download_preset`:
  `abstractvision download MiniMaxAI/MiniMax-H3 --allow-non-8bit` for the MiniMax-H3 source repository,
  `abstractvision download AbstractFramework/minimax-h3-8bit` for a package; `ValueError` when no form
  of the command selects it, or when the catalog lists the repository but not for `engine` (a repository
  outside the catalog is fetched whole, whatever the engine).
- `plan_model_preset_download(preset, *, base_model, model_dir, token, all_files)`: a `DownloadPlan`,
  read from the Hub listings without writing anything. `parts` are the repositories the download fetches
  from (`DownloadPart`: `role`, `plan`): the package, a stable-diffusion.cpp bundle's companions (`vae`,
  `llm`), and the adapter of the MLX-Gen schedule `base_model` unless mlx-gen finds it cached
  (`adapter`, `adapter_path`). Each part's `plan` is a `HubDownloadPlan`: `files` (each a `HubFile` with
  `name`, `size`, `complete` (its snapshot link or blob is in the cache, huggingface_hub's own test) and
  `partial` (the bytes its `.incomplete` file holds)), `complete_files`, `fetch_files`, `total_bytes`,
  `complete_bytes`, `fetch_bytes`, `partial_bytes`, `required_bytes`, `free_bytes`, `commit` (the commit
  the listing named, which the fetch takes), `gated`, `listing_error` (why there is no listing; the byte
  counts are then None). The `DownloadPlan` adds the totals, `legacy_import` / `legacy_remove` (a legacy
  tree), `summary_lines()`, `disk_space_error()` (the message when the files to fetch do not fit under
  `DISK_RULE`, else None) and `to_dict()`. `download --dry-run` prints it. Raises
  `HuggingFaceAccessError` when the Hub refuses a repository, `ValueError` when `base_model` is not a
  schedule of the package, and `OptionalDependencyMissingError` when the adapter can only be named by
  mlx-gen and mlx-gen cannot be imported.
- `DISK_RULE`: the files to fetch count at their full size, less what their partial `.incomplete` files
  already hold, because huggingface_hub writes each file into that same file (continuing it over plain
  HTTP, rewriting it from the start over Xet).
- `download_model_preset(preset, *, base_model, model_dir, token, max_workers, all_files, report)`: plans
  first and passes the summary to `report`. A legacy `<model_dir>/<preset.local_dir_name>` tree
  (`legacy_model_tree`) is moved into the cache and used as the package as it is (`report` says it was
  not compared with the Hub). Raises `InsufficientDiskSpaceError` (a `RuntimeError`) before anything is
  written when the files to fetch do not fit; fetches exactly the files to fetch of every part (none
  when every file is complete), from the commit each listing named, and records that commit as the
  repository's `main`; raises `HuggingFaceAccessError` when the Hub refuses a repository (naming the
  licence when the catalog marks it gated) and `RuntimeError` when files are missing after the download.
  Without a listing it uses what a local look finds in the cache as it is when it finds every part, else
  raises `RuntimeError` saying why there is no listing and what to do. Returns the package snapshot.
- `repository_preset(repo_id)`: a repository the catalog does not list, downloaded whole through the same
  plan.
- `local_cache_state(preset)`: the local look the listings use, offline: `snapshot_dir`, `files`,
  `bytes`, `gaps` (what it can see is missing: partial files, links without content, weight files an
  index names, components `model_index.json` names whose folder the preset's patterns name, no weight
  file) and `state` (`cached`, `incomplete`
  or `absent`). No gap does not prove the snapshot holds every file the package selects; only the plan
  can tell.
- `preset_status(preset)`: `cache`, `cache_bytes`, `cache_gaps` and `snapshot_dir` (from
  `local_cache_state`), `memory_modes` (what the backend serving the preset honours on this host; `None`
  when that backend cannot run here) and, for MLX-Gen prepared packages whose capability rows publish
  measured runs, `memory_peaks` (below) and `smallest_tested_memory_gb` (per mode, the smallest unified
  memory mlx-gen completed a run of that width on, where it publishes it). The figures are read from the
  installed mlx-gen at run time.
- `memory_peaks(repo_id)`: MLX-Gen's measured runs for one catalog package, as JSON rows
  `{task, memory_mode, width, height, frames, steps, peak_bytes, machine_total_ram_bytes}` (`peak_bytes` is
  the whole-process footprint, `machine_total_ram_bytes` the memory of the Mac it ran on), kept to the
  package's stored width. A run names its canvas, frames and steps but not the schedule it ran with, and
  mlx-gen publishes the same runs on every MiniMax-H3 schedule (all at 8 steps), so the rows are
  per package, not per schedule. Empty for a repository that is not a prepared MLX-Gen package of the
  catalog, or when mlx-gen is not installed or publishes nothing; no model is built.
- `abstractvision.backends.mflux.resolve_mlx_gen_schedule_adapter(base_model, download=False)`: the
  adapter an MLX-Gen schedule loads (the MiniMax-H3 Turbo LoRA) and where mlx-gen finds it, or `None`
  when the schedule loads none. `abstractvision download --base-model` fetches the adapter through its
  plan (into huggingface_hub's cache, where mlx-gen looks), not with `download=True`.

## Artifacts and stores

Artifact helpers and store implementations live in [`../src/abstractvision/artifacts.py`](../src/abstractvision/artifacts.py):

- `LocalAssetStore` (standalone local files, default `~/.abstractvision/assets`)
- `RuntimeArtifactStoreAdapter` (duck-typed adapter for an external artifact store)
- `is_artifact_ref(...)` / `make_media_ref(...)`

See: [docs/reference/artifacts.md](reference/artifacts.md).

## Errors you may want to handle

Common exceptions (defined in [`../src/abstractvision/errors.py`](../src/abstractvision/errors.py)):

- `BackendNotConfiguredError` (calling `VisionManager` without a backend)
- `CapabilityNotSupportedError` (task isn’t supported by the model registry or backend, or the backend does not accept the requested `memory_mode` or another typed option)
- `GenerationCancelledError` (the request's `cancel_event` was set)
- `UnknownModelError` (model id isn’t present in the registry)
- `OptionalDependencyMissingError` (backend dependency is missing, e.g. Diffusers/Torch)
- `GpuOutOfMemoryError` (a CUDA out-of-memory during a Diffusers generation: the message names the model's size, its placement, what was free and what to change: a smaller canvas or fewer steps, sequential CPU offload, or the GGUF path; raised instead of torch's traceback. On MLX-Gen MiniMax-H3 routes, raised when MLX-Gen's preflight reports that the weights or a run cannot fit, naming the `memory_mode` it used and the lower ones; MLX-Gen reports this for MiniMax-H3 only)
--- >8 --- END FILE: docs/api.md --- >8 ---

--- 8< --- FILE: docs/architecture.md --- 8< ---
# AbstractVision architecture

AbstractVision is a model-agnostic Python layer that standardizes **generative vision outputs** behind a small API:
text→image, image→image (and optionally video when a backend supports it).

This document describes the *current code in this repo* and links to the supporting reference docs.

See also:
- Docs index: [docs/README.md](README.md)
- Getting started: [docs/getting-started.md](getting-started.md)
- API reference: [docs/api.md](api.md)
- FAQ: [docs/faq.md](faq.md)
- ADR index: [docs/adr/README.md](adr/README.md)
- Backends: [docs/reference/backends.md](reference/backends.md)
- Capability registries: [docs/reference/capabilities-registry.md](reference/capabilities-registry.md)
- Artifacts: [docs/reference/artifacts.md](reference/artifacts.md)
- AbstractCore integration: [docs/reference/abstractcore-integration.md](reference/abstractcore-integration.md)

## AbstractFramework ecosystem (positioning)

AbstractVision is one component in the **AbstractFramework** ecosystem:

- **AbstractFramework** (project hub): <https://github.com/lpalbou/AbstractFramework>
- **AbstractCore** (orchestration + tool calling): <https://github.com/lpalbou/abstractcore>
- **AbstractRuntime** (runtime services, including artifact storage): <https://github.com/lpalbou/abstractruntime>

Where AbstractVision fits:
- AbstractVision focuses on *producing* images/videos (generators).
- AbstractCore focuses on orchestration, tool calling, and higher-level workflows (it can discover AbstractVision via the plugin entry point in `pyproject.toml` and `src/abstractvision/integrations/abstractcore_plugin.py`).
- AbstractRuntime provides runtime services and an artifact store interface; `RuntimeArtifactStoreAdapter` bridges AbstractVision to an AbstractRuntime-style artifact store (`src/abstractvision/artifacts.py`).

## Scope (and non-goals)

AbstractVision focuses on **producing** images/videos.

It is not the owner of “LLM image/video input attachments” (multimodal inputs to LLMs); those concerns live in higher-level layers (e.g., AbstractCore).

## Key components (with evidence pointers)

- **Orchestrator**: [`VisionManager`](../src/abstractvision/vision_manager.py)
  - Delegates execution to a backend.
  - Optionally gates requests using the capability registry when `model_id` is set.
  - Optionally stores outputs and returns artifact refs when `store` is set.
- **Backend contract**: [`VisionBackend`](../src/abstractvision/backends/base_backend.py)
  - Implementations live in [`../src/abstractvision/backends/`](../src/abstractvision/backends/).
- **Capability registries**:
  - [`VisionModelCapabilitiesRegistry`](../src/abstractvision/model_capabilities.py) loads [`vision_model_capabilities.json`](../src/abstractvision/assets/vision_model_capabilities.json) and governs the model catalog, task metadata, and curated download surfaces.
  - [`VisionAdapterCapabilitiesRegistry`](../src/abstractvision/adapter_capabilities.py) loads [`vision_adapter_capabilities.json`](../src/abstractvision/assets/vision_adapter_capabilities.json) and governs package-owned adapter defaults, compatibility hints, and adapter discovery metadata.
  - See [ADR 0005](adr/0005_curated_capability_registry_and_download_catalog.md).
- **Artifact outputs**: [`MediaStore`](../src/abstractvision/artifacts.py), [`LocalAssetStore`](../src/abstractvision/artifacts.py), [`RuntimeArtifactStoreAdapter`](../src/abstractvision/artifacts.py)
  - Artifact ref helper: `is_artifact_ref()` (see [`../src/abstractvision/artifacts.py`](../src/abstractvision/artifacts.py)).
- **CLI/REPL**: `abstractvision` entrypoint ([`../src/abstractvision/cli.py`](../src/abstractvision/cli.py))
  - Lets you inspect the registry and manually test generation backends.
- **AbstractCore integration**:
  - Capability plugin: [`../src/abstractvision/integrations/abstractcore_plugin.py`](../src/abstractvision/integrations/abstractcore_plugin.py) (registered in `pyproject.toml`)
  - Tool helpers: [`../src/abstractvision/integrations/abstractcore.py`](../src/abstractvision/integrations/abstractcore.py)

## High-level flow (library mode)

```mermaid
flowchart LR
  Caller[Caller<br/>(Python / CLI)] --> VM[VisionManager]
  VM -->|request dataclass| BE[VisionBackend]
  BE -->|GeneratedAsset| VM
  VM -->|store set| Store[MediaStore<br/>(LocalAssetStore / Runtime adapter)]
  Store --> Ref[Artifact ref dict]
  VM -->|store not set| Asset[GeneratedAsset<br/>(bytes + mime)]
```

Notes (anchored in code):
- `VisionManager` creates request dataclasses like `ImageGenerationRequest` / `ImageEditRequest` ([`../src/abstractvision/types.py`](../src/abstractvision/types.py)).
- When `store` is set, `VisionManager._maybe_store()` calls `store.store_bytes(...)` and returns an artifact ref dict ([`../src/abstractvision/vision_manager.py`](../src/abstractvision/vision_manager.py), [`../src/abstractvision/artifacts.py`](../src/abstractvision/artifacts.py)).

## Capability gating (model-level) vs runtime gating (backend-level)

AbstractVision separates two kinds of “can I do this?” checks:

1) **Model-level gating** (optional): “Does model X support task Y?”
   - Implemented by `VisionModelCapabilitiesRegistry.require_support(...)` ([`../src/abstractvision/model_capabilities.py`](../src/abstractvision/model_capabilities.py))
   - Used by `VisionManager._require_model_support(...)` when `VisionManager.model_id` is set ([`../src/abstractvision/vision_manager.py`](../src/abstractvision/vision_manager.py))

2) **Backend-level gating** (best-effort): “Does this configured backend support task Y / mask edits / control images?”
   - Backends may implement `get_capabilities()` returning `VisionBackendCapabilities` ([`../src/abstractvision/types.py`](../src/abstractvision/types.py))
   - Enforced by `VisionManager._require_backend_support(...)` and mask checks in `VisionManager.edit_image(...)` ([`../src/abstractvision/vision_manager.py`](../src/abstractvision/vision_manager.py))

## Backend reality (what runs today)

The public API includes `text_to_video`, `image_to_video`, and `multi_view_image`, but backend support is currently limited:

- Built-in backends implement **images** (`text_to_image`, `image_to_image`):
  - OpenAI-compatible HTTP backend ([`../src/abstractvision/backends/openai_compatible.py`](../src/abstractvision/backends/openai_compatible.py))
  - Diffusers backend ([`../src/abstractvision/backends/huggingface_diffusers.py`](../src/abstractvision/backends/huggingface_diffusers.py))
  - stable-diffusion.cpp backend ([`../src/abstractvision/backends/stable_diffusion_cpp.py`](../src/abstractvision/backends/stable_diffusion_cpp.py))
  - MLX-Gen backend for curated Apple-first local MLX presets ([`../src/abstractvision/backends/mflux.py`](../src/abstractvision/backends/mflux.py))
- Local MLX-Gen supports `text_to_image` for curated q4/q8 FLUX.2, Qwen Image, Z-Image, ERNIE Image Turbo, and official FIBO snapshots; supports `image_to_image` for FLUX.2 klein/base, Qwen Image Edit, ERNIE Image Turbo, FIBO, and FIBO Edit models; supports Qwen/FIBO masked edits through route-aware runtime checks (and refuses structured control images); and supports Wan 2.2 TI2V plus task-specific Wan 2.2 A14B packages for `text_to_video` and first-frame `image_to_video`.
- Local Diffusers `text_to_video` remains experimental and is temporarily disabled from the normal local surfaces.
- OpenAI-compatible HTTP can also support `text_to_video` / `image_to_video` when `text_to_video_path` / `image_to_video_path` are configured ([`../src/abstractvision/backends/openai_compatible.py`](../src/abstractvision/backends/openai_compatible.py)).
- No built-in backend implements `multi_view_image` yet (they raise `CapabilityNotSupportedError` in `generate_angles(...)`).

For a detailed support matrix and configuration options, see [docs/reference/backends.md](reference/backends.md).

## Catalog and compatibility policy

AbstractVision treats model discovery, curated downloads, and runtime compatibility as part of the
product surface:

- the registry is global and platform-neutral;
- host-specific recommendation happens later in catalog or preset selection;
- one parent model family may expose multiple engine-specific variants;
- official upstream repos are preferred, with curated community ports used only when they provide
  the best runtime-native artifact for a target engine.

That policy is defined in [ADR 0005](adr/0005_curated_capability_registry_and_download_catalog.md).

## AbstractCore plugin flow (framework integration)

AbstractVision can be discovered by AbstractCore via an entry point:
`[project.entry-points."abstractcore.capabilities_plugins"]` in [`../pyproject.toml`](../pyproject.toml).

```mermaid
flowchart LR
  AC[AbstractCore] -->|loads entry point| Plugin[AbstractVision plugin<br/>register(...)]
  Plugin --> Cap[VisionCapability<br/>(t2i/i2i/t2v/i2v)]
  Cap --> VM[VisionManager]
  VM --> BE{Configured backend}
  BE --> HTTP[OpenAI-compatible HTTP<br/>OpenAI or local /v1 server]
  BE --> HF[Local Diffusers]
  BE --> SDCPP[Local stable-diffusion.cpp]
```

Current plugin behavior (evidence in [`../src/abstractvision/integrations/abstractcore_plugin.py`](../src/abstractvision/integrations/abstractcore_plugin.py)):
- Default: OpenAI HTTP with backend id `abstractvision:openai`; the legacy backend id `abstractvision:openai-compatible` remains registered and preserves compatible-endpoint defaults when selected directly.
- Compatible endpoints should set `OPENAI_BASE_URL`; set `ABSTRACTVISION_BACKEND=openai-compatible` when you want to force compatible-endpoint semantics.
- Local Diffusers and stable-diffusion.cpp are supported when `vision_backend` / `ABSTRACTVISION_BACKEND` selects `diffusers` or `sdcpp`.
- A request whose provider is `endpoint:<id>` runs on that endpoint profile's OpenAI-compatible API with the profile's own base URL and key (resolved by the owning Core provider's host resolver, then the ambient `abstractcore.providers.endpoint_context` resolver, then AbstractCore's `provider_profiles`; only `openai` / `openai-compatible` profiles are accepted).
- Configuration is read from `owner.config` keys like `vision_base_url`, `vision_model_id`, `vision_backend`, and backend-specific keys, then falls back to `ABSTRACTVISION_*` and standard OpenAI env vars where relevant.

## Extending AbstractVision (practical steps)

- Add a new backend:
  1) Implement `VisionBackend` ([`../src/abstractvision/backends/base_backend.py`](../src/abstractvision/backends/base_backend.py))
  2) Add capability reporting via `get_capabilities()` when you can (optional)
  3) Add tests under [`../tests/`](../tests/)
- Update the registries:
  1) Edit [`../src/abstractvision/assets/vision_model_capabilities.json`](../src/abstractvision/assets/vision_model_capabilities.json) for model/task/download metadata or [`../src/abstractvision/assets/vision_adapter_capabilities.json`](../src/abstractvision/assets/vision_adapter_capabilities.json) for adapter defaults/compatibility hints
  2) Validate by running the test suite (validators are wired into both registry loaders)
  3) Use `abstractvision show-model <id>` and `abstractvision adapters --provider mlx-gen --model <id> --task <task> --json` to sanity-check the effective packaged metadata ([`../src/abstractvision/cli.py`](../src/abstractvision/cli.py))
--- >8 --- END FILE: docs/architecture.md --- >8 ---

--- 8< --- FILE: docs/faq.md --- 8< ---
# FAQ

See also:
- Getting started: [docs/getting-started.md](getting-started.md)
- API reference: [docs/api.md](api.md)
- Architecture: [docs/architecture.md](architecture.md)
- Backends: [docs/reference/backends.md](reference/backends.md)
- Configuration: [docs/reference/configuration.md](reference/configuration.md)

## What is AbstractVision?

AbstractVision is a small, model-agnostic API for **generative vision outputs** (images, optional video) with:
- a small orchestrator ([`VisionManager`](../src/abstractvision/vision_manager.py))
- pluggable execution engines (“backends”) in [`../src/abstractvision/backends/`](../src/abstractvision/backends/)
- packaged capability registries ([`vision_model_capabilities.json`](../src/abstractvision/assets/vision_model_capabilities.json), [`vision_adapter_capabilities.json`](../src/abstractvision/assets/vision_adapter_capabilities.json))
- optional artifact-ref outputs via stores ([`../src/abstractvision/artifacts.py`](../src/abstractvision/artifacts.py))

## How does AbstractVision fit into AbstractFramework?

AbstractVision is part of the **AbstractFramework** ecosystem:

- **AbstractFramework** (project hub): <https://github.com/lpalbou/AbstractFramework>
- **AbstractCore** (orchestration + tool calling): <https://github.com/lpalbou/abstractcore>
- **AbstractRuntime** (runtime services, including artifact storage): <https://github.com/lpalbou/abstractruntime>

Where AbstractVision fits:
- It standardizes *generative vision outputs* behind `VisionManager` (library mode).
- AbstractCore can discover and use AbstractVision via the capability plugin (see [`../src/abstractvision/integrations/abstractcore_plugin.py`](../src/abstractvision/integrations/abstractcore_plugin.py) and the entry point in [`../pyproject.toml`](../pyproject.toml)).
- Artifact refs are designed to cross process boundaries; `RuntimeArtifactStoreAdapter` bridges to an AbstractRuntime-style artifact store (see [`../src/abstractvision/artifacts.py`](../src/abstractvision/artifacts.py)).

## What does AbstractVision support today?

- Built-in backends implement **images**: `text_to_image` and `image_to_image`.
- Local MLX-Gen supports curated q4/q8 image presets, Qwen/FIBO/FLUX.2 klein/Z-Image Turbo masked edits, a structured control image on `AbstractFramework/qwen-image-8bit` only, official FIBO image snapshots, SeedVR2 image upscaling and video restoration, shared LoRA adapters, and Wan 2.2 TI2V plus task-specific Wan 2.2 A14B `text_to_video` / first-frame `image_to_video`, with `video_to_video` on Wan 2.2 T2V-A14B and Wan 2.1 VACE 1.3B. MLX-Gen is validated on Apple Silicon. The explicit `mlx-gen` extra also installs on Linux, where it is not validated yet (see [backlog 030](backlog/planned/030_gpu_parity_with_mlx_gen.md)); the NVIDIA/Linux `gpu` and `all-gpu` profiles do not include it.
- Local Diffusers `text_to_video` remains experimental and is temporarily disabled from the normal local runtime surfaces.
- OpenAI-compatible HTTP can also provide `text_to_video` / `image_to_video` **when** video endpoints are configured.
- `multi_view_image` exists in the public API (`VisionManager.generate_angles`) but no built-in backend implements it yet (they raise `CapabilityNotSupportedError`).

Details: [docs/reference/backends.md](reference/backends.md).

## Which backend should I use?

- **OpenAI-compatible HTTP** ([`../src/abstractvision/backends/openai_compatible.py`](../src/abstractvision/backends/openai_compatible.py)): call a server that exposes OpenAI-shaped image endpoints (and optional video endpoints).
- **Diffusers (local)** ([`../src/abstractvision/backends/huggingface_diffusers.py`](../src/abstractvision/backends/huggingface_diffusers.py)): run Diffusers pipelines locally (heavy deps). Local `text_to_video` groundwork exists but is currently quarantined from the normal local surfaces.
- **MLX-Gen (local, Apple-first)** ([`../src/abstractvision/backends/mflux.py`](../src/abstractvision/backends/mflux.py)): run MLX-optimized image models, validated Qwen structured-control and masked-edit routes, FIBO snapshots, shared LoRA adapters, SeedVR2 upscaling, and Wan 2.2 video locally.
- **stable-diffusion.cpp (local GGUF)** ([`../src/abstractvision/backends/stable_diffusion_cpp.py`](../src/abstractvision/backends/stable_diffusion_cpp.py)): run GGUF diffusion models via `sd-cli` or `stable-diffusion-cpp-python`.

## What model should I start with (local)?

If you’re running locally via the Diffusers backend and want a reliable starting point, we recommend:

- **Default / ≤16GB VRAM (cross-platform)**: `runwayml/stable-diffusion-v1-5`

Quickstart:

```bash
abstractvision download stable-diffusion --provider diffusers
export ABSTRACTVISION_BACKEND=diffusers
export ABSTRACTVISION_MODEL_ID=runwayml/stable-diffusion-v1-5
export ABSTRACTVISION_DIFFUSERS_DEVICE=auto
abstractvision cli
```

More model recommendations (by VRAM tier) are in [docs/getting-started.md](getting-started.md).

After that works, `black-forest-labs/FLUX.2-klein-4B` is the recommended next local test for a newer non-gated model
(it currently requires Diffusers from source).

## Do the one-shot CLI commands run locally?

Yes. `abstractvision t2i` / `abstractvision i2i` / `abstractvision t2v` run on this machine's local engine by default (MLX-Gen on Apple silicon, stable-diffusion.cpp on an NVIDIA card, Diffusers on a processor-only host) with FLUX.2 [klein] 4B as the default model (the 8-bit MLX-Gen package, the Q8_0 GGUF on stable-diffusion.cpp, the 16-bit Diffusers pipeline run in float32 on a processor); give `--base-url` for the OpenAI-compatible HTTP backend or `--provider` for another local engine.

For interactive local generation, use `abstractvision cli` (legacy alias: `abstractvision repl`) with `/backend diffusers ...`, `/backend mlx-gen ...`, or `/backend sdcpp ...`.

Current local video note:
- local Diffusers `t2v` is currently experimental and disabled from the normal bundled local surfaces;
- local MLX-Gen `t2v` / `i2v` is available through task-specific Wan A14B packages such as `AbstractFramework/wan2.2-t2v-a14b-diffusers-8bit` and `AbstractFramework/wan2.2-i2v-a14b-diffusers-8bit`;
- MLX-Gen denoise-step video progress is shown by default in the shell and interactive CLI and is available to Python/Core callers through `on_progress(event)`;
- remote `text_to_video` / `image_to_video` still depend on the OpenAI-compatible backend being configured with video endpoints.

## Where do generated outputs go?

It depends on whether you configured a store:

- **CLI/REPL**: stores outputs in a local store by default (`LocalAssetStore`), under `~/.abstractvision/assets` unless `ABSTRACTVISION_STORE_DIR` is set ([`../src/abstractvision/artifacts.py`](../src/abstractvision/artifacts.py), [`../src/abstractvision/cli.py`](../src/abstractvision/cli.py)).
- **Python**:
  - if `VisionManager.store` is set, methods return an artifact ref dict (stored via `store.store_bytes(...)`)
  - otherwise they return a `GeneratedAsset` containing bytes ([`../src/abstractvision/types.py`](../src/abstractvision/types.py))

## What is an “artifact ref”?

An artifact ref is a small JSON dict that points to a stored blob. Minimal shape:

```json
{"$artifact":"<id>"}
```

Helpers: `is_artifact_ref()` / `make_media_ref()` in [`../src/abstractvision/artifacts.py`](../src/abstractvision/artifacts.py).

## How do I allow or block Diffusers downloads?

- REPL: cache-only is the default. Pre-download models separately, or set `ABSTRACTVISION_DIFFUSERS_ALLOW_DOWNLOAD=1` when you intentionally want runtime downloads ([`../src/abstractvision/cli.py`](../src/abstractvision/cli.py)).
- Python: `HuggingFaceDiffusersBackendConfig` defaults to `allow_download=False`; set `allow_download=True` only when you want runtime downloads ([`../src/abstractvision/backends/huggingface_diffusers.py`](../src/abstractvision/backends/huggingface_diffusers.py)).

## Why do I get “missing pipeline class” errors (e.g. `GlmImagePipeline`)?

Some newer pipelines may only exist on Diffusers GitHub `main`. Install:

- `pip install -U "abstractvision[diffusers-dev]"` (compatible dependency versions)
- `pip install -U "git+https://github.com/huggingface/diffusers@main"` (Diffusers `main`)

See: [docs/getting-started.md](getting-started.md).

## macOS (MPS): why do I get black images / dtype errors?

The Diffusers backend includes MPS-specific mitigations (e.g. VAE upcast and optional fp32 retry) in [`../src/abstractvision/backends/huggingface_diffusers.py`](../src/abstractvision/backends/huggingface_diffusers.py).

Common fixes:
- set `ABSTRACTVISION_DIFFUSERS_TORCH_DTYPE=float32` (more stable, higher memory)
- disable retry if memory is tight: `ABSTRACTVISION_DIFFUSERS_AUTO_RETRY_FP32=0`
- consider using the stable-diffusion.cpp backend for GGUF diffusion models ([docs/getting-started.md](getting-started.md))

## Windows/Linux (CUDA): why is `torch.cuda.is_available()` false?

On Windows/Linux, `pip install torch` (and packages that depend on `torch`) may install a CPU-only PyTorch build by default.

If you have an NVIDIA GPU and want CUDA acceleration:

1) Install a CUDA-enabled PyTorch wheel using the official selector: <https://pytorch.org/get-started/locally/>  
2) Verify:

```bash
python -c "import torch; print('cuda', torch.cuda.is_available())"
```

## How do I pass advanced flags / parameters?

AbstractVision exposes an `extra` dict on requests ([`../src/abstractvision/types.py`](../src/abstractvision/types.py)), and the REPL forwards unknown `--flags` into `request.extra` ([`../src/abstractvision/cli.py`](../src/abstractvision/cli.py)).

Examples:
- Shared LoRA contract: use `lora_adapters=[LoRAAdapterSpec(...)]` in Python, or repeated `--lora` / `--lora-scale` / `--lora-target-role` in the CLI.
- Diffusers backend: still accepts compatibility keys like `loras_json` and `rapid_aio_repo` (used by older Qwen Image Edit flows; see [docs/getting-started.md](getting-started.md) and [`../src/abstractvision/backends/huggingface_diffusers.py`](../src/abstractvision/backends/huggingface_diffusers.py)).
- stable-diffusion.cpp backend:
  - CLI mode forwards flags to `sd-cli`
  - python-binding mode maps supported keys to binding kwargs and ignores unsupported keys ([`../src/abstractvision/backends/stable_diffusion_cpp.py`](../src/abstractvision/backends/stable_diffusion_cpp.py))

## How do I change the size of a Wan video?

Each Wan model has a default size in the MLX-Gen backend
(`WAN_VIDEO_DEFAULT_CANVASES` in [`../src/abstractvision/backends/mflux.py`](../src/abstractvision/backends/mflux.py)):
832x480 for TI2V-5B (121 frames at 24 fps, 50 steps) and for both A14B models
(81 frames at 16 fps, 40 steps). Override any of them per request:

- CLI: `abstractvision t2v ... --width 1280 --height 704 --frames 121 --fps 24 --steps 30`
- Python: `vm.generate_video(prompt, width=1280, height=704, num_frames=121, fps=24, steps=30)`
- AbstractCore / Gateway: pass the same fields (`width`, `height`, `num_frames`,
  `fps`, `steps`) in the video request or its `output={...}` options.

TI2V-5B accepts multiples of 32 from 832x480 (or 480x832) upward; the A14B
models accept multiples of 16. Frame counts follow Wan's `4n+1` rule (for
example 81 or 121). At 832x480 and below, TI2V-5B uses `flow_shift=3.0` unless
you set `flow_shift` yourself.

## How much memory does Wan video need?

The figures below are MLX allocator peaks of a full AbstractVision generation
(text encoding, denoising and VAE decode), measured with AbstractVision/mlx-gen
0.38 on an Apple M5 Max. The denoising peak does not depend on the step count.
AbstractVision keeps the text encoder and VAE in memory, so these are this
engine's figures, not the models' own minimums.

| Model | Size (width x height x frames) | Peak, tiled decode (default) | Peak, untiled decode |
|---|---|---|---|
| TI2V-5B | 832x480x121 (default) | 16.3 GiB (image-to-video 16.6 GiB) | 23.4 GiB |
| TI2V-5B | 1280x704x121 | 25.4 GiB | 51.2 GiB |
| T2V-A14B | 832x480x81 (default) | 38.3 GiB | 47.4 GiB |
| T2V-A14B | 640x352x81 | 35.1 GiB | 41.8 GiB |
| T2V-A14B | 1280x720x81 | 53.5 GiB | 71.6 GiB |
| I2V-A14B | 832x480x81 (default) | 38.4 GiB | not measured |
| I2V-A14B | 1280x720x81 | not measured | 71.7 GiB |

The MLX-Gen backend decodes Wan video in overlapping spatial tiles (on by
default), so the peak is set by denoising rather than by the VAE decode. Pass
`extra={"vae_tiling": False}` (CLI `--no-vae-tiling`) to decode whole frames at
once; at small sizes that decodes somewhat faster, and it raises the peak to the
"untiled" figures.

To lower the peak further, pass `memory_mode="low"` (CLI `--memory-mode low`):
MLX-Gen low-RAM mode clears the MLX cache after every step and transformer block
and holds it at 1 GB, and releases the denoisers (and on A14B the inactive
expert) before the decode, at some cost in speed; the model is loaded again on
the next request. The figures above were measured without it. See [Memory modes](api.md#memory-modes-memory_mode).

Time grows with the canvas and the step count: on the same Mac a default
TI2V-5B clip (832x480, 121 frames, 50 steps) took about 25 minutes end to end.
Lower `steps` for quick drafts: it changes the time, not the peak memory.

## How do I know whether a model route supports LoRA?

Use provider/model discovery:

- `abstractvision catalog --provider mlx-gen` to browse downloadable models
- `abstractvision show-model <model-id>` for the exact runtime route contract
- `abstractvision adapters --provider mlx-gen --model <model-id> --task <task>` for locally cached overlays that match one route
- `VisionManager.list_provider_models(...)`
- `VisionManager.list_provider_adapters(...)`
- `llm.vision.list_provider_models(...)` through the AbstractCore plugin

MLX-Gen route rows surface:

- `supports_lora`
- `lora_status`
- `lora_target_roles`
- `lora_validation_profile`

Wan TI2V-5B uses one target role, `transformer`. Wan A14B routes require
explicit `high_noise_transformer` / `low_noise_transformer` assignment.

## What do the capability registries mean (and what do they not mean)?

The model registry answers “what a model *claims* to support” (task keys/params) and can be used for **optional gating**:

- `VisionModelCapabilitiesRegistry.supports(...)` / `.require_support(...)` ([`../src/abstractvision/model_capabilities.py`](../src/abstractvision/model_capabilities.py))
- `VisionManager(model_id=...)` uses it to fail fast before calling a backend ([`../src/abstractvision/vision_manager.py`](../src/abstractvision/vision_manager.py))

The adapter registry answers “what package-owned adapter defaults and compatibility hints are curated for one adapter family?”:

- `VisionAdapterCapabilitiesRegistry.match_profile(...)` ([`../src/abstractvision/adapter_capabilities.py`](../src/abstractvision/adapter_capabilities.py))
- `abstractvision adapters --provider mlx-gen --model <model-id> --task <task> --json` to inspect recommended parameters, docs links, and compatibility notes for locally cached overlays

Neither registry guarantees that one exact configured backend route can execute the request. Runtime route support is a separate backend-owned constraint ([docs/reference/backends.md](reference/backends.md)).

## I only need the HTTP backend. Do I have to install Torch/Diffusers?

No. The base install is lightweight and includes the stdlib OpenAI-compatible HTTP backend without Torch/Diffusers (see [`../pyproject.toml`](../pyproject.toml)). Heavy local backend modules are still imported lazily ([`../src/abstractvision/backends/__init__.py`](../src/abstractvision/backends/__init__.py)).

Install `abstractvision[diffusers]` only when you want local Diffusers generation. Use `abstractvision[sdcpp]` or an external `sd-cli` only when you need stable-diffusion.cpp.

## How do I integrate with AbstractCore?

Two options (details in [docs/reference/abstractcore-integration.md](reference/abstractcore-integration.md)):

- **Capability plugin**: [`../src/abstractvision/integrations/abstractcore_plugin.py`](../src/abstractvision/integrations/abstractcore_plugin.py) supports Diffusers, stable-diffusion.cpp, and OpenAI-compatible backends through env/config.
- **Tool helpers**: `make_vision_tools(...)` in [`../src/abstractvision/integrations/abstractcore.py`](../src/abstractvision/integrations/abstractcore.py) requires `VisionManager.store` for artifact-ref outputs.

AbstractCore is the host package; AbstractVision does not install it as a dependency.

## How do I run tests?

From the repo root:

```bash
python -m unittest discover -s tests -p "test_*.py" -q
```
--- >8 --- END FILE: docs/faq.md --- >8 ---

--- 8< --- FILE: docs/troubleshooting.md --- 8< ---
# Troubleshooting

See also:
- Getting started: [docs/getting-started.md](getting-started.md)
- Backends: [docs/reference/backends.md](reference/backends.md)
- Configuration: [docs/reference/configuration.md](reference/configuration.md)
- FAQ: [docs/faq.md](faq.md)

This page covers the current user-facing failure modes that are most likely when
using local backends, the playground, and the AbstractCore integration.

## Local backend says a dependency is missing

### Symptom

- `OptionalDependencyMissingError`
- import errors mentioning `diffusers`, `torch`, `torchvision`, `stable_diffusion_cpp`, `mlxgen`, or `mflux`
- errors like `Qwen2VLVideoProcessor requires the Torchvision library...` when using `Qwen/Qwen-Image-Edit-*`

### Likely cause

The base install is intentionally lightweight. Local runtimes are not installed
unless you choose the matching extra.

### Fix

- Diffusers: `pip install "abstractvision[diffusers]"`
- If the error mentions missing `torchvision`: `pip install torchvision` (or upgrade/reinstall `abstractvision[diffusers]`)
- stable-diffusion.cpp bindings: `pip install "abstractvision[sdcpp]"`
- MLX-Gen: `pip install "abstractvision[mlx-gen]"` (or compatibility alias `abstractvision[mflux]`). MLX-Gen is validated on Apple Silicon. The extra also installs on Linux, where it is not validated yet (see [backlog 030](backlog/planned/030_gpu_parity_with_mlx_gen.md)); the `gpu` and `all-gpu` profiles do not include it, so install `abstractvision[mlx-gen]` explicitly there.

### Verify

- `abstractvision cli`
- `abstractvision catalog --provider diffusers`

## MLX-Gen refuses the installed mlx-gen or MLX version

### Symptom

- The first MLX-Gen model load raises `OptionalDependencyMissingError`: `The MLX-Gen backend needs
  mlx-gen>=0.40.3,<0.41.0; mlx-gen <version> is installed` or `The MLX-Gen backend needs mlx>=0.32.4 on
  macOS; mlx <version> is installed`.

### Likely cause

This release calls mlx-gen 0.40.x, and on macOS needs MLX 0.32.4 or later: MLX 0.31.0 to 0.32.3 can end
the process with a Metal "invalid resource" error during a MiniMax-H3 decode when the MLX cache is small.
`pip install -U abstractvision` without the extra upgrades AbstractVision and keeps the mlx-gen and MLX
already installed, so the backend checks both before it loads a model.

### Fix

- `pip install -U "abstractvision[mlx-gen]"` (or the profile you installed, such as `abstractvision[apple]`):
  it installs `mlx-gen>=0.40.3,<0.41.0` and, on macOS, `mlx>=0.32.4`.
- With the one-line installer, run the same line again.

### Verify

- `python -c "import importlib.metadata as m; print(m.version('mlx-gen'), m.version('mlx'))"`
- `abstractvision show-model AbstractFramework/flux.2-klein-4b-8bit`

## Local Diffusers cannot find the model

### Symptom

- local Diffusers generation fails before inference starts
- the error mentions a missing snapshot or cache-only/offline behavior

### Likely cause

The Diffusers backend is cache-only by default and the required model is not yet
present in the Hugging Face cache.

Another common case is an interrupted Hugging Face download: the snapshot
directory exists, but the repo still contains `.incomplete` blobs and the
package rejects that cache entry as unusable until the download is finished.

### Fix

- Pre-download the model with `abstractvision download ... --provider diffusers`
- or allow runtime downloads explicitly with `ABSTRACTVISION_DIFFUSERS_ALLOW_DOWNLOAD=1`
- if the repo already exists but is partial, rerun the same `abstractvision download ... --provider diffusers`
  command: it fetches the files that are not complete in the cache

Examples:

```bash
abstractvision download stable-diffusion --provider diffusers
abstractvision download qwen-image-edit-2511 --provider diffusers
```

### Verify

- `abstractvision catalog --provider diffusers`
- `abstractvision show-model Qwen/Qwen-Image-Edit-2511`

## Local Diffusers `text_to_video` is experimental and currently disabled

### Symptom

- the local playground has no active local `Text→Video` model choices
- local Diffusers `t2v` raises a capability/disabled error

### Likely cause

AbstractVision intentionally quarantines the current local Diffusers
`text_to_video` groundwork because the operator validation bar is not met yet.
This does not apply to the MLX-Gen Wan path.

### Fix

- use MLX-Gen Wan locally: `abstractvision t2v --provider mlx-gen --model AbstractFramework/wan2.2-t2v-a14b-diffusers-8bit "prompt"`; or
- use the OpenAI-compatible backend when video is served remotely; or
- follow the backlog item that tracks the local re-validation work:
  [`docs/backlog/planned/0023_local_runtime_capability_quarantine_for_glm_mflux_and_t2v.md`](backlog/planned/0023_local_runtime_capability_quarantine_for_glm_mflux_and_t2v.md)

## `GLM-Image` is temporarily disabled in the local Diffusers backend

### Symptom

- `zai-org/GLM-Image` does not appear in local runtime-backed model selectors
- direct local Diffusers calls reject it as temporarily disabled

### Likely cause

Operator testing and runtime investigation showed that current local GLM output
quality/runtime behavior is not honest enough to ship as a working local
capability.

### Fix

Use another local Diffusers image model for now, for example:
- `runwayml/stable-diffusion-v1-5`
- `Qwen/Qwen-Image-Edit-2511`
- `black-forest-labs/FLUX.2-klein-4B`

The follow-up investigation is tracked in:
- [`docs/backlog/planned/0023_local_runtime_capability_quarantine_for_glm_mflux_and_t2v.md`](backlog/planned/0023_local_runtime_capability_quarantine_for_glm_mflux_and_t2v.md)

## MLX-Gen `image_to_image` is missing or rejected

### Symptom

- `flux2-klein-4b`, `flux2-klein-9b`, `flux2-klein-base-*`, or `qwen-image-edit-*` (MLX-Gen) do not appear in the playground `Image→Image` tab; or
- local MLX-Gen `image_to_image` calls raise `CapabilityNotSupportedError`

### Likely cause

- You are on an older AbstractVision version where the Apple-local edit surface was narrower.
- The optional MLX-Gen extra is not installed (`abstractvision[mlx-gen]`).
- The q4/q8 prepared model is not present in the Hugging Face cache yet.
- You are attempting a mask or structured-control request on a route that does not advertise that capability.

### Fix

- Upgrade AbstractVision to a version that supports MLX-Gen q4/q8 presets.
- Install the backend extra: `pip install "abstractvision[mlx-gen]"`
- Download the prepared model first, for example `abstractvision download AbstractFramework/qwen-image-edit-2511-4bit --provider mlx-gen`.
- For MLX-Gen mask edits, use a validated masked-edit route such as `AbstractFramework/qwen-image-edit-2511-8bit`, FLUX.2 klein, Z-Image Turbo, `briaai/Fibo-Edit`, or `briaai/Fibo-Edit-RMBG`.
- Structured control (`--control-image` / `--control-strength`, Python `control_image=` / `control_strength=`) runs on MLX-Gen's `AbstractFramework/qwen-image-8bit` only, with the ControlNet side weights in the cache (`abstractvision download InstantX/Qwen-Image-ControlNet-Union`); every other model and backend refuses a `control_image` with `CapabilityNotSupportedError` (`field="control_image"`), and MLX-Gen also refuses a `control_strength` given alone.
- If you need a mask on another local route, use local Diffusers or `stable-diffusion.cpp` instead of expecting AbstractVision to silently fall back.

Notes:
- MLX-Gen edit strength is passed as `strength` and normalized to the runtime `image_strength` parameter where the model supports it.
- If you need stricter scene preservation, Diffusers often remains the more conservative baseline for `image_to_image`.

## MLX-Gen LoRA is rejected as incompatible

### Symptom

- a local MLX-Gen image or video run fails before generation with a LoRA
  compatibility error
- the message says the adapter targets a different base model than the selected
  route

### Likely cause

- the adapter model card targets a different base model family
- the selected route does not expose LoRA support
- a Wan route requires explicit target-role assignment and none was provided

### Fix

- inspect the route first with `abstractvision show-model <model-id>` or
  `abstractvision catalog --provider mlx-gen`
- confirm the route advertises `supports_lora: true`
- match the adapter to the route's base model family
- for Wan TI2V-5B, pass `--lora-target-role transformer`
- for Wan A14B, pass explicit
  `high_noise_transformer` / `low_noise_transformer` roles

### Verify

- rerun with the same model id and a compatible adapter
- confirm the generated metadata includes requested/applied LoRA details such as
  `requested_lora_adapters`, `lora_application_reports`,
  `lora_applied_file_count`, and `lora_applied_target_count`

## Wan video runs out of memory or is slow

### Symptom

- a Wan video generation fails with a Metal out-of-memory error, or the Mac
  starts swapping heavily
- a Wan video takes far longer than expected

### Likely cause

- the request asks for a larger canvas than the model's default (for example
  `1280x704` for TI2V-5B); memory and time grow with the frame size
- `vae_tiling` was switched off, so the VAE decode holds whole frames at once
- another large model is loaded in the same machine

### Fix

- leave `width`/`height` unset to use the model's default (832x480 for every
  Wan model), or request a smaller canvas; see
  [docs/faq.md](faq.md#how-much-memory-does-wan-video-need) for measured needs
- keep the tiled VAE decode on (the default); do not pass `--no-vae-tiling` /
  `extra={"vae_tiling": False}` on a memory-constrained Mac
- lower `--steps` for quick drafts: the step count changes the time, not the
  peak memory
- unload other models before a video run

## Diffusers on CUDA is slow or runs out of memory

### Symptom

- an image generation on an NVIDIA GPU that runs many steps takes longer than
  expected, and the result metadata reports `cpu_offload: "sequential"`
- the log shows `Diffusers: sequential CPU offload on cuda ... (much less GPU
  memory; each step slower than model CPU offload)`
- a generation fails with `CUDA out of memory`

### Likely cause

- another process (for example a text model) holds part of the GPU, so the
  free memory cannot hold the pipeline's largest component and the backend
  falls back to sequential CPU offload
- `cpu_offload="model"` or `"none"` was set explicitly on a GPU that is too
  small for that placement

### Fix

- unload the other model from the GPU before generating; with enough free
  memory the backend uses model CPU offload or moves the pipeline whole
- leave `cpu_offload` at `"auto"` (the default) so the backend picks a
  placement that fits; see
  [docs/reference/backends.md](reference/backends.md#diffusers-backend-local)
  for how it decides
- use a smaller model or a quantized (GGUF) variant on small GPUs
- an out-of-memory during the generation itself is raised as
  `GpuOutOfMemoryError` with the model's size, its placement, what was free
  and what to change; model CPU offload also needs host RAM for the whole
  float16 weights plus about 3 GB (FLUX.2 klein 4B peaks near 24 GB of RAM)

## A Diffusers result is an all-black image on CUDA

### Symptom

- the generation finishes, the file is written, the image is uniformly black

### Likely cause

The model was trained in bfloat16 (Z-Image, OmniGen and others) and ran in
float16, which overflows in its layers. Cards before Ampere (compute capability
8.0, for example the Turing Quadro RTX 5000) have no native bfloat16.

### Fix

- on Ampere or newer, set `torch_dtype=bfloat16`
- on older cards, run the model in float32 (slower, more memory; OmniGen at
  1024² took about 12 minutes with sequential offload on a 16 GB Turing card)
  or use its GGUF variant through stable-diffusion.cpp

## Linux without a GPU: Diffusers reports its runtime missing

### Symptom

- `pip install "abstractvision[gpu]"` on a processor-only Linux host, then
  "Diffusers runtime missing" although `diffusers` is installed, or
  `operator torchvision::nms does not exist` when importing

### Likely cause

`torch` was installed from PyTorch's CPU index and `torchvision` from PyPI
(the CUDA build): the two do not match.

### Fix

Install both from the same index before the package:

```bash
pip install torch torchvision --index-url https://download.pytorch.org/whl/cpu
pip install "abstractvision[gpu]"
```

The processor path then runs in float32 (the default on cpu) and the profile
reports `cpu`; hiding the card with an empty or `-1` `CUDA_VISIBLE_DEVICES`
gives the same result on a GPU host.

## stable-diffusion.cpp (`sd-cli`) fails with a `GLIBC` version error on Linux

### Symptom

- a GGUF generation fails with `version 'GLIBC_2.43' not found` (or similar)
  right after `sd-cli` was auto-installed

### Likely cause

Since release master-1044 (2026-11-03) stable-diffusion.cpp's Linux builds are
made on Ubuntu 26.04 and need glibc 2.43; Ubuntu 24.04 has 2.39.

### Fix

The auto-install now picks the newest release whose Linux build the host's
glibc can run (master-1043 on Ubuntu 24.04) and skips ROCm builds. A host that
auto-installed a newer build before this fix keeps it: delete
`~/.abstractvision/bin` and let the next GGUF call install again. `sd-cli`
reloads the model on every call (the Diffusers path keeps it resident).

## `mps` was requested but is unavailable

### Symptom

- local Diffusers startup fails with an error mentioning `mps`

### Likely cause

PyTorch does not report Apple Metal / MPS as available in the current
environment.

### Checks

```bash
python - <<'PY'
import torch
print(torch.backends.mps.is_available())
PY
```

### Fix

- use a PyTorch build with MPS support on Apple Silicon;
- or switch the backend device to `cpu`.

### Verify

- rerun the check above;
- then retry with `--diffusers-device mps` or `--diffusers-device cpu`

## Playground panel is disabled

### Symptom

- Image → Image or Text → Video controls stay disabled in the playground

### Likely cause

The currently selected model does not advertise the required task in the
packaged capability registry, or the backend cannot really execute that task.

### Fix

Choose a model that advertises the task:

- image edits: a model with `image_to_image`
- local MLX-Gen text-to-video: `AbstractFramework/wan2.2-t2v-a14b-diffusers-8bit` or `Wan-AI/Wan2.2-TI2V-5B-Diffusers`
- remote text-to-video: an OpenAI-compatible backend configured with a video endpoint

### Verify

- open `GET /v1/vision/models`
- inspect the selected model’s `tasks` and `task_specs`

## AbstractCore tool expected an artifact ref

### Symptom

- `vision_text_to_image`, `vision_image_to_image`, or `vision_text_to_video`
  reports that an artifact ref was expected

### Likely cause

`make_vision_tools(...)` expects `VisionManager.store` to be set so outputs can
be returned as artifact references instead of raw bytes.

### Fix

Create the manager with a store, for example `LocalAssetStore()` or a runtime
adapter.

### Verify

- rerun the tool call and confirm the result contains `"$artifact"`
--- >8 --- END FILE: docs/troubleshooting.md --- >8 ---

--- 8< --- FILE: docs/reference/backends.md --- 8< ---
# Backends (execution engines)

AbstractVision executes tasks via a `VisionBackend` adapter ([`../../src/abstractvision/backends/base_backend.py`](../../src/abstractvision/backends/base_backend.py)).
`VisionManager` is intentionally thin and delegates to the configured backend ([`../../src/abstractvision/vision_manager.py`](../../src/abstractvision/vision_manager.py)).

See also:
- Getting started (interactive CLI examples): [docs/getting-started.md](../getting-started.md)
- Configuration (env vars / CLI flags): [docs/reference/configuration.md](configuration.md)

## Support matrix (built-in backends)

| Backend | Implementation | Tasks implemented | Notes |
|---|---|---|---|
| OpenAI-compatible HTTP | [`openai_compatible.py`](../../src/abstractvision/backends/openai_compatible.py) | `text_to_image`, `image_to_image` (+ optional `text_to_video`, `image_to_video`) | Stdlib-only (`urllib`). Video is **opt-in** via configured paths. |
| Diffusers (local) | [`huggingface_diffusers.py`](../../src/abstractvision/backends/huggingface_diffusers.py) | `text_to_image`, `image_to_image` | Requires `abstractvision[diffusers]`. Supports cache-only/offline mode. Local `text_to_video` groundwork exists but is currently experimental and disabled from the normal local surfaces. |
| MLX-Gen (local, Apple-first) | [`mflux.py`](../../src/abstractvision/backends/mflux.py) | `text_to_image`, `image_to_image`, `text_to_video`, `image_to_video`, `video_to_video` | Requires `abstractvision[mlx-gen]` (or compatibility extra `abstractvision[mflux]`, or `abstractvision[all-apple]`). The current AbstractVision release is validated on Apple Silicon first; the install extra also exposes Linux support when upstream `mlx-gen` / `mlx` markers are available. Uses downloaded AbstractFramework q4/q8 MLX-Gen image preset snapshots plus official FIBO/Wan runtime snapshots from the Hugging Face cache; `ABSTRACTVISION_MODEL_DIR` is legacy migration input only. |
| stable-diffusion.cpp (local GGUF/checkpoints) | [`stable_diffusion_cpp.py`](../../src/abstractvision/backends/stable_diffusion_cpp.py) | `text_to_image`, `image_to_image` | Uses external `sd-cli` if present, else `abstractvision[sdcpp]` python bindings. Start with single-file Stable Diffusion models; curated Qwen/FLUX GGUF presets now auto-resolve required VAE + LLM companions from the cache. |

Notes:
- `multi_view_image` (`VisionManager.generate_angles`) is part of the public API, but **no built-in backend implements it yet** (all raise `CapabilityNotSupportedError` today).
- Backends may also expose best-effort `get_capabilities()`, `preload()`, `unload()`, `generate_image_with_progress(...)`, `edit_image_with_progress(...)`, and video progress hooks via the shared `VisionBackend` contract.
- `has_loaded_model()` is part of that contract: whether this process holds the backend's model weights now. A backend that loads a model in process answers it (MLX-Gen, Diffusers and stable-diffusion.cpp's Python binding do); the default, `False`, is the answer of one that holds nothing here (a remote, `sd-cli`). The AbstractCore plugin lists, pins and unloads loads by this answer, so a backend that keeps the default is never listed or reported as resident.
- A backend injected into the AbstractCore plugin (`vision_backend_instance`, or what `vision_backend_factory`, called once, returns) that lacks `has_loaded_model`, `preload`, `unload`, `supported_memory_modes`, `list_provider_models` or `list_provider_adapters` is refused when the capability is built, with a `TypeError` naming the missing methods and saying to inherit `abstractvision.backends.base_backend.VisionBackend`, which provides them.
- Backends may also implement `normalize_image_generation_request(...)`, `normalize_image_edit_request(...)`, `normalize_video_generation_request(...)`, and `normalize_image_to_video_request(...)`. `VisionManager`, the CLI/REPL, the playground API, and the AbstractCore plugin all route through those hooks so model-specific defaults and constraints are applied consistently instead of being hard-coded in one surface.

## OpenAI-compatible HTTP backend

**When to use**
- You already run a service that exposes OpenAI-shaped endpoints (local or remote).
- You want to keep inference out-of-process.

**Core config**
- `base_url` (required): points to a `/v1`-style root, e.g. `http://localhost:1234/v1`
- `api_key` (optional): sent as `Authorization: Bearer ...`
- `model_id` (optional): forwarded as `model` in requests
- `models_path` (default `/models`): provider catalog path for explicit model listing

Request shape:
- Unknown/local endpoints receive local extension fields when provided, including `steps`, `seed`, `guidance_scale`, `negative_prompt`, `width`, and `height`.
- The OpenAI API (a base URL whose host is `api.openai.com` or one of its subdomains, such as `eu.api.openai.com`; `looks_like_openai_api`) and known OpenAI image models use the narrower OpenAI request shape; GPT image models do not receive unsupported local-only fields such as `steps`, `seed`, or `guidance_scale`.

Memory modes, `quantize` and sound:
- The backend asks `GET {base_url}/vision/models` what the remote takes. AbstractCore's server answers it (the server side of these fields is AbstractCore's; see its vision endpoint documentation): an entry that lists `memory_modes` advertises `memory_mode`, `quantize` and, when `supports_audio` is true, the fields in its `audio_fields` (`soundscape`, `music`, `generate_audio`, `audio_shift`). The entry is the one whose `routed_model` is the model the request sends (`extra["model"]`, else the configured `model_id`), which such a remote receives as given (`provider/model`, as the server routes it, prefixes such as `openai/` included; `<provider>/default` names a task's default), or, with no `model_id`, `defaults[<task>]`, the model the remote runs for a request that names none; its `id` alone does not select it.
- For such a remote, `get_capabilities().memory_modes` lists its modes for the model, and the fields are sent at the top level of the request (form fields on multipart routes): `memory_mode` when the request or `$ABSTRACTVISION_MEMORY_MODE` names one, the others when set, whether the request set them as fields or in `extra`. A request that carries `extra` (keys other than `model`), or names its model with an `openai/` or `openai-compatible/` prefix, asks the remote whether it serves `GET /vision/models` until it answers (a definite answer, HTTP 404, 405 or 501 included, is kept for the backend's life; a failed question is asked again after 30 seconds): to a server that does, the request's other `extra` keys go nested, as an `extra` object in JSON bodies and an `extra_json` form field on multipart routes (AbstractCore's bodies refuse unknown top-level keys), and the model as named; to any other remote, and while the answer is unknown, the keys go at the top level of the body (form fields on multipart routes), as before, and the model without the prefix. A model named without such a prefix is sent as given to every remote.
- The remote's HTTP 422 with the error code `capability_not_supported`, and a remote job that fails with `error_code` `capability_not_supported`, are raised as `CapabilityNotSupportedError` with the remote's message, and its `field` and `supported` (`error_field`, `error_supported` on a job) when it carries them.
- A video response's `audio` object (`present`, `sample_rate`, `channels`, `codec`, and `wav` = `{"b64_json"}` or `{"url"}` when the soundtrack is not muxed into the MP4) fills `GeneratedAsset.audio` (`GeneratedAudioTrack`, with the WAV bytes in `data` when unmuxed); `metadata["memory_mode"]` holds the remote's `memory_mode_used` (from the response, or for a job from its result, else from the job), and is absent when the remote does not report it.
- A request with `cancel_event` runs as a remote job (`POST {base_url}/vision/jobs/...`, polled); setting the event sends `POST {base_url}/vision/jobs/{id}/cancel` and raises `GenerationCancelledError`, and a poll that ends any other way (a network error, an interrupt) sends the same cancel before the error propagates. AbstractCore's server runs one job at a time and refuses a job while another generation runs (where a request without `cancel_event` waits); the backend raises that refusal as a `RuntimeError` saying another generation is running on the server.
- Without that route (a plain OpenAI image endpoint, and always for the OpenAI API), only `default` is listed, a request that sets any of these fields (or `extra["memory_mode"]`) is refused with `CapabilityNotSupportedError` before anything is sent, and none of them is ever sent as a field; other `extra` keys, `quantize` or the soundtrack names included, reach it as before.
- `list_provider_models()` and a request that sets one of the fields or a `cancel_event` (or runs under `$ABSTRACTVISION_MEMORY_MODE`) ask, as does a request that carries `extra` or a prefixed model while the remote's kind is unknown; the answer is reused for 30 seconds, and `get_capabilities()` and `supported_memory_modes()` read the last one without a request. A request that sets none of them and carries no `extra` makes no discovery request. An answer (the catalog, or a 200 without one, or an HTTP 4xx or 501) is kept; a discovery request that fails (timeout, connection error, another HTTP 5xx) is not: the previous answer stays in use, and without one a request that names a memory mode other than `default`, `quantize` or a soundtrack field is refused with the reason, and a request with a `cancel_event` raises the `RuntimeError` a failed request raises (whether the remote runs jobs is unknown, and the request is not run uncancellable); the next such request asks again. A request with `cancel_event` to the OpenAI API, to a remote whose discovery route answers HTTP 404, 405 or 501, or to a vision-route remote for a model it does not list runs as a plain request, the event checked only before sending. A request that arrives while that question is in flight waits for its answer. On such a remote, `list_provider_models()` lists that catalog itself, each entry with its `memory_modes`, `supports_audio` and `audio_fields` (see Provider model catalogs below).

Provider model catalogs:
- `OpenAICompatibleVisionBackend.list_provider_models(...)` on a remote that serves the vision routes (AbstractCore's server) lists `GET {base_url}/vision/models`: one entry per model, named by the `routed_model` a request sends, with its `memory_modes` and audio support (that server's `GET /models` lists text models). On any other remote it queries `GET /models` (the configured `models_path`) as before; a remote that answers it with HTTP 404, 405 or 501 has no model catalog, and the backend raises `CapabilityNotSupportedError` saying so.
- `VisionManager.list_provider_models(...)` delegates to the configured backend.
- The AbstractCore plugin exposes the same catalog through `llm.vision.list_provider_models(...)`.
- CLI examples: `abstractvision provider-models --openai --task text_to_image` and `abstractvision provider-models --base-url http://localhost:1234/v1 --task text_to_image`.
- Listing is explicit; AbstractVision does not use provider catalogs to silently select a model.

Code pointers:
- Config: `OpenAICompatibleBackendConfig` ([`../../src/abstractvision/backends/openai_compatible.py`](../../src/abstractvision/backends/openai_compatible.py))
- Backend: `OpenAICompatibleVisionBackend` ([`../../src/abstractvision/backends/openai_compatible.py`](../../src/abstractvision/backends/openai_compatible.py))

**Video endpoints (optional)**
`OpenAICompatibleVisionBackend` only enables:
- `text_to_video` if `text_to_video_path` is set
- `image_to_video` if `image_to_video_path` is set

## Diffusers backend (local)

**When to use**
- You want local inference for Diffusers pipelines.
- Start with `runwayml/stable-diffusion-v1-5` for the lowest-risk local test.
- Move to `black-forest-labs/FLUX.2-klein-4B` after that if you want a newer non-gated model and can install Diffusers `main`.

Install:
- `pip install "abstractvision[diffusers]"`
- For newer/unreleased pipeline classes: `pip install "abstractvision[diffusers-dev]"` plus Diffusers from source.

Model downloads (curated):
- See what's downloadable for Diffusers:
  - `abstractvision catalog --provider diffusers` (add `--all-targets` to compare engines)
  - Tip: `--provider diffusers` implies `--target diffusers` (you usually set one or the other).
- Download a curated Diffusers snapshot into the Hugging Face cache (legacy `~/models` trees auto-migrate when encountered):
  - `abstractvision download stable-diffusion --provider diffusers`
  - `abstractvision download sd1.4 --provider diffusers`
  - `abstractvision download sd1.5-inpaint --provider diffusers`
  - `abstractvision download instruct-pix2pix --provider diffusers`
  - `abstractvision download sdxl-base --provider diffusers`
  - `abstractvision download sdxl-refiner --provider diffusers`
  - `abstractvision download sdxl-inpaint --provider diffusers`
  - `abstractvision download sdxl-turbo --provider diffusers`
  - `abstractvision download sd-turbo --provider diffusers`
  - `abstractvision download sd3-medium --provider diffusers`
  - `abstractvision download sd3.5-medium --provider diffusers`
  - `abstractvision download sd3.5-large --provider diffusers`
  - `abstractvision download sd3.5-large-turbo --provider diffusers`
  - `abstractvision download ernie-image --provider diffusers`
  - `abstractvision download qwen-image --provider diffusers`
  - `abstractvision download qwen-image-edit-2511 --provider diffusers`
  - `abstractvision download flux2-dev --provider diffusers`
  - `abstractvision download flux2-klein-4b --provider diffusers`
  - `abstractvision download z-image-turbo --provider diffusers`

One-shot generation (uses the cached snapshot when present):
- `abstractvision t2i --provider diffusers --model qwen-image "a studio photo of a ceramic teapot"`

Code pointers:
- Config: `HuggingFaceDiffusersBackendConfig` ([`../../src/abstractvision/backends/huggingface_diffusers.py`](../../src/abstractvision/backends/huggingface_diffusers.py))
- Backend: `HuggingFaceDiffusersVisionBackend` ([`../../src/abstractvision/backends/huggingface_diffusers.py`](../../src/abstractvision/backends/huggingface_diffusers.py))

**Offline / cache-only mode**
The Python backend and interactive CLI are cache-only by default (`allow_download=False`). Pre-download model weights separately,
or set `allow_download=True` / `ABSTRACTVISION_DIFFUSERS_ALLOW_DOWNLOAD=1` when runtime downloads are desired (see
config/env in [docs/reference/configuration.md](configuration.md)).

Config fields:
- `model_id`, `device`, `torch_dtype`
- `allow_download`, `auto_retry_fp32`
- `cache_dir`, `revision`, `variant`
- `use_safetensors`, `low_cpu_mem_usage`
- `cpu_offload` (CUDA only): `"auto"` (default) picks the fastest placement that fits the GPU's free memory minus a working reserve (the larger of 1.5 GiB and 10% of the card): the whole pipeline on the GPU when it fits, else Diffusers' model CPU offload when the largest component fits, else Diffusers' sequential CPU offload. `"model"` always uses model CPU offload, `"sequential"` always uses sequential CPU offload, `"none"` never offloads

Runtime behavior notes:
- The Diffusers backend now reads packaged registry task metadata for known models when it normalizes requests.
- A local `model_id` is identified by its own folder or file name (a GGUF file by its file name), or, inside a Hugging Face cache, by the repository id followed by the path below the snapshot for a file or subfolder in it (`org/name`, `org/name/model.gguf`), never by a parent directory or the snapshot revision; a repository id, or a relative text that is not on disk, is its own name. That name sets the bfloat16 default of Qwen-Image-Edit `image_to_image` and inpainting on MPS, and the fallback chat template of a pipeline whose snapshot ships none (Qwen, FLUX.2, Z-Image, ERNIE-Image, GLM-Image). A Qwen-Image-Edit folder whose own name does not say so runs in the automatic dtype unless `torch_dtype="bfloat16"` is set.
- Local Diffusers `GLM-Image` is temporarily disabled for both `text_to_image` and `image_to_image` pending the follow-up in [`../backlog/planned/0023_local_runtime_capability_quarantine_for_glm_mflux_and_t2v.md`](../backlog/planned/0023_local_runtime_capability_quarantine_for_glm_mflux_and_t2v.md).
- Local Diffusers `text_to_video` is currently experimental and disabled from the normal local surfaces.
- Local video export still requires an `ffmpeg` executable on `PATH` whenever a local backend emits frames for MP4 packaging.
- On CUDA, a pipeline larger than the GPU's free memory runs with model CPU offload instead of failing with CUDA out of memory. Model CPU offload moves one whole component (text encoder, transformer, VAE) to the GPU at a time, so it needs the largest component plus activations. For example, FLUX.2 [klein] 4B in float16 (14.9 GiB of weights, largest component about 7.5 GiB) generates 768x768 in about 17 s at 4 steps on a free 16 GB card, with a peak near 8 GiB.
- When the free memory cannot hold even the largest component, for example because another model is loaded on the same GPU, the pipeline runs with sequential CPU offload: weights stream to the GPU one submodule at a time. It uses much less GPU memory, and each step is slower because it reads the weights from system memory again. For example, FLUX.2 [klein] 4B at 768x768 and 4 steps on a 16 GB card with 6.5 GiB held by another model peaks near 1.4 GiB and takes 10.9-15.6 s (13.4-18.5 s with model CPU offload), but about 2.3 s per step against 1.5 s, so models that run many steps are slower with it. The backend logs a warning that says so; unload the other model to get model CPU offload back.
- `cpu_offload="sequential"` on a pipeline that does not support sequential offload logs a warning and uses model CPU offload.
- The result metadata reports the execution device (for example `cuda:0`) and `cpu_offload: "model"` or `cpu_offload: "sequential"` when the pipeline is offloaded.
- This backend is where model-specific defaults and constraints such as packaged step counts, guidance defaults, dimension constraints, and unsupported-parameter dropping are enforced for all callers.
- The request-level `memory_mode` maps onto `cpu_offload` on CUDA: `"low"` needs at least model CPU offload and `"lowest"` sequential CPU offload. The request only raises the placement: the higher of the configured `cpu_offload` (or what `"auto"` picks) and the request's level runs, and a loaded pipeline with less offload is loaded again. On CPU and MPS only `"default"` is accepted; other modes raise `CapabilityNotSupportedError`. `supported_memory_modes()` and `get_capabilities()` answer from an explicit `device` directly; with `device="auto"` they answer `"default"` on macOS (no CUDA) without importing torch, and elsewhere ask torch, importing it once.
- A repository the catalog marks `explicit_download` (the MiniMax-H3 packages and source) is never fetched by generation, even with `allow_download=True`: it loads from the cache only. A model that is not in the cache and may not be downloaded is refused before anything loads; a cached model's own load error is raised as it is.

## MLX-Gen backend (local Apple-first)

**When to use**
- You want local quantized MLX generation through the optional MLX-Gen runtime. This release is validated on Apple Silicon first, and the install extra also exposes the upstream Linux/CUDA path when `mlx[cuda13]` markers apply.
- You want the AbstractFramework-published q4/q8 prepared folders from the [AbstractFramework/mlx-gen Hugging Face collection](https://huggingface.co/collections/AbstractFramework/mlx-gen/).
- You want the official MLX-Gen `0.40.3+` FIBO snapshots (`briaai/FIBO`, `briaai/Fibo-lite`, `briaai/Fibo-Edit`, `briaai/Fibo-Edit-RMBG`).
- You want the official Prism ML Bonsai ternary 2-bit checkpoint (`prism-ml/bonsai-image-ternary-4B-mlx-2bit`) for very small local `text_to_image`.
- You want SeedVR2 single-image upscaling through canonical `AbstractFramework/seedvr2-{3b,7b}-{8bit,4bit}` packages or the official `ByteDance-Seed/SeedVR2-*` bases.
- You want local Wan 2.2 video generation through MLX-Gen `0.40.3+`, including the prepared TI2V package and the task-specific A14B `text_to_video` / first-frame `image_to_video` packages.

Install:
- `pip install "abstractvision[mlx-gen]"` (or `pip install "abstractvision[all-apple]"`)
- `pip install "abstractvision[mflux]"` remains a compatibility alias for older install instructions.

Model presets:
- See what's downloadable for your machine/engine:
  - `abstractvision catalog --provider mlx-gen` (add `--all` for full fallback list)
  - Tip: `--provider mlx-gen` implies `--target mlx` (you usually set one or the other).
- Download an exact published model repo into the Hugging Face cache (legacy `~/models` trees auto-migrate when encountered):
  - `abstractvision download AbstractFramework/flux.2-klein-4b-4bit --provider mlx-gen`
  - `abstractvision download AbstractFramework/flux.2-klein-4b-8bit --provider mlx-gen`
  - `abstractvision download AbstractFramework/qwen-image-2512-4bit --provider mlx-gen`
  - `abstractvision download AbstractFramework/qwen-image-edit-2511-4bit --provider mlx-gen`
  - `abstractvision download AbstractFramework/z-image-4bit --provider mlx-gen`
  - `abstractvision download AbstractFramework/z-image-turbo-4bit --provider mlx-gen`
  - `abstractvision download AbstractFramework/ernie-image-turbo-4bit --provider mlx-gen`
  - `abstractvision download AbstractFramework/ernie-image-turbo-8bit --provider mlx-gen`
  - `abstractvision download briaai/FIBO --provider mlx-gen`
  - `abstractvision download briaai/Fibo-lite --provider mlx-gen`
  - `abstractvision download briaai/Fibo-Edit --provider mlx-gen`
  - `abstractvision download briaai/Fibo-Edit-RMBG --provider mlx-gen`
  - `abstractvision download prism-ml/bonsai-image-ternary-4B-mlx-2bit --provider mlx-gen`
  - `abstractvision download Wan-AI/Wan2.2-TI2V-5B-Diffusers --provider mlx-gen`
  - `abstractvision download AbstractFramework/wan2.2-t2v-a14b-diffusers-8bit --provider mlx-gen`
  - `abstractvision download AbstractFramework/wan2.2-i2v-a14b-diffusers-8bit --provider mlx-gen`
  - `abstractvision download AbstractFramework/seedvr2-3b-8bit --provider mlx-gen`
  - `abstractvision download AbstractFramework/seedvr2-7b-8bit --provider mlx-gen`
- q4 repos are the default recommendation for most generation/edit models. Use the exact
  matching `AbstractFramework/...-8bit` model id when quality is paramount. Qwen
  and ERNIE q4 prepared folders can mix q4 and q8 components, but remain the
  default prepared choice.
- `abstractvision t2i`, `abstractvision i2i`, and Python callers select q4/q8
  by exact model id. Quantization is metadata of the published folder, not a
  generation-time parameter.
- A source repository id (`black-forest-labs/FLUX.2-klein-4B`, `Tongyi-MAI/Z-Image`, `Qwen/Qwen-Image-2512`,
  `baidu/ERNIE-Image-Turbo`, ...) whose own snapshot is in the Hugging Face cache is that model: it runs the
  released 16-bit weights, unquantized, as `mlxgen generate --model <id>` does, even when one of its
  prepared packages is cached too. The snapshot counts when it can load as the model: `model_index.json` and
  readable `transformer/*.safetensors`, no partial download. It is a source, not a prepared package, as id or
  as folder: `get_capabilities().quantize_bits` lists the engine's load-time widths and a request may set
  `quantize`. The AbstractCore plugin passes such an id to the backend unchanged. A source runs at several
  times a prepared package's memory (the 16-bit weights against q8 or q4). When the source is not cached (or
  lacks those files), an id that maps to several prepared packages is refused as ambiguous, naming them: use
  the exact package id.
- `abstractvision upscale` defaults to `--provider mlx-gen --model AbstractFramework/seedvr2-3b-8bit --resolution 2x --softness 0.25`.
  Use `--resolution <pixels>` for a target short edge,
  `AbstractFramework/seedvr2-7b-8bit` when memory allows, and q4 SeedVR2
  packages only when memory is tight. `--scale 2x` remains accepted when
  `--resolution` is omitted. `--quantize` is reserved for official/source-weight runs.
- SeedVR2 model chooser:
  - `AbstractFramework/seedvr2-3b-8bit`: default q8 package.
  - `AbstractFramework/seedvr2-7b-8bit`: higher-quality 7B package when memory allows.
  - `AbstractFramework/seedvr2-3b-4bit` / `AbstractFramework/seedvr2-7b-4bit`: lower-memory packages.
  - `ByteDance-Seed/SeedVR2-3B` / `ByteDance-Seed/SeedVR2-7B`: official source weights; pass `--quantize 8` or `--quantize 4` if runtime quantization is needed.
- Prepared local folders work as model values. For example:
  `abstractvision upscale --provider mlx-gen --model /path/to/seedvr2-7b-8bit --image ./input.png --resolution 2x --softness 0.25 --open`.
- Bonsai ternary is a pre-packed low-bit MLX artifact, not a q4/q8 prepared folder. Use the exact repo id; guidance is fixed at 1.0 and negative prompts are ignored. The binary 1-bit Bonsai checkpoint is not surfaced because stock MLX cannot run it yet.
- Current shipped backend coverage includes `text_to_image` for FLUX.2 klein/base, Qwen Image, Z-Image, Z-Image Turbo, ERNIE Image Turbo, FIBO, Fibo-lite, and Bonsai ternary. `image_to_image` edits are implemented for FLUX.2 klein/base, base Qwen Image and Z-Image (latent image-to-image; Z-Image Turbo also masked), Qwen Image Edit, ERNIE Image Turbo, FIBO, Fibo-lite, Fibo-Edit, and Fibo-Edit-RMBG; `image_strength` selects FLUX.2's latent route (see [docs/api.md](../api.md#mlx-gen-image-routes)); FIBO Edit snapshots support masks where the runtime supports them, and FLUX.2 klein runs masked edits with `Flux2KleinInpaint`. `image_upscale` is implemented for SeedVR2.

One-shot shell commands:

```bash
abstractvision t2i --provider mlx-gen --model AbstractFramework/qwen-image-2512-4bit "a studio product photo of a white ceramic mug with the AbstractFramework logo" --steps 20 --guidance-scale 1.0 --open
abstractvision i2i --provider mlx-gen --model AbstractFramework/qwen-image-edit-2511-4bit --image ./input.png "replace the background with a clean white studio setup" --steps 20 --guidance-scale 2.5 --strength 0.75 --open
abstractvision t2i --provider mlx-gen --model briaai/FIBO "a studio product photo of a white ceramic mug with the AbstractFramework logo" --steps 50 --guidance-scale 4.0 --open
abstractvision t2i --provider mlx-gen --model prism-ml/bonsai-image-ternary-4B-mlx-2bit "a bonsai tree in a quiet ceramic studio" --steps 4 --guidance-scale 1.0 --open
abstractvision i2i --provider mlx-gen --model briaai/Fibo-Edit --image ./input.png "remove the background and keep the object edges clean" --steps 20 --guidance-scale 4.0 --open
abstractvision upscale --provider mlx-gen --model AbstractFramework/seedvr2-3b-8bit --image ./input.png --resolution 2x --softness 0.25 --open
abstractvision upscale --provider mlx-gen --model /path/to/seedvr2-7b-8bit --image ./input.png --resolution 2x --softness 0.25 --open
abstractvision t2v --provider mlx-gen --model AbstractFramework/wan2.2-t2v-a14b-diffusers-8bit "a red fox walking through a snowy forest, cinematic" --width 432 --height 240 --frames 41 --fps 10 --steps 20 --guidance-scale 4.0 --guidance-2 3.0 --open
abstractvision i2v --provider mlx-gen --model AbstractFramework/wan2.2-i2v-a14b-diffusers-8bit --image ./first-frame.png "slow camera push-in" --width 432 --height 240 --frames 41 --fps 10 --steps 20 --guidance-scale 3.5 --guidance-2 3.5 --open
```

MLX-Gen image, edit, and Wan video progress is surfaced as normalized progress
events. Shell image commands accept `--progress`; shell video commands and the
interactive CLI render denoise-step progress with frame context by default.
Python and AbstractCore callers can pass `on_progress(event)` to receive the
same events. Image events carry denoise-step `progress`; video events also carry
`frame`, `total_frames`, and `frame_progress`.

MLX-Gen LoRA support uses the shared AbstractVision `lora_adapters`
contract across Python, CLI, and AbstractCore. Catalog rows surface backend
truth for each exact route through:

- `supports_lora`
- `lora_status`
- `lora_target_roles`
- `lora_validation_profile`

Wan LoRA callers must respect route-specific target roles. TI2V-5B uses
`transformer`. A14B routes require explicit
`high_noise_transformer` / `low_noise_transformer` assignment.

Quantization guidance:

- The upstream LightX2V Qwen Lightning docs warn against mixing a BF16-trained
  Lightning LoRA with the raw unscaled FP8 Qwen base
  (`qwen_image_fp8_e4m3fn.safetensors`); that pairing can produce grid
  artifacts. Use the fp8-trained Lightning LoRA variant on that raw FP8 base,
  or use a scaled FP8/BF16-compatible base with the BF16-trained Lightning
  LoRA instead. Reference:
  <https://github.com/ModelTC/LightX2V-Qwen-Image-Lightning#-using-lightning-loras-with-fp8-models>
- AbstractVision's normal local MLX-Gen routes are curated q4/q8 prepared
  folders rather than that raw upstream FP8 base. For local LoRA-heavy Qwen and
  Wan runs, prefer the curated `...-8bit` routes when memory allows; q4 remains
  the lighter fallback.

Use `abstractvision show-model <model-id>` for one route's defaults and
`abstractvision adapters --provider mlx-gen --model <model-id> --task <task>`
for the locally cached overlay inventory on that route.

Interactive CLI/REPL commands:

```text
/backend mlx-gen AbstractFramework/qwen-image-2512-4bit
/t2i "a studio product photo of a white ceramic mug with the AbstractFramework logo" --steps 20 --guidance-scale 1.0 --open
/backend mlx-gen AbstractFramework/qwen-image-edit-2511-4bit
/i2i --image ./input.png "replace the background with a clean white studio setup" --steps 20 --guidance-scale 2.5 --strength 0.75 --open
/backend mlx-gen briaai/FIBO
/t2i "a studio product photo of a white ceramic mug with the AbstractFramework logo" --steps 50 --guidance-scale 4.0 --open
/backend mlx-gen prism-ml/bonsai-image-ternary-4B-mlx-2bit
/t2i "a bonsai tree in a quiet ceramic studio" --steps 4 --guidance-scale 1.0 --open
/backend mlx-gen AbstractFramework/wan2.2-t2v-a14b-diffusers-8bit
/t2v "a red fox walking through a snowy forest, cinematic" --width 432 --height 240 --frames 41 --fps 10 --steps 20 --guidance-scale 4.0 --guidance-2 3.0 --open
/backend mlx-gen AbstractFramework/wan2.2-i2v-a14b-diffusers-8bit
/i2v --image ./first-frame.png "slow camera push-in" --width 432 --height 240 --frames 41 --fps 10 --steps 20 --guidance-scale 3.5 --guidance-2 3.5 --open
```

Config/env:
- `ABSTRACTVISION_PROVIDER=mlx-gen` (alias: `ABSTRACTVISION_BACKEND=mlx-gen`)
- `ABSTRACTVISION_MFLUX_MODEL=AbstractFramework/flux.2-klein-4b-4bit` (or routed ids like `mlx-gen/AbstractFramework/flux.2-klein-4b-4bit`)
- Optional: `ABSTRACTVISION_MFLUX_BASE_MODEL`, `ABSTRACTVISION_MFLUX_ALLOW_DOWNLOAD`, `ABSTRACTVISION_MODEL_DIR` (legacy migration root only)
- Legacy `mflux` provider values and routed ids remain accepted as compatibility aliases.

Non-curated MLX-Gen models:
- If you have an MLX-Gen-compatible Hugging Face repo id that is not in `model-presets`, you can still use it:
  - Pre-download it with `abstractvision download org/name` (HF cache) or `hf download org/name`
  - Set `ABSTRACTVISION_MFLUX_MODEL` to that repo id or local path (the base model is inferred from a local folder's own name or card, or, inside a Hugging Face cache, its repo id, never from a parent directory; otherwise set `ABSTRACTVISION_MFLUX_BASE_MODEL=qwen-image`).

Runtime behavior notes:
- MLX-Gen request normalization is backend-level, so model constraints such as fixed guidance for turbo/distilled families, minimum step counts, and unsupported negative prompts are handled the same way through the CLI/REPL, playground API, and AbstractCore.
- Local MLX-Gen `image_to_image` is supported for FLUX.2 klein/base, base Qwen Image, Z-Image, Qwen Image Edit, ERNIE Image Turbo, FIBO, and FIBO Edit models. Route-aware masked edit is available on `AbstractFramework/qwen-image-edit-2511-8bit`, FLUX.2 klein, Z-Image Turbo, `briaai/Fibo-Edit`, and `briaai/Fibo-Edit-RMBG`; unsupported routes fail closed instead of silently dropping the mask.
- Local MLX-Gen runs structured control on `AbstractFramework/qwen-image-8bit` only (`QwenImageControlNet`, see [docs/api.md](../api.md#control-image-control_image)); on any other model a typed `control_image` (CLI `--control-image`) is refused with `CapabilityNotSupportedError` (`field="control_image"`), as on every other built-in backend, and is never reinterpreted as an image edit.
- Edit strength is passed as `strength` and normalized to MLX-Gen's `image_strength` parameter where the runtime supports it.
- Local MLX-Gen video is implemented for `Wan-AI/Wan2.2-TI2V-5B-Diffusers`, `AbstractFramework/wan2.2-ti2v-5b-diffusers-8bit`, and the task-specific Wan A14B packages `AbstractFramework/wan2.2-t2v-a14b-diffusers-8bit` / `AbstractFramework/wan2.2-i2v-a14b-diffusers-8bit`. TI2V-5B should be run at `832x480` / `480x832` or above in practice. Wan A14B dimensions must be multiples of 16 and can still be smoke-tested at `480x240`.
- Local MLX-Gen also serves MiniMax-H3 (`MiniMaxAI/MiniMax-H3`; packages `AbstractFramework/minimax-h3-8bit`, `-bf16`, `-4bit`): a video with a synchronized stereo soundtrack, `text_to_video` and first-frame `image_to_video`. Set `base_model` to `minimax-h3-turbo-544p`, `minimax-h3-turbo` or `minimax-h3` to pick the schedule. Requests take `soundscape`, `music`, `generate_audio`, `flow_shift` (the video shift) and `audio_shift`; MLX-Gen's capability row and its own MiniMax-H3 planning code (aspect window, prompt composition, adapter check) decide what is accepted, and every value is checked before any weights load, with an error that names the field. Results are the MP4 with its AAC track plus `GeneratedAsset.audio` and `GeneratedAsset.audio_summary()`; a track MLX-Gen could not mux is kept as a WAV (a second artifact when a store is set). `preload()` loads the model without a warm-up run, as for Wan. The weights are never downloaded during generation (gated; territorial licence). See [Video with sound](../api.md#video-with-sound-minimax-h3). `abstractvision download MiniMaxAI/MiniMax-H3 --base-model minimax-h3-turbo-544p` fetches the recommended package and the Turbo adapter.
- Every MLX-Gen request takes `cancel_event` (stopped between steps, `GenerationCancelledError`; what stays loaded per family is listed under [Host integration](../api.md#host-integration)) and load-time `quantize` (validated against the route; refused on prepared packages); `describe_routes()` returns MLX-Gen's capability rows as JSON; progress callback errors are logged and never stop a run. The backend holds one model instance: a request with another model, adapter set, `quantize` or block streaming releases the loaded one (and clears the MLX cache) before the new one loads. Result metadata names models and adapters by repo id or file name, never by local path. Diffusers and stable-diffusion.cpp check `cancel_event` before a run and refuse `quantize` and the soundtrack options; the OpenAI-compatible backend sends them to a remote that advertises them, and cancels the remote job when `cancel_event` is set (see its section above). See [Host integration](../api.md#host-integration).
- Task-specific Wan A14B uses two guidance controls. `guidance_scale` controls the primary/high-noise stage and `guidance_2` controls the second-stage/low-noise stage. `guidance_2` is a typed video request field, CLI/REPL flag `--guidance-2`, and registry parameter default; it is not passed through `extra`.
- Wan requests can pass `max_sequence_length` through Python `extra={...}` or CLI/REPL `--max-sequence-length`.
- Each Wan model has its own default size (`WAN_VIDEO_DEFAULT_CANVASES`): 832x480 for TI2V-5B (121 frames at 24 fps, 50 steps) and for the A14B models (81 frames at 16 fps, 40 steps). Explicit `width`, `height`, `num_frames`, `fps` and `steps` always win. The Wan VAE decode runs in overlapping spatial tiles by default; `extra={"vae_tiling": False}` / CLI `--no-vae-tiling` decodes whole frames. Measured memory per size: [FAQ](../faq.md#how-much-memory-does-wan-video-need).
- Generation does not silently download model files. Missing-cache errors tell you which `abstractvision download ... --provider mlx-gen` or `mlxgen` preparation step is needed.
- `memory_mode="low"` (CLI `--memory-mode low`) runs a request in MLX-Gen low-RAM mode as the route's `mlxgen` command does with `--low-ram`, with the 1 GB MLX cache set before the model loads: on image and edit routes mlx-gen's `MemorySaver` tiles the VAE decode and frees the text encoders before the denoising loop and the transformer after it; on Wan routes the MLX cache is cleared after every step and transformer block and the denoisers are released before the decode (and, on A14B, the inactive expert); on MiniMax-H3 the transformer is freed before the decode; on SeedVR2 upscaling the cache limit is the whole change. Image, edit, Wan and MiniMax-H3 instances are dropped when a `low` run ends and loaded again by the next request, a batch item included (MiniMax-H3 after `lowest` too), so every item of a batch peaks as one `low` run; SeedVR2 keeps its instance. The 1 GB limit is never raised above a limit already in force, and `default` runs leave the limit to MLX-Gen. `memory_mode="lowest"` adds transformer block streaming (`--stream-blocks`) and is accepted only for models whose routes stream transformer blocks; it is accepted for MiniMax-H3 and refused on every other current catalog model. See [Memory modes](../api.md#memory-modes-memory_mode).

Code pointers:
- Config: `MLXGenBackendConfig` / compatibility alias `MFluxBackendConfig` ([`../../src/abstractvision/backends/mflux.py`](../../src/abstractvision/backends/mflux.py))
- Backend: `MLXGenVisionBackend` / compatibility alias `MFluxVisionBackend` ([`../../src/abstractvision/backends/mflux.py`](../../src/abstractvision/backends/mflux.py))

## stable-diffusion.cpp backend (local GGUF/checkpoints)

**When to use**
- You want to run single-file Stable Diffusion checkpoints/GGUF or component-based GGUF diffusion models locally.

Runtime modes (auto-selected):
- **CLI mode** via `sd-cli` (stable-diffusion.cpp executable) when available in `PATH`
- **Python mode** via `stable-diffusion-cpp-python` when `sd-cli` is not available

Notes:
- If you care about **GPU acceleration** (macOS **Metal**, NVIDIA **CUDA**, etc.), prefer **CLI mode** via `sd-cli`.
- Python bindings run whatever backend the installed wheel was built with. On macOS, that often means **CPU-only**, so FLUX/Qwen-class models can be extremely slow.
- Operators who want to hide GGUF presets (and reject GGUF execution) on macOS can set `ABSTRACTVISION_DISABLE_GGUF_ON_MACOS=1`.
- `memory_mode="low"` keeps the model parameters in system RAM and moves them to the compute device when needed: `--offload-to-cpu` for `sd-cli` (an operator's own flag stays) and `offload_params_to_cpu` for the Python binding, which reloads the model when the loaded one was not offloaded. On a CPU-only build the parameters are in RAM already. `"lowest"` is refused.
- The optional python binding is constrained below `0.4.6` because that sdist
  currently misses vendored CMake files needed by native Linux builds.
- Interactive CLI selection supports both `/backend sdcpp <model_key|model.gguf|model.safetensors> [sd_cli_path]` and
  `/backend sdcpp <diffusion_model.gguf> <vae.safetensors> <llm.gguf> [sd_cli_path]`.
- One-shot CLI, playground, and the AbstractCore plugin can also accept curated `sdcpp` model keys such as
  `flux2-klein-base-4b` or `qwen-image` after `abstractvision download ... --provider sdcpp`.
- Python code and AbstractCore plugin configuration can also pass component paths such as `clip_l`, `clip_g`, `t5xxl`, `llm_vision`, plus `extra_args` and `cwd`. Local image generation is not killed by a default timeout.

Code pointers:
- Config: `StableDiffusionCppBackendConfig` ([`../../src/abstractvision/backends/stable_diffusion_cpp.py`](../../src/abstractvision/backends/stable_diffusion_cpp.py))
- Backend: `StableDiffusionCppVisionBackend` ([`../../src/abstractvision/backends/stable_diffusion_cpp.py`](../../src/abstractvision/backends/stable_diffusion_cpp.py))
--- >8 --- END FILE: docs/reference/backends.md --- >8 ---

--- 8< --- FILE: docs/reference/configuration.md --- 8< ---
# Configuration (CLI)

AbstractVision configuration is intentionally simple:

- In Python, you configure backends by instantiating backend config objects (see [docs/reference/backends.md](backends.md)).
- The CLI/playground reads `ABSTRACTVISION_*` environment variables to set defaults ([`../../src/abstractvision/cli.py`](../../src/abstractvision/cli.py), [`../../src/abstractvision/playground_server.py`](../../src/abstractvision/playground_server.py)). The interactive command is `abstractvision cli` (legacy alias: `abstractvision repl`).
- The AbstractCore capability plugin also reads `owner.config` plus a small set of standard OpenAI environment aliases. Plugin-only aliases are called out below.

See also:
- Getting started (examples): [docs/getting-started.md](../getting-started.md)
- Backends: [docs/reference/backends.md](backends.md)

## CLI commands (overview)

Implemented in [`../../src/abstractvision/cli.py`](../../src/abstractvision/cli.py):

- `abstractvision models` — list known registry model ids (one per line); `--json` adds each model's downloads with the fields `show-model` prints
- `abstractvision tasks` — list known tasks
- `abstractvision show-model <id> [--json]` — print a model’s tasks + params and, for each download, whether the Hugging Face repository is gated (and the licence to accept), its cache state (`cached` with its size on disk, `incomplete` with the gap, or `absent`; the download size comes from `download --dry-run`), the `memory_mode` values this host can run and, for MLX-Gen packages whose capability rows publish measured runs, the peak memory of each mode and the smallest memory it was tested on; for MiniMax-H3 it also lists the schedules (`base_model`) and the adapter each loads
- `abstractvision catalog [--provider ...] [--task ...] [--json]` — browse the downloadable models: target, engine, bits (`*` marks the recommended package), access (gated or open), cache state and the memory modes this host can run
- `abstractvision download <model id or repo id> [--bits N] [--base-model SCHEDULE] [--dry-run]` — download a curated preset into the Hugging Face cache (see [Downloads](#downloads))
- `abstractvision adapters --provider mlx-gen --model <id> --task <task>` — list backend-discovered cached adapters for one exact route
- `abstractvision provider-models --openai --task text_to_image` — explicitly query the official OpenAI `/models` catalog
- `abstractvision provider-models --base-url http://localhost:1234/v1 --task text_to_image` — explicitly query an OpenAI-compatible provider catalog
- `abstractvision cli` — interactive testing (supports `openai`, `diffusers`, `mlx-gen`, `sdcpp`; legacy alias: `abstractvision repl`; `mflux` is accepted as a compatibility alias)
- `abstractvision playground [--host 127.0.0.1] [--port 8091]` — self-contained local web UI and `/v1/vision/*` API
- `abstractvision serve [--host 127.0.0.1] [--port 8091]` — alias for `abstractvision playground`
- `abstractvision t2i ...` / `abstractvision i2i ...` / `abstractvision t2v ...` / `abstractvision i2v ...` — one-shot commands using the configured provider/backend (`openai`/`openai-compatible` by default; also supports local `diffusers`, `mlx-gen`, and `sdcpp`; MLX-Gen provides image progress, shared LoRA adapters, multi-reference edits, SeedVR2 upscaling, and Wan `t2v`/`i2v`, including A14B task-specific checkpoints)
- `abstractvision upscale ...` — one-shot SeedVR2 image upscaling; defaults to `--provider mlx-gen --model AbstractFramework/seedvr2-3b-8bit --resolution 2x --softness 0.25` and supports `--scale`, `--resolution`, `--softness`, `--seed`, optional source-weight `--quantize`, and `--vae-tiling`

Note:
- `abstractvision t2i` / `abstractvision i2i` / `abstractvision t2v` / `abstractvision i2v` run on this machine's local engine by default with FLUX.2 [klein] 4B: the 8-bit MLX-Gen package on Apple silicon, the Q8_0 GGUF on stable-diffusion.cpp on an NVIDIA card, the 16-bit Diffusers pipeline (run in float32) on a processor; `--base-url` selects the OpenAI-compatible HTTP backend and `--provider` picks another local engine.
- Local Diffusers requires `abstractvision[diffusers]`. stable-diffusion.cpp python binding fallback requires `abstractvision[sdcpp]`; external `sd-cli` can be used without the binding.
- One-shot image commands write to `ABSTRACTVISION_STORE_DIR` or `--store-dir` and print JSON artifact metadata followed by the local content path. They do not take an `--output` path flag.
- One-shot generation/edit/video commands support `--count` plus optional `--seeds` for reproducible batch orchestration above the exact single-run request surface.
- `width`/`height` are optional request overrides, not global defaults. Leave
  them unset to let the selected provider/model choose its default or `auto`
  size. Some models accept quick-test sizes such as `512x512`; others only
  accept provider-declared sizes such as `1024x1024`, `1024x1536`,
  `1536x1024`, or `auto`.

Examples:

```bash
abstractvision t2i --provider mlx-gen --model AbstractFramework/qwen-image-2512-4bit "a studio product photo of a white ceramic mug" --steps 20 --guidance-scale 1.0 --open
abstractvision i2i --provider mlx-gen --model AbstractFramework/qwen-image-edit-2511-4bit --image ./input.png "replace the background with a clean white studio setup" --steps 20 --guidance-scale 2.5 --strength 0.75 --open
abstractvision t2i --provider mlx-gen --model briaai/FIBO "a studio product photo of a white ceramic mug" --steps 50 --guidance-scale 4.0 --open
abstractvision t2i --provider mlx-gen --model prism-ml/bonsai-image-ternary-4B-mlx-2bit "a bonsai tree in a quiet ceramic studio" --steps 4 --guidance-scale 1.0 --open
abstractvision i2i --provider mlx-gen --model briaai/Fibo-Edit --image ./input.png "remove the background and keep the object edges clean" --steps 20 --guidance-scale 4.0 --open
abstractvision upscale --provider mlx-gen --model AbstractFramework/seedvr2-3b-8bit --image ./input.png --resolution 2x --softness 0.25 --open
abstractvision t2v --provider mlx-gen --model AbstractFramework/wan2.2-t2v-a14b-diffusers-8bit "a red fox walking through a snowy forest, cinematic" --width 432 --height 240 --frames 41 --fps 10 --steps 20 --guidance-scale 4.0 --guidance-2 3.0 --open
abstractvision i2v --provider mlx-gen --model AbstractFramework/wan2.2-i2v-a14b-diffusers-8bit --image ./first-frame.png "slow camera push-in" --width 432 --height 240 --frames 41 --fps 10 --steps 20 --guidance-scale 3.5 --guidance-2 3.5 --open
```

For MLX-Gen Wan, one-shot `t2v` and `i2v` show denoise-step progress with
frame context on stderr by default. `upscale` also shows denoise-step progress
by default. Add `--no-progress` when you need quiet shell output.

`t2i`, `i2i`, `upscale`, `t2v` and `i2v` take `--memory-mode default|low|lowest`
(default: `$ABSTRACTVISION_MEMORY_MODE`, else `default`) to lower the run's
memory peak at some cost in speed: MLX-Gen low-RAM mode, Diffusers CPU offload
on CUDA, stable-diffusion.cpp CPU offload of parameters. A mode the provider
cannot honour is refused. See [Memory modes](../api.md#memory-modes-memory_mode).

```bash
abstractvision t2v --provider mlx-gen --model AbstractFramework/wan2.2-t2v-a14b-diffusers-8bit "a red fox walking through a snowy forest, cinematic" --memory-mode low --open
```

`t2i`, `i2i`, `t2v` and `i2v` take `--quantize BITS` (load-time quantization of a
source snapshot on MLX-Gen; refused elsewhere). `t2v` and `i2v` take the soundtrack
options of MiniMax-H3: `--soundscape`, `--music`, `--no-audio`, `--audio-shift`
(`--flow-shift` is its video shift):

```bash
abstractvision t2v --provider mlx-gen --model AbstractFramework/minimax-h3-8bit --mflux-base-model minimax-h3-turbo-544p "A red fox trots through fresh snow at dawn." --soundscape "Paws in dry snow, faint wind." --music "Sparse piano." --width 640 --height 352 --frames 124 --seed 42 --open
```

## Interactive CLI backend selection

Inside `abstractvision cli`:

- `/backend openai <base_url> [api_key] [model_id]`
- `/provider-models [--task text_to_image] [--json]` — query the configured OpenAI-compatible provider catalog
- `/backend mlx-gen <preset_or_local_path> [base_model]`
- `/backend diffusers <model_id_or_path> [device] [torch_dtype]`
- `/backend sdcpp <model_key|model.gguf|model.safetensors> [sd_cli_path]`
- `/backend sdcpp <diffusion_model.gguf> <vae.safetensors> <llm.gguf> [sd_cli_path]`

Run `/help` in the interactive CLI to see the full command list (generated by `_repl_help()` in [`../../src/abstractvision/cli.py`](../../src/abstractvision/cli.py)).

Interactive generation commands include `/t2i`, `/i2i`, `/t2v`, and `/i2v`. The local Diffusers `text_to_video` path remains experimental and disabled from the normal local surfaces, while MLX-Gen Wan supports local `t2v` and `i2v`. Interactive image commands follow the same size rule as one-shot commands: omit width and height unless you intentionally want a specific backend-supported size.

Examples:

```text
/backend mlx-gen AbstractFramework/qwen-image-2512-4bit
/t2i "a studio product photo of a white ceramic mug" --steps 20 --guidance-scale 1.0 --open
/backend mlx-gen AbstractFramework/qwen-image-edit-2511-4bit
/i2i --image ./input.png "replace the background with a clean white studio setup" --steps 20 --guidance-scale 2.5 --strength 0.75 --open
/backend mlx-gen briaai/FIBO
/t2i "a studio product photo of a white ceramic mug" --steps 50 --guidance-scale 4.0 --open
/backend mlx-gen prism-ml/bonsai-image-ternary-4B-mlx-2bit
/t2i "a bonsai tree in a quiet ceramic studio" --steps 4 --guidance-scale 1.0 --open
/backend mlx-gen AbstractFramework/wan2.2-t2v-a14b-diffusers-8bit
/t2v "a red fox walking through a snowy forest, cinematic" --width 432 --height 240 --frames 41 --fps 10 --steps 20 --guidance-scale 4.0 --guidance-2 3.0 --open
/backend mlx-gen AbstractFramework/wan2.2-i2v-a14b-diffusers-8bit
/i2v --image ./first-frame.png "slow camera push-in" --width 432 --height 240 --frames 41 --fps 10 --steps 20 --guidance-scale 3.5 --guidance-2 3.5 --open
```

Interactive `/t2v` and `/i2v` also show denoise-step video progress by default
and accept `--no-progress`.

Important runtime note:
- Model-specific request adjustments are not implemented only in the interactive UI. The shared backend normalization hooks are applied by `VisionManager` and by the playground API server, so the same parameter corrections reach `abstractvision cli`, the legacy `repl` alias, one-shot CLI commands, the playground, and the AbstractCore plugin.

## Environment variables

The interactive CLI state object (`_ReplState` in [`../../src/abstractvision/cli.py`](../../src/abstractvision/cli.py)) reads the common and backend env vars below. The playground server reads the same backend family plus a few playground-only Diffusers cache/version vars through `PlaygroundServerConfig` in [`../../src/abstractvision/playground_server.py`](../../src/abstractvision/playground_server.py).

### Common

- `ABSTRACTVISION_PROVIDER` — preferred backend selector: `openai`, `openai-compatible`, `diffusers`, `mlx-gen`, or `sdcpp` (alias: `ABSTRACTVISION_BACKEND`; `mflux` remains accepted as a compatibility alias)
  - AbstractCore plugin default: `openai` using `https://api.openai.com/v1` plus `OPENAI_API_KEY`
  - AbstractCore compatibility: selecting `abstractvision:openai-compatible` directly, or setting `OPENAI_BASE_URL` to a non-OpenAI endpoint, keeps compatible-endpoint semantics
  - if unset and `OPENAI_BASE_URL` is set, the interactive CLI/playground default to `openai`
  - if unset and no base URL is configured, no backend is selected until you use `/backend ...` or load a model explicitly
- `ABSTRACTVISION_STORE_DIR` — local artifact output directory (default: `~/.abstractvision/assets`)
- `ABSTRACTVISION_TIMEOUT_S` — optional timeout for OpenAI-compatible catalog/control calls. Image and video generation calls do not have a default timeout.
- `ABSTRACTVISION_MODEL` — preferred model selector for the current backend/provider (alias: `ABSTRACTVISION_MODEL_ID`)
- `ABSTRACTVISION_MODEL_ID` — model id for the current backend in the interactive CLI (legacy):
  - `openai`: sent as `model` in HTTP requests (optional; server-dependent)
  - `diffusers`: Diffusers model id or local path
- `ABSTRACTVISION_MODEL_DIR` — legacy preset root imported into the Hugging Face cache when older installs are migrated
- `ABSTRACTVISION_CAPABILITIES_MODEL_ID` — optional capability-gating model id (must exist in the registry)
- `ABSTRACTVISION_MEMORY_MODE` — `default`, `low` or `lowest`: the memory mode of every generation request that names none, in the CLI, the playground, Python and the AbstractCore plugin; a request value wins. A mode that comes from `$ABSTRACTVISION_MEMORY_MODE` is one value for every backend of the process, so a backend that cannot honour it for its model and device runs the lowest-memory mode it lists that is not below it (`lowest` becomes `low` where `low` is listed, else `default`) and logs that once; a mode passed on the request is refused instead. Warmups (`preload`) follow the same rule. See [Memory modes](../api.md#memory-modes-memory_mode).

Note:
- Curated `abstractvision download ...` presets are written to the Hugging Face cache by default, and older `~/models/<preset>` trees are imported into that same cache on first use.

### Downloads

`abstractvision download` takes an exact package repo id (`AbstractFramework/minimax-h3-4bit`), its
short name (`minimax-h3-4bit`), or a model id (`MiniMaxAI/MiniMax-H3`), and selects one package:

- Without `--bits`, a model with a single package selects it, whatever its width (`stabilityai/stable-diffusion-xl-base-1.0`
  selects its Diffusers pipeline, `briaai/Fibo-Edit` its 16-bit MLX-Gen snapshot).
- Across targets, the host's order decides (Apple silicon: `mlx`, `gguf`, `diffusers`, `hf-snapshot`;
  NVIDIA: `gguf`, `diffusers`, `hf-snapshot`; processor only: `diffusers`, `hf-snapshot`, `gguf`),
  preferring an 8-bit package. `--target` or `--provider` restricts the choice to one target or engine;
  a name with no package for it is refused, with the packages it has. `--bits 2|4|8|16` selects among the
  packages of that width only, in every target of the host, or stops saying none has it and listing the
  widths there are.
- Within the chosen target, several packages select the one the catalog marks as recommended (`*` in
  `catalog`: MiniMax-H3's and SeedVR2's 8-bit packages, FIBO's 4-bit package, Qwen-Image-2512's 4-bit
  MLX-Gen package, GGUF and Diffusers pipeline). With several and no recommendation the command stops and lists them, whatever
  `--bits`, `--provider` or `--allow-non-8bit` narrowed them to (`tencent/HunyuanVideo-1.5` lists its eight
  Diffusers pipelines; FLUX.2 [klein] its 4-bit and 8-bit packages): name one.
- `--allow-non-8bit`, or naming the MLX-Gen engine (`--provider mlx-gen`), drops the 8-bit preference. A
  repository named exactly then selects that repository instead of a package made from it (when `--bits`
  is its width or not given), on every host
  (`abstractvision download briaai/FIBO --provider mlx-gen` is the FIBO source repository): `abstractvision download
  MiniMaxAI/MiniMax-H3 --allow-non-8bit` fetches the MiniMax-H3 source repository, which the model id
  alone does not (it selects the recommended 8-bit package), and `stabilityai/sdxl-turbo` selects that
  Diffusers pipeline instead of its GGUF package. Where the host's order puts a target without an 8-bit
  package first (processor only: `diffusers`), that target is chosen (`Qwen/Qwen-Image` then selects the
  Diffusers pipeline instead of the GGUF package). A model with a single package needs no flag.
- A Hugging Face `owner/name` that the catalog does not list downloads every file of the repository.

What the command does:

- The plan: before anything is written, every repository the download fetches from is listed on the
  Hugging Face Hub (metadata only; a Diffusers pipeline's `model_index.json` is read into memory to keep
  only the files the Diffusers backend loads): the package, a stable-diffusion.cpp bundle's companion
  repositories (the VAE and text encoder a GGUF diffusion model needs), and the adapter of `--base-model`.
  Each file is either complete in the cache (huggingface_hub's own test: its snapshot link or its blob
  exists) or to fetch. The command prints the access, the size and file count, how many files are
  complete and how many are to fetch, one line per companion or adapter, one total, and the free space
  of the cache disk.
- The disk check: the files to fetch must fit at their full size, less what their partial `.incomplete`
  files already hold (huggingface_hub writes each file into that same file, continuing it over plain
  HTTP and rewriting it from the start over Xet, so its space is reused); the `disk:` line states this
  rule and the bytes it needs. Otherwise the download stops and writes nothing.
- Fetching: only the files to fetch are requested, from the commit the listing named, so a repository
  updated during the download cannot mix two commits; the cache then records that commit as the
  repository's `main`. When nothing is to fetch, the command says every file is already present and
  fetches nothing. Ctrl-C exits with code 130; the files that completed stay in the cache, and the same
  command fetches the rest. A download that ends with files missing gives their count and one of them.
- Without the Hub listing, nothing is sized or fetched, and the command says why and what to do:
  offline mode (`HF_HUB_OFFLINE`), the Hub unreachable, an HTTP error, huggingface_hub (or a module it
  imports) not installed, or a listing without file sizes (huggingface.co gives every size; a mirror set
  with `HF_ENDPOINT` may not). What the cache holds is reported as it is, not compared with the Hub;
  the command stops when a local look sees a gap or a repository is missing.
- Legacy trees: a `~/models/<preset>` tree (`ABSTRACTVISION_MODEL_DIR`, or `--model-dir`) is moved into
  the cache; `download` then says it was imported and not compared with the Hub, and fetches nothing for
  the package on top of it. When the cache already holds the package, the tree is removed.
- A 401 for a repository not marked gated means it does not exist, is private, or is gated: the Hub
  does not say which.
- Gated repositories (for example the `AbstractFramework/minimax-h3-*` packages): accept the licence on
  the repository page while logged in to Hugging Face, then authenticate (`hf auth login`, `HF_TOKEN`, or
  `--token`). A refused download ends with a message naming the page and the licence.
- `--base-model <schedule>`: for MLX-Gen models whose schedules load an adapter, the adapter is part of
  the plan (what it is, cached or to fetch, its size) and is fetched into huggingface_hub's cache, where
  mlx-gen finds it. The MiniMax-H3 Turbo schedules `minimax-h3-turbo-544p` and `minimax-h3-turbo` load a
  lightx2v Turbo LoRA; `minimax-h3` loads none. Which adapter a schedule loads is read from mlx-gen: a
  `--base-model` that is not a schedule of the package, or an adapter that cannot be named because
  mlx-gen is not installed, stops the command before anything is fetched. Without `--base-model`, the
  command prints the schedules whose adapter is absent, with the command that fetches it.
- `--dry-run`: prints the selection and the same plan (with the commit of each repository the fetch would
  take), writes nothing and exits 0; when the download
  would not fit, its last line says so.
- `catalog` and `show-model` show each download's cache state from a local look, offline: `cached` is a
  snapshot with no gap that look can see (a partial file, a link without content, a weight file an index
  names, a component `model_index.json` names whose folder the package's patterns name, such as
  `transformer_2/`, or no weight file at all), `incomplete` names the gap, `absent` is nothing in the
  cache. Only `download` (or `--dry-run`) compares a snapshot with the Hub, so a file nothing local
  refers to, such as one an interrupted download never started, can be missing from a snapshot shown as
  `cached`.
- Generation (MLX-Gen and Diffusers) never downloads a repository whose catalog download is marked `explicit_download: true`
  (today the four MiniMax-H3 repositories: `AbstractFramework/minimax-h3-8bit|bf16|4bit` and
  `MiniMaxAI/MiniMax-H3`), or an MLX-Gen adapter, even with `ABSTRACTVISION_MFLUX_ALLOW_DOWNLOAD=1` or `ABSTRACTVISION_DIFFUSERS_ALLOW_DOWNLOAD=1`. `gated`
  only says whether the Hub asks for the licence to be accepted.

```bash
abstractvision show-model MiniMaxAI/MiniMax-H3
abstractvision download MiniMaxAI/MiniMax-H3 --dry-run
abstractvision download MiniMaxAI/MiniMax-H3 --base-model minimax-h3-turbo-544p
abstractvision download MiniMaxAI/MiniMax-H3 --bits 4
abstractvision download MiniMaxAI/MiniMax-H3 --allow-non-8bit   # the source repository
```

### OpenAI / OpenAI-Compatible HTTP Backend

- `OPENAI_BASE_URL` — optional OpenAI-compatible `/v1` endpoint override; when unset, the official OpenAI profile uses `https://api.openai.com/v1`
- `OPENAI_API_KEY` — bearer token for official OpenAI and compatible `/v1` endpoints that require auth
- `ABSTRACTVISION_MODEL_ID` — optional remote model id/name (see also “Common”)
- `OPENAI_IMAGE_MODEL_ID` / `OPENAI_IMAGE_MODEL` — plugin-only OpenAI model aliases when `ABSTRACTVISION_MODEL_ID` / `vision_model_id` are unset
- `ABSTRACTVISION_MODELS_PATH` / `vision_models_path` — provider catalog path for explicit listing (default: `/models`, so a `/v1` base URL queries `/v1/models`)
- Many OpenAI-compatible providers expose `GET /models`. AbstractVision exposes that catalog via `abstractvision provider-models`, `VisionManager.list_provider_models(...)`, and the AbstractCore plugin method `llm.vision.list_provider_models(...)`; it does not call the catalog automatically or use it to select a model. The plugin uses its static default (`gpt-image-1`) unless a model id is configured.
- `ABSTRACTVISION_IMAGES_GENERATIONS_PATH` — default: `/images/generations`
- `ABSTRACTVISION_IMAGES_EDITS_PATH` — default: `/images/edits`
- `ABSTRACTVISION_TEXT_TO_VIDEO_PATH` — optional (enables `text_to_video`)
- `ABSTRACTVISION_IMAGE_TO_VIDEO_PATH` — optional (enables `image_to_video`)
- `ABSTRACTVISION_IMAGE_TO_VIDEO_MODE` — `multipart` (default) or `json_b64`

### Diffusers backend

- `ABSTRACTVISION_DIFFUSERS_DEVICE` — `auto` (default), `cpu`, `cuda`, `mps`, …
- `ABSTRACTVISION_DIFFUSERS_TORCH_DTYPE` — optional (`float16`, `bfloat16`, `float32`)
- `ABSTRACTVISION_DIFFUSERS_ALLOW_DOWNLOAD` — `0` (default/cache-only/offline) or `1` to permit runtime downloads
- `ABSTRACTVISION_DIFFUSERS_AUTO_RETRY_FP32` — `1` (default) or `0` (MPS-only image fallback behavior; local video does not auto-promote above 16-bit on MPS)

Playground-only Diffusers vars:
- `ABSTRACTVISION_ALLOW_DOWNLOAD` — legacy fallback used only when `ABSTRACTVISION_DIFFUSERS_ALLOW_DOWNLOAD` is unset
- `ABSTRACTVISION_DIFFUSERS_CACHE_DIR` — optional Hugging Face cache directory override
- `ABSTRACTVISION_DIFFUSERS_REVISION` — optional model revision
- `ABSTRACTVISION_DIFFUSERS_VARIANT` — optional model variant

### MLX-Gen backend (Apple-first)

- `ABSTRACTVISION_MFLUX_MODEL` — exact published MLX-Gen repo id, local model path, or custom repo id (examples: `AbstractFramework/flux.2-klein-4b-4bit`, `AbstractFramework/ernie-image-turbo-8bit`, `briaai/FIBO`, `prism-ml/bonsai-image-ternary-4B-mlx-2bit`, `briaai/Fibo-Edit`, `Wan-AI/Wan2.2-TI2V-5B-Diffusers`, `AbstractFramework/wan2.2-t2v-a14b-diffusers-8bit`, `AbstractFramework/wan2.2-i2v-a14b-diffusers-8bit`, `/path/to/preset-dir`)
- `ABSTRACTVISION_MFLUX_BASE_MODEL` — optional base family for local paths or custom repos (`flux2-klein-4b`, `flux2-klein-9b`, `flux2-klein-base-4b`, `flux2-klein-base-9b`, `bonsai-image-ternary`, `z-image`, `z-image-turbo`, `qwen-image`, `qwen-image-edit-2511`, `ernie-image-turbo`, `fibo`, `fibo-lite`, `fibo-edit`, `fibo-edit-rmbg`, `wan2.2-ti2v-5b`, `wan2.2-t2v-a14b`, `wan2.2-i2v-a14b`), or the MiniMax-H3 schedule (`minimax-h3-turbo-544p`, `minimax-h3-turbo`, `minimax-h3`)
- `ABSTRACTVISION_MFLUX_ALLOW_DOWNLOAD` — `0` (default) or `1` to permit runtime downloads when a preset/repo is missing from the local cache, except for the repositories the catalog marks `explicit_download` (see [Downloads](#downloads))
- `ABSTRACTVISION_MODEL_DIR` — legacy preset root only; curated downloads now land in the Hugging Face cache
- `ABSTRACTVISION_MLX_GEN_LORA_PATHS` / `ABSTRACTVISION_MFLUX_LORA_PATHS` — optional default LoRA adapters applied by the MLX-Gen backend when a request does not carry its own `lora_adapters`
- `ABSTRACTVISION_MLX_GEN_LORA_SCALES` / `ABSTRACTVISION_MFLUX_LORA_SCALES` — optional default LoRA scales aligned with the configured default paths
- `ABSTRACTVISION_MLX_GEN_LORA_TARGET_ROLES` / `ABSTRACTVISION_MFLUX_LORA_TARGET_ROLES` — optional default target roles aligned with the configured default paths; primarily useful for Wan routes
- Canonical provider/model routing is `mlx-gen` / `mlx-gen/<exact-huggingface-repo>`, for example `mlx-gen/AbstractFramework/flux.2-klein-4b-4bit`. Legacy `mflux` provider values, routed ids, and env var names are accepted for compatibility, but the model id itself should be the exact published repo id.

MLX-Gen LoRA notes:

- CLI callers should prefer repeated `--lora`, `--lora-scale`, and
  `--lora-target-role` flags.
- Python and AbstractCore callers should prefer the shared typed
  `lora_adapters` request field.
- Catalog discovery surfaces exact-route LoRA truth through `supports_lora`,
  `lora_status`, `lora_target_roles`, and `lora_validation_profile`.
- For LightX2V Qwen Lightning adapters, do not manually pair a BF16-trained
  Lightning LoRA with the raw unscaled FP8 Qwen base
  (`qwen_image_fp8_e4m3fn.safetensors`); upstream documents grid artifacts for
  that mix. See:
  <https://github.com/ModelTC/LightX2V-Qwen-Image-Lightning#-using-lightning-loras-with-fp8-models>
- For local LoRA-heavy Qwen and Wan runs through MLX-Gen, prefer curated
  `...-8bit` model ids when memory allows. q4 remains the lighter fallback.

Capability asset overrides:

- `ABSTRACTVISION_MODEL_CAPABILITIES_PATH` — optional filesystem path to a replacement `vision_model_capabilities.json`
- `ABSTRACTVISION_ADAPTER_CAPABILITIES_PATH` — optional filesystem path to a replacement `vision_adapter_capabilities.json`

These let operators update curated model/adapter metadata and default
parameters without changing Python code.

### stable-diffusion.cpp backend

- `ABSTRACTVISION_SDCPP_BIN` — `sd-cli` path/name (default: `sd-cli`)
- `ABSTRACTVISION_SDCPP_MODEL` — optional curated model key or single-file model path. For curated keys such as `flux2-klein-base-4b` or `qwen-image`, AbstractVision resolves cached VAE/LLM companions automatically.
- `ABSTRACTVISION_SDCPP_DIFFUSION_MODEL` — GGUF diffusion model path
- `ABSTRACTVISION_SDCPP_VAE` — VAE safetensors path (required for component-mode models like Qwen Image GGUF and FLUX.2 GGUF)
- `ABSTRACTVISION_SDCPP_LLM` — text encoder path (often GGUF; required for component-mode models like Qwen Image GGUF and FLUX.2 GGUF)
- `ABSTRACTVISION_SDCPP_LLM_VISION` — optional vision encoder GGUF path
- `ABSTRACTVISION_SDCPP_EXTRA_ARGS` — extra `sd-cli` flags (string, split like a shell)
- `ABSTRACTVISION_DISABLE_GGUF_ON_MACOS` — set to `1` to hide/disable GGUF/stable-diffusion.cpp catalog entries and execution on macOS (default: `0` / GGUF enabled)

Curated bundle flow:
- `abstractvision download flux2-klein-base-4b --provider sdcpp`
- `abstractvision t2i --provider sdcpp --model flux2-klein-base-4b "a studio photo of an espresso machine"`

This keeps the UX simple for external users: the package owns the bundle map and resolves side artifacts from the cache.

Tip:
- If you want **Metal** acceleration on macOS (Apple Silicon), install a Metal-capable `sd-cli` binary from
  stable-diffusion.cpp releases and point `ABSTRACTVISION_SDCPP_BIN` at it (or pass the path as the last arg to
  `/backend sdcpp ...` in the REPL). If you don’t, the backend may fall back to python bindings that run CPU-only.
--- >8 --- END FILE: docs/reference/configuration.md --- >8 ---

--- 8< --- FILE: docs/reference/capabilities-registry.md --- 8< ---
# Capability registries (`vision_model_capabilities.json`, `vision_adapter_capabilities.json`)

AbstractVision keeps two packaged capability assets:

- Asset: [`../../src/abstractvision/assets/vision_model_capabilities.json`](../../src/abstractvision/assets/vision_model_capabilities.json)
- Loader + validator: `VisionModelCapabilitiesRegistry` / `validate_capabilities_json()` in [`../../src/abstractvision/model_capabilities.py`](../../src/abstractvision/model_capabilities.py)
- Asset: [`../../src/abstractvision/assets/vision_adapter_capabilities.json`](../../src/abstractvision/assets/vision_adapter_capabilities.json)
- Loader + validator: `VisionAdapterCapabilitiesRegistry` / `validate_adapter_capabilities_json()` in [`../../src/abstractvision/adapter_capabilities.py`](../../src/abstractvision/adapter_capabilities.py)

See also:
- CLI/REPL inspection commands: [docs/reference/configuration.md](configuration.md)
- Backends (execution reality): [docs/reference/backends.md](backends.md)
- ADR policy: [docs/adr/0005_curated_capability_registry_and_download_catalog.md](../adr/0005_curated_capability_registry_and_download_catalog.md)

## Policy boundary

The packaged assets are not just descriptive metadata. In this repo they feed:

- model discovery;
- adapter discovery hints and default parameter recommendations;
- task and parameter introspection;
- curated download surfacing;
- backend request normalization.

Under [ADR 0005](../adr/0005_curated_capability_registry_and_download_catalog.md), this inventory is:

- global rather than host-specific;
- organized around parent model families with engine-specific download variants;
- official-upstream-first, with clearly labeled community ports only when they are the best
  runtime-native choice for a target engine;
- explicit about download-only or backend-not-supported states.

Important boundary:

- `vision_model_capabilities.json` is the curated package view of model-family tasks, downloadable variants, and model-level defaults.
- `vision_adapter_capabilities.json` is the curated package view of adapter families, compatible base-model aliases, and adapter default/recommended parameters.
- Backend/runtime route truth still stays backend-owned. For example, MLX-Gen decides whether one exact local route currently supports `mask` or LoRA target roles at runtime (it runs `control_image` only on the Qwen-Image route whose row has a ControlNet).

## What the registry is used for

- **Discovery**: list known task keys and model ids.
- **Optional safety gating**:
  - `VisionManager(model_id=..., registry=...)` will fail fast if the model doesn’t support a task ([`../../src/abstractvision/vision_manager.py`](../../src/abstractvision/vision_manager.py)).
  - The CLI/REPL can enforce gating via `--capabilities-model-id` (CLI) or `/cap-model` (REPL).
- **Task-aware UI/catalog metadata**:
  - `image_to_image` in a model’s `tasks` map is the explicit “this model supports edits” signal.
  - The playground API surfaces that structured metadata as `task_specs` so local tooling can enable edit-only flows without re-encoding model rules elsewhere.
- **Request normalization hints**:
  - additive parameter metadata such as `default`, `const`, `min`, `multiple_of`, `supported`, and `auto_derived_from_input` can be consumed by backends to keep model-specific defaults and constraints in one packaged source of truth.
- **Adapter-aware request normalization hints**:
  - adapter profiles carry package-owned defaults such as recommended `steps`, `guidance_scale`, documentation links, and quantization notes.
  - the packaged profiles cover the LightX2V Qwen-Image and Wan Lightning adapters and `dx8152/Flux2-Klein-9B-Consistency` (its V2 file: an image-to-image LoRA for FLUX.2 klein 9B edits, validated by MLX-Gen on the 8-bit package's `flux2.edit` route); `abstractvision adapters --provider mlx-gen --model AbstractFramework/flux.2-klein-9b-8bit --task image_to_image` lists it once it is in the Hugging Face cache (`--json` adds its notes and link); [MLX-Gen local examples](../mlx-gen-local-examples.md#flux2-klein-9b-edit-with-the-consistency-lora) shows an edit with it.

Important:
- The registry describes **model capability intent**.
- Your configured backend still needs to implement the task at runtime (see backend support matrix in [docs/reference/backends.md](backends.md)).

## Override paths

Both registries can be redirected to local JSON files without changing Python code:

- `ABSTRACTVISION_MODEL_CAPABILITIES_PATH`
- `ABSTRACTVISION_ADAPTER_CAPABILITIES_PATH`

You can also pass `asset_path=...` directly when constructing either registry.
That keeps the code/package boundary stable while letting operators update
curated model/adapter metadata independently.

Practical workflow:

1. Copy the packaged JSON you want to override.
2. Edit the local copy.
3. Point the matching env var at that file.
4. Verify the effective metadata with:
   - `abstractvision show-model <model-id>`
   - `abstractvision adapters --provider mlx-gen --model <model-id> --task <task> --json`

## Curation rules

When editing the registry:

- keep one parent entry per real model family;
- keep host-specific or engine-specific artifacts in `downloads`, not as duplicated top-level
  model entries;
- prefer official upstream repos;
- use community repos only for runtime-native artifacts such as GGUF or MLX ports when no
  official equivalent exists;
- do not promote adapter-only or component-only repos as standalone curated models unless the
  runtime can orchestrate them as first-class flows;
- mark non-runnable local entries explicitly when the backend is not shipped yet.

## Minimal Python usage

```python
from abstractvision import VisionModelCapabilitiesRegistry
from abstractvision.adapter_capabilities import VisionAdapterCapabilitiesRegistry

reg = VisionModelCapabilitiesRegistry()
print(reg.schema_version())
print(reg.list_tasks())

assert reg.supports("runwayml/stable-diffusion-v1-5", "text_to_image")
print(reg.models_for_task("text_to_image"))

adapter_reg = VisionAdapterCapabilitiesRegistry()
profile = adapter_reg.match_profile(
    repo_id="lightx2v/Qwen-Image-2512-Lightning",
    relative_path="Qwen-Image-2512-Lightning-4steps-V1.0-bf16.safetensors",
)
print(profile.to_profile_dict()["recommended_parameters"])
```

## JSON shape (high level)

The validator enforces a “soft schema”:

- Top-level keys:
  - `schema_version`
  - `tasks` (keyed by task name; includes human descriptions)
  - `models` (keyed by model id)
- Each model entry includes:
  - `provider` (string)
  - `license` (string; informational)
  - optional `license_name` (the licence's display name, used where access requires accepting it)
  - optional `downloads` (list of downloadable artifacts; informational metadata used by `abstractvision show-model`)
  - `tasks` (map of task name → task spec)
- Each task spec includes:
  - `inputs`, `outputs` (lists of strings)
  - `params` (object where each param has `required: bool`, plus additive fields)
  - optional `requires` for dependencies like `base_model_id`

Examples of additive `params` metadata used in this repo:
- `default`: backend fills a missing value
- `const`: backend forces a model-specific fixed value
- `min`: backend clamps the value upward
- `multiple_of`: backend rounds dimensions to a required multiple
- `supported: false`: backend drops an unsupported optional parameter
- `auto_derived_from_input: true`: image-edit backends can infer a missing size from the input image

### Downloads (optional)

Some models include a `downloads` list to document what AbstractVision considers “downloadable” for common engines:

- `key`: the canonical short name used in `model-presets` / `download` (e.g. `qwen-image`, `flux2-klein-4b`)
- `engine`: `mlx-gen`, `diffusers`, `stable-diffusion.cpp`, ...
- `target`: `mlx`, `diffusers`, `gguf`, ...
- `bits`: typically `8` (quantized) or `16` (full snapshot)
- `repo_id`: Hugging Face repo id to download
- optional `source`, `notes`
- optional `recommended: true`: the package `download <name>` selects when several packages of one target
  remain and no `--bits` is given; at most one per model and target (a test checks it). It marks
  MiniMax-H3's and SeedVR2's 8-bit packages, FIBO's 4-bit package and Qwen-Image-2512's 4-bit MLX-Gen
  package, GGUF and Diffusers pipeline, and `catalog` shows it with `*` in `bits`
- optional `gated: true`: the Hugging Face repository is gated; downloading it needs its licence
  accepted on the repository page (the model's optional `license_name` names it in messages)
- optional `explicit_download: true`: generation (MLX-Gen and Diffusers) never downloads this repository, even with
  `allow_download` (`ABSTRACTVISION_MFLUX_ALLOW_DOWNLOAD=1`, `ABSTRACTVISION_DIFFUSERS_ALLOW_DOWNLOAD=1`); it is fetched only by an explicit
  `abstractvision download`, and the refusal names that command. Today the four MiniMax-H3 repositories
  carry it. `gated` says only whether the Hub asks for the licence to be accepted.

Download sizes are not stored: `download` and `download --dry-run` read them from the Hub listing.

This metadata is descriptive, but in this repo it is maintained to align with the curated
download surfaces exposed by `abstractvision catalog`, `abstractvision model-presets`, and
`abstractvision download`.

In this repo, we keep `downloads` entries aligned with the curated preset table (`model_downloads._PRESETS`) so `abstractvision show-model` and the docs can reliably describe what the CLI can download.
That alignment is intentionally user-facing: if a variant is curated for download, it should have
clear provenance, a realistic runtime target, and a documented readiness story.
--- >8 --- END FILE: docs/reference/capabilities-registry.md --- >8 ---

--- 8< --- FILE: docs/adr/README.md --- 8< ---
# ADRs

This directory records durable engineering policy for `abstractvision`.

## Accepted

- [ADR 0003: Keep the base package lightweight and make local runtimes explicit](0003_lightweight_base_package_and_explicit_runtime_extras.md)
  Base installs stay dependency-light; heavy local runtimes and model-download helpers remain optional extras.
- [ADR 0004: Keep the orchestrator thin and make model semantics backend-owned](0004_thin_orchestrator_and_backend_owned_model_semantics.md)
  `VisionManager` delegates; backend normalization and runtime-specific behavior stay in the backend/package layer.
- [ADR 0005: Own a curated capability registry and cache-backed model catalog](0005_curated_capability_registry_and_download_catalog.md)
  The packaged registry and curated download surfaces are product-facing compatibility contracts, not incidental metadata.
- [ADR 0006: Keep runtime selection explicit and operator-controlled](0006_operator_control_configuration_precedence_and_explicit_network_use.md)
  Config precedence, cache-only defaults, and model selection must stay explicit across CLI, playground, and AbstractCore.
- [ADR 0007: Disclose fallbacks and degraded modes explicitly](0007_explicit_fallback_and_degraded_mode_disclosure.md)
  Fallbacks that change provenance, quality, or runtime behavior must be surfaced rather than hidden.
- [ADR 0008: Require validation and evidence-based change reporting](0008_validation_and_evidence_based_change_reporting.md)
  Backend, catalog, and performance claims need reproducible checks and clear measured-versus-estimated reporting.
- [ADR 0009: Keep docs, backlog, and ADRs code-first](0009_code_first_docs_backlog_and_adr_discipline.md)
  Code is the operational source of truth; durable policy lives here, and execution history lives in `docs/backlog/`.

## Superseded

- [ADR 0001: AbstractVision owns the curated cross-platform model catalog and compatibility layer](0001_curated_cross_platform_model_catalog.md)
  Superseded by ADR 0005 and ADR 0006.
- [ADR 0002: Vision overlays and adapter composition are package-owned](0002_vision_overlays_and_adapter_composition_are_package_owned.md)
  Superseded by ADR 0004.

## Working Rules

- Use ADRs for durable engineering policy that should constrain future changes.
- Use `docs/backlog/` for planning state, implementation history, and completion reports.
- When code, docs, backlog, and ADRs drift, fix the drift explicitly instead of relying on chat history.
--- >8 --- END FILE: docs/adr/README.md --- >8 ---

--- 8< --- FILE: docs/adr/0005_curated_capability_registry_and_download_catalog.md --- 8< ---
# ADR 0005: Own a curated capability registry and cache-backed model catalog

Status: Accepted.

## Context

AbstractVision does more than expose a generic image API. It also ships a packaged registry,
download presets, model-catalog commands, and compatibility-oriented docs. Users therefore treat
the registry and catalog as product surfaces, not as incidental internal metadata.

The failure mode is predictable when this policy is left implicit:

- host-specific ports crowd out the real parent model family;
- catalog entries imply local support that the backend does not actually provide;
- official upstream weights, runtime-native community conversions, and raw side artifacts get
  mixed together without clear provenance;
- users must manually assemble hidden companion files after following a “curated” flow.

The current code already has the ingredients for a better contract:

- [`vision_model_capabilities.json`](../../src/abstractvision/assets/vision_model_capabilities.json)
  is packaged and validated;
- [`model_downloads.py`](../../src/abstractvision/model_downloads.py) drives curated download
  surfaces and host-aware selection;
- curated `sdcpp` bundle resolution now maps model keys to their required companion artifacts.

## Decision

AbstractVision owns a curated, package-level compatibility inventory and download surface.

The rules are:

1. The packaged capability registry is the authoritative source of truth for parent model families,
   task metadata, and curated download variants.
2. The registry stays global and platform-neutral. Host-specific recommendation belongs in catalog
   and preset selection logic, not in the model-family inventory itself.
3. Each real model family should have one parent entry. Engine-specific variants, quantizations,
   and runtime-native ports belong under that family.
4. Official upstream repositories are preferred. Community repositories are allowed only when they
   provide the best runtime-native artifact for a supported engine, and they must carry clear
   provenance notes.
5. Curated user flows must minimize undocumented manual assembly. If a curated local runtime path
   needs companion artifacts such as VAE or encoder files, AbstractVision should own the mapping
   and resolution for that flow.
6. Readiness claims must match shipped backend reality. Catalog-only or download-only entries are
   allowed, but they must be labeled honestly.
7. The registry and curated download surface must stay aligned. A curated model path should have a
   realistic runtime story, not just a repo id.

## Consequences

### Positive

- Users get a clearer discovery and download story.
- Parent families, runtime-native ports, and side artifacts are modeled more honestly.
- The package can keep improving local UX without turning the registry into an unstructured repo
  dump.

### Negative

- Curating the catalog becomes an explicit maintenance obligation.
- Adding new model families requires provenance review and runtime validation work.
- Some attractive community artifacts must stay out of the curated path until the runtime story is
  honest.

### Neutral

- This ADR does not require every model family to support every engine.
- Download-only entries can still exist when that is the truthful state.

## Enforcement

- Reviewers should reject registry or preset changes that:
  - duplicate a model family as host-specific top-level entries;
  - promote side artifacts or adapters as standalone curated models without first-class runtime
    orchestration;
  - claim runtime readiness without a matching backend path or explicit limitation;
  - use a community artifact without explaining why it is the right runtime-native choice.
- Changes to curated local flows must update both code and user-facing docs in the same pass.
- When a curated `sdcpp` or similar component-based path is added, the package should prefer
  package-owned bundle resolution over manual operator assembly.

## Validation

- Load and validate the packaged registry from a repo checkout.
- Verify representative `model-catalog`, `model-presets`, and `show-model` output.
- For changed curated download paths, verify the preset resolves the intended artifact and that the
  resulting runtime flow is either runnable or explicitly marked as not yet runnable.
- Add or keep focused tests for cache-backed bundle resolution when curated local flows depend on
  companion artifacts.

## Backlog links

- [docs/backlog/completed/003_hf_model_landscape_and_capability_registry.md](../backlog/completed/003_hf_model_landscape_and_capability_registry.md)
- [docs/backlog/completed/004_capability_schema_and_validation.md](../backlog/completed/004_capability_schema_and_validation.md)
- [docs/backlog/completed/016_abstractcore_plugin_catalog_discovery_surface.md](../backlog/completed/016_abstractcore_plugin_catalog_discovery_surface.md)
- [docs/backlog/completed/019_best_effort_preload_warmup_for_local_backends.md](../backlog/completed/019_best_effort_preload_warmup_for_local_backends.md)
- [docs/backlog/planned/020_adapter_aware_model_graph_and_catalog.md](../backlog/planned/020_adapter_aware_model_graph_and_catalog.md)

## Related

- [docs/reference/capabilities-registry.md](../reference/capabilities-registry.md)
- [docs/architecture.md](../architecture.md)
- [src/abstractvision/model_capabilities.py](../../src/abstractvision/model_capabilities.py)
- [src/abstractvision/model_downloads.py](../../src/abstractvision/model_downloads.py)
- [src/abstractvision/assets/vision_model_capabilities.json](../../src/abstractvision/assets/vision_model_capabilities.json)
--- >8 --- END FILE: docs/adr/0005_curated_capability_registry_and_download_catalog.md --- >8 ---

--- 8< --- FILE: docs/adr/0006_operator_control_configuration_precedence_and_explicit_network_use.md --- 8< ---
# ADR 0006: Keep runtime selection explicit and operator-controlled

Status: Accepted.

## Context

AbstractVision can be driven through Python, CLI/REPL, playground, and AbstractCore. Those surfaces
all combine defaults, environment variables, explicit arguments, and backend-specific behavior. The
package also has multiple paths that could silently change operator intent if left unchecked:

- runtime backend selection;
- provider model ids;
- cache-only versus download-enabled local behavior;
- provider catalog inspection versus actual model selection;
- curated bundle resolution for component-based local models.

The current code already has good instincts here:

- local Diffusers and MLX-Gen default to cache-only behavior;
- provider catalogs are inspection-only;
- AbstractCore owner config is read before env vars;
- curated `sdcpp` keys resolve cached companion files and fail clearly when they are missing.

That behavior needs to become durable policy.

## Decision

AbstractVision keeps runtime-affecting choices explicit and operator-controlled.

The rules are:

1. Caller-supplied config for a surface takes precedence over ambient environment variables, and
   ambient environment variables take precedence over baked defaults.
2. In the AbstractCore plugin, `owner.config` is authoritative over `ABSTRACTVISION_*` and related
   environment aliases.
3. Provider model catalogs are explicit inspection only. AbstractVision must not silently select or
   switch image models based on `/models` responses.
4. Local runtime downloads are opt-in. Cache-backed or pre-downloaded behavior remains the default
   unless the operator explicitly enables downloads or runs `download-model`.
5. Curated model keys are allowed for local flows when the package can resolve them to explicit
   cached artifacts. Missing required artifacts must fail early with an actionable message.
6. Legacy aliases and compatibility shims may exist, but they must remain documented and auditable.
7. No surface should silently change backend, network, or download behavior in a way that surprises
   an operator who did not explicitly ask for it.

## Consequences

### Positive

- Operators can reason about backend selection and network use more reliably.
- Cache-only local workflows stay predictable.
- Curated local flows become simpler without hiding what files are actually being used.

### Negative

- Some convenience shortcuts remain intentionally unavailable if they would hide important operator
  choices.
- Config docs and tests must keep pace with precedence rules.

### Neutral

- This ADR still allows smart defaults, as long as those defaults do not silently perform material
  new work such as downloading weights or switching to a different provider model.

## Enforcement

- Reviewers should reject new automatic model-selection behavior driven only by provider catalogs.
- Reviewers should reject runtime downloads enabled by default for local backends unless a future
  ADR changes that policy.
- Config precedence changes must update the docs and tests in the same pass.
- Error messages for missing curated local components must stay actionable and point back to the
  supported download or configuration path.

## Validation

- Keep CLI, playground, and AbstractCore tests passing for config precedence and cache-only local
  behavior.
- Verify provider model listing remains inspection-only.
- Verify curated local key resolution either resolves explicit cached files or fails with a precise
  remediation hint.

## Backlog links

- [docs/backlog/completed/014_lightweight_openai_compatible_packaging.md](../backlog/completed/014_lightweight_openai_compatible_packaging.md)
- [docs/backlog/completed/015_vision_install_profiles_and_pending_defaults.md](../backlog/completed/015_vision_install_profiles_and_pending_defaults.md)
- [docs/backlog/completed/016_abstractcore_plugin_catalog_discovery_surface.md](../backlog/completed/016_abstractcore_plugin_catalog_discovery_surface.md)
- [docs/backlog/completed/018_capability_residency_hooks.md](../backlog/completed/018_capability_residency_hooks.md)

## Related

- [docs/reference/configuration.md](../reference/configuration.md)
- [docs/reference/abstractcore-integration.md](../reference/abstractcore-integration.md)
- [src/abstractvision/cli.py](../../src/abstractvision/cli.py)
- [src/abstractvision/playground_server.py](../../src/abstractvision/playground_server.py)
- [src/abstractvision/integrations/abstractcore_plugin.py](../../src/abstractvision/integrations/abstractcore_plugin.py)
--- >8 --- END FILE: docs/adr/0006_operator_control_configuration_precedence_and_explicit_network_use.md --- >8 ---

--- 8< --- FILE: docs/reference/artifacts.md --- 8< ---
# Artifacts (artifact refs + stores)

AbstractVision supports “artifact-first” outputs: return a small JSON dict that points to a stored blob instead of inlining bytes.

Code pointers:
- Store interface + helpers: [`../../src/abstractvision/artifacts.py`](../../src/abstractvision/artifacts.py)
- Orchestration logic: `VisionManager._maybe_store()` in [`../../src/abstractvision/vision_manager.py`](../../src/abstractvision/vision_manager.py)

See also:
- Getting started (REPL stores outputs by default): [docs/getting-started.md](../getting-started.md)

## Output shapes

`VisionManager` returns:

- **Without a store**: `GeneratedAsset` ([`../../src/abstractvision/types.py`](../../src/abstractvision/types.py))
  - contains bytes (`data`), `mime_type`, and best-effort metadata
- **With a store**: an artifact ref dict (via `MediaStore.store_bytes(...)`)
  - minimum shape: `{"$artifact": "<id>"}` (`is_artifact_ref()` checks this)
  - common fields: `content_type`, `sha256`, `filename`, `size_bytes`, `metadata`

## LocalAssetStore (standalone mode)

`LocalAssetStore` stores files under `~/.abstractvision/assets` by default ([`../../src/abstractvision/artifacts.py`](../../src/abstractvision/artifacts.py)):

- Blob: `~/.abstractvision/assets/<artifact_id>.<ext>`
- Metadata: `~/.abstractvision/assets/<artifact_id>.meta.json`

Minimal usage:

```python
from abstractvision import LocalAssetStore, VisionManager
from abstractvision.backends import OpenAICompatibleBackendConfig, OpenAICompatibleVisionBackend

store = LocalAssetStore()
backend = OpenAICompatibleVisionBackend(config=OpenAICompatibleBackendConfig(base_url="http://localhost:1234/v1"))
vm = VisionManager(backend=backend, store=store)

ref = vm.generate_image("a watercolor painting of a lighthouse")
blob = store.load_bytes(ref["$artifact"])  # type: ignore[index]
```

## RuntimeArtifactStoreAdapter (framework mode)

`RuntimeArtifactStoreAdapter` is a duck-typed adapter for an external artifact store (designed for AbstractRuntime),
so AbstractVision can depend on an artifact store **without** a hard dependency ([`../../src/abstractvision/artifacts.py`](../../src/abstractvision/artifacts.py)).

Related:
- AbstractRuntime: <https://github.com/lpalbou/abstractruntime>
--- >8 --- END FILE: docs/reference/artifacts.md --- >8 ---

--- 8< --- FILE: docs/reference/abstractcore-integration.md --- 8< ---
# AbstractCore integration

AbstractVision offers two integration surfaces for AbstractCore:

1) **Capability plugin** (so `abstractcore` can discover a vision backend)
2) **Tool helpers** (so you can expose vision tasks as tools with artifact-ref outputs)

Code pointers:
- Plugin: [`../../src/abstractvision/integrations/abstractcore_plugin.py`](../../src/abstractvision/integrations/abstractcore_plugin.py)
- Tools: [`../../src/abstractvision/integrations/abstractcore.py`](../../src/abstractvision/integrations/abstractcore.py)
- Entry point registration: [`../../pyproject.toml`](../../pyproject.toml) (`[project.entry-points."abstractcore.capabilities_plugins"]`)

See also:
- Artifacts: [docs/reference/artifacts.md](artifacts.md)
- Backends: [docs/reference/backends.md](backends.md)

## 1) Capability plugin (AbstractCore → VisionCapability)

The plugin registers these backend ids:

- `abstractvision:openai` (default backend id) and `abstractvision:openai-compatible` (legacy compatibility backend id) are registered by [`../../src/abstractvision/integrations/abstractcore_plugin.py`](../../src/abstractvision/integrations/abstractcore_plugin.py). The implementation also supports local backends.

Current behavior:
- Default `abstractvision:openai`: OpenAI HTTP (`https://api.openai.com/v1`). Set `OPENAI_API_KEY`.
- Endpoint profiles: `provider="endpoint:<id>"` on `t2i` / `i2i` (and the batch, video and upscale methods) sends the request to that profile's OpenAI-compatible endpoint with its base URL and API key, for example `llm.vision.t2i("a red cube", provider="endpoint:relay", model="gpt-image-2")`. The profile comes from the resolver a host attached to the Core provider (`resolve_provider_endpoint_profile`, which AbstractRuntime sets for AbstractGateway runs), else the ambient resolver in `abstractcore.providers.endpoint_context`, else AbstractCore's `provider_profiles`. Only `openai` and `openai-compatible` profiles are accepted; an `openai-compatible` profile without a key never borrows `OPENAI_API_KEY`.
- OpenAI model ids are configured, not discovered dynamically. Providers may expose an OpenAI-compatible `GET /models` catalog; AbstractVision exposes it through `abstractvision provider-models`, `VisionManager.list_provider_models(...)`, and the plugin method `llm.vision.list_provider_models(...)`, but the plugin does not call it automatically or use it to select a model. The static plugin default is `gpt-image-1`; set `OPENAI_IMAGE_MODEL_ID`, `OPENAI_IMAGE_MODEL`, `ABSTRACTVISION_MODEL_ID`, or `vision_model_id` for newer provider models.
- Compatible HTTP: set `OPENAI_BASE_URL` to a local/remote compatible `/v1` server. Set `ABSTRACTVISION_BACKEND=openai-compatible` when you want to force compatible-endpoint semantics.
- Legacy `abstractvision:openai-compatible`: keeps compatible-endpoint defaults when that backend id is selected directly.
- Local Diffusers: install `abstractvision[diffusers]`, then set `ABSTRACTVISION_BACKEND=diffusers` with `runwayml/stable-diffusion-v1-5` or another supported Diffusers model. It is cache-only/offline unless `ABSTRACTVISION_DIFFUSERS_ALLOW_DOWNLOAD=1` is set. Local `text_to_video` groundwork exists but is currently experimental and disabled from the normal local plugin surfaces.
- Local MLX-Gen (Apple-first): install `abstractvision[mlx-gen]` (or `abstractvision[all-apple]`), then set `ABSTRACTVISION_BACKEND=mlx-gen`. The current AbstractVision release is validated on Apple Silicon first; the install extra also exposes Linux support when upstream `mlx-gen` / `mlx` markers are available. Download exact model repos such as `abstractvision download AbstractFramework/flux.2-klein-4b-4bit --provider mlx-gen`, `abstractvision download AbstractFramework/ernie-image-turbo-8bit --provider mlx-gen`, `abstractvision download briaai/FIBO --provider mlx-gen`, `abstractvision download prism-ml/bonsai-image-ternary-4B-mlx-2bit --provider mlx-gen`, `abstractvision download AbstractFramework/seedvr2-3b-8bit --provider mlx-gen`, `abstractvision download AbstractFramework/seedvr2-7b-8bit --provider mlx-gen`, `abstractvision download Wan-AI/Wan2.2-TI2V-5B-Diffusers --provider mlx-gen`, `abstractvision download AbstractFramework/wan2.2-t2v-a14b-diffusers-8bit --provider mlx-gen`, or `abstractvision download AbstractFramework/wan2.2-i2v-a14b-diffusers-8bit --provider mlx-gen` (stored in the Hugging Face cache; `ABSTRACTVISION_MODEL_DIR` is only a legacy import root). Use routed exact model ids such as `mlx-gen/AbstractFramework/flux.2-klein-4b-4bit`, `mlx-gen/prism-ml/bonsai-image-ternary-4B-mlx-2bit`, `mlx-gen/AbstractFramework/seedvr2-3b-8bit`, `mlx-gen/AbstractFramework/seedvr2-7b-8bit`, `mlx-gen/AbstractFramework/wan2.2-t2v-a14b-diffusers-8bit`, or `mlx-gen/AbstractFramework/wan2.2-i2v-a14b-diffusers-8bit`. q4 repos are the memory-efficient default recommendation for most generation/edit models; SeedVR2 defaults to canonical q8 packages and offers q4 packages for tighter memory. Bonsai ternary is already pre-packed at 2-bit and is selected by its exact repo id. Legacy `mflux` provider values remain accepted as aliases.
- stable-diffusion.cpp: set `ABSTRACTVISION_BACKEND=sdcpp` and configure either a model path or a curated model key such as `flux2-klein-base-4b`. Use an external `sd-cli`, or install `abstractvision[sdcpp]` for the python binding fallback.
- The plugin reads AbstractCore owner config keys when present, then falls back to `ABSTRACTVISION_*` env vars.
- Gateway/Core should pass process-level config or `owner.config` and report readiness; they should not mutate AbstractVision environment variables per request.

Key config keys (owner.config):
- `vision_backend_instance` / `vision_backend_factory` (advanced injection hooks; bypass env-driven backend creation)
- `vision_backend` (`openai`, `openai-compatible`, `diffusers`, `mlx-gen`, or `sdcpp`; default `openai`; `mflux` is accepted as a compatibility alias)
- `vision_model_id` (Diffusers/OpenAI-compatible model id; default `gpt-image-1` only for the official OpenAI profile and `runwayml/stable-diffusion-v1-5` for Diffusers)
- `vision_device` / `vision_torch_dtype` / `vision_allow_download` / `vision_auto_retry_fp32` (Diffusers)
- `vision_base_url` / `vision_api_key` (OpenAI or compatible HTTP)
- `vision_mflux_model` / `vision_mflux_base_model` / `vision_mflux_allow_download` (MLX-Gen; env/config names keep MFLUX compatibility)
- `vision_mlx_gen_lora_paths` / `vision_mflux_lora_paths`, `vision_mlx_gen_lora_scales` / `vision_mflux_lora_scales`, and `vision_mlx_gen_lora_target_roles` / `vision_mflux_lora_target_roles` for backend-default MLX-Gen LoRA adapters
- `vision_model_dir` (legacy preset import root used by MLX-Gen compatibility/migration helpers; new downloads land in the Hugging Face cache)
- `vision_sdcpp_model` / `vision_sdcpp_diffusion_model` / `vision_sdcpp_bin` (stable-diffusion.cpp; `vision_sdcpp_model` may be a curated model key such as `flux2-klein-base-4b`)
- `vision_sdcpp_vae` / `vision_sdcpp_llm` / `vision_sdcpp_llm_vision` / `vision_sdcpp_clip_l` / `vision_sdcpp_clip_g` / `vision_sdcpp_t5xxl` / `vision_sdcpp_extra_args` (stable-diffusion.cpp component mode)
- `vision_timeout_s` (optional; applies to OpenAI-compatible catalog/control behavior, not image/video generation deadlines)
- `vision_models_path` (optional provider catalog path; default `/models`)
- Optional video endpoint keys:
  - `vision_text_to_video_path`
  - `vision_image_to_video_path`
  - `vision_image_to_video_mode`

Env-only aliases:
- `ABSTRACTVISION_DIFFUSERS_MODEL_ID` is accepted for the Diffusers plugin backend before falling back to `ABSTRACTVISION_MODEL_ID`.
- `OPENAI_BASE_URL` is accepted by the OpenAI-shaped HTTP backend.
- Compatible OpenAI-shaped endpoints can use `OPENAI_API_KEY` when they require bearer auth.
- `OPENAI_IMAGE_MODEL_ID` and `OPENAI_IMAGE_MODEL` are accepted when `vision_model_id` / `ABSTRACTVISION_MODEL_ID` are unset.
- `ABSTRACTVISION_SDCPP_CLIP_L`, `ABSTRACTVISION_SDCPP_CLIP_G`, and `ABSTRACTVISION_SDCPP_T5XXL` are accepted for stable-diffusion.cpp component mode.

Examples:

```bash
# Local Diffusers. Pre-download weights first, or explicitly allow runtime downloads.
export ABSTRACTVISION_BACKEND=diffusers
export ABSTRACTVISION_MODEL_ID=runwayml/stable-diffusion-v1-5
export ABSTRACTVISION_DIFFUSERS_DEVICE=auto
```

```python
from abstractcore import create_llm

llm = create_llm("openai", model="gpt-4o-mini")
png_bytes = llm.vision.t2i("a red square", width=512, height=512, steps=20)
```

Per-call routing can select the same backend/model ids used by the
`abstractvision` shell commands. For MLX-Gen, pass the exact published model
repo id: a prepared package carries its own width. `quantize=<bits>` quantizes a
source model at load, on the routes that accept it (`get_capabilities().quantize_bits`),
and is refused on prepared packages and on the other local backends.

```python
from pathlib import Path

from abstractcore import create_llm

llm = create_llm("openai", model="gpt-4o-mini")

png_bytes = llm.vision.t2i(
    "a studio product photo of a white ceramic mug with the AbstractFramework logo",
    provider="mlx-gen",
    model="AbstractFramework/qwen-image-2512-4bit",
    steps=20,
    guidance_scale=1.0,
    on_progress=lambda event: print(f"{event.phase}: step {event.step}/{event.total_steps}"),
)

edited_png = llm.vision.i2i(
    "replace the background with a clean white studio setup",
    image="./input.png",
    provider="mlx-gen",
    model="AbstractFramework/qwen-image-edit-2511-4bit",
    steps=20,
    guidance_scale=2.5,
    strength=0.75,
    on_progress=lambda event: print(f"{event.phase}: step {event.step}/{event.total_steps}"),
)

multi_ref_png = llm.vision.i2i(
    "compose the subject using the second image as style and layout reference",
    image="./subject.png",
    provider="mlx-gen",
    model="AbstractFramework/qwen-image-edit-2511-4bit",
    reference_images=[Path("./style-reference.png").read_bytes()],
    steps=20,
    guidance_scale=2.5,
)

def on_video_progress(event):
    print(
        f"{event.phase}: step {event.step}/{event.total_steps}, "
        f"frame {event.frame}/{event.total_frames}"
    )

mp4_bytes = llm.vision.t2v(
    "a red fox walking through a snowy forest, cinematic",
    provider="mlx-gen",
    model="AbstractFramework/wan2.2-t2v-a14b-diffusers-8bit",
    width=432,
    height=240,
    num_frames=41,
    fps=10,
    steps=20,
    guidance_scale=4.0,
    guidance_2=3.0,
    max_sequence_length=256,
    on_progress=on_video_progress,
)

edited_mp4 = llm.vision.v2v(
    "the same street at night",
    "./source-clip.mp4",
    provider="mlx-gen",
    model="AbstractFramework/wan2.2-t2v-a14b-diffusers-8bit",
    video_strength=0.6,
    width=480,
    height=240,
    num_frames=17,
)

restored_mp4 = llm.vision.upscale_video(
    "./source-clip.mp4",
    provider="mlx-gen",
    model="AbstractFramework/seedvr2-3b-8bit",
    start_seconds=1.0,
    max_frames=17,
    seed=42,
)

first_frame_mp4 = llm.vision.i2v(
    "./first-frame.png",
    prompt="slow camera push-in",
    provider="mlx-gen",
    model="AbstractFramework/wan2.2-i2v-a14b-diffusers-8bit",
    width=432,
    height=240,
    num_frames=41,
    fps=10,
    steps=20,
    guidance_scale=3.5,
    guidance_2=3.5,
    max_sequence_length=256,
    on_progress=on_video_progress,
)
```

`llm.vision.i2i(...)` accepts `image` as bytes, a local file path, or an
artifact ref dict when an `artifact_store` is supplied. Without an artifact
store the plugin returns bytes; with `artifact_store=...` it returns the stored
artifact ref, matching the runtime/gateway artifact path.
Typed per-call keyword arguments such as `control_image`, `control_strength`,
`lora_adapters`, `guidance_2`, `reference_images` (each item bytes, a file path
or an artifact ref, resolved to bytes) and `on_progress` survive the plugin
boundary. Unknown per-call keyword arguments such as `max_sequence_length` are
preserved in the AbstractVision request `extra` dict for local backends.
`llm.vision.t2i(...)`, `llm.vision.i2i(...)`, `llm.vision.t2v(...)`, and
`llm.vision.i2v(...)` forward `on_progress` to MLX-Gen. Image/edit events
include diffusion-step progress; Wan video events use diffusion-step
`progress` and also include frame counters and `frame_progress`.

For task-specific Wan A14B video models, `guidance_2` is a typed request
parameter for the second-stage/low-noise guidance path. Pass it directly to
`t2v(...)` / `i2v(...)`; do not wrap it in `extra`.

`control_image=<bytes>` and `control_strength=<float>` reach the request as
typed fields: MLX-Gen applies them on `AbstractFramework/qwen-image-8bit`
(its Qwen ControlNet route) and refuses a `control_image` on any other model
(`field="control_image"`) and a `control_strength` given alone; the other
built-in backends refuse a `control_image`. `i2i` refuses both keywords.

The same applies to LoRA adapters. Prefer the shared typed contract:

```python
from abstractvision import LoRAAdapterSpec

png = llm.vision.t2i(
    "Pixel art astronaut floating above Earth",
    provider="mlx-gen",
    model="AbstractFramework/qwen-image-2512-8bit",
    lora_adapters=[
        LoRAAdapterSpec(
            source="prithivMLmods/Qwen-Image-2512-Pixel-Art-LoRA:Qwen-Image-2512-Master-Pixel-Art-LoRA.safetensors",
            scale=1.0,
        )
    ],
)
```

Wan LoRA calls may also need `target_role` in each adapter spec. TI2V-5B uses
`transformer`. A14B routes require explicit
`high_noise_transformer` / `low_noise_transformer` roles.

To lower a run's memory peak, pass `memory_mode` (`"default"`, `"low"` or
`"lowest"`) to `t2i`, `i2i`, `upscale_image`, `t2v`, `i2v` or their `_batch`
variants; without it, `$ABSTRACTVISION_MEMORY_MODE` applies, else `"default"`
(a backend that cannot honour the environment value runs the nearest less
aggressive mode it lists, `lowest` → `low` → `default`, and logs it once per
process; a value passed on the call is refused instead).
MLX-Gen runs `"low"` in its low-RAM mode, Diffusers on CUDA runs `"low"` /
`"lowest"` with model / sequential CPU offload, and stable-diffusion.cpp runs
`"low"` with CPU offload of its parameters (see
[Memory modes](../api.md#memory-modes-memory_mode)). A mode the selected
backend cannot honour, passed on the call, raises `CapabilityNotSupportedError` before any model
loads: `"lowest"`, for example, is accepted for MiniMax-H3 and refused on every
other current MLX-Gen catalog model.

```python
mp4 = llm.vision.t2v(
    "A red fox trots through fresh snow",
    provider="mlx-gen",
    model="AbstractFramework/wan2.2-t2v-a14b-diffusers-8bit",
    memory_mode="low",
)
```

AbstractCore's HTTP vision routes take `memory_mode` and `quantize` as request
fields (JSON bodies and forms; the video routes take the soundtrack fields too).
The server builds AbstractVision backends and calls them directly, and every
backend reads and checks the value itself, so the same refusal applies there.

On MLX-Gen, a `"low"` run frees parts of the model and drops the instance (a
MiniMax-H3 `"lowest"` run drops it too), so the plugin no longer lists the model
as loaded, a resident one included, whether the run succeeded or failed; the
next request loads the model again, unpinned. The same
holds after every Wan TI2V-5B run, which releases its denoiser before the decode.

A batch, through `llm.vision.t2i_batch(...)` and the other `_batch` methods or
through the AbstractCore server's HTTP batch routes, is a series of requests:
with `"low"` each item loads the model again.

The current AbstractCore server's residency records are its own and independent
of what this plugin lists as loaded.

The facade forwards every typed field of the request a method builds, under the
same name: `control_image` / `control_strength` on `t2i` (applied by MLX-Gen on
`AbstractFramework/qwen-image-8bit`), `image_strength`, `reference_images`,
`outpaint_padding`, `outpaint_fill`, `outpaint_fill_color` and `reframe_padding`
on `i2i` (MLX-Gen's latent, multi-reference, outpaint and reframe edits; the
other backends refuse them by name), `soundscape`, `music`,
`generate_audio`, `audio_shift` on `t2v` / `i2v`, and `quantize`, `memory_mode`
and `cancel_event` on all of them. Two kinds of keyword are refused with
`CapabilityNotSupportedError`: `guidance_2` on `t2i` / `i2i`, `control_image` and
`control_strength` on `i2i`, and the soundtrack
and edit options (`soundscape`, `music`, `generate_audio`, `audio_shift`;
`image_strength`, `reference_images`, the outpaint and reframe fields) on a call
whose request has none, unless the value is unset (None, an empty list, a blank
string). Image inputs (`image`, `mask`, `control_image`, `reference_images`
items) take bytes-like values, file paths (any path-like) and artifact refs;
`v2v`'s and `upscale_video`'s `video` keeps a file path as a path. `strength=` is not the typed
field: it stays `extra["strength"]`, as in 0.3.37. Every other unknown keyword remains a backend-specific `extra`
parameter:
`t2v(..., vae_tiling=False)` reaches Wan as `extra["vae_tiling"]`, and
`t2i(..., fps=24)` lands in `extra` too.

With an `artifact_store`, a MiniMax-H3 clip whose soundtrack MLX-Gen could not
mux into the MP4 comes back with its WAV stored as a second artifact: the
returned ref carries `audio` (the `GeneratedAsset.audio_summary()` shape:
`present`, `sample_rate`, `channels`, `codec`, `muxed`, `duration_seconds`, and
`wav`, the WAV's artifact ref, when `muxed` is false), and the stored metadata
records the same object. Without a store the facade returns the MP4 bytes only
and logs a warning when the soundtrack is not in them.

`load_resident_model(...)` / `load_model(...)` preload the backend, with the
request's `memory_mode` and `quantize` when it carries them (checked as a
generation request's are, before anything loads), so that requests with those
values reuse the model; on MLX-Gen a video model (Wan, MiniMax-H3) is loaded
without a warm-up run. The payload's `task` also goes to a backend whose `preload`
takes a `task` (MLX-Gen) as the task the host is about to run: on a model that has
it, MLX-Gen loads the class a request of that task uses (`image_to_image` on
FLUX.2 klein warms `Flux2KleinEdit` instead of `Flux2Klein`); other backends, and
a payload without `task`, load as before. `task` takes `"video_upscale"` (also
`"video-upscale"`, `"upscale_video"`) for a SeedVR2 video restoration. The
payload's `warm_up` (default true) goes the same way to a `preload` that takes it:
`false` builds the model without its warm-up; the record's `warmed` says whether
the preload warmed it (`null` from a backend that does not say). When the preload
fails, the backend drops what it loaded and the plugin does not list it; a
preload refused for its values, or one that fails after reusing the model
already held, leaves that model held (and listed).

Discovery, and where each part is visible:

- Every MLX-Gen entry of `llm.vision.list_provider_models(...)`, which the
  AbstractCore HTTP model listing also returns, carries
  `parameter_constraints["memory_mode"]` = `{"enum": [...]}`; `enum` holds the
  modes that model can honour.
- `llm.vision.available_providers()["details"][<provider>]["memory_modes"]`
  lists what the backend a request for that provider runs on reports with its
  configured model and device (`supported_memory_modes()`; for an
  OpenAI-compatible remote, the modes of its last discovery answer, else
  `default`), without loading a model or sending a request. Diffusers with
  `device="auto"` lists `default` on macOS (no CUDA) without importing torch,
  and elsewhere asks torch, importing it once. AbstractCore's HTTP server
  reads it for `GET /v1/vision/providers/` and for the `memory_modes` of the
  entries of `GET /v1/vision/models`.
- `llm.vision.memory_peaks(model)` returns MLX-Gen's measured memory peaks for
  one catalog package as JSON rows `{task, memory_mode, width, height, frames,
  steps, peak_bytes, machine_total_ram_bytes}`, with `task` in AbstractVision's
  form (`text_to_video`) and `memory_mode` one of its modes. The rows are
  already kept to that package's stored width, so a host relays them as they
  are. They are per package, not per schedule: a run names its canvas, frames
  and steps but not the schedule it ran with, and mlx-gen publishes the same
  runs on every MiniMax-H3 schedule. The list is empty when the model is not a prepared
  MLX-Gen package of the catalog or when mlx-gen is not installed or publishes
  nothing, and the call builds no model and reads no weights.
- With an `artifact_store`, the stored artifact's metadata records `memory_mode`
  (and `low_ram` / `stream_blocks` on MLX-Gen); without one the plugin returns
  bytes only.

```bash
# OpenAI API.
export OPENAI_API_KEY=...
export OPENAI_IMAGE_MODEL=gpt-image-1
```

```bash
# Local OpenAI-compatible HTTP server, for example AbstractCore Server.
export ABSTRACTVISION_BACKEND=openai-compatible
export OPENAI_BASE_URL=http://localhost:8000/v1
# No model id: each request runs the server's default for its task. To name one, use the id the
# server routes, its `routed_model` in GET /v1/vision/models (for example mlx-gen/<repo>).
```

### Provider Catalog Discovery

Core/Gateway hosts can inspect provider-advertised model catalogs through the same capability
object used for generation:

```python
models = llm.vision.list_provider_models(task="text_to_image")
for model in models:
    print(model["id"])
```

The return value is a JSON-safe list of dictionaries serialized from `ProviderModelInfo`. Raw
provider metadata is retained in a bounded `raw` field for diagnostics. This method is explicit
inspection only: it does not mutate the configured backend or select a generation model.

Backends that do not implement provider catalog listing, and an OpenAI-compatible remote without a
`GET /models` route, raise `CapabilityNotSupportedError` saying so instead of returning a misleading
empty catalog; a backend without a catalog is skipped when another backend answers. When multiple
backends are enabled, the plugin probes their catalogs concurrently so discovery waits for the slowest backend instead of the sum of
serial scans. Local Diffusers and stable-diffusion.cpp model discovery
remain separate local-backend concerns, while MLX-Gen and Diffusers provider listings reflect
cache-backed snapshots rather than a separate `~/models` download tree.

The same capability object also exposes installed adapter discovery for routes
that support LoRAs:

```python
adapters = llm.vision.list_provider_adapters(
    provider="mlx-gen",
    model="AbstractFramework/wan2.2-ti2v-5b-diffusers-8bit",
    task="text_to_video",
)
for adapter in adapters:
    print(adapter["id"], adapter.get("suggested_target_roles"))
```

Adapter truth stays backend-owned. The plugin serializes
`ProviderAdapterInfo` into JSON-safe dictionaries, but it does not invent
compatibility metadata on its own.

### Batch generation through Core

The plugin exposes explicit batch helpers in addition to the singular task
methods:

- `llm.vision.t2i_batch(...)`
- `llm.vision.i2i_batch(...)`
- `llm.vision.t2v_batch(...)`
- `llm.vision.i2v_batch(...)`

These methods use the same typed request contract as the singular calls:
stacked `lora_adapters=[...]`, explicit `seeds=[...]`, optional base `seed`
expansion, and typed video controls such as `guidance_2` / `flow_shift`.

```python
from abstractvision import LoRAAdapterSpec

videos = llm.vision.t2v_batch(
    "A compact silver spaceship lifts off from an icy canyon at dawn.",
    provider="mlx-gen",
    model="AbstractFramework/wan2.2-ti2v-5b-diffusers-8bit",
    count=2,
    seeds=[6251, 6252],
    flow_shift=3.0,
    lora_adapters=[
        LoRAAdapterSpec(
            source="AlekseyCalvin/HSToric_Color_Wan2.2_5B_LoRA_BySilverAgePoets:HSToric_color_Wan22_5b_LoRA.safetensors",
            scale=0.9,
            target_role="transformer",
        )
    ],
)
```

### Local Model Residency Control

Core/Gateway hosts can also control in-process local model residency through the same capability
object:

```python
llm.vision.load_resident_model(
    {"task": "text_to_image", "provider": "mlx-gen", "model": "AbstractFramework/flux.2-klein-4b-4bit"}
)
llm.vision.load_resident_model(
    {"task": "text_to_video", "provider": "mlx-gen", "model": "AbstractFramework/wan2.2-t2v-a14b-diffusers-8bit"}
)

loaded = llm.vision.list_loaded_models()
resident = llm.vision.list_resident_models()

llm.vision.unload_resident_model(
    {"provider": "mlx-gen", "model": "AbstractFramework/flux.2-klein-4b-4bit"}
)
```

Notes:

- this surface is local-only and process-local;
- it controls only AbstractVision-managed in-process backends (`diffusers`, `mlx-gen`, `sdcpp`);
- OpenAI/OpenAI-compatible HTTP backends are intentionally rejected here, even on `localhost`,
  because the plugin cannot honestly control another process's loaded-state.

`list_loaded_models()` reports both explicitly preloaded resident models and transient currently
loaded local models from recent generation requests. `list_resident_models()`
returns the explicit pinned subset. Both ask each backend, when called, whether it holds its model
(`VisionBackend.has_loaded_model()`): a model a run, a failed preload or an unload released is not
listed, and its next load starts unpinned.

Each loaded-model entry includes stable routing metadata such as `load_id`, `backend_kind`,
`resident`, and a `tasks` list of observed task aliases using that loaded backend.

A request's model is listed when its backend holds it after the run, whatever the run's outcome (a
failed or cancelled first request included), and `unload_resident_model()` calls the backend's
`unload()` whenever it resolves one, listed or not, then reports from the listing.

`load_resident_model()` returns the same entry plus `loaded_new`: `true` when that call loaded the
model, `false` when it was already in memory. AbstractCore and AbstractRuntime use it to report the
load as `loaded` or `already_loaded`. When the backend holds no model after the preload (`sd-cli`,
or a backend that keeps the default `has_loaded_model()`), it returns `state: "not_loaded"`,
`resident: false`, `loaded_new: false` and `reason: "this backend holds no model in this process"`,
and nothing is listed or pinned.

For deterministic unload behavior, prefer:

- `load_id`, or
- both `provider`/`backend` and `model`.

Broad unload filters that match multiple loaded models are rejected as ambiguous.

## Shared request normalization

`llm.vision` calls go through `VisionManager`, which applies backend normalization hooks before
execution. That means model-specific constraints are shared with the CLI/REPL and playground API
instead of being reimplemented in the plugin layer.

Current examples:
- Distilled MLX-Gen/FLUX-family models can clamp guidance or minimum steps in the backend.
- Diffusers-backed image requests pick up registry-driven defaults such as recommended step counts,
  guidance defaults, and dimension constraints.
- Unsupported parameters, such as negative prompts on constrained model families, are dropped in
  the backend rather than surfacing as per-surface validation bugs.

## 2) Tool helpers (`make_vision_tools`)

`make_vision_tools(...)` builds AbstractCore `@tool` callables for:
- adapter discovery for the selected model
- text→image
- batch text→image
- image→image
- batch image→image
- image upscaling
- multi-view image
- text→video
- batch text→video
- image→video
- batch image→video

The helper surface now stays aligned with the main AbstractCore capability
plugin surface:

- `lora_adapters=[...]` is accepted on text→image, image→image, text→video,
  and image→video tool calls.
- batch tools accept `count` plus optional explicit `seeds=[...]`.
- image-edit tools accept `reference_images=[...]`, where each item can be an
  artifact ref dict or a `{"b64": "..."}` payload.
- `vision_list_adapters(task=...)` returns the currently discovered compatible
  adapter inventory for the selected model.
- A parameter the tool call leaves unset takes the catalog's `default` (or
  `const`) for the model and task; one the catalog lists without a default stays
  unset, so the backend applies the engine's own default (MiniMax-H3: the
  schedule's 8 steps on the Turbo entries, 50 on the base model). A tool's
  built-in step count applies only to a model whose catalog entry does not list
  `steps`.
- Generated videos with a soundtrack that is not in the MP4 return its WAV as a
  second artifact, under the ref's `audio["wav"]` (see the plugin section).
- `make_vision_tools(..., memory_mode="low")` applies one memory mode to every
  generation call of the tools. It is not a tool parameter, so the model cannot
  choose it; a value that is not a memory mode raises `ValueError` when the tools
  are made, and the backend checks it against the modes it supports at each call. Without it each call follows `$ABSTRACTVISION_MEMORY_MODE`.

Important:
- Tool outputs are designed to be **artifact refs**, so `VisionManager.store` must be set ([`../../src/abstractvision/integrations/abstractcore.py`](../../src/abstractvision/integrations/abstractcore.py)).
- This module requires AbstractCore to be installed by the host application. AbstractVision does not install AbstractCore as a dependency.

Tip (framework mode):
- If your runtime provides an artifact store (e.g. AbstractRuntime), use `RuntimeArtifactStoreAdapter` so tool outputs can be stored and referenced across processes (see [docs/reference/artifacts.md](artifacts.md)).
--- >8 --- END FILE: docs/reference/abstractcore-integration.md --- >8 ---

--- 8< --- FILE: playground/README.md --- 8< ---
# AbstractVision Playground (Web)

This is a tiny web UI for testing AbstractVision locally. It is powered by the
self-contained `abstractvision playground` command; it does **not** require an
AbstractCore server.

The playground is a local/dev surface. Do not expose it as an authenticated
production serving boundary; use AbstractCore/Gateway for production routing,
authentication, and browser-origin policy.

## Required API endpoints

The page calls:

- `GET /v1/models` (ping)
- `GET /v1/vision/models` (list cached models + active model)
- `POST /v1/vision/model/load` (load a model into memory)
- `POST /v1/vision/jobs/images/generations` (start a text→image job)
- `POST /v1/vision/jobs/videos/generations` (start a text→video job)
- `POST /v1/vision/jobs/images/edits` (start an image→image job)
- `GET /v1/vision/jobs/{job_id}` (poll job status)
  - on success, the page calls `GET /v1/vision/jobs/{job_id}?consume=1` to fetch-and-consume the result

## 1) Start the local playground server

From an AbstractVision checkout:

```bash
PYTHONPATH=src python -m abstractvision playground --port 8091
```

Or, when installed:

```bash
abstractvision playground --port 8091
```

Quick sanity checks (should return JSON):

```bash
curl -s http://127.0.0.1:8091/v1/models | head
curl -s http://127.0.0.1:8091/v1/vision/models | head
```

## 2) Open the page

Open:

- `http://127.0.0.1:8091/vision_playground.html`

Usage notes:
- The page is split into task tabs (`Text→Image`, `Image→Image`, `Text→Video`, and a placeholder `Image→Video` tab for later work).
- Each active task tab has its own model selector and unload button.
- Selecting a different model unloads the current active backend first, then auto-loads the replacement to keep memory usage bounded.
- Raw Hugging Face model ids such as `runwayml/stable-diffusion-v1-5` load directly; no `diffusers/` provider prefix is required.
- For first tests, prefer a small cached model such as Stable Diffusion 1.5 before loading larger Qwen/FLUX models.
- The Image→Image panel is enabled only for models that both advertise `image_to_image` and remain enabled by backend runtime truth.
- MLX-Gen models are surfaced only for tasks the backend currently enables: curated q4/q8 text-to-image presets plus image-to-image for FLUX.2 klein/base and Qwen Image Edit (no masks yet).
- The bundled local `Text→Video` tab is experimental and currently expected to have no shipped local model options until [`docs/backlog/planned/0023_local_runtime_capability_quarantine_for_glm_mflux_and_t2v.md`](../docs/backlog/planned/0023_local_runtime_capability_quarantine_for_glm_mflux_and_t2v.md) is resolved.
- Response logs intentionally show a shortened `b64_json` preview instead of the full base64 payload.
- “Extra JSON” is forwarded to the server:
  - T2I: merged into the JSON request body
  - I2I: sent as a string field `extra_json` in the multipart form body
- Model-specific request fixes happen in the backend/API layer, so the same normalization rules apply to the playground, CLI/REPL, and AbstractCore integration.
- Local video export requires an `ffmpeg` executable on `PATH` whenever a local backend emits frames for packaging.

## 3) stable-diffusion.cpp / GGUF notes

If your server is configured to run GGUF diffusion models via stable-diffusion.cpp, you’ll typically need:
- a diffusion model (`.gguf`)
- a VAE (`.safetensors`) for some families (e.g. Qwen Image GGUF)
- a text encoder/LLM (`.gguf`) for some families (e.g. Qwen Image GGUF)

Exact configuration is backend-specific; check AbstractVision’s backend docs.
--- >8 --- END FILE: playground/README.md --- >8 ---

--- 8< --- FILE: CONTRIBUTING.md --- 8< ---
# Contributing to AbstractVision

Thanks for taking the time to contribute. This repository aims to stay small, stable-by-design, and easy to integrate.

AbstractVision is part of the **AbstractFramework** ecosystem:
- AbstractFramework: <https://github.com/lpalbou/AbstractFramework>
- AbstractCore: <https://github.com/lpalbou/abstractcore>
- AbstractRuntime: <https://github.com/lpalbou/abstractruntime>

## Ground rules

- Keep the public API stable (`VisionManager` in [`src/abstractvision/vision_manager.py`](src/abstractvision/vision_manager.py)).
- Prefer additive changes (new fields, new models, new backends) over breaking changes.
- Don’t commit model weights, large binaries, or cache artifacts.
- Make docs and examples match the code (the repo is intended to be “readme-first”).
- Keep imports lazy for heavy stacks (see [`src/abstractvision/backends/__init__.py`](src/abstractvision/backends/__init__.py)).

## Development setup

```bash
python -m venv .venv
. .venv/bin/activate
python -m pip install -U pip
python -m pip install -e ".[dev]"
```

Optional (if you work on AbstractCore integration locally):

```bash
python -m pip install abstractcore
```

The `abstractvision[abstractcore]` extra is only a compatibility marker. AbstractCore is intentionally supplied by the host application, not installed by AbstractVision.

## Run tests

```bash
python -m unittest discover -s tests -p "test_*.py" -q
```

## Common contribution types

### 1) Improve documentation

Core entrypoints:
- [`README.md`](README.md)
- [`docs/getting-started.md`](docs/getting-started.md)
- [`docs/architecture.md`](docs/architecture.md)
- [`docs/api.md`](docs/api.md)
- [`docs/faq.md`](docs/faq.md)
- [`docs/adr/README.md`](docs/adr/README.md)

Doc hygiene checklist:
- Commands are copy/pastable.
- Links resolve (relative links are preferred).
- Claims about support status match the current code (see [`docs/reference/backends.md`](docs/reference/backends.md)).
- Major claims are anchored in evidence (link to the relevant `src/` implementation).
- Prefer diagrams in Mermaid when they improve clarity ([`docs/architecture.md`](docs/architecture.md) is the canonical place).

### 2) Add or update models in the capability registry

Source of truth:
- `src/abstractvision/assets/vision_model_capabilities.json`

Validator + loader:
- `src/abstractvision/model_capabilities.py`

Checklist:
- Add/update the model entry in the JSON.
- Keep the model family platform-neutral; add engine-specific artifacts as download variants rather
  than as host-specific duplicate models.
- Prefer official upstream repos. Use community repos only when they provide the best runtime-native
  artifact for a target engine and label them clearly.
- Do not treat adapters or component artifacts as standalone curated models unless the runtime path
  is first-class.
- Keep the change aligned with
  [ADR 0005](docs/adr/0005_curated_capability_registry_and_download_catalog.md),
  [ADR 0006](docs/adr/0006_operator_control_configuration_precedence_and_explicit_network_use.md),
  and [docs/reference/capabilities-registry.md](docs/reference/capabilities-registry.md).
- Run the unit tests (they validate schema + coverage).
- Sanity check CLI output:
  - `abstractvision show-model <model_id>`

### 3) Add a new backend

Backend interface:
- `src/abstractvision/backends/base_backend.py`

Where backends live:
- `src/abstractvision/backends/`

Checklist:
- Implement the `VisionBackend` methods (raise `CapabilityNotSupportedError` for unsupported tasks).
- Keep imports lazy (avoid importing Torch/Diffusers at module import time unless unavoidable).
- Add/extend tests under `tests/`.
- Document the backend in `docs/reference/backends.md` and, if user-facing, add a short section in `docs/getting-started.md`.

## Submitting a change

Please include:
- A short explanation of the change and why it’s needed.
- Test results (`python -m unittest ...`).
- Any doc updates required to keep the repository truthful.

## Questions / discussions

If you’re unsure about scope or design, open an issue with a minimal proposal and a concrete example (inputs/outputs).
--- >8 --- END FILE: CONTRIBUTING.md --- >8 ---

--- 8< --- FILE: SECURITY.md --- 8< ---
# Security policy

We take security issues seriously and appreciate responsible disclosure.

## Reporting a vulnerability

Please **do not** open a public GitHub issue for security reports.

Instead, report privately by email:

- `contact@abstractcore.ai`

Include as much of the following as you can:

- A clear description of the issue and its impact
- Reproduction steps (or a minimal PoC)
- Affected versions / commit hash (if known)
- Any relevant logs, stack traces, or configuration
- Suggested mitigation (if you have one)

If you believe the issue is in an upstream dependency (e.g. Torch/Diffusers), it can still be helpful to notify us so we can assess impact and coordinate messaging for AbstractVision users.

## What to expect

We aim to:

- Acknowledge receipt within **3 business days**
- Provide a status update within **7 business days**

If a coordinated disclosure timeline is needed, please include your preferred timeline in the report.

## Scope

This policy applies to vulnerabilities in this repository’s code and packaging.

For non-security bugs and feature requests, please use the normal issue tracker.
--- >8 --- END FILE: SECURITY.md --- >8 ---

--- 8< --- FILE: ACKNOWLEDGMENTS.md --- 8< ---
# Acknowledgments

AbstractVision stands on the shoulders of excellent open-source projects and communities.

## Optional runtime dependencies (declared as extras)

- **Hugging Face Diffusers** (local pipeline runtime; used by the Diffusers backend): [`src/abstractvision/backends/huggingface_diffusers.py`](src/abstractvision/backends/huggingface_diffusers.py) (declared in the `diffusers`/`local`/`all` extras)
- **PyTorch** (tensor runtime for local inference; used via Diffusers): [`src/abstractvision/backends/huggingface_diffusers.py`](src/abstractvision/backends/huggingface_diffusers.py) (declared in the `diffusers`/`local`/`all` extras)
- **Hugging Face Transformers** (tokenizers/encoders used by some diffusion pipelines; imported by the Diffusers backend): [`src/abstractvision/backends/huggingface_diffusers.py`](src/abstractvision/backends/huggingface_diffusers.py) (declared in the `diffusers`/`local`/`all` extras)
- **Accelerate** (installed for ecosystem compatibility; used transitively by some pipelines): declared in optional extras in `pyproject.toml`
- **Safetensors** (model weight format support; used by Diffusers/Transformers): declared in optional extras in `pyproject.toml`
- **SentencePiece** (T5/tokenizer support for some model families): declared in optional extras in `pyproject.toml`
- **protobuf** (runtime dependency for some tokenizers/pipelines): declared in optional extras in `pyproject.toml`
- **einops** (tensor ops used by some modern architectures): declared in optional extras in `pyproject.toml`
- **PEFT** (LoRA adapter support used by Diffusers): declared in optional extras in `pyproject.toml`
- **Pillow** (image I/O utilities used by local backends): [`src/abstractvision/backends/huggingface_diffusers.py`](src/abstractvision/backends/huggingface_diffusers.py), [`src/abstractvision/backends/stable_diffusion_cpp.py`](src/abstractvision/backends/stable_diffusion_cpp.py) (declared in optional extras in `pyproject.toml`)
- **stable-diffusion-cpp-python** (python bindings used when `sd-cli` is not available): [`src/abstractvision/backends/stable_diffusion_cpp.py`](src/abstractvision/backends/stable_diffusion_cpp.py) (declared in the `sdcpp`/`local`/`all` extras)

## Runtime dependencies (transitive but central)

- **huggingface_hub** (model and adapter downloads; used by Diffusers/Transformers pipelines)

## Upstream projects

- **stable-diffusion.cpp** (upstream project that provides `sd-cli` and the core GGUF runtime wrapped by the bindings): [`src/abstractvision/backends/stable_diffusion_cpp.py`](src/abstractvision/backends/stable_diffusion_cpp.py)

## Referenced model/component publishers

- **Comfy-Org** (component artifacts referenced by docs and download helpers for `stable-diffusion.cpp` examples, notably Qwen Image and FLUX.2 VAE files): [`docs/getting-started.md`](docs/getting-started.md), [`scripts/download_model_sets.py`](scripts/download_model_sets.py)
- **Black Forest Labs** (official FLUX.2 upstream weights and side artifacts referenced by the capability registry and local-backend docs): [`src/abstractvision/assets/vision_model_capabilities.json`](src/abstractvision/assets/vision_model_capabilities.json), [`docs/getting-started.md`](docs/getting-started.md)
- **Qwen** (official Qwen Image / Qwen Image Edit upstream weights referenced by the capability registry and `stable-diffusion.cpp` component-mode docs): [`src/abstractvision/assets/vision_model_capabilities.json`](src/abstractvision/assets/vision_model_capabilities.json), [`docs/getting-started.md`](docs/getting-started.md)
- **Unsloth** (community GGUF conversions and companion encoder files referenced by the capability registry and some GGUF download presets): [`src/abstractvision/assets/vision_model_capabilities.json`](src/abstractvision/assets/vision_model_capabilities.json), [`scripts/download_model_sets.py`](scripts/download_model_sets.py)
- **leejet** (stable-diffusion.cpp maintainer-published runtime and GGUF conversions referenced by the `sdcpp` backend docs and GGUF download presets): [`src/abstractvision/backends/stable_diffusion_cpp.py`](src/abstractvision/backends/stable_diffusion_cpp.py), [`scripts/download_model_sets.py`](scripts/download_model_sets.py)

## Optional integrations

- **AbstractCore** (tool integration helpers + capability plugin): [`src/abstractvision/integrations/`](src/abstractvision/integrations/) (optional dependency in [`pyproject.toml`](pyproject.toml))

## Packaging

- **setuptools** and **wheel** (build system): [`pyproject.toml`](pyproject.toml)

## Community and contributors

Thanks to everyone who reports issues, suggests improvements, and contributes fixes or documentation updates.
--- >8 --- END FILE: ACKNOWLEDGMENTS.md --- >8 ---

--- 8< --- FILE: CHANGELOG.md --- 8< ---
# Changelog

## 0.3.38 - 2026-11-27

This release adds typed image-edit options on MLX-Gen (latent image-to-image, FLUX.2 masked edits,
multi-reference edits, outpaint and reframe), Z-Image edits, a control image on Qwen-Image, video-to-video
on Wan 2.2 T2V-A14B and Wan 2.1 VACE 1.3B, SeedVR2 video restoration (`video_upscale`), cached source
repository ids, and `preload(task=..., warm_up=...)`. The MLX-Gen backend requires
`mlx-gen>=0.40.3,<0.41.0` and, on macOS, MLX 0.32.4 or later. Requests that set none of the new fields run
as in 0.3.37, except for the changes listed under Changed.

### New

- **MLX-Gen image routes chosen by the engine's planner.** Every `image_to_image` request on FLUX.2, Z-Image and
  base Qwen-Image, and a request on any MLX-Gen model that sets `image_strength`, is routed by mlx-gen's own planner
  (`resolve_generation_plan`, the one `mlxgen generate` uses) against the model's capability rows; the capability id
  it selects decides the MLX-Gen class and call (`abstractvision.backends.mlx_gen_routes`). Other requests run as in
  0.3.37. Everything is checked before any weights load, in `normalize_image_edit_request` as in `edit_image`: two
  options that contradict each other raise `ValueError`; an option no row of the model applies, and adapters on a
  row that takes none, raise `CapabilityNotSupportedError` naming the field (`supported=()`); a combination no row
  serves raises it with the planner's message (`field=None`). A route new in this release writes the run's files
  into one temporary directory, removed whatever the outcome; no metadata names it.
- **Latent image-to-image: `ImageEditRequest.image_strength`**, in `(0, 1]` (the plugin's `i2i(image_strength=...)`).
  On MLX-Gen, `extra["image_strength"]` is the same option. FLUX.2 klein runs it with `Flux2Klein` (the base models
  pass the negative prompt, which their latent row takes); base Qwen-Image (`AbstractFramework/qwen-image-8bit`, the
  Qwen-Image-2512 packages) now runs `image_to_image` with `QwenImage`, at `image_strength=0.4` when the request
  names none; ERNIE-Image-Turbo runs it as its 0.3.37 latent edit. `list_provider_models()` publishes
  `parameter_defaults["image_strength"] = 0.4` and its range for every model with a latent route, and the catalog
  names the parameter `image_strength` on FLUX.2 klein, Qwen-Image, Z-Image and ERNIE (ERNIE's `strength` is
  described as the 0.3.37 keyword below).
  `extra["strength"]` (the CLI's `--strength`, the plugin's `strength=`) is the 0.3.37 cross-backend keyword: on
  every route 0.3.37 had it keeps exactly its 0.3.37 meaning, and on the latent routes new in this release it is
  read as the run's strength with the same clamp to `[0, 1]`. It never selects a route and is not read on a masked
  route, and combined with `image_strength` it raises `ValueError`. A task this release adds to a model
  (`image_to_image` on base Qwen-Image and Z-Image, `video_to_video` on Wan) is published and accepted only where the
  engine's rows carry a route for it; without rows the model has its 0.3.37 tasks.

- **FLUX.2 masked edits.** An edit with a `mask` on FLUX.2 klein runs `Flux2KleinInpaint` (MLX-Gen's
  `flux2.inpaint`): the mask is decoded before any weights load (`ValueError` naming `mask` when it is not a
  picture), the bytes are passed unchanged, an unset `guidance_scale` stays unset so the class applies its default,
  and the base models take a negative prompt. A mask with `image_strength` raises `ValueError`; adapters on a row
  that takes none are refused (`field="lora_adapters"`). The instance is built for masked edits: a plain edit after
  it builds `Flux2KleinEdit` again, after releasing it.

- **Multi-reference edits: `ImageEditRequest.reference_images`**, the images after `image` in order (bytes or file
  paths; the plugin's `i2i` and `i2i_batch` resolve file paths and artifact refs to bytes). On MLX-Gen,
  `extra["reference_images"]` is the same option. FLUX.2 klein and Qwen-Image-Edit 2509/2511 run it on their
  multi-reference route (the 0.3.37 edit call with the list after the source); no maximum count is published or
  enforced. A model without that route refuses it (`field="reference_images"`, `supported=()`), as does a
  combination with a mask or a strength (`field=None`): the planner counts every picture, those of the 0.3.37
  `extra` keys included, so a reference is never dropped. An item that is not image bytes or a path, or a picture
  that fails to decode, raises `ValueError`. On a model the engine publishes no rows for, references run their
  0.3.37 edit branch. The pictures a routed request carries (a mask, references) are decoded once
  its route is known, still before any weights load.

- **Outpaint and reframe: `ImageEditRequest.outpaint_padding`, `outpaint_fill`, `outpaint_fill_color`,
  `reframe_padding`.** They run MLX-Gen's own canvas session (`mflux.outpaint`: canvas, fill policy, pass plan),
  its workspace in the run's directory: FLUX.2 klein outpaint with `Flux2KleinOutpaint` and reframe (distilled)
  with `Flux2KleinEdit`, Qwen-Image-Edit both with `QwenImageEdit`. The session is built before any weights load
  and refuses a box the engine cannot apply (`ValueError` naming the field); a fill the row does not list, a fill or
  color on Qwen's fixed fill, a color without `outpaint_fill="solid"`, a fill without an outpaint and
  `extra["width"]`/`["height"]` with either are refused naming the field. A two-pass outpaint counts its progress
  across both passes and is refused in low-RAM mode (`field="memory_mode"`, `supported=("default",)`). Results carry
  `outpaint_notice` and `outpaint_warnings`.

- **Video-to-video: `VideoToVideoRequest`, `VisionBackend.video_to_video`, `VisionManager.video_to_video` and the
  plugin's `v2v`**, a new task `video_to_video` (catalog, residency names `video_to_video`, `video-to-video`, `v2v`).
  On MLX-Gen, Wan 2.2 T2V-A14B runs it with `Wan2_2_TI2V`: `video_strength` in `(0, 1]` (unset: the engine's 0.8),
  an optional one-image `mask`, the A14B defaults and memory plan of text-to-video, and a negative prompt only when
  set; as on the engine CLI, `guidance_2` takes the model's 3.0 only when the request sets neither guidance (a
  `guidance_scale` set alone leaves it to the engine, which then uses the same value). The source is a file read in place or bytes written once to the run's directory, and is probed before any
  weights load (a clip too short for `num_frames` at `fps` is refused with `field="num_frames"`); `extra` takes the
  progress callbacks, `max_sequence_length` and `vae_tiling`. The other backends refuse the task.

- **Wan 2.1 VACE 1.3B (`Wan-AI/Wan2.1-VACE-1.3B-diffusers`)**, a new catalog entry and MLX-Gen model
  (`wan2.1-vace-1.3b`, run by `WanVace`) for `video_to_video`: `reference_images` (any number, in order),
  `masked_region_mode` (`generate` or `repaint`, with a mask) and `conditioning_scale` (default 1.0); it refuses
  `video_strength` and `guidance_2` by name, and Wan 2.2 T2V-A14B refuses the three VACE fields. Defaults 832x480,
  81 frames at 16 fps, 30 steps, guidance 5.0; `memory_mode="low"` releases the denoiser before the decode and drops
  the model. A VACE preload loads `WanVace` and runs no warm-up generation; in the default mode it reads the
  transformer and the VAE ahead, as the other Wan preloads do (Changed 23).

- **Z-Image edits.** `image_to_image` on Z-Image and Z-Image-Turbo runs `ZImage` latent (at `image_strength=0.4`
  when the request names none; Turbo keeps its forced guidance 0.0 and passes a negative prompt, which its row takes), and a `mask` on
  Z-Image-Turbo runs its masked edit (the mask instead of the strength). Base Z-Image refuses a mask
  (`field="mask"`), and both refuse references, outpaint and reframe by name.

- **Control image on Qwen-Image (`AbstractFramework/qwen-image-8bit`).** `control_image` (and `control_strength`,
  unset: the engine CLI's 0.4) runs `QwenImageControlNet` with the ControlNet its row names
  (`InstantX/Qwen-Image-ControlNet-Union`). Its side weights are looked up in the Hugging Face cache before any
  weights load and never downloaded during a generation; when missing, the request is refused
  (`field="control_image"`) naming the repository, the file and `abstractvision download
  InstantX/Qwen-Image-ControlNet-Union`. Any other model refuses `control_image`; a `control_strength` without it is
  refused, and one that is not a finite number raises `ValueError`. A plain generation after a control run builds
  `QwenImage` again.

- **`preload(task=...)` on MLX-Gen.** The MLX-Gen backend's `preload` takes `task`, the task the host is about to
  run, as a hint: a model that has it is loaded as a request of that task loads it (on FLUX.2 klein,
  `task="image_to_image"` loads `Flux2KleinEdit`; a latent, masked or outpaint request rebuilds its own class); a
  model without it, or `task=None`, preloads as before. It never refuses. The AbstractCore plugin's
  `load_resident_model` passes the payload's `task` to a backend whose `preload` takes a `task` (or `**kwargs`).

- **FLUX.2 klein 9B consistency LoRA profile.** `vision_adapter_capabilities.json` describes
  `dx8152/Flux2-Klein-9B-Consistency` (file `Flux2-Klein-9B-consistency-V2.safetensors`): an image-to-image LoRA that
  improves the consistency of klein 9B edits, no trigger word, apache-2.0, validated by MLX-Gen on
  `AbstractFramework/flux.2-klein-9b-8bit`'s edit route; no parameter recommendation (the model card gives none).
  `list_provider_adapters` (and `abstractvision adapters`) carries its notes and link once it is cached.

- **`preload(warm_up=False)` on MLX-Gen.** The warm-up is optional: `warm_up=False` resolves, checks and builds the
  model (a bad model still fails at the preload) and runs and reads nothing ahead; the default, `True`, warms as
  Changed 23 says, and `low` / `lowest` are the same either way. `preload_warmed()` says whether the held model was
  warmed; the plugin passes the load payload's `warm_up` to a `preload` that takes it, and its loaded-model records
  carry `warmed` (`None` from a backend that does not say).

- **SeedVR2 video restoration (`video_upscale`).** `VideoUpscaleRequest(video, resolution, softness, seed,
  start_seconds, max_frames, drop_audio, quantize, ...)`, `VisionManager.upscale_video(video, **kwargs)` and the plugin's
  `upscale_video(video, **kwargs)` restore a clip on SeedVR2 3B and 7B (MLX-Gen). `video` is the clip's bytes or a
  local file read in place (a `str` or `Path` in the plugin). Before any weights load, MLX-Gen's own plan
  (`SeedVR2VideoRestorePlan.for_video`, the one `mlxgen upscale --video-path` uses) probes the clip and decides the
  scale, the chunking and the memory profile; a scale above 1x is refused (`field="resolution"`), a clip beyond the
  safe memory profile or below its temporal quality floor is refused (`field=None`), each with the engine's message.
  The plan counts the weights as loaded when this backend already holds the instance the run reuses. The run
  applies the plan as the CLI does (MLX-Gen's low-RAM saver keeping the transformer, `restore_video_to_path` with
  the planned chunks) in `memory_mode` `default` and `low` alike, under one MLX cache limit from before the load to
  the end (the plan's 8 GB, never above a limit the host set), and drops the model at its end. The result is an MP4
  whatever the source's container (the source's audio copied by MLX-Gen, which fails the run after the restoration when it
  cannot; `drop_audio=True` gives a silent result, no copy attempted), progress is per chunk, a cancel removes the partial output. Unset values are the engine's: 1x, softness 0.0, from the clip's start to its
  end. `preload(task="video_upscale")` reads the transformer and the VAE the run keeps.
- **MLX-Gen 0.40.3.** Every extra that installs MLX-Gen (`mlx-gen`, `mflux`, `apple`, `all`, `all-apple`)
  requires `mlx-gen>=0.40.3,<0.41.0` (0.3.37 required `>=0.40.1`) and, on macOS, `mlx>=0.32.4` as before.
  0.40.3 is required because in it the engine names a local model by the same rule as AbstractVision (Changed
  28): its own folder or file name, or its repository id inside a Hugging Face cache, never a parent directory.
  Upgrade with `pip install -U "abstractvision[mlx-gen]"`. `video_upscale` runs on the SeedVR2 video
  restoration plan that 0.40.2 adds. 0.40.2 also changes, with no change to AbstractVision's calls: the Wan
  prompt encoding (Changed 27); SeedVR2 video restoration, which needs a fraction of 0.40.1's memory with
  identical output and restores frames up to about 1.4 megapixels on its safe memory profile's 48 GB budget
  (1280x720 fits), a larger frame being refused before the model loads (`field=None`) with a message naming the
  largest size that fits; and FLUX.2 klein, which keeps one copy of its transformer weights whatever the number
  of canvas sizes a process runs.

### Changed

Against 0.3.37 (the entries are numbered so that others can refer to them):

1. MLX-Gen refuses an `image_strength`, typed or `extra["image_strength"]`, outside `(0, 1]`
   (`CapabilityNotSupportedError`, `field="image_strength"`); 0.3.37 clamped `extra["image_strength"]` to `[0, 1]`.
2. MLX-Gen raises `ValueError` for an `extra["image_strength"]` that is not a finite number; 0.3.37 dropped it.
3. `extra["image_strength"]` on FLUX.2 (a model the engine publishes rows for) runs the latent route
   (`Flux2Klein`); 0.3.37 ignored it and ran `Flux2KleinEdit`.
4. `extra["image_strength"]` on Qwen-Image-Edit and FIBO-Edit is refused (`field="image_strength"`, `supported=()`);
   0.3.37 ignored it.
5. `extra["image_strength"]` on FIBO and Fibo-lite is refused before the model loads; 0.3.37 loaded it, then the
   engine raised.
6. `extra["reference_images"]` on a model whose rows have no multi-reference route is refused
   (`field="reference_images"`): on plain Qwen-Image-Edit (not 2509 or 2511), where 0.3.37 passed the references to
   the edit, and on ERNIE-Image-Turbo, FIBO and Fibo-lite, where 0.3.37 ran the edit and ignored them. A local
   ERNIE-Image-Turbo, FIBO or Fibo-lite folder the engine publishes no rows for refuses them too; a FLUX.2 or
   Qwen-Image-Edit folder without rows runs them as 0.3.37 did.
7. `extra["reference_images"]` with an adapter on a route that takes none (`AbstractFramework/qwen-image-edit-2509-8bit`)
   is refused (`field="lora_adapters"`); 0.3.37 ran it.
8. A typed `image_strength` or `reference_images` with the same `extra` key of another value raises `ValueError`, as
   does `image_strength` with `extra["strength"]` and `reference_images` with `extra["images"]`,
   `["additional_images"]` or `["image_paths"]`.
9. The plugin keywords `image_strength=`, `reference_images=`, `outpaint_padding=`, `outpaint_fill=`,
   `outpaint_fill_color=` and `reframe_padding=` are refused with `field=` on `t2i`, `t2v`, `i2v` and
   `upscale_image` on every backend, where 0.3.37 put them in `extra` and nothing read them; on `i2i` they are typed
   fields, which Diffusers, OpenAI-compatible and stable-diffusion.cpp refuse by name (0.3.37 put them in `extra`,
   which the OpenAI-compatible backend forwarded to the remote). An unset value (None, an empty list, a blank
   string) is never refused. Passed as `extra={...}`, and `strength=`, they travel unchanged.
10. `i2i(control_image=...)` and `i2i(control_strength=...)` are refused (`field=`); 0.3.37 put them in `extra`, where
    nothing read them.
11. `image_to_image` on base Qwen-Image and on Z-Image runs latent, at `image_strength=0.4` unless set; 0.3.37
    refused the task.
12. A `mask` on FLUX.2 klein runs `Flux2KleinInpaint`; 0.3.37 refused it (`field="mask"`) after loading the model.
13. `control_image` on `AbstractFramework/qwen-image-8bit` runs `QwenImageControlNet`; 0.3.37 refused it
    (`field="control_image"`).
14. Published answers: `get_capabilities().supports_mask` is true on FLUX.2 klein and Z-Image-Turbo, and
    `supports_control_image` on `AbstractFramework/qwen-image-8bit`;
    `supported_tasks` and `list_provider_models(task="image_to_image")` include base Qwen-Image and Z-Image, and
    `supported_tasks` gains `video_to_video` on Wan 2.2 T2V-A14B and Wan 2.1 VACE 1.3B. The catalog lists
    `image_to_image` on `Qwen/Qwen-Image`, `Qwen/Qwen-Image-2512`, `Tongyi-MAI/Z-Image` and
    `Tongyi-MAI/Z-Image-Turbo` (for the MLX-Gen backend), `image_strength` on FLUX.2 klein, ERNIE-Image-Turbo and
    those four, `outpaint_padding`, `outpaint_fill` and `outpaint_fill_color` on FLUX.2 klein, `reframe_padding` on
    the distilled FLUX.2 klein 4B and 9B (not on klein Base), `outpaint_padding` and `reframe_padding` on
    Qwen-Image-Edit, 2509 and 2511 (no fill fields),
    `control_image` and `control_strength` on `Qwen/Qwen-Image`'s `text_to_image`, and the new task
    `video_to_video`. `reference_images` is no longer listed for `Qwen/Qwen-Image-Edit`.
    `list_provider_models()`' `parameter_constraints["negative_prompt"]` follows the engine's rows as the runs do
    (Changed 21): FLUX.2 klein Base and Z-Image-Turbo no longer publish `{"supported": false}` (a task whose routes
    disagree publishes `supported: true` with a description naming it); a model without rows keeps 0.3.37's answer.
15. A typed request option that is an empty list or tuple counts as unset (`option_is_set`). No 0.3.37 option is a
    sequence, so no 0.3.37 request changes.
16. stable-diffusion.cpp, which lists every catalog task of a model, lists `image_to_image` (and `supports_mask`)
    with `capabilities_model_id` set to `Qwen/Qwen-Image`, `Qwen/Qwen-Image-2512`, `Tongyi-MAI/Z-Image` or
    `Tongyi-MAI/Z-Image-Turbo`, and `video_to_video` with
    `Wan-AI/Wan2.2-T2V-A14B`.
17. On a model the engine publishes no rows for (a local folder whose name it cannot place), `extra["image_strength"]`
    is refused (`field="image_strength"`) on every family but ERNIE-Image-Turbo, where it runs 0.3.37's latent edit;
    0.3.37 ignored it on the other families.
18. `metadata["mlx_gen"]` no longer carries `controlnet_image_path`, which 0.3.37 returned (always `None` then): it
    is left out like the other temporary file paths of a run.
19. In `memory_mode="default"` the MLX cache is capped as the engine's CLI caps it (total RAM / 8, between 1 and 8
    GiB, once per process; a limit the host set at or below half of physical memory is left alone, a higher one is
    replaced by the default cap) for every MLX-Gen model; 0.3.37 left Wan models uncapped (the Wan loader does not
    apply the cap itself).
20. Some requests 0.3.37 refused are now refused before the model loads instead of after, or with a different
    `field` or exception type: a mask with references on FLUX.2; `extra["reference_images"]` on FIBO-Edit;
    references with `extra["images"]` on FIBO-Edit; a mask on a FLUX.2 folder the engine cannot place; a mask with
    `extra["reference_images"]` on ERNIE-Image-Turbo, FIBO, Fibo-lite and Qwen-Image-Edit 2509 and 2511 (now refused
    before the load); `supported` on FIBO's and Fibo-lite's refusals goes from `None` to `()`. Nothing that ran is
    affected.
21. A negative prompt follows the row of the route a request runs (`supports_negative_prompt`) on every MLX-Gen
    image route of a model the engine publishes rows for. It is now passed on FLUX.2 klein Base (4B and 9B) on
    text-to-image, edit and multi-reference (0.3.37 dropped it; the latent, masked and outpaint routes already
    passed it), and on Z-Image-Turbo on text-to-image, latent and masked edits (0.3.37 dropped it; at its forced
    guidance 0.0 the engine runs no negative branch). FLUX.2 klein Base with a negative prompt at `guidance_scale`
    1.0 or below now raises the engine's `ValueError` after the model loads. A route whose row takes none still
    drops it silently; a model without rows keeps 0.3.37's answer.
22. `load_resident_model({"task": "image_to_image", ...})` on an MLX-Gen model that has both text-to-image and
    image-to-image (FLUX.2 klein, ERNIE-Image-Turbo, FIBO, Fibo-lite, and base Qwen-Image and Z-Image, which gain
    image-to-image in this release) loads the model for image-to-image (on FLUX.2 klein `Flux2KleinEdit`) and warms
    it with one image-to-image run (Changed 23) where 0.3.37 loaded the text-to-image class and ran its text-to-image
    warm-up. A payload without `task`, or with
    `text_to_image`, loads as in 0.3.37; other backends are unchanged.
23. A default-mode MLX-Gen `preload` warms what a run of its task reads with a small ordinary request of that
    route. 0.3.37 ran one text-to-image generation at the backend's default canvas (1024x1024 unless
    `default_width` / `default_height` were set) and the model's default steps, and only built the object for every
    other task. Now an image task runs one warm-up of the task on its plain route, its output discarded, at 256x256
    (352 on base Qwen-Image, FIBO and Fibo-lite, 384 on FIBO-Edit, 512 on ERNIE-Image-Turbo and Bonsai: the smallest
    side MLX-Gen itself runs those families at) and 2 steps (the fewest MLX-Gen's flow-match scheduler takes); a
    backend whose `default_width` / `default_height` were set keeps that canvas, as in 0.3.37. Image-to-image preloads (Qwen-Image-Edit, FIBO-Edit,
    and the image models given `task="image_to_image"`: `Flux2KleinEdit` on FLUX.2 klein) and SeedVR2 preloads (a
    64x64 picture at 1x) run one too. Video preloads read the first denoiser and, where the run encodes an input
    (image-to-video, video-to-video), the VAE (Wan TI2V-5B, T2V-A14B, I2V-A14B, VACE). The preload is short and the
    weights are resident when it returns; the first request reads none. MiniMax-H3 and the `low` and `lowest` modes
    are unchanged.
24. SeedVR2's published answers gain `video_upscale`: `get_capabilities().supported_tasks` and
    `list_provider_models()` on SeedVR2 3B and 7B, and the catalog (a top-level `video_upscale` task, with its params
    on `ByteDance-Seed/SeedVR2-3B` and `-7B`). The catalog's `min_runtime_version` of Wan T2V-A14B and VACE
    `video_to_video` and of MiniMax-H3 is 0.40.3, the package floor. The image upscale is unchanged.
25. With mlx-gen 0.40.1 or 0.40.2 installed, every MLX-Gen request now raises `OptionalDependencyMissingError` naming
    `mlx-gen>=0.40.3,<0.41.0`, as any version outside the pins already did.
26. On MLX-Gen, a source repository id that maps to several prepared packages (the four FLUX.2 klein repos,
    `Tongyi-MAI/Z-Image` and `Z-Image-Turbo`, the five Qwen-Image repos, `baidu/ERNIE-Image-Turbo`) runs its own
    cached snapshot as released (16-bit, unquantized, as `mlxgen generate --model <id>` does), even when a
    prepared package of it is cached too; 0.3.37 refused the id as ambiguous whatever was cached. Cached means a
    snapshot that can load as the model: `model_index.json` and readable `transformer/*.safetensors`, no partial
    download. It is a source, not a prepared package: it publishes the engine's load-time `quantize` widths and
    accepts `quantize`. Through the AbstractCore plugin the id reaches the backend unchanged (0.3.37 rewrote
    `Qwen/Qwen-Image-2512` to `qwen-image`, which it still does when that source is not cached). A source needs
    several times a prepared package's memory. Not cached, or cached without those files, the id is refused as
    ambiguous as before. The `Qwen/Qwen-Image-2512` source snapshot given as a folder, which 0.3.37 answered as a
    prepared package (no `quantize` widths, `quantize` refused), is a source too.
27. With mlx-gen 0.40.2 and later, Wan videos on MLX-Gen (Wan 2.2 text-, image- and video-to-video, Wan 2.1
    VACE) for a given prompt and seed differ slightly from those of 0.3.37 with mlx-gen 0.40.1: the same scene and
    composition, with small differences in details, because the engine's prompt encoding is now exact (float32).
    A new prompt is encoded in seconds instead of more than a minute. See MLX-Gen's
    [Wan prompt encoding](https://github.com/lpalbou/mlx-gen/blob/main/docs/wan-text-encoder.md).
28. On MLX-Gen and Diffusers, a local model is identified by its own name, by the rule mlx-gen 0.40.3 follows
    too: a local folder or file by its own name (`~/models/qwen-image-edit/my-flux` is `my-flux`, a GGUF file
    its file name); a path inside a Hugging Face cache by the repository id, followed by the path below the
    snapshot for a file or subfolder in it (`models--org--name/snapshots/<revision>` is `org/name`, its
    `transformer` folder `org/name/transformer`, a file in it `org/name/<file>`); a repository id, an alias, or a
    relative text that is not on disk, as written. A parent directory and the snapshot revision never decide; on
    MLX-Gen the model's own card does as before. On MLX-Gen this name sets its base model when `base_model` is not
    given, its stored width (`metadata["quantization_bits"]` of a request without `quantize`, and the SeedVR2
    local-folder match), the routes MLX-Gen publishes for it, and whether discovery skips it as a partial or
    incompatible download. On Diffusers it sets the bfloat16 default of Qwen-Image-Edit image-to-image and
    inpainting on Apple MPS, and the fallback chat template a pipeline gets when its snapshot ships none (Qwen,
    FLUX.2, Z-Image, ERNIE-Image, GLM-Image). 0.3.37 read the whole path, so a model under a parent named after
    another model or width (`~/models/qwen-image-edit_q4/flux2-klein-4b`, `~/models/qwen-image-edit/my-flux`,
    `models_q4`, a temporary folder whose random name holds `_q1`) could be identified, routed or refused as that
    other model, get a width it does not have, or run on Diffusers with another family's dtype or chat template,
    and a parent named `*.partial`, `*-partial` or `*.incompatible` hid every MLX-Gen model under it. On MLX-Gen a
    folder whose own name and card place no model needs `base_model`; on Diffusers a Qwen-Image-Edit folder whose
    own name does not say so runs in the automatic dtype unless `torch_dtype="bfloat16"` is set.

## 0.3.37 - 2026-11-26

This release adds MiniMax-H3 (video with a synchronized stereo soundtrack), a `memory_mode` setting on every
generation request, downloads planned against the cache with a disk-space check, model listings that show access,
cache state and memory per mode, and what an application embedding `VisionManager` needs: cancellation, load-time quantization, the
engine's route rows and metadata. It requires MLX-Gen 0.40.1. Requests that set none of the new fields run as before,
except for the changes listed below.

### New

- **MLX-Gen 0.40.1.** Every extra that installs MLX-Gen (`mlx-gen`, `mflux`, `apple`, `all`, `all-apple`) requires
  `mlx-gen>=0.40.1,<0.41.0` (0.3.36 required `>=0.38.0,<0.39.0`). It brings MiniMax-H3, saves images and videos with
  Pillow 13, and publishes capability schema 17. The calls AbstractVision makes for FLUX.2, Z-Image, Qwen, ERNIE,
  FIBO, Bonsai, SeedVR2 and Wan are unchanged. On macOS the same extras require `mlx>=0.32.4`: MLX 0.31.0 to 0.32.3
  can end the process with a Metal "invalid resource" error during a MiniMax-H3 decode when the MLX cache is small,
  and MLX 0.32.4 fixed it. In those versions the scalar a convolution pads its channels with is not kept alive until
  the GPU runs the convolution: in the 3D convolution path (0.31.0 to 0.32.3), which the MiniMax-H3 video decode
  runs, and in a 2D convolution path that pads input channels (0.32.1 to 0.32.3); 0.32.4 keeps it alive in both.
  Upgrade with `pip install -U "abstractvision[mlx-gen]"`. An upgrade without the extra
  keeps the installed mlx-gen and MLX, so the MLX-Gen backend refuses an mlx-gen outside `>=0.40.1,<0.41.0`, and on
  macOS an MLX older than 0.32.4: the first request or `preload()` raises `OptionalDependencyMissingError` naming the
  installed version and that command, before the model is looked for; a pre-release of a floor is below it.
- **MiniMax-H3: video with a synchronized stereo soundtrack**, `text_to_video` and first-frame `image_to_video`,
  through the MLX-Gen backend. The catalog entry `MiniMaxAI/MiniMax-H3` lists the packages
  `AbstractFramework/minimax-h3-8bit` (recommended), `AbstractFramework/minimax-h3-bf16` and
  `AbstractFramework/minimax-h3-4bit`, and the source repository. `base_model` picks the schedule:
  `minimax-h3-turbo-544p` (8 steps, 960x544), `minimax-h3-turbo` (8 steps, 1344x768) or `minimax-h3` (50 steps).
  - Video requests take the typed fields `soundscape`, `music`, `generate_audio` and `audio_shift`; `flow_shift` is
    the video shift. The prompt is passed to MLX-Gen unchanged, and values left unset keep the schedule's defaults.
  - Every value is checked before any weights load, against MLX-Gen's capability row (frame grid `17n+5` at 24 fps,
    canvas multiple) and its own MiniMax-H3 rules (aspect window 1:4 to 4:1, prompt composition, adapters), and a
    refusal about one field names it: what the route cannot apply or a value outside what it accepts raises
    `CapabilityNotSupportedError` (negative prompt, guidance, another fps, an unknown `extra` key, an adapter on
    another role, a canvas off the grid, a frame count that rounds outside 124 to 345: a count from 108 to 345 is
    rounded up to the next `17n+5` count, so 125 runs as 141); a value of the wrong type, or two fields that contradict
    each other, raises `ValueError`. A first frame is decoded first. Wan and the other local backends refuse the
    soundtrack fields.
  - Results are the MP4 with its AAC soundtrack, `GeneratedAsset.audio` (`GeneratedAudioTrack`: sample rate,
    channels, duration, codec, whether muxed, and the track as WAV bytes when it could not be muxed),
    `GeneratedAsset.audio_summary()` (the one shape the store, the plugin, the tools and HTTP report), and MLX-Gen's
    metadata under `metadata["mlx_gen"]` (the composed prompt, audio facts, memory peaks). With a store,
    `VisionManager` stores a soundtrack that could not be muxed as a WAV artifact of its own and records the summary
    as `audio` on the video's ref and metadata; without a store, the AbstractCore plugin returns the MP4 bytes and
    logs that the soundtrack is not in them.
  - `memory_mode="low"` frees the transformer before the decode, and the next request, a batch item included, loads
    the model again: with the 8-bit package, a 640x352, 124-frame clip peaked at 24.7 GiB alone, in sequence and
    in a batch, and building the instance again took 1.3 to 3.1 s per clip. `"lowest"` adds transformer block streaming (10.6 GiB on the
    same clip; the next request also loads the model again) and is refused with load-time `quantize` and with an
    adapter that trains the AdaLN projections.
  - The AbstractFramework packages are gated on Hugging Face, and the MiniMax H3 Community License's grant excludes
    the European Union, the United Kingdom, the Republic of Korea and the United States of America. AbstractVision
    never downloads these weights or the Turbo adapters during generation, even with `allow_download`; download them
    explicitly after accepting the licence (`abstractvision download MiniMaxAI/MiniMax-H3 --base-model
    minimax-h3-turbo-544p`).
  - CLI: `--soundscape`, `--music`, `--no-audio` and `--audio-shift` on `t2v` and `i2v`.
- **`memory_mode` on every generation request**: `default`, `low` or `lowest`, as a request field, a
  `VisionManager` keyword (batches included), `--memory-mode` on `t2i`, `i2i`, `upscale`, `t2v` and `i2v`, an
  AbstractCore plugin keyword, `extra["memory_mode"]` and a `make_vision_tools(..., memory_mode=...)` argument.
  `ABSTRACTVISION_MEMORY_MODE` sets a process default for requests that name none.
  - MLX-Gen: `low` is MLX-Gen's low-RAM mode as each route's `mlxgen` command applies `--low-ram`, with a 1 GB MLX
    cache from before the model loads. Image and edit routes free the text encoders and the transformer, Wan routes
    clear the cache every step and release the denoisers before the decode, SeedVR2 sets the cache limit only, and
    MiniMax-H3 frees the transformer before the decode. `lowest` adds transformer block streaming; it is accepted
    for MiniMax-H3 and refused on every other current catalog model.
  - Diffusers on CUDA: `low` and `lowest` run with model and sequential CPU offload; a request only raises the
    configured `cpu_offload`, never lowers it, and every result records the mode in `metadata["memory_mode"]`.
    stable-diffusion.cpp: `low` offloads the model parameters to the CPU, and its results record the mode too.
    OpenAI-compatible: the modes the remote lists for the model (see below), else `default` only.
  - A mode named on a request that the backend cannot honour raises `CapabilityNotSupportedError` before any model
    loads or any request is sent, in every backend; `VisionManager`, the plugin and the tools pass the value through
    (`make_vision_tools` refuses only a value that is not a memory mode). A process default the backend cannot
    honour runs as the nearest less aggressive mode the backend lists (`lowest` → `low` → `default`), with one
    warning per process.
  - Image, edit, Wan and MiniMax-H3 models run in `low` (MiniMax-H3 in `lowest` too) free part of the model, which
    is dropped when the run ends, whatever its outcome; the next request loads it again, and the AbstractCore plugin
    no longer lists it as loaded. A batch is a series of such requests: each item loads the model and drops it,
    so every item peaks as one `low` run and under 1.3 GiB stays held between items. Measured per item of a `low`
    batch: FLUX.2 [klein] 9B 8-bit at 1024x1024, 4 steps, 13.2 to 15.4 GiB and 0.5 to 2.5 s to build the instance;
    Wan 2.2 T2V-A14B 8-bit at 480x240, 17 frames, 4 steps, 29.0 to 29.5 GiB and 1.4 to 2.7 s (the weights are then
    read during the run). SeedVR2's `low` is the cache limit alone and keeps its model.
  - `low` and `lowest` hold MLX-Gen's 1 GB MLX cache limit from before the model loads to the end of the run, never
    above a limit already in force; overlapping runs share it, and the limit found before is restored when the last
    one ends. `default` runs set no limit: MLX-Gen applies its own (RAM/8, 1 to 8 GiB) and keeps one the host set.
  - Discovery: `get_capabilities().memory_modes`, `parameter_constraints["memory_mode"]`
    on each MLX-Gen catalog entry, and `memory_modes` per provider in the plugin's `available_providers()` (what
    that provider's backend lists for its configured model and device, without loading a model or sending a
    request). Diffusers with `device="auto"` lists `default` on macOS (no CUDA) without importing torch; elsewhere
    it asks torch, importing it once.
- **Downloads.**
  - `abstractvision download <model id>` selects one package. The host's target order picks the target (preferring
    an 8-bit package unless `--allow-non-8bit`; `--provider` or `--target` restricts it); within that target, a single
    package is selected, and several select the one the catalog marks as recommended (MiniMax-H3 and SeedVR2: the
    8-bit package; Qwen-Image-2512 and FIBO: the 4-bit package); with none recommended, the command
    stops and lists them, whatever `--bits`, `--provider` or `--allow-non-8bit` narrowed them to. `--bits 2|4|8|16`
    selects among the packages of that width only, in every target of the host, or stops saying none has it and
    listing the widths there are. A repository named exactly with `--allow-non-8bit`, or with its MLX-Gen engine named
    (`--provider mlx-gen`), selects that repository (when `--bits` is not given or is its width) on every host (`abstractvision download MiniMaxAI/MiniMax-H3
    --allow-non-8bit` fetches the MiniMax-H3 source repository, which the model id alone does not).
  - Every download is planned before anything is written, for every repository it fetches from: the package, a
    stable-diffusion.cpp bundle's companions (the text encoder and VAE a GGUF diffusion model needs), and with
    `--base-model <schedule>` the adapter that MLX-Gen schedule loads (the MiniMax-H3 Turbo LoRA). The files each
    selects are read from the Hugging Face listing (metadata only; a Diffusers pipeline's `model_index.json` is read
    into memory), and each is either complete in the cache or to fetch. The command prints the access (`open` or
    `gated`), the size and file count, how many files are complete and how many are to fetch, one line per companion
    or adapter, one total, and the free space of the cache disk. The files to fetch must fit there at their full
    size, less what their partial `.incomplete` files already hold (huggingface_hub writes each file into that same
    file, continuing it over plain HTTP and rewriting it from the start over Xet), a rule the `disk:` line states;
    otherwise the command stops (`InsufficientDiskSpaceError`) and writes nothing. It then fetches exactly the files
    to fetch, from the commit the listing named, and records that commit as the repository's `main`: a package whose
    files are all in the cache is reported as present and nothing is fetched, and one missing files (for example a
    Wan 2.2 A14B package downloaded by 0.3.36, without `transformer_2/`) gets them.
  - A `--base-model` that is not a schedule of the package, or an adapter that cannot be named because mlx-gen
    cannot be imported, stops the command before anything is fetched, naming what is missing. The adapter is fetched
    into huggingface_hub's cache, where mlx-gen finds it. Without `--base-model`, `download` lists the schedules
    whose adapter is absent, with the command that fetches it.
  - Ctrl-C ends the command with exit code 130 and says that the files that completed stay in the cache and that
    the same command continues with the rest. A download that ends with files missing gives their count and one of
    them.
  - Without the Hub listing, `download` fetches nothing and says why (offline mode, the Hub unreachable, an HTTP
    error, huggingface_hub or a module it imports not installed, or a listing without file sizes, which huggingface.co
    always gives but a mirror set with `HF_ENDPOINT` may not), and what to do. It reports what the cache holds as it
    is, not compared with the Hub; when a local look sees a gap or a repository is missing, it stops. Generation with
    `allow_download` that finds the model cached makes no Hub request, as before.
  - `--dry-run` prints the same plan, the commit of each repository the fetch would take included; it writes
    nothing and exits 0, and when the download would not fit, its last line says so.
  - A Hugging Face `owner/name` the catalog does not list downloads the whole repository through the same plan,
    size and disk check, with its access from the listing.
  - The catalog marks gated repositories (`gated: true`). `download` says so before it starts, and a gated
    repository that refuses the account ends with `HuggingFaceAccessError` naming the repository page and the
    licence to accept. For a repository not marked gated, a 401 says what the Hub's answer means: the repository
    does not exist, is private, or is gated, and the Hub does not say which.
  - Python: `select_download_preset(name, *, target, engine, bits, allow_non_8bit)` (the selection `download`
    makes), `download_command(repo_id, *, engine, base_model)` (the command that selects exactly that repository on
    this host), `find_model_preset(..., bits=, download_rule=)`, `plan_model_preset_download(preset, *, base_model, model_dir, token,
    all_files)` (a `DownloadPlan` of `DownloadPart`s, each with its `HubDownloadPlan`), `download_model_preset(...,
    base_model=, report=)`, `repository_preset(repo_id)`, `abstractvision.model_inventory.preset_status(preset)` and
    `local_cache_state(preset)`, and `abstractvision.backends.mflux.resolve_mlx_gen_schedule_adapter(base_model,
    download=False)`.
- **Model listings.** `catalog` marks the recommended package with `*` in `bits` and adds the `access`, `cache`
  and `memory_modes` columns. `show-model` adds, per download, its access, cache state with size on disk, the memory
  modes this host can run and, for MLX-Gen packages with published measurements, the peak memory of each mode and
  the smallest memory it was tested on (read from the installed mlx-gen), plus the schedules and the adapter each
  loads. `models --json` and `show-model --json` print the same as JSON. The peaks come from
  `abstractvision.model_inventory.memory_peaks(repo_id)`, also the AbstractCore plugin's `memory_peaks(model)`: one
  row per measured run of that package's stored width, with its `task` and `memory_mode`; a run names no schedule,
  and mlx-gen publishes the same runs on every MiniMax-H3 schedule. The cache state is a local look, offline:
  `cached` is a snapshot with no gap it can see (no partial file, link without content or missing weight file an
  index names, every `model_index.json` component whose folder the package's patterns name present, at least one
  weight file), `incomplete` names the gap, `absent` is nothing in the cache: the same three words in the `catalog`
  table, `show-model` and `--json`. Only `download` compares a snapshot with
  the Hub, so a file that nothing local refers to, such as one an interrupted download never started, can be
  missing from a snapshot shown as `cached`.
- **OpenAI-compatible backend with AbstractCore's server.** A remote that lists `memory_modes` for the model in
  `GET {base_url}/vision/models` (the entry whose `routed_model` is the model sent, `extra["model"]` included, which
  such a remote receives as given, or `defaults[<task>]` when the request names none) receives `memory_mode`, `quantize` and the soundtrack fields it advertises; a
  request with `cancel_event` runs there as a remote job, and setting the event cancels it (AbstractCore's server
  refuses such a job while another generation runs, which the backend raises as a `RuntimeError` saying so); a
  video response's `audio` fills `GeneratedAsset.audio`, and `metadata["memory_mode"]` holds the mode the
  remote reports it ran. Such a remote receives the request's other `extra` keys nested (an `extra` object in JSON,
  an `extra_json` form field). Any other remote refuses these fields with `CapabilityNotSupportedError` before
  anything is sent, and receives `extra` at the top level as before. A request with `cancel_event` to the OpenAI
  API, to a remote whose discovery route answers HTTP 404, 405 or 501 (an answer, kept), or to a vision-route remote
  for a model it does not list, runs as a plain request, the event checked only before sending; while the remote
  has not answered (its discovery request failed), such a request raises the `RuntimeError` of a failed request.
- **For applications embedding AbstractVision.**
  - `cancel_event` on every request (and AbstractCore plugin keyword): MLX-Gen stops between denoising steps and
    raises the new `GenerationCancelledError`; Diffusers and stable-diffusion.cpp check it before a run starts
    (`get_capabilities().cancellation`). What stays loaded after a cancelled MLX-Gen run is listed per model family
    in the API guide; the error carries no traceback of the run, so a caller that keeps it holds none of its memory.
  - Load-time `quantize` (bits) on generation requests, as `--quantize` and as an AbstractCore plugin keyword,
    validated against the route (`get_capabilities().quantize_bits`) and refused on prepared packages and on the
    other local backends. MLX-Gen and a remote that advertises it read it by one integer rule: a bool, a non-integral
    number or a string that is not a decimal integer raises `ValueError` naming `quantize`, and the remote receives
    the width as an integer (an upscale request and a SeedVR2 preload read `False` and the other unquantized
    spellings as an unquantized load, see Changed).
  - `VisionManager.describe_routes(model=..., task=...)` returns MLX-Gen's capability rows as JSON, so a host can
    build its controls and memory planning without importing MLX-Gen.
  - MLX-Gen results carry the engine's metadata under `metadata["mlx_gen"]` on every route, upscaling included.
  - On MiniMax-H3, weights or a run that MLX-Gen's preflight finds cannot fit in memory raise
    `GpuOutOfMemoryError` naming the `memory_mode` it used and the lower ones to try (MLX-Gen 0.40.1 has this
    preflight for MiniMax-H3 only). On Wan, a `MemoryError` raised while the model loads or runs is raised as the
    same `GpuOutOfMemoryError`.
  - Importing AbstractVision and constructing a `VisionManager` write no files, set no environment variables and
    import neither AbstractCore nor an engine.
  - `extra["memory_mode"]` is the memory mode on every backend; `extra["quantize"]` and the soundtrack keys are the
    options only on a backend that applies them (MLX-Gen, a remote that advertises them) and pass through `extra`
    unchanged elsewhere. A field and an `extra` value that disagree raise `ValueError`.
  - `CapabilityNotSupportedError.field` and `.supported` name the refused request field and the values accepted
    there, when a refusal is about one field (None otherwise); the message is unchanged. On MLX-Gen a refusal
    about one field names it (`memory_mode`, `quantize` with the accepted widths, `width`, `num_frames`, `steps`, the
    shifts, `fps`, `negative_prompt`, guidance, `lora_adapters`, `control_image`, `mask`); a refusal about two fields
    together (`memory_mode="lowest"` with load-time `quantize`, or with an adapter that trains the AdaLN projections)
    leaves both None.
  - `preload(memory_mode=None, quantize=None)` on every backend: the values are checked as a request's are, before
    anything loads, and the model loads as a request carrying them loads it, so that request reuses it; a backend
    that takes no load-time quantize refuses it. The AbstractCore plugin's `load_resident_model(...)` passes a
    request's `memory_mode` and `quantize`. On MLX-Gen the load runs under that request's cache hold; in a mode
    whose runs drop the model (`low`, `lowest`, and every mode on Wan TI2V-5B, which releases its denoiser before
    the decode), the preloaded instance serves one request and no warm-up runs.
    Only a text-to-image model kept by its mode runs one warm-up generation, in that mode; an edit-only model is
    loaded for edits.
  - MLX-Gen records `memory_mode` (with `low_ram` and `stream_blocks`) in every result's metadata, `"default"`
    included.
  - MLX-Gen checks a request once, on its own thread: `VisionManager` still calls the backend's `normalize_*`
    (any backend may rely on it), and the backend's entry point does not check the request it returned again.
    A task the configured model has no route for (an image task on MiniMax-H3) is refused before anything is read.
  - `VisionBackend.has_loaded_model()` says whether this process holds a backend's model weights now (MLX-Gen,
    Diffusers and stable-diffusion.cpp's Python binding answer; the default, `False`, is the answer of a backend
    that loads nothing here). The AbstractCore plugin lists and pins loaded models by it, asking it when called, and
    a load whose backend answers `False` returns `state: "not_loaded"` with a `reason`.

### Changed

- `download` of a catalog model with a single package (for example `stabilityai/stable-diffusion-xl-base-1.0`,
  `briaai/Fibo-Edit`, the alias `stable-diffusion`) selects that package without flags and fetches the files it
  selects (for a Diffusers pipeline, those the backend loads), where 0.3.36 fetched the whole repository of an
  `owner/name` and refused any other name without `--allow-non-8bit` (which selected the same package).
- `download` without flags selects the package 0.3.36 selected for every name it selected one for, on every host:
  where several packages of one target remain, the catalog now marks that package `recommended` (Qwen-Image-2512's
  4-bit MLX-Gen package, GGUF and Diffusers pipeline, FIBO's 4-bit package, SeedVR2's 8-bit packages), so `catalog`
  shows the `*` on these rows too. A model id for which 0.3.36 fetched the whole upstream repository unfiltered and
  that has several packages in the chosen target and none recommended (FLUX.2 [klein], Qwen-Image, Qwen-Image-Edit,
  Z-Image, ERNIE-Image-Turbo, the Wan 2.2 models, HunyuanVideo-1.5) stops and lists them; so does
  `tencent/HunyuanVideo-1.5` with `--provider diffusers` or `--allow-non-8bit`, where 0.3.36 took the first of its
  eight pipelines by name. Name a package, or, for a source repository, name it with `--allow-non-8bit`. On Apple
  silicon, `Qwen/Qwen-Image-2512`, `briaai/FIBO`, `ByteDance-Seed/SeedVR2-3B` and `-7B`, for which 0.3.36 fetched
  the whole upstream repository, select the recommended package; `--allow-non-8bit` fetches the repository itself.
- `download <owner/name> --allow-non-8bit` selects that repository on every host, where 0.3.36 did so on Apple
  silicon and picked the host's first target or package elsewhere (on an NVIDIA host, the GGUF package of
  `black-forest-labs/FLUX.2-klein-4B` rather than that Diffusers pipeline; on NVIDIA and processor-only hosts, the
  SeedVR2 8-bit and FIBO 4-bit packages rather than `ByteDance-Seed/SeedVR2-3B`, `-7B` and `briaai/FIBO`).
- `download <owner/name> --provider <engine>` (or `--target`) for a model with no package of that engine stops and
  lists the packages it has, where 0.3.36 ignored the provider and fetched the whole repository. With
  `--provider mlx-gen`, a model id that has several MLX-Gen packages stops and lists them, or selects the
  recommended one (`Qwen/Qwen-Image-2512` is the 4-bit package), where 0.3.36 fetched the whole upstream
  repository.
- A name that is neither in the catalog nor an `owner/name` points to `abstractvision catalog` instead of listing
  every known name.
- The one-shot commands' local-default notice gives the `download` command that selects the package that engine
  loads on this host (for Diffusers, `abstractvision download black-forest-labs/FLUX.2-klein-4B --allow-non-8bit`:
  the model id alone selects the GGUF package on NVIDIA and processor-only hosts and stops on Apple silicon), and no
  longer calls that default 8-bit.
- `--allow-non-8bit` is no longer needed for a model with a single package; it still lets the host's target order
  choose a target without an 8-bit package.
- `download` prints the package's own target and engine (a GGUF package says `gguf` and `stable-diffusion.cpp`).
- A legacy `~/models/<preset>` tree (or one under `--model-dir`) is still moved into the cache as before, and
  `download` then says it was imported and not compared with the Hub, and fetches nothing on top of it.
- `make_vision_tools`: a parameter the call leaves unset and the catalog lists without a default stays unset, so the
  engine applies its own default. Models whose catalog lists `steps` without a default no longer run at the tool's
  10 steps (15 for edits).
- AbstractCore plugin: `guidance_2` on `t2i` or `i2i` raises `CapabilityNotSupportedError` (it raised `TypeError`), as
  do the soundtrack options on an image call. Every other unknown keyword stays a backend `extra` parameter.
- MLX-Gen result metadata names the model and adapters by repo id (a Hugging Face cache snapshot) or by file or
  directory name, never by local path: every field of the engine's metadata that holds a path (`model`,
  `lora_paths`, `lora_application_reports`, the video file checked by `video_health`, and the `original_*` fields an
  upscale copies from its input), in `metadata["mlx_gen"]` and its top-level copies, and `requested_lora_adapters`.
  The fields naming the files written for a run (the source image or first frame, an edit's image list and mask, the
  clip and its audio sidecar) are left out.
  The refusals of a prepared package given `quantize`, of a model path that does not exist and of an adapter
  `lowest` cannot stream name the model or adapter the same way.
- MLX-Gen SeedVR2 upscaling checks `quantize` as the other families do: a prepared package refuses it (on
  `upscale_image` and `preload`), and the source accepts MLX-Gen's widths, refusing any other integer with
  `CapabilityNotSupportedError` (`field="quantize"`, it raised `ValueError`) and a non-integral number with
  `ValueError` (it was truncated). An upscale request still accepts `"none"`, `""`, `"0"`, `0`, `"false"`, `False`,
  `"off"` and `"no"` (in any case) and now loads unquantized for them on every path, as a SeedVR2
  `preload(quantize=...)` does: in 0.3.36 a direct backend call did, while `VisionManager` and the plugin loaded the
  8-bit default. `extra={"quantize": ""}` is now an unset option.
- MLX-Gen video requests are type-checked: a width, height, frame count, fps, step count or Wan
  `extra["max_sequence_length"]` that is not an integer, a guidance scale, `guidance_2` or shift (a field, or Wan's
  `extra["flow_shift"]`) that is not a finite number (NaN, infinity), or a seed outside `[0, 2**64 - 1]`, raises
  `ValueError` naming the field instead of being truncated or passed on; an image-to-video first frame that cannot
  be decoded raises `ValueError` naming `image`.
- MLX-Gen Wan results carry, under `metadata["mlx_gen"]`, the metadata MLX-Gen's save writes beside the clip (as
  MiniMax-H3 results do), which adds what only the save knows (video health, the process's peak memory).
- MLX-Gen refuses `control_image`, and `control_strength` given alone, with `CapabilityNotSupportedError` (`field`
  names it) before anything loads, and `get_capabilities().supports_control_image` is `False`: MLX-Gen runs structured control through its
  Qwen ControlNet variant and a ControlNet sidecar repository, which AbstractVision does not load. The catalog no
  longer lists `control_image` and `control_strength` for Qwen Image.
- An exception raised in a progress callback is logged once and no longer ends the run; stop a run with
  `cancel_event`.
- OpenAI-compatible backend: `list_provider_models()` and a request that sets a memory, sound or `quantize` field
  or a `cancel_event` (or runs under `ABSTRACTVISION_MEMORY_MODE`) also query `GET {base_url}/vision/models` (10 s
  timeout, answer reused for 30 s; never for the OpenAI API); `get_capabilities()` reads
  the last answer without a request, and a request that sets none of them, carries no `extra` and names its model
  without an `openai/` or `openai-compatible/` prefix makes the same HTTP calls as before. A discovery request that fails (timeout, connection error, an HTTP 5xx other than 501) is not kept: the
  previous answer stays in use, and without one a request that names a memory mode other than `default`,
  `quantize` or a soundtrack field is refused with the reason, and one with a `cancel_event` raises the
  `RuntimeError` of a failed request. A discovery answered with HTTP 501, like 404 and 405, is an answer. A remote HTTP 422 with the error code `capability_not_supported`, and
  a remote job that fails with that `error_code`, raise `CapabilityNotSupportedError` with the remote's message,
  `field` and `supported` instead of `RuntimeError`.
- OpenAI-compatible backend: `list_provider_models()` on a remote that serves the vision routes (AbstractCore's
  server) lists its `GET {base_url}/vision/models` catalog, each model by the `routed_model` a request sends, with
  its memory modes and audio support; it read that server's `GET /models`, which lists text models. Other remotes
  are listed from `GET /models` as before.
- OpenAI-compatible backend: `list_provider_models()` against a remote that answers `GET /models` with HTTP 404, 405
  or 501 raises `CapabilityNotSupportedError` (the remote has no model catalog) instead of `RuntimeError`. The
  AbstractCore plugin's `list_provider_models()` raises it as it is when no backend has a catalog, as it does when
  the selected backend cannot list models, instead of `AbstractVisionError`; a backend without one is skipped when
  another answers.
- OpenAI-compatible backend: a request that carries `extra` (keys other than `model`), or names its model with an
  `openai/` or `openai-compatible/` prefix, first asks the remote with `GET {base_url}/vision/models` whether it
  serves the vision routes (never the OpenAI API). The answer to that question is kept for the backend's life (the
  memory modes and options it lists are still reused for 30 s, as above); a question that fails
  (timeout, connection error, an HTTP 5xx other than 501) is asked again after 30 s, and until then the remote's kind
  is unknown. A
  remote that serves them receives `extra` nested, as described under New, and the model as named; any other
  remote, or one whose kind is unknown, receives `extra` at the top level and the model without the prefix. A model
  named without such a prefix is sent as given to every remote.
- OpenAI-compatible backend and AbstractCore plugin: a base URL is the OpenAI API when its host is `api.openai.com`
  or one of its subdomains (such as `eu.api.openai.com`); a URL that has `api.openai.com` only in its path or
  query, or a look-alike host, is an OpenAI-compatible remote.
- AbstractCore plugin: a backend given through `vision_backend_instance` or `vision_backend_factory` (called once,
  when the capability is built) that lacks `has_loaded_model`, `preload`, `unload`, `supported_memory_modes`,
  `list_provider_models` or `list_provider_adapters` is refused when the capability is built, with a `TypeError`
  that names the missing methods and says to inherit `abstractvision.backends.base_backend.VisionBackend`, which
  provides them. Unloading the configured backend by provider or `load_id` calls its `unload()` whether or not it
  is listed. A `vision_backend_factory` that raises fails the capability's construction with that error (0.3.36
  ignored it and built the configured default backend), and an injection added to the owner's config after the
  capability is built is not read.
- Diffusers refuses a model that is not in the cache and that generation may not download (downloads off, or a
  repository marked `explicit_download`) before loading anything; a cached model's own load error is raised as it is.
- The cache lookups of model resolution, the Diffusers refusal, the `cache` column and `show-model` also read the
  cache huggingface_hub reads, by its own precedence (`HF_HUB_CACHE`, `HUGGINGFACE_HUB_CACHE`, `HF_HOME`,
  `XDG_CACHE_HOME`), so a model that only `HUGGINGFACE_HUB_CACHE` or `XDG_CACHE_HOME` locates is found; downloads
  write where they did.
- `HuggingFaceAccessError` says that the repository is gated and names the licence when the catalog marks it gated,
  otherwise what the HTTP status tells (401, 403, 404), and keeps the first line of the upstream error.
- Diffusers recognises a CUDA out-of-memory by its type (`torch.cuda.OutOfMemoryError`), no longer by the words
  "CUDA out of memory" in a message, and its `GpuOutOfMemoryError` no longer says how much more memory the run
  needed (that figure was read from torch's message).

### Fixed

- MLX-Gen reads the `base_model` of a model or adapter card that starts with a byte-order mark; such a card was read
  as having no front matter.
- Downloads of the Wan 2.2 A14B MLX-Gen packages fetch the low-noise expert (`transformer_2/`), and MLX-Gen package
  downloads fetch the chat-template files (`*.jinja`) the Qwen, ERNIE and Bonsai tokenizers load; both were left out.
  Running `download` again on a package downloaded by 0.3.36 fetches them.
- MLX-Gen releases the loaded model, and clears the MLX cache, before it loads another one (another model or
  adapter set): two instances are never in memory together.
- A failed MLX-Gen `preload()` drops the model it loaded before raising, and the AbstractCore plugin does not list
  it as loaded. A preload refused for its values, or one that fails after reusing the model already held, leaves
  that model held. A failed preload that had to replace the held model (another `quantize`, mode or adapter set)
  leaves nothing loaded.
- AbstractCore plugin: `control_image` and `control_strength` reach `t2i` (they were dropped), where every built-in
  backend refuses `control_image`, and MLX-Gen also refuses `control_strength` given alone (the other built-in
  backends do not use it).

### Removed

- `abstractvision.cli.looks_like_hf_repo_id`, a name the CLI module imported: use
  `abstractvision.model_downloads.looks_like_hf_repo_id`, where it is defined.
- `abstractvision.cli.download_hf_repo_snapshot`, a name the CLI module imported: use
  `abstractvision.model_downloads.download_hf_repo_snapshot`, where it is defined (it now plans and checks the disk
  before fetching).
- `abstractvision.backends.mflux.WAN_VIDEO_MLX_CACHE_LIMIT_CEILING_BYTES` and `WAN_VIDEO_MLX_CACHE_LIMIT_FLOOR_BYTES`:
  AbstractVision no longer sets an MLX cache limit for Wan `default` runs; MLX-Gen applies its own (RAM/8, 1 to
  8 GiB), and `low` / `lowest` runs hold 1 GB (see `memory_mode`).

## 0.3.36 - 2026-11-11

- **The one-shot commands run locally by default**: `abstractvision t2i`, `i2i` and the other generation commands
  pick this machine's engine and FLUX.2 [klein] 4B in 8 bits when no `--provider`, `--model`, `ABSTRACTVISION_PROVIDER`
  or base URL is given: MLX-Gen with `AbstractFramework/flux.2-klein-4b-8bit` on Apple silicon, stable-diffusion.cpp
  with the Q8_0 GGUF of `black-forest-labs/FLUX.2-klein-4B` on an NVIDIA card (the artifact `abstractvision download`
  already picks there), Diffusers with the same model on a processor-only host. The command prints its choice and the
  download command for the model. A `--base-url` (or `$OPENAI_BASE_URL`) selects the OpenAI-compatible HTTP backend as
  before; `--provider` keeps winning. Until now the commands defaulted to the remote backend on every platform and
  stopped with `Missing --base-url`. Tests cover the three profiles, the base URL and the explicit provider.
- Docs: a platform check of 0.3.35 (`docs/benchmark.md`) with the measured generation times per model on Linux
  without a GPU, Linux with an NVIDIA card and Apple silicon, linked from the README and the docs index.

## 0.3.35 - 2026-11-10

Linux release check: this version was run end to end on an Ubuntu 24.04 host with an NVIDIA Quadro RTX 5000
(16 GB, Turing) and on a processor-only Ubuntu 26.04 host with Python 3.14. On the card, `abstractvision[gpu]`
installs with no compiler, the Diffusers backend picks `cuda` and float16 (the fast dtype on Turing, which has no
native bfloat16), FLUX.2 [klein] 4B generates 1024² in 18-20 s with 8.6 GB of GPU memory and about 24 GB of host RAM
for model CPU offload, the model stays resident between calls and `unload` returns the memory; the SDXL family, the
turbo models, SD 1.5, Kolors, Lumina-2, PixArt-Sigma, the inpaint and instruct-pix2pix pipelines and the GGUF path
(FLUX.2 klein, Z-Image, Qwen-Image-2512, Qwen-Image-Edit-2511 through `sd-cli`) all ran at their catalog defaults.
On the processor the backend picks `cpu` and float32 and generates without a CUDA warning.

- One-line standalone install: `curl -LsSf https://abstractframework.ai/vision/install.sh | sh` (macOS/Linux) and
  `powershell -ExecutionPolicy ByPass -c "irm https://abstractframework.ai/vision/install.ps1 | iex"` (Windows),
  `scripts/install.sh` / `scripts/install.ps1`: no admin rights, uv and Python 3.12 installed when missing,
  `abstractvision[<profile>]==<version>` as an isolated user tool; the profile is detected like the framework
  installer's (Apple Silicon + macOS 14 -> `apple`, NVIDIA or ROCm -> `gpu`, else `light`); `--print`, `--profile`,
  `--pin`, `--from`; a re-run upgrades in place.
- Diffusers on the processor loads every component in float32 (the CPU default dtype was unset, so Transformers 5
  loaded float16 text encoders next to a float32 UNet and every generation failed with a dtype mismatch).
- `local_model_profile()` reports `cpu` when `CUDA_VISIBLE_DEVICES` is empty or `-1` (it said `cuda`).
- A CUDA out-of-memory during a Diffusers generation is raised as `GpuOutOfMemoryError`, naming the model's size,
  its placement, what was free and what to change, instead of torch's traceback.
- 8-bit GGUF presets download and run their `Q8_0` file only (they fetched every quantization of the repository:
  258 GB for Qwen-Image-2512's 22 GB file, 92 GB for Z-Image, and then ran the BF16 file).
- `sd-cli` auto-install picks the newest stable-diffusion.cpp release whose Linux build the host's glibc can run
  and skips ROCm builds (since master-1044 the Linux builds need glibc 2.43, so every GGUF call failed on Ubuntu
  24.04); a host that already installed a newer build deletes `~/.abstractvision/bin` once.
- Z-Image GGUF presets bring their text encoder (Qwen3-4B Q4_K_M) and VAE, so `sd-cli` can build its context.
- The GGUF path runs at the catalog's steps and guidance (it ran `sd-cli`'s 20 steps and cfg 7 for every model);
  guidance below 1 is sent as cfg 1 for turbo and distilled models.
- Qwen-Image-Edit-2511 on `sd-cli` passes `--model-args qwen_image_zero_cond_t=true` (the flag it used did not exist).
- On a CUDA host, `abstractvision download <model>` no longer picks the FP8 side artifacts (for example
  `black-forest-labs/FLUX.2-klein-4b-fp8`): no AbstractVision backend loads them. The CUDA auto order is gguf,
  diffusers, hf-snapshot; FP8 is left out rather than moved last because downloads are 8-bit by default and FP8 is
  the only 8-bit artifact of flux1-dev and flux2-klein-9b-kv. `--target fp8` still lists and downloads them.
- A Diffusers download fetches only what the backend loads on this host: each component listed in
  `model_index.json` with one safetensors set (fp16 on CUDA and Apple silicon, the default set on the processor),
  without root single-file checkpoints or `.bin` / `.onnx` / `.msgpack` copies. Measured on the Quadro RTX 5000:
  stabilityai/sdxl-turbo went from 41.6 GB in 162 s to 6.9 GB in 38 s and generated the same image; FLUX.2-klein-4B
  goes from 23.7 GB to 16.0 GB. `abstractvision download --all-files` restores the full download. AbstractCore's own
  Diffusers route downloads go through its model materializer and are not trimmed by this.
- `sd-cli` guidance follows the model family: FLUX dev models get `--guidance <catalog value>` with `--cfg-scale 1`
  (their guidance is distilled, not classifier-free), Qwen-Image-Edit defaults to cfg 2.5 as stable-diffusion.cpp
  documents (checked on one edit with the same seed: 2.5 gives the asked-for subject, 1.0 a hybrid). The sd-cli
  installer requires the host architecture in the build it picks, refuses Ubuntu builds newer than its glibc table and
  says when no build fits; GGUF preset downloads take root files only; a valueless `--model-args` gets its value in
  place; on a GPU out-of-memory the failed step's memory is released before the free figure is reported.

## 0.3.34 - 2026-10-18

- Endpoint profiles: a request whose provider is `endpoint:<id>` (an OpenAI-compatible connection kept as an
  AbstractCore provider profile or by a host such as AbstractGateway) now runs on that endpoint, with the
  profile's base URL and API key, through the OpenAI-compatible backend. Before, the provider fell through
  to the configured default backend, so an image route set to an endpoint serving `gpt-image-2` could not
  reach it. The profile is resolved by the owning Core provider's host resolver
  (`resolve_provider_endpoint_profile`), then the ambient resolver (`abstractcore.providers.endpoint_context`),
  then AbstractCore's `provider_profiles`; an unknown or disabled profile, or one of another family than
  `openai` / `openai-compatible`, fails with an error that never contains the key. An `openai-compatible`
  endpoint without a key never borrows `OPENAI_API_KEY`. Tests: `tests/test_endpoint_profile_routing.py`.

## 0.3.33 - 2026-09-29

- Diffusers on CUDA: `cpu_offload="auto"` falls back to Diffusers' sequential CPU offload when the
  GPU's free memory (minus the working reserve) cannot hold the pipeline's largest component,
  which model CPU offload moves to the GPU whole. This covers a GPU shared with another loaded
  model: on a 16 GB Quadro RTX 5000 with 6.5 GiB held by a text model (about 7.8 GiB free),
  FLUX.2 [klein] 4B in float16 (largest component about 7.5 GiB) leaves model CPU offload no working
  room. Sequential CPU offload uses much less GPU memory (about 1.4 GiB peak there) and each step is
  slower: measured at 768x768 and 4 steps, 10.9-15.6 s against 13.4-18.5 s with model CPU offload,
  but about 2.3 s per step against 1.5 s, so it is slower for models that run many steps. The
  backend logs a warning that says why it was chosen, and the result metadata reports
  `cpu_offload: "sequential"`. The whole-pipeline and model CPU offload placements are unchanged
  when they fit.
- `HuggingFaceDiffusersBackendConfig(cpu_offload=...)` accepts `"sequential"` to always use
  sequential CPU offload; `"model"` and `"none"` keep their meaning. A pipeline that does not
  support sequential offload logs a warning and uses model CPU offload instead.
- Diffusers: unloading a model now releases its memory. The pipeline (including its CPU offload
  hooks) is freed when the unload returns, and on Linux the freed memory is returned to the
  operating system. Measured on CUDA (FLUX.2 [klein] 4B with model CPU offload): 0.86 GB still
  held after the unload, down from 16.3 GB. This matters when a host such as AbstractGateway
  unloads an image model to make room for the next one.
- AbstractCore plugin: `load_resident_model` reports `loaded_new` — `true` when the call loaded the
  model, `false` when it was already in memory — so AbstractCore and AbstractRuntime report a fresh
  image-model load as `loaded` instead of `already_loaded`.

## 0.3.32 - 2026-09-29

- Install profiles: the `gpu` and `all-gpu` extras no longer install MLX-Gen. They are the
  NVIDIA/Linux profiles: `gpu` installs Diffusers/torch and `all-gpu` adds stable-diffusion.cpp.
  On Linux, MLX-Gen pulled `mlx[cuda13]` (about 2.1 GB of CUDA 13 wheels next to torch's own CUDA
  runtime) that AbstractCore never routes on CUDA hosts, and it required glibc 2.35 or newer. The
  `gpu` and `all-gpu` installs are now that much smaller and install on Linux with an older glibc.
  MLX-Gen still comes with `apple`, `all-apple` and `all`; to try it on Linux, install the explicit
  `mlx-gen` extra (it installs there but is not validated; see backlog 030).
- Install profiles: `all-gpu` no longer installs stable-diffusion.cpp on Windows
  (`stable-diffusion-cpp-python; sys_platform != 'win32'`). PyPI ships it as a source build only,
  and that build needs MSVC (an elevated install), so `abstractcore[gpu]` could not install on
  Windows with wheels. Diffusers on PyTorch's CUDA build covers image generation there (not yet validated on Windows
  hardware); Linux and
  macOS keep stable-diffusion.cpp in `all-gpu` (framework backlog 0988).
- Diffusers on CUDA: a pipeline whose weights do not fit the GPU's free memory (minus a working
  reserve of max(1.5 GiB, 10% of the card)) now loads with Diffusers' model CPU offload (one
  component on the GPU at a time) instead of being moved whole and failing with CUDA out of memory.
  Measured on a 16 GB Quadro RTX 5000 (framework backlog 0989): FLUX.2 [klein] 4B in float16
  (14.9 GiB of weights) went from OOM to 768x768 in about 17 s at 4 steps, 7.8-8.3 GiB peak.
  `HuggingFaceDiffusersBackendConfig(cpu_offload="auto" | "model" | "none")`; the result metadata
  reports the execution device (`cuda:0`, not the CPU the idle weights wait on) and
  `cpu_offload: "model"`.

## 0.3.31 - 2026-09-29

- MLX-Gen Wan video: every Wan model has its own default generation size, kept in one table
  (`WAN_VIDEO_DEFAULT_CANVASES` in `backends/mflux.py`) that the backend, provider discovery and
  the packaged capability registry follow. TI2V-5B now defaults to 832x480, 121 frames at 24 fps,
  50 steps (was 1280x704), with `flow_shift=3.0` at that size; T2V-A14B and I2V-A14B default to
  832x480, 81 frames at 16 fps, 40 steps (was 1280x720). Pass `width`, `height`, `num_frames`,
  `fps` and `steps` (CLI `--width/--height/--frames/--fps/--steps`) to generate at any other size.
- MLX-Gen Wan video decodes in overlapping spatial tiles by default, so the VAE decode no longer
  sets the run's memory peak. Measured on Apple silicon (mlx-gen 0.38): TI2V-5B at 832x480 peaks at
  16.3 GiB (23.4 GiB untiled) and at 1280x704 at 25.4 GiB (51.2 GiB untiled); T2V-A14B at 832x480
  peaks at 38.3 GiB (47.4 GiB untiled). Pass `extra={"vae_tiling": False}` (CLI `--no-vae-tiling`)
  to decode whole frames at once. Generated video metadata records `vae_tiling`.
- MLX-Gen Wan video caps MLX's allocator cache while a video generates and decodes, and releases the
  TI2V-5B denoiser before the decode (the next TI2V request loads it again, which takes about a minute). This keeps the
  process footprint close to the MLX peak instead of holding every freed decode buffer.

## 0.3.30 - 2026-09-27

- MLX-Gen: unloading a model now returns MLX's cached Metal memory to the operating system. Previously the released weights could stay reserved in the MLX allocator cache, so a process with no loaded model could still hold most of the model's memory. No API change.

## 0.3.29 - 2026-09-23

- Runtime dependency: raise the optional MLX-Gen runtime floor to `mlx-gen>=0.38.0,<0.39.0` in every extra that installs it (`mlx-gen`, `mflux`, `apple`, `gpu`, `all`, `all-apple`, `all-gpu`). The MLX-Gen 0.38 line requires Python 3.10+, `transformers>=5`, and `Pillow>=12.1.1`; the AbstractVision backend call surface is unchanged.

## 0.3.28 - 2026-06-16

- MLX-Gen capabilities: align advertised `supports_mask` with the backend family gate so FLUX.2 models do not report mask support from inpaint-only route metadata when masked edits are implemented only for Qwen Image Edit and FIBO Edit families.
- AbstractCore plugin: probe provider catalogs concurrently so `list_provider_models` waits for the slowest backend instead of the sum of serial scans.

## 0.3.27 - 2026-06-16

- Runtime dependency: raise the optional MLX-Gen runtime floor to `mlx-gen>=0.18.19,<0.19.0`.
- MLX-Gen Qwen routes: expose validated base-Qwen structured control through typed `control_image` / `control_strength` and validated Qwen 2511 masked edit through `mask`, with explicit fail-closed backend gating instead of older family-only assumptions.
- Adapter capability registry: add packaged `vision_adapter_capabilities.json` plus `VisionAdapterCapabilitiesRegistry` so package-owned adapter defaults, compatibilities, docs links, and quantization guidance are data-driven instead of hard-coded in Python branches.
- CLI, provider catalog, and docs: surface structured-control parameters, adapter recommendations, registry override paths, and the updated MLX-Gen Qwen route guidance consistently across the CLI, REPL, AbstractCore integration, troubleshooting docs, and AI-readable indexes.

## 0.3.26 - 2026-06-13

- AbstractCore plugin surface: expose `list_provider_adapters(...)` plus first-class batch methods for `t2i`, `i2i`, `t2v`, and `i2v`, keeping stacked LoRA adapters, explicit seed planning, and route-specific video controls on the same typed boundary used by direct `VisionManager` callers.
- AbstractCore tool helpers: bring `make_vision_tools(...)` up to the same contract with adapter discovery, stacked LoRA adapters, batch helpers, and multi-reference image-edit inputs.
- Core-hosted proof: expand regression coverage so the plugin contract is explicitly validated for installed-adapter discovery, image batch seed expansion, and video batch forwarding.
- Packaging docs: clarify that `abstractvision[local]` covers the Diffusers + `sdcpp` runtime stack, while MLX-Gen stays explicit through `abstractvision[mlx-gen]` or the aggregate `all` / `all-apple` profiles.

## 0.3.25 - 2026-06-13

- Provider discovery: fix SeedVR2 local prepared-folder discovery for bare local folder names such as `seedvr2-7b-8bit` and `seedvr2-7b-4bit`, so clean environments surface both exact local upscaler variants without relying on a populated Hugging Face cache.

## 0.3.24 - 2026-06-13

- Provider discovery: fix SeedVR2 local prepared-folder discovery so `AbstractFramework/seedvr2-7b-8bit` and `AbstractFramework/seedvr2-7b-4bit` both surface correctly from a configured local model directory even when no Hugging Face cache is available, while keeping the canonical base alias aligned with the preferred local variant.

## 0.3.23 - 2026-06-13

- Runtime dependency: raise the MLX-Gen optional runtime floor to `mlx-gen>=0.18.18,<0.19.0` and expose the same upstream install surface that now includes Linux/CUDA markers in addition to Apple Silicon.
- Shared LoRA contract: add `LoRAAdapterSpec` plus typed `lora_adapters` request fields across `ImageGenerationRequest`, `ImageEditRequest`, `VideoGenerationRequest`, and `ImageToVideoRequest`.
- MLX-Gen integration: route typed LoRA adapters through local `t2i`, `i2i`, `t2v`, and `i2v`, keep backend-default adapters as a separate config path, and preserve adapter provenance in generated metadata.
- CLI/Core integration: add first-class repeated `--lora*` flags for one-shot MLX-Gen image/video commands and forward `lora_adapters` plus typed `guidance_2` through the AbstractCore plugin surface.
- Provider discovery: surface MLX-Gen route-level LoRA truth (`supports_lora`, `lora_status`, `lora_target_roles`, `lora_validation_profile`) through catalog/provider-model discovery instead of duplicating compatibility truth in the packaged registry.
- Batch generation: add and document first-class batch orchestration through `VisionManager.generate_image_batch(...)`, `edit_image_batch(...)`, `generate_video_batch(...)`, `image_to_video_batch(...)`, plus CLI `--count` / `--seeds`.
- Adapter inventory hygiene: add route-aware installed-adapter discovery through `abstractvision adapters ...` / `VisionManager.list_provider_adapters(...)` and filter full-model component snapshots out of that inventory so only optional overlays are surfaced as adapters.
- Wan video validation: reject undersized TI2V-5B requests below `832x480` / `480x832` in the MLX-Gen backend boundary and publish only validated `832x480` TI2V and `480x240` task-specific Wan A14B proof assets.
- Docs/tests: add a bundled MLX-Gen proof page with current batch image/video runs, stacked-adapter image-edit evidence, validated TI2V-5B and Wan A14B visual proofs, progress logs, provider-adapter discovery evidence, and expanded regression coverage for exact Qwen edit routing, CLI propagation, plugin propagation, Diffusers compatibility bridging, adapter inventory filtering, and packaging markers.

## 0.3.22 - 2026-06-07

- Runtime dependency: raise the MLX-Gen optional runtime floor to `mlx-gen>=0.18.14,<0.19.0` so Apple Silicon installs pick up SeedVR2 large-output VAE decode stability, official base-model support, canonical q8/q4 packages, and the latest image-edit fixes.
- Image upscaling: add first-class `ImageUpscaleRequest`, `VisionManager.upscale_image(...)`, backend `upscale_image_with_progress(...)`, and canonical `image_upscale` capability metadata.
- MLX-Gen SeedVR2: surface official `ByteDance-Seed/SeedVR2-3B` and `ByteDance-Seed/SeedVR2-7B` base models plus canonical `AbstractFramework/seedvr2-{3b,7b}-{8bit,4bit}` packages. Short selectors such as `seedvr2-3b` resolve to the recommended 8-bit package, while exact q4/q8 model ids remain exact.
- CLI/Core integration: add one-shot `abstractvision upscale` with default `mlx-gen/AbstractFramework/seedvr2-3b-8bit`, AbstractCore plugin tool support, and residency/catalog support for upscaler-only models.
- Progress events: relay SeedVR2 denoise-step progress through the same normalized progress event surface used by image/video generation, with `task="image_upscale"`.

## 0.3.21 - 2026-06-04

- Wan A14B guidance controls: promote MLX-Gen `guidance_2` to a first-class `VideoGenerationRequest` / `ImageToVideoRequest` field, CLI `--guidance-2` flag, REPL flag, playground job parameter, and AbstractCore tool parameter.
- Model registry: declare `guidance_2` defaults for Wan 2.2 A14B text-to-video and image-to-video tasks so discovery, tool defaults, and provider catalogs agree.
- OpenAI-compatible video: forward typed `guidance_2` to custom text-to-video and image-to-video endpoints that support the Wan-style two-stage guidance contract.

## 0.3.20 - 2026-06-04

- Runtime dependency: raise the MLX-Gen optional runtime floor to `mlx-gen>=0.18.10,<0.19.0` so Apple Silicon installs pick up the current capability planner, shared image/video progress events, and multi-reference edit routing.
- MLX-Gen progress: surface image generation and image edit progress through backend `*_with_progress(...)`, Python/Core `on_progress(event)` callbacks, and opt-in one-shot CLI `--progress` flags while preserving video progress availability for shell, Python, and AbstractCore callers.
- MLX-Gen progress semantics: align normalized video progress, the CLI display, and backend progress-bar callbacks with MLX-Gen denoise-step progress while retaining video frame counters as contextual event fields.
- MLX-Gen multi-reference edits: allow FLUX.2 and Qwen Image Edit requests to pass additional reference images through `extra.reference_images` / CLI `--reference-image`, and mark the supported model task metadata accordingly.
- Docs/tests: document image/edit/video progress across CLI, Python, and AbstractCore plugin calls; add propagation coverage for manager, CLI, plugin, Flux.2 multi-reference edit paths, and MLX-Gen denoise-step video progress normalization.
- Examples: add a bundled MLX-Gen local example gallery with copy-paste image/edit/video commands, generated PNG/MP4 outputs, contact sheet, manifest, and AbstractCore plugin progress-event capture.

## 0.3.19 - 2026-06-03

- Docs: clarify MLX-Gen `0.18.8` setup, Wan 2.2 A14B text-to-video/image-to-video usage, and generated-media configuration references.
- AI-readable docs: refresh `llms.txt` and `llms-full.txt` for the current AbstractVision Apple profile and video model surface.

## 0.3.18 - 2026-05-31

- Runtime dependency: raise the MLX-Gen optional runtime floor to `mlx-gen>=0.18.8,<0.19.0` so Apple Silicon installs pick up Wan 2.2 A14B text-to-video and image-to-video support.
- Wan A14B catalog: expose `Wan-AI/Wan2.2-T2V-A14B-Diffusers` and `Wan-AI/Wan2.2-I2V-A14B-Diffusers` through the canonical `mlx-gen` provider with task-specific defaults and capability metadata.
- Core propagation: prepare AbstractVision `0.3.18` so AbstractCore can depend on the corrected MLX-Gen runtime contract.

## 0.3.17 - 2026-05-29

- Docs: update the docs-site favicon and add an embedded text-to-video example carousel (5s MP4) to `docs/getting-started.md`.
- Runtime dependency: raise the MLX-Gen optional runtime floor to `mlx-gen>=0.18.7,<0.19.0` so Apple Silicon installs pick up the latest Wan video/model fixes.
- Core propagation: prepare the next AbstractVision package version (`0.3.17`) so AbstractCore can depend on the corrected MLX-Gen runtime contract.

## 0.3.16 - 2026-05-26

- MLX-Gen video progress: surface Wan `text_to_video` / `image_to_video` progress events through one-shot `abstractvision t2v` / `i2v`, interactive `/t2v` / `/i2v`, and Python/Core `on_progress(event)` callbacks.
- Backend API: add normalized `VideoProgressEvent` objects with phase, frame, total frame, step, total step, and progress fields while preserving backend `*_with_progress(...)` two-argument callbacks for generic progress bars.
- Capability filtering: keep Diffusers task support aligned with backend-specific registry requirements so MLX-Gen-only edit paths do not leak into Diffusers capability reports.
- AbstractCore integration: forward `on_progress` through plugin `t2v` / `i2v` requests so gateway/runtime callers can observe local MLX-Gen video runs without hardcoded backend plumbing.
- Docs/tests: document video progress usage across shell, REPL, Python, and AbstractCore examples; expand regression coverage for MLX-Gen progress bridging and quiet CLI flags.

## 0.3.15 - 2026-05-26

- CLI compatibility: canonicalize legacy `mflux/<model>` model prefixes to the `mlx-gen` runtime path for one-shot commands, matching `--provider mflux` and canonical `--provider mlx-gen` behavior.
- Tests: add one-shot `t2i`/`i2i` coverage proving the legacy `mflux` alias routes through the MLX-Gen backend without changing catalog/provider identity.

## 0.3.14 - 2026-05-26

- MLX-Gen migration: switch the Apple Silicon image runtime dependency to `mlx-gen`, expose `mlx-gen` as the canonical provider/engine, and keep `mflux` names as compatibility aliases.
- Catalog/model coverage: prioritize the AbstractFramework Hugging Face MLX-Gen q4/q8 prepared model collection, default q4 for local memory efficiency, and keep q8 variants discoverable for quality-focused runs.
- Local image support: expand the MLX-Gen backend/catalog surface for FLUX.2 klein/base, Qwen Image, Qwen Image Edit, Z-Image, Z-Image Turbo, and ERNIE Image Turbo q4/q8, including Qwen Image Edit `image_to_image` routing.
- Runtime dependency: require `mlx-gen>=0.18.5` for ERNIE Image Turbo q4/q8 prepared-folder support.
- Core/Gateway propagation: surface canonical `mlx-gen` provider/model metadata through AbstractCore and Gateway catalog paths while preserving legacy routed ids.
- Docs/tests: refresh CLI, backend, AbstractCore integration, and agent docs for MLX-Gen naming and q4/q8 guidance.

## 0.3.13 - 2026-05-23

- MFLUX edits: enable `image_to_image` for the curated FLUX.2 klein presets (`flux2-klein-4b`, `flux2-klein-9b`) so they surface in the playground edit UI and can be called through `VisionManager.edit_image(...)` (mask edits are not supported yet).
- Request normalization: map edit `strength` into the underlying MFLUX `image_strength` parameter and infer width/height from the input image when omitted so the UI/CLI behave consistently across backends.
- macOS GGUF policy: re-enable stable-diffusion.cpp GGUF presets on Apple Silicon by default and add an explicit opt-out (`ABSTRACTVISION_DISABLE_GGUF_ON_MACOS=1`) to hide GGUF catalog entries and reject GGUF execution for operators who want that behavior.
- Docs/tests: refresh README + core docs for the new MFLUX edit surface and the GGUF opt-out, and expand regression coverage for catalog surfacing and edit parameter plumbing.

## 0.3.12 - 2026-05-22

- Release packaging: publish the current clean tracked repository state as a fresh patch release.

## 0.3.11 - 2026-05-22

- Hugging Face cache integrity: treat repo-level `.incomplete` blobs as an incomplete snapshot, so interrupted Diffusers downloads no longer masquerade as a usable cached model.
- Qwen Image Edit downloads: `abstractvision download qwen-image-edit-2511 --provider diffusers` now resumes the real 16-bit snapshot instead of incorrectly short-circuiting on a partial cache.

## 0.3.10 - 2026-05-22

- Catalog/handles: make the curated Qwen Image Edit aliases consistent across the registry, downloads, and CLI catalog surfaces (`qwen-image-edit`, `qwen-image-edit-2509`, `qwen-image-edit-2511`), and re-verify all packaged Hugging Face repo ids in `vision_model_capabilities.json`.
- Runtime truth: quarantine unreliable local runtime task paths until they are re-validated. Local Diffusers `GLM-Image` is now hidden/disabled, local MFLUX is surfaced for `text_to_image` only, and local Diffusers `text_to_video` is marked experimental and disabled from the normal local surfaces.
- Playground/catalog UX: keep the per-task playground tabs with per-tab load/unload controls, but filter task selectors through backend-supported runtime truth so disabled local tasks do not surface. Update the `download` command messaging so curated 16-bit Diffusers snapshots are reported honestly instead of looking like a failed 8-bit fallback.
- Docs/backlog/tests: add the planned quarantine follow-up item, refresh the core docs around current local support policy, expand regression coverage for the runtime blacklists and catalog filtering, and regenerate `llms-full.txt`.

## 0.3.9 - 2026-05-21

- Local Diffusers video: implement the first in-process `text_to_video` path through `zai-org/CogVideoX-2b` / `THUDM/CogVideoX-2b`, including registry-backed request normalization, preload warmup, unload support, MPS-safe explicit FP16 device moves, and MP4 artifact outputs packaged through `ffmpeg`.
- Interactive surfaces: add one-shot `abstractvision t2v`, REPL `/t2v`, and playground `Text → Video` generation with backend/task-aware model discovery, progress reporting, and catalog surfacing for local video-capable models.
- AbstractCore integration: route plugin `t2v` / `i2v` calls through the same explicit backend binding path used by image generation, extend residency task aliases for video, and track request-warm local `text_to_video` models in the loaded-model inventory.
- Catalog/tests/docs: add curated capability/download metadata for `zai-org/CogVideoX-2b`, keep local image-edit surfaces intact, expand backend/CLI/playground/plugin regression coverage, refresh README/reference/FAQ/getting-started docs, and regenerate `llms-full.txt`.

## 0.3.8 - 2026-05-20

- Model registry/catalog: expand the curated `vision_model_capabilities.json` inventory with more current official or reputable vision model families and cross-platform download variants, tighten provider provenance, remove adapter-only repos from the standalone model catalog, and expose richer model notes / `task_specs` through the CLI catalog surfaces.
- Apple/MLX semantics: treat `mlx` as a download target rather than a runnable backend, fail fast on generic `mlx` provider/model routing across CLI, playground, and AbstractCore, and limit shipped MFLUX presets/docs to the families the backend actually supports today.
- GGUF / local-runtime routing: improve stable-diffusion.cpp bundle resolution for curated multi-artifact models and legacy Qwen GGUF repo ids, resolve curated `sdcpp` model keys consistently in both one-shot CLI and REPL paths, and make AbstractCore request-scoped `sdcpp` routing explicit while canonicalizing MFLUX aliases for backend reuse.
- Docs/policy/tests: add the ADR set and planned backlog items for curated catalog ownership, adapter-aware model graphs, and the long-term native MLX direction; refresh README/reference/FAQ/agent docs; regenerate `llms-full.txt`; and expand regression coverage for catalog aliases, GLM defaults, MFLUX routing, and local backend bundle selection.

## 0.3.7 - 2026-05-19

- AbstractCore plugin: add explicit local model residency control for in-process `diffusers`, `mflux`, and `sdcpp` backends through `load_resident_model(...)`, `list_loaded_models(...)`, `list_resident_models(...)`, and `unload_resident_model(...)`, with `load_model(...)` / `unload_model(...)` compatibility aliases for Core route adapters.
- Residency semantics: preserve explicit resident models across model switches while keeping the previous unload-on-switch behavior for non-resident request-warm backends, and report stable process-local `load_id` / `backend_kind` / `resident` metadata instead of relying on backend private fields.
- Safety/robustness: reject OpenAI/OpenAI-compatible HTTP backends for residency control even on localhost, normalize provider/task filters consistently, reject ambiguous unload requests, and keep unload behavior deterministic for injected local backends.
- Tests/docs: expand AbstractCore plugin coverage for local preload/list/unload flows, request-warm loaded-state reporting, task-aware loaded-model filters, injected backend residency, and switch-survival behavior; document the new local residency control surface and regenerate `llms-full.txt`.

## 0.3.6 - 2026-05-18

- Model registry/downloads: expand `vision_model_capabilities.json` and curated preset coverage for current Hugging Face text-to-image and image-to-image models, including FLUX.1/2, Qwen Image, ERNIE Image, GLM Image, Z-Image, SDXL, SD Turbo, and SD3.5. The registry now remains the packaged source of truth for both downloadable artifacts and task capability metadata.
- Cache/catalog: keep curated downloads in the Hugging Face cache by default, migrate older `~/models/<preset>` trees into that cache on first use, and align Diffusers/MFLUX cache discovery across CLI, REPL, playground, and AbstractCore so cached local models surface consistently.
- API-level normalization: move model-specific parameter normalization into shared backend hooks used by `VisionManager` and the playground server. Model constraints such as MFLUX distilled `guidance_scale=1.0`, unsupported negative prompts, and GLM `steps/guidance_scale/32-multiple dimensions` now apply consistently through the CLI/REPL, playground, and AbstractCore integration.
- Playground/API: expose structured per-model `task_specs` from `/v1/vision/models`, only enable the edit surface for models that advertise `image_to_image`, switch models by auto-loading the new selection, and truncate `b64_json` in logs instead of dumping the full base64 payload.
- AbstractCore/provider catalogs: keep remote provider/model listing robust when internet or API credentials are unavailable, and keep local provider/model catalogs aligned with the same cache-backed discovery used by the interactive surfaces.
- CLI/docs: keep `abstractvision cli` as the canonical interactive command (with `repl` as a legacy alias), expand model catalog/docs coverage, refresh backend/configuration/AbstractCore/playground references, and regenerate `llms.txt` / `llms-full.txt` for release.

## 0.3.5 - 2026-05-13

- AbstractCore plugin: accept runtime output metadata such as `provider` and `size` without rejecting image generation requests, and forward per-call image model selectors to OpenAI-compatible backends.


## 0.3.4 - 2026-05-09

- Packaging: constrain the optional `stable-diffusion-cpp-python` binding to
  `<0.4.6` for `sdcpp`, `local`, `apple`, `all`, `all-apple`, and `all-gpu`
  extras. Version `0.4.6` currently ships an sdist that fails native Linux
  builds because required vendored libwebm CMake files are missing.

## 0.3.3 - 2026-05-08

- Packaging: add shared native install profiles. `abstractvision[apple]` and
  `abstractvision[all-apple]` install the full local macOS vision stack;
  `abstractvision[gpu]` installs the Diffusers/Torch GPU stack; and
  `abstractvision[all-gpu]` installs Diffusers plus stable-diffusion.cpp
  bindings for full local GPU-capable deployments.
- Docs/tests: document and verify the Apple/GPU profile aliases while keeping
  the base package lightweight and remote/OpenAI-compatible by default.

## 0.3.2 - 2026-05-08

- AbstractCore plugin: switch the default backend id to `abstractvision:openai` with official OpenAI defaults, while keeping `abstractvision:openai-compatible` registered as a legacy-compatible backend id.
- OpenAI configuration: use standard `OPENAI_API_KEY`, `OPENAI_BASE_URL`, `OPENAI_IMAGE_MODEL_ID`, and `OPENAI_IMAGE_MODEL` aliases for the plugin default path; keep compatible endpoints explicit with `ABSTRACTVISION_BACKEND=openai-compatible` and `OPENAI_BASE_URL`.
- Provider catalogs: add OpenAI/OpenAI-compatible `/models` discovery through `VisionManager.list_provider_models(...)`, `abstractvision provider-models`, REPL `/provider-models`, and `llm.vision.list_provider_models(...)` in the AbstractCore plugin.
- API/contracts: add `ProviderModelInfo`, provider catalog backend hooks, task filtering for OpenAI image model catalogs, and JSON-safe bounded provider metadata at the AbstractCore plugin boundary.
- Docs/agent context: refresh AbstractCore integration, backend/configuration/API docs, playground production-boundary notes, completed backlog reports, `llms.txt`, and regenerated `llms-full.txt`.
- Tests: add coverage for OpenAI defaults, legacy compatible aliases, provider catalog parsing/filtering, plugin catalog exposure, CLI/REPL catalog commands, manager delegation, and a credential-gated live OpenAI catalog check.

## 0.3.1 - 2026-05-07

- CI/release: move GitHub Actions checkout/setup-python/artifact/release actions to Node 24-compatible major versions, removing the Node 20 deprecation warnings from release runs.
- Tests: strengthen packaging metadata coverage so Diffusers aliases and `local`/`all` runtime bundles cannot drift from their intended dependency sets.
- Docs: separate contributor-only extras from runtime install profiles and explicitly mark `dev` as unsuitable for application/runtime dependency declarations.

## 0.3.0 - 2026-05-07

- Packaging: make the base install lightweight. `pip install abstractvision` no longer installs Torch, Diffusers, Transformers, Pillow, or local inference runtimes by default.
- Extras: add canonical runtime profiles `abstractvision[openai]`, `abstractvision[openai-compatible]`, `abstractvision[diffusers]`, `abstractvision[sdcpp]`, `abstractvision[local]`, and `abstractvision[all]`; keep `huggingface`/`huggingface-dev` compatibility aliases.
- Runtime defaults: keep AbstractCore plugin and one-shot CLI remote-first, and stop the REPL/playground from silently selecting Diffusers when no backend is configured.
- Errors/tests/CI: improve local-backend missing-extra hints, add stronger packaging/import-light/OpenAI-compatible coverage, and split CI into lightweight base and local Diffusers paths.
- Docs: update install guidance, backend references, and internal backlog policy for explicit local runtime extras.

## 0.2.6 - 2026-05-06

- Docs: refresh install extras, AbstractCore integration, playground ownership, OpenAI-compatible request-shape notes, and backend/config references so the public docs match the current code.
- Agent docs: update `llms.txt`, include playground endpoint docs in the generated `llms-full.txt` bundle, and regenerate the AI-ready documentation from current sources.
- Contributing: clarify that `abstractvision[abstractcore]` is a compatibility marker and that AbstractCore is supplied by the host application.

## 0.2.5 - 2026-05-06

- Packaging: keep the default Diffusers backend installable while moving `stable-diffusion-cpp-python` out of the base dependency set and into the explicit `sdcpp`/`local` extras. This keeps AbstractCore plugin installs from failing on platforms where stable-diffusion.cpp bindings need a local native build.
- AbstractCore plugin: restore the OpenAI-compatible HTTP backend as the default while keeping local `diffusers` and `sdcpp` backends explicit through config/env.
- OpenAI-compatible backend: shape requests correctly for real OpenAI GPT image models while preserving local OpenAI-compatible extensions for unknown model ids.
- Playground: capture the active backend at job submission time so background jobs do not accidentally run on a newly selected model.
- Docs/tests: clarify the default install shape, document when to install `abstractvision[sdcpp]`, and add metadata/OpenAI/playground coverage so these paths do not regress.

## 0.2.4 - 2026-05-06

- Playground: add a self-contained `abstractvision playground` command that serves both the web UI and `/v1/vision/*` API locally, so playground testing no longer depends on an AbstractCore server.
- Playground: package the HTML asset in the wheel, default the UI to the serving origin, and avoid stale persisted API URLs that could keep calling an older AbstractCore endpoint.
- Playground model loading: accept raw Hugging Face ids such as `runwayml/stable-diffusion-v1-5` directly, while still accepting explicit backend prefixes like `diffusers/...`, `sdcpp/...`, and `openai-compatible/...`.
- Packaging/CI: keep AbstractCore out of AbstractVision dependency metadata and test workflows; AbstractCore remains an optional host integration loaded lazily when present.
- Docs/tests: refresh playground docs around the self-contained local server and add coverage for cached model listing, raw model loading, playground jobs, and tool integration without installing AbstractCore.

## 0.2.3 - 2026-05-06

- AbstractCore plugin: support local Diffusers and stable-diffusion.cpp backends through `llm.vision`, not only OpenAI-compatible HTTP. The default plugin path now matches the REPL default: local Diffusers with `runwayml/stable-diffusion-v1-5`, cache-only unless `ABSTRACTVISION_DIFFUSERS_ALLOW_DOWNLOAD=1` is set.
- AbstractCore plugin: keep OpenAI-compatible usage available with `ABSTRACTVISION_BACKEND=openai` plus `OPENAI_BASE_URL`, and preserve artifact-store behavior for generated media outputs.

## 0.2.2 - 2026-05-06

- Release automation: add GitHub Actions CI/release workflows, issue templates, pre-commit config, MkDocs config, PyPI trusted publishing, GitHub Releases, and release-time docs deployment to `gh-pages`.
- Packaging: support Python 3.9-3.13, modernize license metadata, include package data explicitly, and add test/docs/dev extras.
- Defaults: make the REPL default to local Diffusers with `runwayml/stable-diffusion-v1-5`, `ABSTRACTVISION_DIFFUSERS_DEVICE=auto`, and cache-only/offline runtime downloads disabled by default.
- Diffusers backend: keep `allow_download=False` as the default, force Hugging Face offline/cache-only env during loads/calls, disable implicit HF token use offline, and load from cached snapshot paths when present.
- Diffusers backend: ignore unknown REPL `extra` flags that the pipeline `__call__` does not accept, avoiding `unexpected keyword argument` crashes.
- Diffusers backend: add better fp16 variant fallback behavior, MPS dtype/invalid-output retry handling, LoRA/Rapid-AIO offline handling, and clearer missing-local-model errors.
- Capability registry: add `black-forest-labs/FLUX.2-klein-9B` and normalize FLUX license id to `flux-non-commercial-license`.
- Docs: refresh quickstarts around Stable Diffusion 1.5 first, add clearer macOS Metal/NVIDIA CUDA/CPU guidance, expand stable-diffusion.cpp notes, and point users to cache-only local workflows.
- Tooling: add `scripts/download_model_sets.py` for explicit heavyweight model downloads (Stable Diffusion 1.5, FLUX 2 GGUF/Diffusers, and Qwen Image snapshots).
- Cleanup: remove the misspelled duplicate `ACKNOWLEDMENTS.md`.

## 0.2.1

- Documentation refresh for public release:
  - add `docs/api.md` and strengthen cross-linking between README and docs
  - add `CONTRIBUTING.md`, `SECURITY.md`, and `ACKNOWLEDGMENTS.md`
  - add `llms.txt` and generated `llms-full.txt` for agent-oriented context
  - clarify playground/server endpoint expectations (`/v1/vision/*`)

## 0.2.0

- Add stable-diffusion.cpp (`sd-cli`) backend for local GGUF diffusion models.
- REPL: forward unknown `--flags` as backend `extra` parameters.
- Add a tiny web playground (`playground/vision_playground.html`) for testing via AbstractCore Server vision endpoints (`/v1/vision/*`).

## 0.1.0

- Initial MVP: capability registry + schema validation.
- Artifact-first outputs via `LocalAssetStore` and runtime adapter.
- OpenAI-compatible HTTP backend for image generation/editing (optional video endpoints via config).
- Local Diffusers backend for images (opt-in deps).
- AbstractCore tool integration (`make_vision_tools`) with artifact refs.
- CLI/REPL for interactive manual testing.
--- >8 --- END FILE: CHANGELOG.md --- >8 ---

--- 8< --- FILE: pyproject.toml --- 8< ---
```toml
[build-system]
requires = ["setuptools>=77.0.0", "wheel"]
build-backend = "setuptools.build_meta"

[project]
name = "abstractvision"
dynamic = ["version"]
description = "Model-agnostic generative vision abstractions (image/video) for the Abstract ecosystem"
keywords = [
  "vision",
  "image-generation",
  "text-to-image",
  "image-to-video",
  "text-to-video",
  "mlx-gen",
  "mlx",
  "diffusers",
  "stable-diffusion",
  "abstractcore",
  "generative-ai",
  "openai-compatible",
]
readme = "README.md"
license = "MIT"
license-files = ["LICENSE"]
authors = [{name = "Laurent-Philippe Albou", email = "contact@abstractcore.ai"}]
requires-python = ">=3.9"
classifiers = [
  "Development Status :: 3 - Alpha",
  "Intended Audience :: Developers",
  "Operating System :: OS Independent",
  "Programming Language :: Python :: 3",
  "Programming Language :: Python :: 3.9",
  "Programming Language :: Python :: 3.10",
  "Programming Language :: Python :: 3.11",
  "Programming Language :: Python :: 3.12",
  "Programming Language :: Python :: 3.13",
  "Topic :: Multimedia",
  "Topic :: Scientific/Engineering :: Artificial Intelligence",
]
# Base install is intentionally lightweight. Local inference runtimes are
# explicit extras so OpenAI-compatible/AbstractCore plugin hosts do not pull
# Torch, Diffusers, CUDA-adjacent wheels, or local model stacks by default.
dependencies = []

[project.urls]
Homepage = "https://github.com/lpalbou/abstractvision"
Repository = "https://github.com/lpalbou/abstractvision"

[project.scripts]
abstractvision = "abstractvision.cli:main"

[project.entry-points."abstractcore.capabilities_plugins"]
abstractvision = "abstractvision.integrations.abstractcore_plugin:register"

[project.optional-dependencies]
# Official OpenAI image endpoint intent. The backend is stdlib-only today and
# does not require the OpenAI SDK.
openai = []

# Generic OpenAI-shaped HTTP endpoint intent (local or remote /v1 servers).
# The backend is stdlib-only today; keep this extra for readable install commands.
openai-compatible = []

# Local image generation via Hugging Face Diffusers/Torch.
diffusers = [
  "diffusers>=0.36.0",
  "torch>=2.0,<3.0.0",
  "torchvision>=0.15.0",
  "transformers>=4.0,<6.0.0",
  "accelerate>=0.0",
  "safetensors>=0.0",
  "huggingface_hub>=0.24.0",
  # Needed by T5 tokenizers used in SD3/FLUX and some other diffusion pipelines.
  "sentencepiece>=0.1.99",
  # Some HF tokenizers/pipelines require protobuf at runtime.
  "protobuf>=3.20.0",
  # Used by some modern diffusion architectures.
  "einops>=0.7.0",
  # LoRA adapter support in Diffusers.
  "peft>=0.10.0",
  # GGUF transformer loading in Diffusers.
  "gguf>=0.10.0",
  "Pillow>=9.0",
]

# Local generation via stable-diffusion.cpp python bindings (pip-installable).
sdcpp = [
  "stable-diffusion-cpp-python>=0.4.2,<0.4.6",
  "huggingface_hub>=0.24.0",
  "Pillow>=9.0",
]

# Native Apple image generation via MLX-Gen. Kept optional because it pulls
# Apple-specific local runtime dependencies.
mlx-gen = [
  "mlx-gen>=0.40.3,<0.41.0; (platform_system == 'Darwin' or platform_system == 'Linux') and python_version >= '3.10'",
  "mlx>=0.32.4; platform_system == 'Darwin' and python_version >= '3.10'",
]

# Compatibility extra for callers that still install the historical MFLUX extra.
# It intentionally installs MLX-Gen, not the retired standalone mflux package.
mflux = [
  "mlx-gen>=0.40.3,<0.41.0; (platform_system == 'Darwin' or platform_system == 'Linux') and python_version >= '3.10'",
  "mlx>=0.32.4; platform_system == 'Darwin' and python_version >= '3.10'",
]

# Native Apple Python install profile. Docker cannot expose Apple's Metal stack,
# but direct macOS installs can use PyTorch/MPS, stable-diffusion.cpp/Metal, and MLX-Gen/MLX.
apple = [
  "diffusers>=0.36.0",
  "torch>=2.0,<3.0.0",
  "torchvision>=0.15.0",
  "transformers>=4.0,<6.0.0",
  "accelerate>=0.0",
  "safetensors>=0.0",
  "huggingface_hub>=0.24.0",
  "sentencepiece>=0.1.99",
  "protobuf>=3.20.0",
  "einops>=0.7.0",
  "peft>=0.10.0",
  "gguf>=0.10.0",
  "stable-diffusion-cpp-python>=0.4.2,<0.4.6",
  "mlx-gen>=0.40.3,<0.41.0; (platform_system == 'Darwin' or platform_system == 'Linux') and python_version >= '3.10'",
  "mlx>=0.32.4; platform_system == 'Darwin' and python_version >= '3.10'",
  "Pillow>=9.0",
]

# NVIDIA/Linux install profile: Diffusers/torch only, no MLX. MLX-Gen is Apple-first
# and AbstractCore never routes it on CUDA hosts; its Linux build pulls mlx[cuda13]
# (~2.1 GB of CUDA 13 wheels) and requires glibc >= 2.35. Opt in explicitly with
# the `mlx-gen` extra to measure it on CUDA (backlog 030).
gpu = [
  "diffusers>=0.36.0",
  "torch>=2.0,<3.0.0",
  "torchvision>=0.15.0",
  "transformers>=4.0,<6.0.0",
  "accelerate>=0.0",
  "safetensors>=0.0",
  "huggingface_hub>=0.24.0",
  "sentencepiece>=0.1.99",
  "protobuf>=3.20.0",
  "einops>=0.7.0",
  "peft>=0.10.0",
  "gguf>=0.10.0",
  "Pillow>=9.0",
]

# Compatibility extra for callers that still request the historical Diffusers extra.
huggingface = [
  "diffusers>=0.36.0",
  "torch>=2.0,<3.0.0",
  "torchvision>=0.15.0",
  "transformers>=4.0,<6.0.0",
  "accelerate>=0.0",
  "safetensors>=0.0",
  "huggingface_hub>=0.24.0",
  "sentencepiece>=0.1.99",
  "protobuf>=3.20.0",
  "einops>=0.7.0",
  "peft>=0.10.0",
  "gguf>=0.10.0",
  "Pillow>=9.0",
]

# Convenience: installs both local backends (Diffusers + stable-diffusion.cpp python bindings).
local = [
  "diffusers>=0.36.0",
  "torch>=2.0,<3.0.0",
  "torchvision>=0.15.0",
  "transformers>=4.0,<6.0.0",
  "accelerate>=0.0",
  "safetensors>=0.0",
  "huggingface_hub>=0.24.0",
  "sentencepiece>=0.1.99",
  "protobuf>=3.20.0",
  "einops>=0.7.0",
  "peft>=0.10.0",
  "gguf>=0.10.0",
  "stable-diffusion-cpp-python>=0.4.2,<0.4.6",
  "Pillow>=9.0",
]

# Convenience: installs every runtime backend, but not contributor tooling.
all = [
  "diffusers>=0.36.0",
  "torch>=2.0,<3.0.0",
  "torchvision>=0.15.0",
  "transformers>=4.0,<6.0.0",
  "accelerate>=0.0",
  "safetensors>=0.0",
  "huggingface_hub>=0.24.0",
  "sentencepiece>=0.1.99",
  "protobuf>=3.20.0",
  "einops>=0.7.0",
  "peft>=0.10.0",
  "gguf>=0.10.0",
  "stable-diffusion-cpp-python>=0.4.2,<0.4.6",
  "mlx-gen>=0.40.3,<0.41.0; (platform_system == 'Darwin' or platform_system == 'Linux') and python_version >= '3.10'",
  "mlx>=0.32.4; platform_system == 'Darwin' and python_version >= '3.10'",
  "Pillow>=9.0",
]

# Full native Apple profile: every runtime backend relevant to macOS/Apple
# Silicon, excluding NVIDIA/CUDA-specific stacks.
all-apple = [
  "diffusers>=0.36.0",
  "torch>=2.0,<3.0.0",
  "torchvision>=0.15.0",
  "transformers>=4.0,<6.0.0",
  "accelerate>=0.0",
  "safetensors>=0.0",
  "huggingface_hub>=0.24.0",
  "sentencepiece>=0.1.99",
  "protobuf>=3.20.0",
  "einops>=0.7.0",
  "peft>=0.10.0",
  "gguf>=0.10.0",
  "stable-diffusion-cpp-python>=0.4.2,<0.4.6",
  "mlx-gen>=0.40.3,<0.41.0; (platform_system == 'Darwin' or platform_system == 'Linux') and python_version >= '3.10'",
  "mlx>=0.32.4; platform_system == 'Darwin' and python_version >= '3.10'",
  "Pillow>=9.0",
]

# Full NVIDIA profile: Diffusers/torch + stable-diffusion.cpp, no MLX. On Windows,
# stable-diffusion-cpp-python is left out: PyPI ships only its source build, which needs MSVC
# (elevated install); Diffusers on PyTorch's CUDA build covers image generation there.
all-gpu = [
  "diffusers>=0.36.0",
  "torch>=2.0,<3.0.0",
  "torchvision>=0.15.0",
  "transformers>=4.0,<6.0.0",
  "accelerate>=0.0",
  "safetensors>=0.0",
  "huggingface_hub>=0.24.0",
  "sentencepiece>=0.1.99",
  "protobuf>=3.20.0",
  "einops>=0.7.0",
  "peft>=0.10.0",
  "gguf>=0.10.0",
  "stable-diffusion-cpp-python>=0.4.2,<0.4.6; sys_platform != 'win32'",
  "Pillow>=9.0",
]

# NOTE: PyPI rejects VCS/direct URL dependencies in package metadata.
# If you need Diffusers "main" for unreleased pipelines, install it explicitly *after*:
#   pip install "abstractvision[diffusers-dev]"
#   pip install "diffusers @ git+https://github.com/huggingface/diffusers@main"
diffusers-dev = [
  "diffusers>=0.36.0",
  "torch>=2.0,<3.0.0",
  "torchvision>=0.15.0",
  "transformers>=5.0",
  "accelerate>=0.0",
  "safetensors>=0.0",
  "huggingface_hub>=0.24.0",
  "sentencepiece>=0.1.99",
  "protobuf>=3.20.0",
  "einops>=0.7.0",
  "peft>=0.10.0",
  "gguf>=0.10.0",
  "Pillow>=9.0",
]

# Compatibility extra for callers that still request the historical dev extra.
huggingface-dev = [
  "diffusers>=0.36.0",
  "torch>=2.0,<3.0.0",
  "torchvision>=0.15.0",
  "transformers>=5.0",
  "accelerate>=0.0",
  "safetensors>=0.0",
  "huggingface_hub>=0.24.0",
  "sentencepiece>=0.1.99",
  "protobuf>=3.20.0",
  "einops>=0.7.0",
  "peft>=0.10.0",
  "gguf>=0.10.0",
  "Pillow>=9.0",
]

# Compatibility extra only. AbstractVision is loaded by AbstractCore as a plugin,
# so it deliberately does not install AbstractCore as a dependency.
abstractcore = []

# Local model download helpers. Kept optional so the base package remains
# dependency-free for OpenAI-compatible proxy hosts.
models = [
  "huggingface_hub>=0.24.0",
]

# Test dependencies used by local contributors. CI installs the package with
# `--no-deps` and then adds only these light test-time dependencies.
test = [
  "pytest>=7.0.0",
  "Pillow>=9.0",
  "torch>=2.0,<3.0.0",
]

# Documentation dependencies.
docs = [
  "mkdocs>=1.5.0",
  "mkdocs-material>=9.0.0",
]

# Complete local development environment.
dev = [
  "pytest>=7.0.0",
  "Pillow>=9.0",
  "torch>=2.0,<3.0.0",
  "diffusers>=0.36.0",
  "torchvision>=0.15.0",
  "transformers>=4.0,<6.0.0",
  "accelerate>=0.0",
  "safetensors>=0.0",
  "sentencepiece>=0.1.99",
  "protobuf>=3.20.0",
  "einops>=0.7.0",
  "peft>=0.10.0",
  "mkdocs>=1.5.0",
  "mkdocs-material>=9.0.0",
  "build>=1.0.0",
  "twine>=4.0.0",
  "ruff>=0.5.7",
  "black>=23.0.0",
  "pre-commit>=3.0.0",
]

[tool.setuptools]
packages = [
  "abstractvision",
  "abstractvision.assets",
  "abstractvision.backends",
  "abstractvision.integrations",
  "abstractvision.playground",
]

[tool.setuptools.package-dir]
"" = "src"

[tool.setuptools.dynamic]
version = {attr = "abstractvision.__version__"}

[tool.setuptools.package-data]
abstractvision = ["assets/*.json", "assets/*.metal", "playground/*.html"]

[tool.black]
line-length = 100
target-version = ["py39"]
include = '\.pyi?$'
extend-exclude = '''
/(
  \.eggs
  | \.git
  | \.hg
  | \.mypy_cache
  | \.tox
  | \.venv
  | build
  | dist
)/
'''

[tool.isort]
profile = "black"
multi_line_output = 3
line_length = 100
known_first_party = ["abstractvision"]

[tool.ruff]
target-version = "py39"
line-length = 100

[tool.ruff.lint]
select = [
  "E",
  "W",
  "F",
  "I",
  "B",
  "C4",
  "UP",
]
ignore = [
  "E501",
  "B008",
  "B904",
]

[tool.ruff.lint.per-file-ignores]
"__init__.py" = ["F401"]
"tests/**/*" = ["B011"]

[tool.pytest.ini_options]
pythonpath = ["src"]
minversion = "7.0"
addopts = "-ra --tb=short --strict-markers --strict-config --disable-warnings -p no:cacheprovider"
testpaths = ["tests"]
python_files = ["test_*.py"]
python_functions = ["test_*"]
python_classes = ["Test*"]
```
--- >8 --- END FILE: pyproject.toml --- >8 ---
