If you’re building a browser app and want to avoid exposing API keys, route SDK calls through your backend proxy. See the proxy examples in sdks/sdk/examples/nextjs-proxy and sdks/sdk/examples/express-proxy.
For client-side applications (browsers, mobile apps) using the Realtime API, create short-lived client tokens instead of exposing your permanent API key:
Copy
Ask AI
// On your backendconst { apiKey, expiresAt } = await client.tokens.create();// Send apiKey to your frontend for secure client-side authentication
See Client Tokens for details on secure realtime auth.
The SDK is written in TypeScript with full type definitions. Each model enforces its own required inputs, so you’ll get autocomplete and helpful errors if something is missing.
Copy
Ask AI
// Image-to-video requires 'data' fieldawait client.queue.submitAndPoll({ model: models.video("lucy-pro-i2v"), prompt: "Make it cinematic", data: imageFile, // ✅ Required});// Text-to-video doesn't need 'data'await client.queue.submitAndPoll({ model: models.video("lucy-pro-t2v"), prompt: "A cat walking", data: imageFile, // ❌ Type error});