Webhooks
Get notified when operations finish, checkpoints are saved, models are released or sessions expire.
Long calls return an operation you can poll or wait on. Instead, RSI Labs can POST an event to your HTTPS endpoint when something happens.
| Event | When |
|---|---|
operation.succeeded | An operation finished. Carries its scalar metrics, such as loss. |
operation.failed | An operation failed. Carries the error. |
checkpoint.saved | save_weights() finished. Carries the checkpoint. |
model.released | A live model was released. |
session.expired | A session stopped sending heartbeats and ended. |
Events carry IDs, status and metrics only, never samples, logprobs or training data. Fetch results with the operation's ID.
Create an endpoint
The secret is returned only here and when you rotate it, so store it right away.
endpoint = client.webhooks.create(
"https://example.com/rsi-events",
events=["operation.succeeded", "operation.failed", "checkpoint.saved"],
)
print(endpoint.secret) # whsec_...Use "*" to receive every event type. Endpoints must use HTTPS and resolve to a public address.
Verify each delivery
Every delivery is signed with your endpoint's secret:
RSI-Signature: t=1796180000,v1=5257a869e7ecebeda32affa62cdca3fa51cad7e77a0e56ff536d0ce8e108d8bdv1 is an HMAC-SHA256 of <t>.<raw body>. Verify it against the raw request body before you parse it, and reject timestamps more than five minutes old. The SDK does both:
import rsi
def handle(request):
event = rsi.webhooks.verify(
request.body, request.headers["RSI-Signature"], secret=RSI_WEBHOOK_SECRET
)
if event["type"] == "operation.succeeded":
op_id = event["operation"]["operation_id"]
return 204Delivery
- Any
2xxresponse counts as delivered. Respond quickly and do the work afterwards. - Failed deliveries are retried with exponential backoff, from 30 seconds up to 6 hours apart, for 3 days.
- Delivery is at least once: deduplicate on the event's
id, which is also sent as theRSI-Event-Idheader.
Rotate the secret
endpoint = client.webhooks.rotate_secret(endpoint.id)For 24 hours after a rotation, deliveries carry two v1 signatures, one per secret, so you can switch without missing events.
Manage endpoints
client.webhooks.list()
client.webhooks.update(endpoint.id, events=["*"], disabled=False)
client.webhooks.delete(endpoint.id)