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

modelreins_worker-0.1.0-py3-none-any.whl (5.5 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: modelreins_worker-0.1.0.tar.gz
  • Upload date:
  • Size: 5.2 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.1.0.tar.gz
Algorithm Hash digest
SHA256 cb503d5425537804d260a971186a1758866588a07fb5241ba991d42f9be4706b
MD5 970ec5a17d9ccc9b17331633802a3e3b
BLAKE2b-256 ee3eca38fd9b33340f049b2648173c6b3c3a4eaeb4dc963098a0b43a5f174fe6

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for modelreins_worker-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 7d90297062f5aa348dcb3b1815ccca30d29f2745eec4b1356ad53c62be094d1d
MD5 8d981c08a7041fe29e01ae4e399eac7c
BLAKE2b-256 796dc6d0c15782f1cf1c442ebb0786c5f04cfd458196b7870a2c56cb3e418fe3

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