Metadata-Version: 2.4
Name: spine-sdk
Version: 0.2.0
Summary: Official Python SDK for the Spine API.
Project-URL: Homepage, https://getspine.ai
Project-URL: Documentation, https://docs.getspine.ai/sdks/python/overview
Project-URL: Source, https://github.com/Spine-AI/spine-py
Project-URL: Issues, https://github.com/Spine-AI/spine-py/issues
Project-URL: Changelog, https://github.com/Spine-AI/spine-py/blob/main/CHANGELOG.md
Author-email: Spine <engineering@getspine.ai>
License: MIT License
        
        Copyright (c) 2026 Spine
        
        Permission is hereby granted, free of charge, to any person obtaining a copy
        of this software and associated documentation files (the "Software"), to deal
        in the Software without restriction, including without limitation the rights
        to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
        copies of the Software, and to permit persons to whom the Software is
        furnished to do so, subject to the following conditions:
        
        The above copyright notice and this permission notice shall be included in all
        copies or substantial portions of the Software.
        
        THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
        IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
        FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
        AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
        LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
        OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
        SOFTWARE.
License-File: LICENSE
Keywords: agent,ai,api,research,sdk,spine
Classifier: Development Status :: 4 - Beta
Classifier: Intended Audience :: Developers
Classifier: License :: OSI Approved :: MIT License
Classifier: Operating System :: OS Independent
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3 :: Only
Classifier: Programming Language :: Python :: 3.9
Classifier: Programming Language :: Python :: 3.10
Classifier: Programming Language :: Python :: 3.11
Classifier: Programming Language :: Python :: 3.12
Classifier: Programming Language :: Python :: 3.13
Classifier: Topic :: Software Development :: Libraries :: Python Modules
Classifier: Typing :: Typed
Requires-Python: >=3.9
Requires-Dist: httpx>=0.27
Requires-Dist: pydantic>=2.5
Provides-Extra: dev
Requires-Dist: build>=1.2; extra == 'dev'
Requires-Dist: mypy>=1.10; extra == 'dev'
Requires-Dist: pre-commit>=3.7; extra == 'dev'
Requires-Dist: pytest-asyncio>=0.23; extra == 'dev'
Requires-Dist: pytest-cov>=5.0; extra == 'dev'
Requires-Dist: pytest>=8.0; extra == 'dev'
Requires-Dist: respx>=0.21; extra == 'dev'
Requires-Dist: ruff>=0.6; extra == 'dev'
Description-Content-Type: text/markdown

# spine-sdk

Official Python SDK for the [Spine](https://getspine.ai) API.

[![PyPI version](https://img.shields.io/pypi/v/spine-sdk.svg)](https://pypi.org/project/spine-sdk/)
[![Python versions](https://img.shields.io/pypi/pyversions/spine-sdk.svg)](https://pypi.org/project/spine-sdk/)
[![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](LICENSE)

Create async canvas runs, poll them to completion, and introspect the resulting
canvas graph and task tree — with full type hints, sync and async clients,
and a built-in polling helper.

## Installation

```bash
pip install spine-sdk
```

The package installs as `spine`, so you import it as:

```python
from spine import SpineClient
```

Python 3.9+ is required.

## Quickstart

```python
from spine import SpineClient, Template

with SpineClient(api_key="sk_spine_...") as client:
    handle = client.runs.create(
        prompt="Research the Q4 2025 AI chip market and write a memo",
        template=Template.DEEP_RESEARCH,
    )
    result = handle.wait(timeout=600)
    print(result.final_output)
    for artifact in result.artifacts:
        print(artifact.name, artifact.download_url)
```

The same code in async:

```python
import asyncio
from spine import AsyncSpineClient

async def main() -> None:
    async with AsyncSpineClient() as client:  # reads SPINE_API_KEY from env
        handle = await client.runs.create(prompt="Hello")
        result = await handle.wait()
        print(result.final_output)

asyncio.run(main())
```

## What's in the SDK

- `SpineClient` and `AsyncSpineClient` — fully typed, context-managed HTTP clients.
- `client.runs` — create runs, poll them, wait for completion with exponential
  backoff, or stream progress snapshots.
- `client.canvas` — inspect the canvas block DAG and task tree for any run.
- `client.webhooks` — verify inbound webhook signatures and parse the event
  with `construct_event(payload, sig_header, secret)`.
- Typed Pydantic models for every request and response.
- Typed exceptions (`AuthenticationError`, `NotFoundError`, `BadRequestError`,
  `ServerError`, `SpineTimeoutError`) so you can branch on the exact failure.
- Automatic retry on transient 5xx and 429 responses (honours `Retry-After`).

## Documentation

Full reference and guides: <https://docs.getspine.ai/api-reference/sdks/python>

## License

MIT — see [LICENSE](LICENSE).
