Overview
The Decart SDK provides a unified client interface through thecreateDecartClient factory function. This client gives you access to four specialized sub-clients for different use cases:
- realtime - WebRTC-based real-time video streaming
- process - Synchronous image generation
- queue - Asynchronous video generation with job management
- tokens - Client token generation for secure client-side usage
Creating a Client
The SDK supports two modes of operation: direct API mode and proxy mode.Direct API Mode
In direct API mode, the client communicates directly with the Decart API using your API key.Proxy Mode
In proxy mode, requests are routed through your server proxy, eliminating the need to expose your API key on the client side.You cannot provide both
proxy and apiKey - they are mutually exclusive.Client Configuration
TypeScript Signature
Configuration Options
API key for authentication. Required unless using
proxy mode or the DECART_API_KEY environment variable.URL of the proxy server. When set, the client uses the proxy instead of direct API access and
apiKey is not required. Can be a full URL or a relative path (starting with /).Override the default API base URL.
Override the default WebSocket base URL for realtime connections.
Optional integration identifier for tracking and analytics.
Custom logger for debugging and diagnostics. Use
createConsoleLogger() for console output or noopLogger to disable logging.Enable or disable telemetry data collection.
The Four Clients
Realtime Client
For WebRTC-based real-time video streaming with interactive models.The realtime client always requires direct API access with an API key, even in proxy mode. WebRTC connections cannot be proxied through HTTP.
Learn More
See the Realtime Guide for complete usage examples
Process Client
For synchronous image generation. Only image models (lucy-pro-t2i, lucy-pro-i2i) support the process API.
Learn More
See the Process Guide for complete usage examples
Queue Client
For asynchronous video generation with job management. Only video models support the queue API.submit()- Submit a job and get the job IDstatus()- Check the status of a jobresult()- Get the result of a completed jobsubmitAndPoll()- Submit and automatically poll until completion
Learn More
See the Queue Guide for complete usage examples
Tokens Client
For creating short-lived client tokens that are safe to use on the client side.Learn More
See Authentication for security best practices
Custom Logging
You can provide a custom logger for debugging and diagnostics:debug, info, warn, error
Error Handling
All SDK methods can throwDecartSDKError with specific error codes:
INVALID_API_KEY- API key is missing or invalidINVALID_BASE_URL- Base URL format is invalidINVALID_INPUT- Model inputs failed validationTOKEN_CREATE_ERROR- Failed to create client token