Spaces:
Running
Running
| class MotionMuseIntegration extends HTMLElement { | |
| constructor() { | |
| super(); | |
| this.apiKey = 'free_tier_key'; // Replace with actual free tier key | |
| this.baseUrl = 'https://api.motionmuse.ai/v1'; | |
| } | |
| async generateAnimation(imageData, options = {}) { | |
| try { | |
| const response = await fetch(`${this.baseUrl}/animate`, { | |
| method: 'POST', | |
| headers: { | |
| 'Content-Type': 'application/json', | |
| 'Authorization': `Bearer ${this.apiKey}` | |
| }, | |
| body: JSON.stringify({ | |
| image: imageData, | |
| duration: options.duration || 10, | |
| style: options.style || 'realistic', | |
| music: options.music || false, | |
| nsfw: true | |
| }) | |
| }); | |
| if (!response.ok) { | |
| throw new Error('Animation generation failed'); | |
| } | |
| return await response.json(); | |
| } catch (error) { | |
| console.error('MotionMuse API error:', error); | |
| throw error; | |
| } | |
| } | |
| async getStatus(jobId) { | |
| try { | |
| const response = await fetch(`${this.baseUrl}/status/${jobId}`, { | |
| headers: { | |
| 'Authorization': `Bearer ${this.apiKey}` | |
| } | |
| }); | |
| return await response.json(); | |
| } catch (error) { | |
| console.error('Status check error:', error); | |
| throw error; | |
| } | |
| } | |
| } | |
| customElements.define('motionmuse-integration', MotionMuseIntegration); |