@corti/sdk package is the official JavaScript SDK for the Corti API. It provides full coverage of every REST endpoint and WebSocket connection, with built-in authentication, automatic token refresh, type safety, and error handling.
Package: @corti/sdk on npm | Source: GitHub | Examples: corti-examples
Prerequisites
- Node.js 18 or later
- npm, yarn, or pnpm
- A Corti API client from the Corti Console
Installation
Initialization
The simplest way to get started is with client credentials (server-side):JavaScript
Authentication
The SDK supports five authentication methods to cover different deployment scenarios:
Each method is covered in detail in the Authentication Guide.
Usage examples
Create an interaction
JavaScript
Real-time transcription (WebSocket)
JavaScript
Text generation
JavaScript
Proxy support
When you need to route SDK traffic through your own backend (for security or access control), the SDK supports:baseUrl— redirect all REST and WebSocket traffic to your proxy- Custom environment URLs — fine-grained control over REST, WebSocket, auth, and agent endpoints
CortiWebSocketProxyClient— lightweight WebSocket-only proxy client- Scoped tokens — limit token access to specific endpoints
Error handling
The SDK throws typed exceptions you can catch and inspect:TypeScript types
All request and response types are exported as TypeScript interfaces under theCorti namespace:
Advanced configuration
Retries
The SDK automatically retries on408, 429, and 5xx status codes with exponential backoff. The default retry limit is 2. Override per request:
Timeouts
The SDK defaults to a 60-second timeout. Override per request:Abort requests
Cancel any request using anAbortSignal:
Raw responses
Access the underlying HTTP response alongside parsed data using.withRawResponse():
Pagination
List endpoints are paginated. The SDK provides an async iterator so you can loop over items automatically:Custom fetch client
Supply your ownfetch implementation if you’re running in an unsupported environment or need custom behavior:
Additional headers
Add headers to every request via the constructor, or per request as a request option:Additional query parameters
Add extra query string parameters per request:File uploads
The SDK accepts a variety of types when uploading files:- Stream types:
fs.ReadStream,stream.Readable,ReadableStream - Buffered types:
Buffer,Blob,File,ArrayBuffer,ArrayBufferView,Uint8Array
Logging
The SDK supports configurable logging:Runtime compatibility
The SDK works in the following runtimes:- Node.js 18+
- Vercel
- Cloudflare Workers
- Deno v1.25+
- Bun 1.0+
- React Native
Resources
- npm package — latest version, changelog, and install info
- GitHub source — SDK source code
- Examples repository — working code for authentication, streaming, text generation, and more
- Authentication Guide — all five auth flows with code examples
- Proxy Guide — secure frontend integration patterns
- API Reference — full endpoint specifications
For support or questions, contact us