safetensors
Install
safetensors on PyPI
pip
pip install safetensorsuv
uv add safetensorspoetry
poetry add safetensorsPackage facts
| License | not declared (permissive) |
| Python support | supports the current Python release (>=3.10) |
| Install friction | medium — platform-specific wheel |
| Runtime dependencies | none |
| Maintenance | actively maintained — 65 days since the last release |
| Last repo commit | |
| First released | |
| Popularity | one of the top 1,000 most-downloaded packages on PyPI (30-day window, as of 2026-08-13) |
| Known vulnerabilities | none known (OSV.dev, checked 2026-08-13) |
Evidence: safetensors-0.8.0-cp310-abi3-macosx_10_12_x86_64.whl; safetensors-0.8.0-cp310-abi3-macosx_11_0_arm64.whl; safetensors-0.8.0-cp310-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl; safetensors-0.8.0-cp310-abi3-manylinux_2_17_armv7l.manylinux2014_armv7l.whl; safetensors-0.8.0-cp310-abi3-manylinux_2_17_ppc64le.manylinux2014_ppc64le.whl; safetensors-0.8.0-cp310-abi3-manylinux_2_17_s390x.manylinux2014_s390x.whl; safetensors-0.8.0-cp310-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl; safetensors-0.8.0-cp310-abi3-manylinux_2_31_riscv64.whl; safetensors-0.8.0-cp310-abi3-manylinux_2_5_i686.manylinux1_i686.whl; safetensors-0.8.0-cp310-abi3-musllinux_1_2_aarch64.whl; safetensors-0.8.0-cp310-abi3-musllinux_1_2_armv7l.whl; safetensors-0.8.0-cp310-abi3-musllinux_1_2_i686.whl; safetensors-0.8.0-cp310-abi3-musllinux_1_2_x86_64.whl; safetensors-0.8.0-cp310-abi3-win32.whl; safetensors-0.8.0-cp310-abi3-win_amd64.whl; safetensors-0.8.0-cp310-abi3-win_arm64.whl
About safetensors
from the package's own PyPI description — quoted content, verbatim
Installation
pip install safetensors
Usage
Numpy
from safetensors.numpy import save_file, load_file
import numpy as np
tensors = {
"a": np.zeros((2, 2)),
"b": np.zeros((2, 3), dtype=np.uint8)
}
save_file(tensors, "./model.safetensors")
# Now loading
loaded = load_file("./model.safetensors")
Torch
from safetensors.torch import save_file, load_file
import torch
tensors = {
"a": torch.zeros((2, 2)),
"b": torch.zeros((2, 3), dtype=torch.uint8)
}
save_file(tensors, "./model.safetensors")
# Now loading
loaded = load_file("./model.safetensors")
Developing
# inside ./safetensors/bindings/python
pip install .[dev]
Should be enough to install this library locally.
Testing
# inside ./safetensors/bindings/python
pip install .[dev]
pytest -sv tests/
Read as markdown · JSON record · Source repository · Homepage
AI interpretation — verify before relying
AI-generated interpretation of the package facts above; every digit, version, license, or vulnerability id it cites is grounded in the facts already shown on this page
Serializes and deserializes tensors to a safe, language-agnostic binary format designed for secure model storage and transfer across frameworks.
Medium install friction due to compiled wheels across many platforms, but pre-built binaries are available for Python 3.10+. Active maintenance with recent commits and no runtime dependencies simplifies deployment.
Licensed under Apache Software License (permissive), allowing commercial and private use with minimal restrictions.
Usage
pip install safetensors
from safetensors.numpy import save_file, load_file
tensors = {"a": [[0, 0], [0, 0]]}
save_file(tensors, "model.safetensors")
loaded = load_file("model.safetensors")
Requires Python 3.10 or later; compiled wheels available for common platforms but may require build tools on unsupported architectures.
Verdict: A production-stable, actively maintained serialization library with no known vulnerabilities, zero runtime dependencies, and broad platform support. Medium install friction is offset by pre-built wheels and permissive licensing, making it a low-risk choice for model persistence.
Needs verification
- Performance characteristics (serialization speed, file size overhead) relative to alternatives.
- Compatibility guarantees across safetensors versions for forward/backward reading of saved files.
- Framework-specific integration details beyond the documented usage patterns.
Similar packages
permissive · top 1,000 on PyPI
lazy-loaderpermissive · top 1,000 on PyPI
einopspermissive · top 1,000 on PyPI
itsdangerouspermissive · top 1,000 on PyPI
torchvisionpermissive · top 1,000 on PyPI
opt-einsumpermissive · top 1,000 on PyPI
tensorboardpermissive · top 1,000 on PyPI
ml-dtypespermissive · top 1,000 on PyPI
transformerspermissive · top 1,000 on PyPI
keyringpermissive · top 1,000 on PyPI