A Node.js client for the Hedra API, enabling character video generation using AI.
npm install hedraimport { HedraClient } from 'hedra';
import fs from 'fs';
const client = new HedraClient('your-api-key');
async function generateVideo() {
const audioUpload = await client.uploadAudio(fs.readFileSync('audio.wav'));
const imageUpload = await client.uploadImage(fs.readFileSync('image.jpg'), '16:9');
const generation = await client.generateCharacter({
aspectRatio: '16:9',
audioSource: 'audio',
voiceUrl: audioUpload.url,
avatarImage: imageUpload.url,
});
const completedProject = await client.waitForProjectCompletion(
generation.jobId,
(status) => console.log('Status:', status)
);
if (completedProject.videoUrl) {
await client.downloadVideo(completedProject.videoUrl, 'output.mp4');
console.log('Video downloaded to output.mp4');
}
}
generateVideo().catch(console.error);- Audio and image upload
- Character video generation
- Project status tracking
- Video download
- Project management (listing, sharing, deleting)
-
Create a client instance:
const client = new HedraClient('your-api-key');
-
Upload audio and image:
const audioUpload = await client.uploadAudio(audioFile); const imageUpload = await client.uploadImage(imageFile, '16:9');
-
Generate a character video:
const generation = await client.generateCharacter({ aspectRatio: '16:9', audioSource: 'audio', voiceUrl: audioUpload.url, avatarImage: imageUpload.url, });
-
Wait for completion and download:
const project = await client.waitForProjectCompletion(generation.jobId); await client.downloadVideo(project.videoUrl, 'output.mp4');
For detailed API reference, type information, and advanced usage examples, please refer to the full documentation.
As an unofficial client, contributions, issues, and feature requests are welcome. Please feel free to submit pull requests or open issues on the GitHub repository.
MIT
Note: This client is based on the public Hedra API documentation. For the most up-to-date and official information about the Hedra API, please refer to the official Hedra API documentation.