/** * Example usage of TavusClient with test API key * * This demonstrates how to use the TavusClient for development * with the built-in test API key. */ import { TavusClient, TavusConfig } from '../shared/utils/api-clients/tavus-client'; async function exampleUsage() { console.log('šŸš€ TavusClient Example with Test API Key'); console.log('=========================================='); // Example 1: Using TavusClient without providing an API key // It will automatically use the test API key console.log('\nšŸ“‹ Example 1: Using default test API key'); try { const client1 = new TavusClient({ debug: true, // No apiKey provided - will use test key }); await client1.initialize(); console.log('āœ… Client initialized successfully with test API key'); // Get available replicas const replicas = await client1.getReplicas(); console.log(`šŸ“Š Found ${replicas.length} replicas`); // Get available personas const personas = await client1.getPersonas(); console.log(`šŸ‘„ Found ${personas.length} personas`); } catch (error) { console.error('āŒ Error with test API key:', error); } // Example 2: Using TavusClient with a custom API key console.log('\nšŸ“‹ Example 2: Using custom API key'); try { const client2 = new TavusClient({ apiKey: 'your-custom-api-key-here', debug: true, defaultPipelineMode: 'premium', }); await client2.initialize(); console.log('āœ… Client initialized successfully with custom API key'); // Set pipeline mode client2.setPipelineMode('enterprise'); console.log(`šŸŽ›ļø Pipeline mode set to: ${client2.pipelineMode}`); } catch (error) { console.error('āŒ Error with custom API key:', error); } // Example 3: Video session creation console.log('\nšŸ“‹ Example 3: Creating video session'); try { const client3 = new TavusClient({ debug: true, }); await client3.initialize(); // Create a video session (this would require valid replica and persona IDs) // const session = await client3.createVideoSession('replica-id', 'persona-id', 'premium'); // console.log('šŸŽ„ Video session created:', session.sessionId); // For demo purposes, we'll just show the method signature console.log('šŸŽ„ Video session creation method available'); console.log(' createVideoSession(replicaId, personaId, pipelineMode)'); } catch (error) { console.error('āŒ Error creating video session:', error); } // Example 4: Avatar generation console.log('\nšŸ“‹ Example 4: Avatar generation'); try { const client4 = new TavusClient({ debug: true, }); await client4.initialize(); // Generate an avatar (this would require valid replica and persona IDs) // const avatarRequest = { // replicaId: 'replica-id', // personaId: 'persona-id', // script: 'Hello, how can I help you today?', // pipelineMode: 'premium', // videoQuality: 'high', // audioQuality: 'high', // enableStreaming: false, // }; // const avatar = await client4.generateAvatar(avatarRequest); // console.log('šŸŽ¬ Avatar generated:', avatar.videoUrl); // For demo purposes, we'll just show the method signature console.log('šŸŽ¬ Avatar generation method available'); console.log(' generateAvatar(request)'); } catch (error) { console.error('āŒ Error generating avatar:', error); } console.log('\n✨ Example completed!'); console.log('\nšŸ“ Notes:'); console.log('- The test API key is automatically used when no API key is provided'); console.log('- In production, you should provide your own API key'); console.log('- All methods require valid replica and persona IDs from your Tavus account'); console.log('- The client supports both synchronous avatar generation and real-time streaming'); } // Run the example if this file is executed directly if (require.main === module) { exampleUsage().catch(console.error); } export { exampleUsage };