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.4

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.4
File Size Uploaded Provenance Actions
osp_provider_sdk-0.10.4.tar.gz 61.1 kB Without provenance Details for osp_provider_sdk-0.10.4.tar.gz

Built distribution (wheel)

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

Total release size: 89.5 kB

Release files / osp_provider_sdk-0.10.4.tar.gz

Download URL osp_provider_sdk-0.10.4.tar.gz
Size 61.1 kB
Tags Source
SHA-256 checksum
How to use checksums
1bdf782a0fa91bd9dad092293bc04456827c14b27771af3fc6b0936811ecdfe7
BLAKE2b-256 checksum
How to use checksums
84ce230bd2a2363388b3a5e74c01e81bc97ca6eb14055275bc64a49a238d262a
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.4-py3-none-any.whl

Download URL osp_provider_sdk-0.10.4-py3-none-any.whl
Size 28.3 kB
Tags Python 3
SHA-256 checksum
How to use checksums
a054a7c6c8a059bb4166183f4e882c7948f4d7d701ab9a63af262f8d627da0a2
BLAKE2b-256 checksum
How to use checksums
15a1fcbd40e39ec0eafeb54662625dd19977140c70534e3276e04cee3f50c72f
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.4

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