Install & Compatibility
Where this runs
No compatibility data collected yet for this library.
Code
Verified usage
Verified import paths — ran on the pinned version, not inferred.
spox
✓ import spox
✗ import spox as _
No common wrong import; but avoid importing private modules like spox._future directly.
make_onnx_model
✓ from spox import build, make_onnx_model
✗ from spox import make_model
The function is named make_onnx_model, not make_model.
onnx opset
✓ from spox.opset.ai.onnx import v17
Use specific opset versions like v17, v18, etc., not generic 'onnx'.
Construct an ONNX model for Y = A*X + B using Spox.
import spox
from spox import build, make_onnx_model
from spox.opset.ai.onnx import v17 as op
# Build a simple model: Y = A * X + B
def build_linear_model():
A = spox.argument(spox.Tensor(spox.Float, (3, 3)))
X = spox.argument(spox.Tensor(spox.Float, (3, None)))
B = spox.argument(spox.Tensor(spox.Float, (1, None)))
Y = op.add(op.matmul(A, X), B)
return build(inputs={'A': A, 'X': X, 'B': B}, outputs={'Y': Y})
model = build_linear_model()
print(make_onnx_model(model).SerializeToString()[:100])
Errors
Common errors & fixes
AttributeError: module 'spox' has no attribute 'make_model'
The function is named make_onnx_model, not make_model.
fixUse from spox import make_onnx_model or correct the function name.
ValueError: Failed to infer shape for op MatMul
Missing or mismatched shape information for an input or output tensor.
fixEnsure all argument tensors have correct shapes; use spox.Tensor with dimension symbols or None for unknown.
spox.exceptions.SpoxValueError: Operator 'GroupNormalization' not found in opset 'ai.onnx.v18'
group_normalization was removed from v18, v19, v20 in spox 0.14.0.
fixUse later opset version (v21+) or alternate implementation.
Upgrade
Version history
0.17.1latest on PyPI · released Feb 17, 2026
Audit
Dependencies
onnxrequiredCore dependency for ONNX protobuf model representation and opsets.
ml_dtypesoptionalOptional; needed for extended data types like bfloat16, float8, int4.