Skip to main content

Official Python SDK for the Plumr API.

Project description

plumr

Official Python SDK for the Plumr API.

pip install plumr
# or
uv add plumr
poetry add plumr

Requires Python 3.9+. One runtime dep: httpx.

Usage

Streaming

from plumr import Plumr

client = Plumr(api_key="plm_live_...")

for event in client.run(input="Write a haiku about Mars."):
    if event.type == "llm.delta":
        print(event.text, end="", flush=True)
    elif event.type == "step.end":
        print(f"\n{event.nodeId} ({event.durationMs}ms)")

One-shot

result = client.run_once(input="Write a haiku about Mars.")
print(result.output)

Override plum settings per call

If your plum has API-bound fields (e.g. the orchestrator's model is bound to params.model), swap them at call time:

result = client.run_once(
    input="Hello",
    params={"model": "claude-opus-4-7"},
)

Async

import asyncio
from plumr import AsyncPlumr

async def main():
    async with AsyncPlumr(api_key="plm_live_...") as client:
        async for event in client.run(input="hello"):
            if event.type == "llm.delta":
                print(event.text, end="", flush=True)

asyncio.run(main())

Configuration

Plumr(
    api_key="plm_live_...",
    base_url="https://app.plumr.studio",   # optional — for self-hosted
    timeout=300.0,                          # seconds; long for streaming
)

Event reference

run() yields strongly-typed dataclasses — use event.type for exhaustive matches:

event.type Class Fields
run.start RunStartEvent startedAt
step.start StepStartEvent nodeId, nodeType, label, input
step.end StepEndEvent nodeId, output, durationMs, error
llm.start LlmStartEvent nodeId, provider, model
llm.delta LlmDeltaEvent nodeId, text
llm.end LlmEndEvent nodeId, promptTokens, completionTokens
tool.call ToolCallEvent nodeId, label, note?
run.end RunEndEvent runId, status, output, error, durationMs

Errors

from plumr import PlumrError

try:
    client.run_once(input="…")
except PlumrError as e:
    print(e.status, e.body)

Examples

Develop

pip install -e ".[dev]"
pytest
ruff check
mypy plumr

License

MIT

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

plumr-0.1.0.tar.gz (5.2 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

plumr-0.1.0-py3-none-any.whl (6.3 kB view details)

Uploaded Python 3

File details

Details for the file plumr-0.1.0.tar.gz.

File metadata

  • Download URL: plumr-0.1.0.tar.gz
  • Upload date:
  • Size: 5.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for plumr-0.1.0.tar.gz
Algorithm Hash digest
SHA256 8a4168d5d432764812e68ab2e6598ca3faf6e635f0c48f7cba505047579ebf34
MD5 ca4d5b519b49f328283c3cec99df6c7d
BLAKE2b-256 b780b32898ed133ff1316b163de95cd216eee3919ef4f3da1c43528285c4523b

See more details on using hashes here.

Provenance

The following attestation bundles were made for plumr-0.1.0.tar.gz:

Publisher: python-publish.yml on Plumr-org/sdks

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file plumr-0.1.0-py3-none-any.whl.

File metadata

  • Download URL: plumr-0.1.0-py3-none-any.whl
  • Upload date:
  • Size: 6.3 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for plumr-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 9e8ac5097a57310d3b821491162ed75d589672a37e29b431cf4fae39ba708855
MD5 ea65a7bf0cfb7285012479ea5e7e8fc4
BLAKE2b-256 33cd88779310b79ad90939a168fcdd9de9ac75006219ab4db1e2f4495b832691

See more details on using hashes here.

Provenance

The following attestation bundles were made for plumr-0.1.0-py3-none-any.whl:

Publisher: python-publish.yml on Plumr-org/sdks

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page