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

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.3
File Size Uploaded Provenance Actions
osp_provider_sdk-0.10.3.tar.gz 61.6 kB Without provenance Details for osp_provider_sdk-0.10.3.tar.gz

Built distribution (wheel)

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

Total release size: 90.0 kB

Release files / osp_provider_sdk-0.10.3.tar.gz

Download URL osp_provider_sdk-0.10.3.tar.gz
Size 61.6 kB
Tags Source
SHA-256 checksum
How to use checksums
e48001a6a0875f89b8c09687f8dd2f6e5116521f5877111917d9719c340aaeb0
BLAKE2b-256 checksum
How to use checksums
d49ce7ffb06d9ab06f09ce90403b8065c6b7b361184623689779f9990ee39afd
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.15.0

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

Download URL osp_provider_sdk-0.10.3-py3-none-any.whl
Size 28.3 kB
Tags Python 3
SHA-256 checksum
How to use checksums
8a1d86e6bdd610bbb7956cb1d1b48a4a8d576e42a1febf5f26978ba39eff904c
BLAKE2b-256 checksum
How to use checksums
36d9d620b1430fe507627e00baf847de8b8ed9e6e8c7f9a53749f79aadbb44df
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.15.0

Security for osp-provider-sdk 0.10.3

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