opentrain-ai
Official Python SDK for the OpenTrain API — human verification, evaluation, and labeling for AI teams.
Push model outputs — synthetic rows, eval responses, RL episodes — and get
human verdicts back. Use verify.reward as a human reward function inside a
training loop.
pip install opentrain-ai # imports as `opentrain`
- Python ≥ 3.10, fully typed (
py.typed), Pydantic v2 models, httpx transport - Sync (
OpenTrain) and async (AsyncOpenTrain) clients with the same surface - Apache-2.0
Quickstart
Create an API token at app.opentrain.ai → Settings → Developer, then:
from opentrain import OpenTrain
client = OpenTrain() # reads OPENTRAIN_API_TOKEN
# Push a batch of model outputs for human verification
created = client.verify.batches.create(
items=[
{"prompt": "What is 2+2?", "response": "4"},
{"prompt": "Capital of France?", "response": "Lyon"},
],
)
print(created.batch.batch_id, created.batch.status)
# Read verdicts back (ACCEPT / FIX / REJECT per item)
results = client.verify.batches.results(created.batch.batch_id)
print(results.summary)
Human reward function
# Synchronous LLM-judge scoring (bring your own OpenRouter key in Quality settings)
scored = client.verify.reward.judge_now(
items=[{"prompt": "2+2?", "response": "4"}],
rubric=["The response is factually correct."],
)
print(scored.rewards[0].score) # 0..1
# Asynchronous human scoring — poll or subscribe to verify.reward.completed
queued = client.verify.reward.human_async(
items=[{"prompt": "2+2?", "response": "5"}],
rubric=["The response is factually correct."],
training_run_id="run_...", # optional: links verdicts to your training run
)
rewards = client.verify.reward.get(queued.batch_id)
Async
import asyncio
from opentrain import AsyncOpenTrain
async def main() -> None:
async with AsyncOpenTrain() as client:
created = await client.verify.batches.create(
items=[{"prompt": "p", "response": "r"}]
)
print(created.batch.batch_id)
asyncio.run(main())
Webhooks
from opentrain import verify_webhook_signature
ok = verify_webhook_signature(
secret="whsec_...", # returned once at webhook creation
raw_body=request_body_text, # verify BEFORE parsing JSON
signature_header=headers["X-OpenTrain-Signature"],
)
Other surfaces
client.label.launch(...), client.evaluate.launch(...),
client.synthetic_runs.create(...) / .push_rows(...),
client.training_runs.register_external(...), client.benchmarks.list(),
client.webhooks.create(...). These return dict payloads matching the
OpenAPI document at /api/public/v1/openapi.
Errors
Non-2xx responses raise OpenTrainAPIError with status, code
(e.g. PAYMENT_REQUIRED), request_id, and details.
Development
scripts/test.sh # venv + mypy --strict + pytest
Metadata
Release files for opentrain-ai 0.1.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | |
|---|---|---|---|---|
| opentrain_ai-0.1.0.tar.gz | 25.2 kB | With provenance | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| opentrain_ai-0.1.0-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 51.4 kB
Release files / opentrain_ai-0.1.0.tar.gz
| Download URL | opentrain_ai-0.1.0.tar.gz |
|---|---|
| Size | 25.2 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
31b69feeb990e67cc6f638a421a516aecde5e55c24baecc573cfeac559a2b9d6
|
|
BLAKE2b-256 checksum How to use checksums |
bada2c2645d865d9bd14d96042fde707f6c70c4f3b4a7c13932343787f702890
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/6.1.0 CPython/3.13.12
|
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.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Jul 8, 2026.
Transparency logRelease files / opentrain_ai-0.1.0-py3-none-any.whl
| Download URL | opentrain_ai-0.1.0-py3-none-any.whl |
|---|---|
| Size | 26.2 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
9bc92370a8f01f9ab61e3ea29ed98d554ca8a9e3772e101a71987ff031b1007e
|
|
BLAKE2b-256 checksum How to use checksums |
623ce78bde235b38846141b5f9655620200e131d97815bc99ea8f59ac46fa468
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/6.1.0 CPython/3.13.12
|
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.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Jul 8, 2026.
Transparency logSecurity for opentrain-ai 0.1.0
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.
Full provenance
All 2 files in this release have been uploaded with provenance metadata.
Attestation for opentrain_ai-0.1.0.tar.gz
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Jul 8, 2026.
Transparency logA 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.