Installation & Setup
Learn how to install and set up the Synthesia SDK in your project.
Prerequisites
- Node.js 16 or higher
- TypeScript 4.5 or higher (recommended)
- A Synthesia account with API access (Creator plan or above)
Installation
Using npm
npm install @androettop/synthesia-sdkUsing yarn
yarn add @androettop/synthesia-sdkUsing pnpm
pnpm add @androettop/synthesia-sdkBasic Setup
TypeScript
import { Synthesia } from '@androettop/synthesia-sdk';
const synthesia = new Synthesia({ apiKey: 'your-api-key-here',});JavaScript (CommonJS)
const { Synthesia } = require('@androettop/synthesia-sdk');
const synthesia = new Synthesia({ apiKey: 'your-api-key-here',});JavaScript (ES Modules)
import { Synthesia } from '@androettop/synthesia-sdk';
const synthesia = new Synthesia({ apiKey: 'your-api-key-here',});Configuration Options
The SDK accepts the following configuration options:
const synthesia = new Synthesia({ apiKey: 'your-api-key-here', // Required: Your Synthesia API key baseURL: 'https://api.synthesia.io/v2', // Optional: Custom API base URL});Configuration Parameters
| Parameter | Type | Required | Default | Description |
|---|---|---|---|---|
apiKey | string | ✅ | - | Your Synthesia API key |
baseURL | string | ❌ | https://api.synthesia.io/v2 | Custom API base URL |
Environment Variables
For security, it’s recommended to store your API key in environment variables:
# .env fileSYNTHESIA_API_KEY=your-api-key-hereimport { Synthesia } from '@androettop/synthesia-sdk';
const synthesia = new Synthesia({ apiKey: process.env.SYNTHESIA_API_KEY!,});Getting Your API Key
- Log into your Synthesia account
- Navigate to Integrations in the settings
- Click “Add” to generate a new API key
- Copy the API key and store it securely
📝 Note: API access is available for Creator plans and above. See the official documentation for more details.
Verification
Test your installation and API key:
import { Synthesia } from '@androettop/synthesia-sdk';
const synthesia = new Synthesia({ apiKey: process.env.SYNTHESIA_API_KEY!,});
// Test API connectionasync function testConnection() { try { const videos = await synthesia.videos.listVideos({ limit: 1 });
if (videos.error) { console.error('API Error:', videos.error.message); } else { console.log('✅ SDK connected successfully!'); console.log(`Found ${videos.data?.count} videos in your account`); } } catch (error) { console.error('❌ Connection failed:', error); }}
testConnection();