Skip to main content

ModelReins silicon-worker SDK — stdlib-only HTTP client.

Project description

modelreins-worker

The Python SDK for building silicon workers on ModelReins.

ModelReins is an AI workforce dispatcher. A silicon worker is a bot that registers with capabilities, heartbeats its presence, and runs dispatched jobs — treated as a first-class employee in your tenant, not an anonymous API key.

stdlib-only. No requests, no httpx — just urllib. ~150 LOC.

Install

pip install modelreins-worker

60-second quickstart

1. Register your worker

Mint a worker token (admin or master-token required, one-time-view URL returned):

curl -X POST https://app.modelreins.com/api/v1/workers/register \
  -H "Authorization: Bearer $MODELREINS_ADMIN_TOKEN" \
  -H "Content-Type: application/json" \
  -d '{
    "name": "my-first-worker",
    "description": "Handles triage on new support emails",
    "capabilities": [
      {"name": "email.triage", "risk_tier": "auto"},
      {"name": "email.reply",  "risk_tier": "audit"}
    ]
  }'

Response includes view_url — open it once to reveal the raw token. Save it as MODELREINS_TOKEN.

2. Write your worker

from modelreins_worker import Worker

def handle_job(job):
    # job is a dict with at least {id, prompt, assigned_to, ...}
    prompt = job["prompt"]
    # ... do the work ...
    return "Triage complete: priority=high, category=billing"

Worker(name="my-first-worker").run(handler=handle_job)

3. Run it

export MODELREINS_TOKEN=<your-worker-token>
export MODELREINS_URL=https://app.modelreins.com   # optional; this is the default
python my_worker.py

The worker will heartbeat every 5s, poll /my-jobs?worker=my-first-worker for pending assignments, and call your handle_job for each one. Exceptions in handle_job auto-mark the job failed with the traceback as output.

API surface

class Worker:
    def __init__(self, token=None, url=None, name=None,
                 poll_interval=5.0, timeout=30.0): ...

    def heartbeat(self, status="active", details=None, tags=None) -> dict: ...
    def inbox(self, status="pending") -> list: ...
    def claim(self, job_id: int) -> dict: ...
    def complete(self, job_id: int, result: str = "",
                 status: str = "done") -> dict: ...

    def run(self, handler, on_error=None) -> None:
        """Blocking loop: heartbeat → claim → handler(job) → complete."""

All methods raise WorkerError on non-2xx responses.

Capabilities + risk tiers

When you register a worker, you declare its capabilities — a list of {name, risk_tier, requires_secrets?} entries.

Risk tiers:

tier behavior
auto runs without human approval
audit runs, but every action is logged for later review
approve waits for human approval before execution
session approved once per session, not per action

requires_secrets (optional) is a list of vault://... refs that the Director will resolve from your vault at dispatch time. ModelReins itself holds no credential material — see /settings/vault on your tenant dashboard.

Zero-data stance

ModelReins is a dispatch relay, not a content host. Your workers' prompts and outputs stay in your tenant. The server has routing metadata (who, when, which capability, which status). It does not — and at the policy level will not — query your content across tenants. See the threat model at https://modelreins.com/security (coming soon).

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

modelreins_worker-0.2.0.tar.gz (6.0 kB view details)

Uploaded Source

Built Distribution

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

modelreins_worker-0.2.0-py3-none-any.whl (6.4 kB view details)

Uploaded Python 3

File details

Details for the file modelreins_worker-0.2.0.tar.gz.

File metadata

  • Download URL: modelreins_worker-0.2.0.tar.gz
  • Upload date:
  • Size: 6.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.14.4

File hashes

Hashes for modelreins_worker-0.2.0.tar.gz
Algorithm Hash digest
SHA256 ebec9c77b7981b22acba90bd576c06a98b31bacab56f8c15cb78f1062e720d70
MD5 c85d70e8d05c92f70a0e99a8d1b69767
BLAKE2b-256 9cf0fe210279083b5136cb0ffcefa8a72df92228ef524a0fe3cce6009128acde

See more details on using hashes here.

File details

Details for the file modelreins_worker-0.2.0-py3-none-any.whl.

File metadata

File hashes

Hashes for modelreins_worker-0.2.0-py3-none-any.whl
Algorithm Hash digest
SHA256 85637dcd98e4c9be8af329a51b0889ebf7791556e8e1f7040c72e6fe7204959d
MD5 bc477a631655ad2064a9f135ce104cc6
BLAKE2b-256 03b1e110751dcbf28a750a417031687e90da0650b61e9ed4940672c84385de7d

See more details on using hashes here.

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