Overview
ModelRunner provides a unified JavaScript/TypeScript SDK to call any supported model with a consistent interface. Use it in Node.js, serverless runtimes, and—via a proxy—in the browser.For client-side apps, never expose secrets. Use the proxy pattern shown below to safely forward requests.
Installation
Configure credentials
Configure the client with a single key. Environment variables are recommended on the server.Get your credentials from your ModelRunner account. Keep them server-only.
Call a model
Leverage the queue for long-running tasks. Optionally listen to queue updates.Upload files
Upload local files to ModelRunner storage and receive a temporary URL you can pass to model inputs (for example, image or audio URLs).url to your model input:
In Node.js,
Blob is available in modern runtimes (Node 18+). If you use an older version, consider upgrading or using a compatible polyfill.The storage service accepts any binary file type (images, audio, video, documents).Using the client in browsers (via proxy)
To keep secrets safe, use the official server proxy so credentials stay on your server.Set
MODELRUNNER_KEY in your server environment. The proxy reads this value to authenticate requests. Never expose it in the browser.
