Overview
ModelRunner provides a unified Python SDK to call any supported model with a consistent interface. Use it in scripts, services, and notebooks with both async and sync workflows.For scripts and notebooks, never hardcode secrets. Use environment variables to manage your key securely.
Installation
Configure credentials
Configure the client with a single key. Environment variables are recommended.Call a model
Leverage the queue for long-running tasks. Optionally listen to queue updates.Tag requests with metadata
Attach your own flat string map to a request — job ids, environments, batch labels — by passingmetadata alongside arguments. It’s supported on run, submit, and submit_async:
subscribe and stream, and on every _async variant.
metadata is sent as a reserved top-level sibling of your input fields — never nested inside arguments, and never forwarded to the model. It’s stored on the request so you can filter your history by it later; the client itself has no read-back or filtering API, so read tags back through the request lifecycle metadata filter or the MCP list_my_requests tool.
Limits, enforced locally before the request is dispatched — every violation is reported at once, so a batch of bad tags surfaces in one error:
Get called back with webhooks
Instead of polling a handle, pass awebhook_url and ModelRunner POSTs the result to you when the request settles. Nothing is lost if your process restarts mid-request, which is what makes this the right choice for long video and training jobs.
submit, submit_async and subscribe. See the webhooks guide for the events, the retry schedule, and the full payload shape.
Verify a delivery
Every delivery is signed. Fetch your signing secret once and keep it in your server environment:request.get_data(); in Django it is request.body.
Two more things your endpoint must do, both easy to get wrong:
- Return
2xxdirectly. Redirects are not followed, so a301— a missing trailing slash, anhttp→httpsupgrade — is recorded as a failed attempt and you see nothing but silence. - Deduplicate on the
webhook-idheader. Delivery is at-least-once and that id is stable across retries of the same delivery.
Rotate the secret
Rotating twice inside that window ends it early and breaks receivers still holding the original secret, so this call is never retried automatically. Rotate once, deploy, then rotate again if you need to.
get_webhook_secret_async and rotate_webhook_secret_async; verify_webhook is synchronous in both cases, since it only does local HMAC work.

