Rayon Python SDK
Explicit material preparation (2.0.0)
The additive material preparation API is available through
POST /v1/materials/prepare and
GET /v1/materials/preparations/{preparation_id}. Explicitly prepare the full
context and wait for ready before starting a workload. Ready requires complete
output validation and Rust publication; partial output is not ready, and ready
preparations execute only in Rust.
The 30-day migration schedule will be announced separately. No fixed cutoff is set here, and mandatory prepared-only/Rust-only generation is not enabled by this release.
from rayon_sdk_py import Client, PreparationError
with Client(api_key) as client:
job = client.prepare(shape) # existing full ShapeRequest, no generation
try:
ready = client.wait_until_ready(job.preparation_id, wait_timeout=60)
except PreparationError as error:
# Safe ID can resume an existing job later; timeout does not cancel it.
preparation_id = error.preparation_id
raise
current = client.get_preparation(ready.preparation_id)
# Or explicitly combine creation and waiting:
ready = client.prepare_and_wait(shape, wait_timeout=60)
AsyncClient exposes the same four methods with await. Cancelling an async wait
raises PreparationCancelledError (a PreparationError with kind="aborted") with a safe
preparation_id; the server job continues. PreparationError.kind is timeout,
failed, expired, or aborted. The typed cancellation error preserves resumable
metadata across supported Python versions rather than marking the task cancelled.
HTTP/transport/invalid-response errors during a wait also
retain the safe preparation ID for resumption.
Preparation reports queued, learning, validating, publishing, ready,
failed, or expired. A successful wait returns ReadyMaterial: safe metadata
including the reusable material_ref, material expiry, ready_until, and the
confirmed rust execution backend. It contains no scripts, cookies, or generated
headers. Readiness is scoped to the exact supplied request/profile/cookie/mode/form
context and its lifetime; use the current full context when preparing again.
Preparation is opt-in. generate() keeps its existing signature and result and
never creates a preparation job or waits for learning. Preparation does not reuse
or populate the source-only generation cache, and independent full contexts are
never coalesced. Each prepare invocation uses a fresh Idempotency-Key; the SDK
does not retry ambiguous POST results. Waiting uses bounded long polling and
jittered retries for transient GET failures under a monotonic time budget.
Generate Shape headers or form telemetry and read account usage. Keep your API key server-side. Your integration owns its HTTP client or browser and target session.
Quickstart · SDK guide · All SDKs
Install
python -m pip install 'rayon-sdk-py>=2.0.0,<3'
Check usage, then generate
Set RAYON_API_KEY. Prepare shape.json using the
input guide: source-page URL, complete ordered
script sources, a profile object and the exact target request. Include browser
measurements or JavaScript-visible cookies only when your flow requires them.
import json
import os
from pathlib import Path
from rayon_sdk_py import Client
with Client(os.environ["RAYON_API_KEY"]) as client:
usage = client.usage() # Free; no generation quota used.
print(usage)
shape = json.loads(Path("shape.json").read_text(encoding="utf-8"))
result = client.generate(shape)
# Apply result.headers using your existing target client/session.
# Reuse client here for further requests with their current inputs.
print(result.request_id)
Apply the entire returned header map unchanged, including optional a0, to that
exact request. Keep required application headers, authentication and session state
in your target client. RayonAPI does not download scripts, send the target request
or return target cookies. Inspect the target response to establish acceptance.
Form telemetry
For observed URL-encoded form telemetry, use mode: "form" and supply the exact
application body before telemetry insertion. The result has form_fields and
form_body, without generated headers. Prepend form_body once to the original
body, preserving its bytes, duplicate fields and encoding. See
Form payload integration
for complete examples.
Client options and errors
Requires Python 3.10+. Use AsyncClient with async with,
await client.usage() and await client.generate(shape) in async applications.
Set timeout=45 in the constructor to set the API timeout.
Errors inherit RayonError: ValidationError, TransportError, HTTPError
and InvalidResponseError. Available metadata includes status_code,
request_id, code, retry_after, reason, action, domain, field,
billing_status and retryable.
The default API URL is https://api.rayonapi.com; default timeout is 45 seconds.
Keep one client open across calls. Python and JavaScript SDK 2.0.0 reuse material
in both modes while generating fresh telemetry for each request. Read the
material and recovery policy
for cache scope, limits and the single confirmed uncharged material recovery.
Check request history before resubmitting after a timeout or uncertain billing outcome. See errors and retry guidance, request fields and browser/session inputs. The Python download helper is optional.
Metadata
Release files for rayon-sdk-py 2.0.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 | Actions |
|---|---|---|---|---|
| rayon_sdk_py-2.0.0.tar.gz | 41.1 kB | With provenance | Details for rayon_sdk_py-2.0.0.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| rayon_sdk_py-2.0.0-py3-none-any.whl | Python 3 | none | any | Details for rayon_sdk_py-2.0.0-py3-none-any.whl |
Total release size: 64.4 kB
Release files / rayon_sdk_py-2.0.0.tar.gz
| Download URL | rayon_sdk_py-2.0.0.tar.gz |
|---|---|
| Size | 41.1 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
eb2351d4b0a2d3fd1d2e84173ec9158fb53f332ff96f557ca3caf1b3b4660bfc
|
|
BLAKE2b-256 checksum How to use checksums |
f8aa2cde4785843991dc694a71fdec4e4b85005e1025c4fd4f14192ae3f9ed74
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.16
|
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 Oct 26, 2026.
Transparency logRelease files / rayon_sdk_py-2.0.0-py3-none-any.whl
| Download URL | rayon_sdk_py-2.0.0-py3-none-any.whl |
|---|---|
| Size | 23.3 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
0bed5d68d74f724746596e127df5ba855ea07439de77a39c177788d901ca34fc
|
|
BLAKE2b-256 checksum How to use checksums |
08bfb4e28ee15e1f52aa13f3b7e949ac24f2949e45d25a3818300b6fde1567b5
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.16
|
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 Oct 26, 2026.
Transparency logSecurity for rayon-sdk-py 2.0.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
Both files in this release have been uploaded with provenance metadata.
Attestation for rayon_sdk_py-2.0.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 Oct 26, 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.