JavaScript SDK Documentation
Official JavaScript/TypeScript SDK for the OrbitalsAI API. Process audio, manage billing, and integrate AI-powered features into your applications with ease.
Features
Installation
Install the official orbitalsai package using your preferred package manager. The SDK works across Node.js and browser-based applications and is fully typed for TypeScript projects.
Quick Start
Start with upload-and-transcribe for pre-recorded files, then use real-time streaming when your product needs live transcription in a session. Most teams begin with these two entry points.
Upload & Transcribe
Use this flow for a single pre-recorded file: upload audio, then poll until the transcription task completes.
Real-Time Streaming Transcription
Use streaming for voice assistants, captions, call interfaces, and other low-latency use cases where users need live partial and final text updates.
Initialization
Initialize one client per process or request context and reuse it across calls. Configure timeout and retries based on your network environment and UX expectations.
Get Your API Key
Authentication & Security
OrbitalsAI uses API key authentication. Keep keys server-side when possible, rotate them regularly, and never hardcode production secrets in committed source files.
API Key Authentication
Pass your key through the SDK configuration. The client sends the bearer token on your behalf, so you do not need to manually set headers for every request.
Environment Variables
Store your API key in environment variables and read it at runtime. This keeps secrets out of your codebase and makes environment-specific deployments safer and easier to manage.
Audio Processing
Use these endpoints for pre-recorded files and asynchronous workflows. You can control language behavior, model selection, subtitle output, and polling strategy based on your app requirements.
Selecting Language and model_name
Choose a language when you already know the source speech language, and set model_name when you want explicit control over the transcription model in use.
Upload Audio for Transcription
Upload from either browser file inputs or Node.js buffers. The SDK accepts both and normalizes the request shape for you.
Check Transcription Status
Use this endpoint to fetch the current state of a specific task by task ID. This is useful when you already have task IDs stored and want to retrieve status or final outputs on demand.
Wait for Completion
For simpler flows, use waitForCompletionto handle polling internally with configurable interval and timeout.
Batch Processing (Multiple Files)
For multi-file workflows, upload all files first, then resolve each task independently. This pattern helps you process partial successes without failing the entire batch when one file errors out.
You can also run batch uploads in a deferred mode: upload files now, persist the returned task IDs, and resolve results later. In that flow, use client.audio.getTasks() to list tasks and statuses, then call client.audio.getStatus(taskId) for any specific task when you need its latest status or result.
Tasks and Models
List tasks to build history views and dashboards, and list models to dynamically expose model selection in your product UI.
Get Available Models
Streaming Transcription (Real-Time ASR)
The SDK supports real-time audio transcription via WebSocket connection. This is ideal for live audio streams, voice interfaces, and real-time captioning. Supported languages: English, Hausa, Igbo, Yoruba.
Basic Streaming Setup
Use returnTimestamps: true in connect() to receive word-level timestamps in final events (e.g. for subtitles or alignment).
Enabling Word-Level Timestamps
Set returnTimestamps: true while connecting to receive per-word timing in final messages. Each timestamp entry includes start, end, and text, which is useful for subtitles and transcript alignment.
Sending Audio Data
Audio must be sent as raw PCM data: Int16, mono, 16kHz.
Billing Management
Track account balance and usage history so you can monitor spend, display cost analytics, and enforce usage policies in your app.
Get Account Balance
Get Daily Usage History
Error Handling
The SDK provides detailed error classes for different scenarios:
Error Types
AuthenticationError
Invalid or missing API key (401)
ValidationError
Invalid request parameters (422)
RateLimitError
Too many requests (429)
NetworkError
Connection or timeout issues
TypeScript Support
The SDK is written in TypeScript and provides comprehensive type definitions:
Complete Example
This end-to-end example combines secure initialization, upload options, completion polling, and billing checks in one flow that you can adapt for production.