{"library":"simli-client","title":"Simli WebRTC Client","description":"SimliClient is a WebRTC frontend client designed for real-time interaction with AI-powered facial recognition and avatar services. It enables developers to integrate live audio and video streaming capabilities into their web applications, specifically for scenarios involving AI-driven avatars or face-based interactions. The current stable version is 3.0.1. While a specific release cadence isn't explicitly stated, the package follows semantic versioning, with major version changes (like the jump to v3) indicating significant updates and potential breaking changes. Its primary differentiator is its focus on streamlining the integration of WebRTC with Simli's AI backend for facial analysis and avatar control, abstracting much of the low-level WebRTC API complexity for these specialized use cases.","language":"javascript","status":"active","last_verified":"Wed Apr 22","install":{"commands":["npm install simli-client"],"cli":null},"imports":["import { SimliClient } from 'simli-client';","import type { SimliClientConfig } from 'simli-client';","await client.Initialize(config);"],"auth":{"required":false,"env_vars":[]},"quickstart":{"code":"import { SimliClient } from 'simli-client';\nimport type { SimliClientConfig } from 'simli-client';\n\nasync function setupSimliConnection() {\n  // In a real application, ensure these values are loaded securely (e.g., environment variables)\n  const SIMLI_API_KEY = process.env.SIMLI_API_KEY ?? 'your-simli-api-key-here';\n  const SIMLI_SERVER_URL = process.env.SIMLI_SERVER_URL ?? 'wss://your.simli.server.com/ws';\n\n  if (SIMLI_API_KEY === 'your-simli-api-key-here') {\n    console.warn(\"WARNING: Please replace 'your-simli-api-key-here' with your actual Simli API key.\");\n  }\n  if (SIMLI_SERVER_URL === 'wss://your.simli.server.com/ws') {\n    console.warn(\"WARNING: Please replace 'your.simli.server.com' with your actual Simli server URL.\");\n  }\n\n  const config: SimliClientConfig = {\n    apiKey: SIMLI_API_KEY,\n    serverUrl: SIMLI_SERVER_URL,\n    // Optional: avatarId: 'default-avatar',\n    // Optional: logLevel: 'info' // 'debug', 'warn', 'error'\n  };\n\n  const client = new SimliClient();\n\n  // Attach event listeners for connection status\n  client.on('connected', () => {\n    console.log('SimliClient: Successfully connected to the server.');\n    // You can start sending data here\n    // For demonstration, let's send dummy audio for 5 seconds\n    const dummyAudio = new Uint8Array(1024).fill(0);\n    let sendCount = 0;\n    const interval = setInterval(() => {\n      if (sendCount < 50) { // Send for 50 * 100ms = 5 seconds\n        client.sendAudioData(dummyAudio);\n        sendCount++;\n      } else {\n        clearInterval(interval);\n        console.log('SimliClient: Finished sending dummy audio data.');\n      }\n    }, 100);\n  });\n  client.on('disconnected', () => console.log('SimliClient: Disconnected from the server.'));\n  client.on('failed', (error: Error) => console.error('SimliClient: Connection failed:', error));\n\n  try {\n    console.log('SimliClient: Initializing with provided configuration...');\n    await client.Initialize(config);\n    console.log('SimliClient: Initialization complete. Attempting to start connection...');\n    await client.start(); // This establishes the WebRTC connection\n    console.log('SimliClient: Connection process initiated.');\n\n    // In a real application, you might acquire a MediaStream from getUserMedia\n    // and then use client.listenToMediastreamTrack(audioTrack);\n\n  } catch (error) {\n    console.error('SimliClient: Fatal error during setup or connection:', error);\n    client.close(); // Ensure resources are cleaned up on failure\n  }\n}\n\n// Execute the setup function\nsetupSimliConnection();\n","lang":"typescript","description":"This quickstart demonstrates how to initialize the SimliClient, set up event listeners for connection status, and establish a WebRTC connection. It includes an example of sending dummy audio data after connection and highlights secure API key handling.","tag":null,"tag_description":null,"last_tested":null,"results":[]},"compatibility":null}