Skip to main content

osp-provider-sdk

Write an OSP provider in plain Python. A provider connects OSP to your service: it lists your resources and plans and applies the changes users request. The SDK handles the wire protocol, input validation, approvals, ownership checks and progress reporting, so your code only talks to your backend.

Install

Requires Python 3.13 or newer.

uv pip install osp-provider-sdk

A minimal provider

from contextlib import contextmanager
from datetime import UTC, datetime

from pydantic import BaseModel, ConfigDict, Field

from osp_provider_sdk import App, Done, Page, Resource, ResourceOwnership


@contextmanager
def lifespan():
    yield {}  # your backend client; available as app.state while running


app = App("notes", description="Sticky notes", lifespan=lifespan)


class Create(BaseModel):
    model_config = ConfigDict(frozen=True)
    name: str = Field(title="Name")
    text: str = Field("", title="Text")


class Row(BaseModel):
    text: str = Field(title="Text")


@app.resource("note", fields=Row)
def notes(q, access) -> Page:
    rows = [
        Resource(target_ref=ref, display=ref, ownership=owner, fields={"text": text})
        for ref, (text, owner) in app.state.items()
    ]
    return Page(tuple(rows), observed_at=datetime.now(UTC).isoformat())


@app.action("create", inputs=Create)
def create(req, ctx) -> Done:
    owner = ResourceOwnership(contacts=frozenset(ctx.contacts))
    app.state[req.name] = (req.inputs.text, owner)
    ctx.created(req.name)
    return Done(f"Created note {req.name}")


if __name__ == "__main__":
    app.run()

The input model becomes the form users fill in, the resource becomes an inventory list, and the runtime checks ownership and policy before your handler runs. app.state is whatever lifespan yields, typed from it.

Try it without OSP

Save the code as notes.py. These commands need no orchestrator or RabbitMQ:

python -m osp_provider_sdk manifest notes:app              # what OSP will see
python -m osp_provider_sdk doctor notes:app --offline      # declarations and policy
python -m osp_provider_sdk plan notes:app create '{"text": "buy milk"}' --name milk

python notes.py serves the provider over RabbitMQ; it reads RABBITMQ_URL and PROVIDER_INSTANCE.

Next steps

Metadata

Release files for osp-provider-sdk 0.10.6

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

Source distribution (sdist)

Source distribution for osp-provider-sdk 0.10.6
File Size Uploaded Provenance Actions
osp_provider_sdk-0.10.6.tar.gz 61.2 kB Without provenance Details for osp_provider_sdk-0.10.6.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for osp-provider-sdk 0.10.6
File Interpreter ABI Platform Actions
osp_provider_sdk-0.10.6-py3-none-any.whl Python 3 none any Details for osp_provider_sdk-0.10.6-py3-none-any.whl

Total release size: 89.5 kB

Release files / osp_provider_sdk-0.10.6.tar.gz

Download URL osp_provider_sdk-0.10.6.tar.gz
Size 61.2 kB
Tags Source
SHA-256 checksum
How to use checksums
a6dacb619cd061f7cd8576bddbe13d7e3dcd8685fe51a38b4377dce623ed448d
BLAKE2b-256 checksum
How to use checksums
6aa3422bab76a93de889e988f890cbeaf829d64360dec1ea2c2cfae9e039244d
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.13.15

Release files / osp_provider_sdk-0.10.6-py3-none-any.whl

Download URL osp_provider_sdk-0.10.6-py3-none-any.whl
Size 28.3 kB
Tags Python 3
SHA-256 checksum
How to use checksums
fa7923ba04dbbbe36f4b70a0c58948e11ab49ff1082bf7321398a943a6926c6a
BLAKE2b-256 checksum
How to use checksums
78a7a0bf3e007323eb52c0fbb8a1ae0107bc4971888af31bca2386903b04d3e6
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.13.15

Security for osp-provider-sdk 0.10.6

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.

No provenance found

None of the files in this release were uploaded with provenance metadata.

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.

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