{"id":28253,"library":"spox","title":"Spox","description":"A framework for constructing ONNX computational graphs programmatically. Current version 0.17.1, supports Python >=3.10, and follows a monthly/quarterly release cadence. Spox provides a high-level API to build, inline, and manipulate ONNX models with type-safe operators and shape inference.","status":"active","version":"0.17.1","language":"python","source_language":"en","source_url":"https://github.com/quantco/spox","tags":["onnx","computational-graph","deep-learning","model-building"],"install":[{"cmd":"pip install spox","lang":"bash","label":"Install from PyPI"}],"dependencies":[{"reason":"Core dependency for ONNX protobuf model representation and opsets.","package":"onnx","optional":false},{"reason":"Optional; needed for extended data types like bfloat16, float8, int4.","package":"ml_dtypes","optional":true}],"imports":[{"note":"No common wrong import; but avoid importing private modules like spox._future directly.","wrong":"import spox as _","symbol":"spox","correct":"import spox"},{"note":"The function is named make_onnx_model, not make_model.","wrong":"from spox import make_model","symbol":"make_onnx_model","correct":"from spox import build, make_onnx_model"},{"note":"Use specific opset versions like v17, v18, etc., not generic 'onnx'.","symbol":"onnx opset","correct":"from spox.opset.ai.onnx import v17"}],"quickstart":{"code":"import spox\nfrom spox import build, make_onnx_model\nfrom spox.opset.ai.onnx import v17 as op\n\n# Build a simple model: Y = A * X + B\ndef build_linear_model():\n    A = spox.argument(spox.Tensor(spox.Float, (3, 3)))\n    X = spox.argument(spox.Tensor(spox.Float, (3, None)))\n    B = spox.argument(spox.Tensor(spox.Float, (1, None)))\n    Y = op.add(op.matmul(A, X), B)\n    return build(inputs={'A': A, 'X': X, 'B': B}, outputs={'Y': Y})\n\nmodel = build_linear_model()\nprint(make_onnx_model(model).SerializeToString()[:100])","lang":"python","description":"Construct an ONNX model for Y = A*X + B using Spox."},"warnings":[{"fix":"Use group_normalization from a later opset version (v21+) or implement manually.","message":"Removal of group_normalization constructor: spox.opset.ai.onnx.v18.group_normalization and its re-exports in v19, v20 removed in 0.14.0 due to upstream deprecation.","severity":"breaking","affected_versions":">=0.14.0"},{"fix":"Replace usage with ndonnx.","message":"Importing spox._future.operator_overloading triggers DeprecationWarning since 0.13.0. Consider using ndonnx as an alternative.","severity":"deprecated","affected_versions":">=0.13.0"},{"fix":"Ensure Python version >=3.10, or pin spox<0.17.0 for 3.9 compat.","message":"Python version requirement: Spox 0.17.0+ requires Python >=3.10. Older versions may support down to 3.8.","severity":"gotcha","affected_versions":">=0.17.0"}],"env_vars":null,"last_verified":"2026-05-09T00:00:00.000Z","next_check":"2026-08-07T00:00:00.000Z","problems":[{"fix":"Use from spox import make_onnx_model or correct the function name.","cause":"The function is named make_onnx_model, not make_model.","error":"AttributeError: module 'spox' has no attribute 'make_model'"},{"fix":"Ensure all argument tensors have correct shapes; use spox.Tensor with dimension symbols or None for unknown.","cause":"Missing or mismatched shape information for an input or output tensor.","error":"ValueError: Failed to infer shape for op MatMul"},{"fix":"Use later opset version (v21+) or alternate implementation.","cause":"group_normalization was removed from v18, v19, v20 in spox 0.14.0.","error":"spox.exceptions.SpoxValueError: Operator 'GroupNormalization' not found in opset 'ai.onnx.v18'"}],"ecosystem":"pypi","meta_description":null,"install_score":null,"install_tag":null,"quickstart_score":null,"quickstart_tag":null}