Skip to main content

Official Python SDK for HumanRail — route tasks to vetted human workers when AI hits its limits.

Project description

HumanRail Python SDK

Official Python client library for the HumanRail API.

Route tasks to vetted human workers when your AI hits its limits. Verified results. Instant payouts. One API call.

Installation

pip install humanrail

Requires Python 3.12+.

Quick Start

import os
from humanrail import EscalationClient

client = EscalationClient(api_key=os.environ["HUMANRAIL_API_KEY"])

task = client.tasks.create(
    idempotency_key="order-12345-refund",
    task_type="refund_eligibility",
    risk_tier="medium",
    sla_seconds=300,
    payload={
        "orderId": "order-12345",
        "reason": "Item arrived damaged",
    },
    output_schema={
        "type": "object",
        "required": ["eligible", "reason_code"],
        "properties": {
            "eligible": {"type": "boolean"},
            "reason_code": {"type": "string", "enum": ["approved", "denied_policy", "needs_review"]},
        },
    },
    payout={"currency": "USD", "max_amount": 0.50},
)

result = client.tasks.wait_for_completion(task.id, timeout=600)
print(result.output)
# {"eligible": True, "reason_code": "approved"}

Async Usage

from humanrail import AsyncEscalationClient

async_client = AsyncEscalationClient(api_key=os.environ["HUMANRAIL_API_KEY"])
task = await async_client.tasks.acreate(...)
result = await async_client.tasks.await_for_completion(task.id)

Features

  • Synchronous and async clients
  • Automatic retries with exponential backoff
  • Webhook signature verification (HMAC-SHA256)
  • Idempotency support
  • Typed responses with Pydantic models
  • OpenTelemetry tracing

Documentation

License

MIT - see LICENSE

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

humanrail-0.1.0.tar.gz (14.0 kB view details)

Uploaded Source

Built Distribution

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

humanrail-0.1.0-py3-none-any.whl (14.6 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: humanrail-0.1.0.tar.gz
  • Upload date:
  • Size: 14.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.12.3

File hashes

Hashes for humanrail-0.1.0.tar.gz
Algorithm Hash digest
SHA256 99f08fe7fb579339f6b53214f01ce1ad3d050aadf1d8d6e737fa7429cd519fe9
MD5 bea17941ccbb2c711c062dae4f5e94f2
BLAKE2b-256 b34699fa40300a1e91e301543d5acd8b64a783a6936a76e9ea44afaad88daf2d

See more details on using hashes here.

File details

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

File metadata

  • Download URL: humanrail-0.1.0-py3-none-any.whl
  • Upload date:
  • Size: 14.6 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.12.3

File hashes

Hashes for humanrail-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 15a969744554181f36bc8d1a855c224cb2952b43d62205cb6e863177bd67c8a2
MD5 80614443a5d4ea1f13d1930af574aec9
BLAKE2b-256 85924a193ddf9953e2af1a2bc832e179812942a279bed0085e247ae7347ef9d7

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