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.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 osp-provider-sdk 0.10.2
File Size Uploaded Provenance Actions
osp_provider_sdk-0.10.2.tar.gz 61.4 kB Without provenance Details for osp_provider_sdk-0.10.2.tar.gz

Built distribution (wheel)

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

Total release size: 89.5 kB

Release files / osp_provider_sdk-0.10.2.tar.gz

Download URL osp_provider_sdk-0.10.2.tar.gz
Size 61.4 kB
Tags Source
SHA-256 checksum
How to use checksums
ac03dcba48fad6d65d98614abb718cde3736e1b74fa477369d517bcbab249b0a
BLAKE2b-256 checksum
How to use checksums
e998e316430aebb1f74899ef5c7c7aa785cd3529d234465ff6992c17ffe0d891
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.2-py3-none-any.whl

Download URL osp_provider_sdk-0.10.2-py3-none-any.whl
Size 28.2 kB
Tags Python 3
SHA-256 checksum
How to use checksums
720e80266d8bfb58bb9ab50614d7e676cb70cca642ce23bc816c55b9cc848efd
BLAKE2b-256 checksum
How to use checksums
7765c9979115c269fd838ed92e26cbf7aee04bc99511ad96778cb179d60ac84e
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.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.

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