Skip to main content

Sawvant Python SDK

The official Python client for the Sawvant Cutting Optimization API.

  • API version: 1.0.0
  • Package version: 0.1.0
  • Requires Python 3.8+

Installation

pip install sawvant

Quick Start

import time

import sawvant
from sawvant import (
    CutDirection,
    GrainDirection,
    JobsApi,
    Machine,
    OptimizationApi,
    OptimizeRequest,
    Part,
    Sheet,
)

configuration = sawvant.Configuration(
    host='https://api.sawvant.com',
    api_key={'apiKey': 'sk_your_api_key_here'},
)

with sawvant.ApiClient(configuration) as client:
    optimization = OptimizationApi(client)
    jobs = JobsApi(client)

    # Submit an optimization job. Sizes are in mm.
    request = OptimizeRequest(
        sheets=[
            Sheet(id='board', length=2800, width=2070, quantity=10, grain=GrainDirection.NONE),
        ],
        parts=[
            Part(id='panel-a', length=600, width=400, quantity=10, grain=GrainDirection.NONE),
            Part(id='panel-b', length=300, width=200, quantity=20, grain=GrainDirection.NONE),
        ],
        machine=Machine(blade_thickness=4.4, max_levels=3, cut_direction=CutDirection.DEFAULT),
    )

    job = optimization.create_optimization(request)
    print('Job created:', job.job_id)

    # Poll for results
    result = jobs.get_job(job.job_id)
    while result.status in ('pending', 'running'):
        time.sleep(1)
        result = jobs.get_job(job.job_id)

    if result.status == 'completed':
        print('Optimization complete:', result.result)
    else:
        print('Job failed:', result.error)

SSE Streaming

Stream real-time progress events as the job runs with sawvant.streaming.stream_job. The helper uses httpx, so install the SDK with the streaming extra:

pip install "sawvant[streaming]"

Then stream the events, passing the job_id that create_optimization returned:

from sawvant.streaming import stream_job

job_id = '550e8400-e29b-41d4-a716-446655440000'

for event in stream_job(job_id, 'sk_your_api_key_here'):
    if event.type == 'progress':
        print('Progress:', event.data['progress'])
    elif event.type == 'completed':
        print('Done:', event.data['result'])
        break
    elif event.type == 'failed':
        print('Failed:', event.data.get('error'))
        break

stream_job also accepts base_url (default https://api.sawvant.com) and timeout in seconds. event.data is a plain dict with the job fields.

When a completed event arrives, the SDK fetches the full job via GET /v1/jobs/{id} and puts it in the event, so event.data['result'] holds the complete result. The server leaves the result out of stream events to keep them small. Other events are passed on as received.

Configuration

import os

import sawvant

configuration = sawvant.Configuration(
    host='https://api.sawvant.com',
    api_key={'apiKey': os.environ['SAWVANT_API_KEY']},
    retries=3,
)
Option Description
host API base URL (default: https://api.sawvant.com)
api_key Dictionary with an apiKey entry holding your sk_... key
retries Number of retries for failed requests

Every API method also takes _request_timeout in seconds, for example jobs.get_job(job_id, _request_timeout=30).

API Reference

All endpoints are relative to https://api.sawvant.com.

Class Method HTTP Path Description
OptimizationApi create_optimization POST /v1/optimize Submit a new cutting optimization job
OptimizationApi create_batch_optimization POST /v1/optimize/batch Submit several optimization jobs at once
JobsApi get_job GET /v1/jobs/{id} Retrieve job status and result
JobsApi get_job_diagram_svg GET /v1/jobs/{id}/diagram Cutting diagram as SVG
JobsApi get_job_diagram_pdf GET /v1/jobs/{id}/diagram.pdf Cutting diagram as PDF
stream_job (from sawvant.streaming) GET /v1/jobs/{id}/stream Stream job progress via SSE
SystemApi get_health GET /health Health check (no auth required)
SystemApi list_tiers GET /v1/tiers List subscription tiers (no auth required)

License

Apache-2.0. See LICENSE.

Metadata

Release files for sawvant 1.1.2

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for sawvant 1.1.2
File Size Uploaded Provenance Actions
sawvant-1.1.2.tar.gz 47.2 kB With provenance Details for sawvant-1.1.2.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for sawvant 1.1.2
File Interpreter ABI Platform Actions
sawvant-1.1.2-py3-none-any.whl Python 3 none any Details for sawvant-1.1.2-py3-none-any.whl

Total release size: 125.7 kB

Release files / sawvant-1.1.2.tar.gz

Download URL sawvant-1.1.2.tar.gz
Size 47.2 kB
Tags Source
SHA-256 checksum
How to use checksums
c116df084f335ffdb2ed1db6ed2b6c4630b2303757bcc8f0c06633cd0306818f
BLAKE2b-256 checksum
How to use checksums
fda4b1eafed589f05ffa1e164b58557bc5ce00ccb7031de8a4e51e0af11cc919
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Oct 21, 2026.

Transparency log

Release files / sawvant-1.1.2-py3-none-any.whl

Download URL sawvant-1.1.2-py3-none-any.whl
Size 78.4 kB
Tags Python 3
SHA-256 checksum
How to use checksums
a8970be53915093ce55f9e5d0e5efe5d2eba8845ae461c203b3c6fe1761c4817
BLAKE2b-256 checksum
How to use checksums
63f1568ecec7928110308d35ab1b1b95467bdad07921f5acc852d99fa66db248
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Oct 21, 2026.

Transparency log

Security for sawvant 1.1.2

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

Full provenance

Both files in this release have been uploaded with provenance metadata.

Select from 2 files

Attestation for sawvant-1.1.2.tar.gz

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Oct 21, 2026.

Transparency log

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Release history Release notifications | RSS feed

This release

1.1.2 This release

2 release files Full provenance

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page