2026-02-03 21:21:07 +01:00
2026-02-03 22:10:04 +01:00

tensors

A CLI tool for working with safetensor files and CivitAI models.

Features

  • Read safetensor metadata - Parse headers, count tensors, extract embedded metadata
  • CivitAI integration - Search models, fetch info, identify files by hash
  • Download models - Resume support, type-based default paths
  • Hash verification - SHA256 computation with progress display

Installation

# Clone and install
git clone https://github.com/aladac/tensors.git
cd tensors
uv sync

# Or install directly
uv pip install git+https://github.com/aladac/tensors.git

Usage

Search CivitAI

# Search by query
tsr search "illustrious"

# Filter by type and base model
tsr search -t lora -b sdxl

# Sort by newest, limit results
tsr search -t checkpoint -s newest -n 10

Get Model Info

# Get model info by ID (shows all versions)
tsr get 12345

# Get specific version info
tsr get -v 67890

Download Models

# Download latest version of a model
tsr dl -m 12345

# Download specific version
tsr dl -v 67890

# Download by hash lookup
tsr dl -H ABC123...

# Custom output directory
tsr dl -m 12345 -o ./models

Inspect Local Files

# Read safetensor file and lookup on CivitAI
tsr info model.safetensors

# Skip CivitAI lookup
tsr info model.safetensors --skip-civitai

# Output as JSON
tsr info model.safetensors -j

# Save metadata files
tsr info model.safetensors --save-to ./metadata

Configuration

# Show current config
tsr config

# Set CivitAI API key
tsr config --set-key YOUR_API_KEY

Configuration

Config file: ~/.config/tensors/config.toml

[api]
civitai_key = "your-api-key"

Or set via environment variable:

export CIVITAI_API_KEY="your-api-key"

Default Paths

Models are downloaded to XDG-compliant paths:

Type Path
Checkpoint ~/.local/share/tensors/models/checkpoints/
LoRA ~/.local/share/tensors/models/loras/
Metadata ~/.local/share/tensors/metadata/

Search Options

Option Values
-t, --type checkpoint, lora, embedding, vae, controlnet, locon
-b, --base sd15, sdxl, pony, flux, illustrious
-s, --sort downloads, rating, newest
-n, --limit Number of results (default: 20)

Development

# Install dev dependencies
uv sync --group dev

# Run tests
uv run pytest

# Lint and format
uv run ruff check .
uv run ruff format .

# Type check
uv run mypy tensors.py

License

MIT

S
Description
CLI toolkit for inspecting safetensor files, downloading CivitAI models, and generating images.
Readme 8.4 MiB
Languages
Python 98.4%
Shell 1.1%
Ruby 0.3%
Just 0.1%