mugib_voice 0.2.1
mugib_voice: ^0.2.1 copied to clipboard
Official Flutter SDK for Mugib voice agents. One client for VAPI and Google Gemini Live — pass apiKey and agentId only.
mugib_voice #
Official Flutter SDK for Mugib real-time voice agents.
Talk to your AI agent by voice with a single client. The SDK includes VAPI
and Gemini Live support — you only pass apiKey + agentId. The SDK
calls /token and picks the right provider automatically (same flow as
voice-widget.js).
Install #
Add to your app's pubspec.yaml:
dependencies:
mugib_voice: ^0.2.0
Then:
flutter pub get
Monorepo / local dev: use
path: ../sdk/flutter/mugib_voiceinstead of the version constraint above.
Requirements: Flutter 3.24+ / Dart 3.5+
Bundled dependencies:
vapi— VAPI WebRTC callsweb_socket_channel— Gemini Live streamrecord— microphone PCM captureflutter_pcm_sound— Gemini PCM playbackhttp— agent list + token API
Platform setup #
iOS — ios/Runner/Info.plist #
<key>NSMicrophoneUsageDescription</key>
<string>We need the microphone for voice conversations.</string>
Set the minimum iOS version to 12.0+ in ios/Podfile:
platform :ios, '12.0'
Android — android/app/src/main/AndroidManifest.xml #
<uses-permission android:name="android.permission.RECORD_AUDIO" />
<uses-permission android:name="android.permission.INTERNET" />
Set minSdkVersion 23 (or higher) in android/app/build.gradle.
Quick start #
import 'package:mugib_voice/mugib_voice.dart';
// Once at app startup (initializes VAPI native layers)
await MugibVoice.initialize();
// List agents to show a picker (includes provider per agent)
final agents = await MugibVoice.listAgents(apiKey: 'YOUR_PROJECT_API_KEY');
for (final a in agents) {
print('${a.id} ${a.name} provider=${a.provider}');
}
final call = MugibVoiceClient(
apiKey: 'YOUR_PROJECT_API_KEY',
agentId: 34,
// baseUrl: 'https://api.mugib.com',
);
call.state.listen((s) => print('state: $s'));
call.transcripts.listen((t) => print('${t.role}: ${t.text}'));
call.errors.listen((e) => print('error: $e'));
await call.start(); // fetches /token → VAPI or Gemini Live
call.mute();
call.unmute();
await call.end();
await call.dispose();
API #
MugibVoice #
| Method | Description |
|---|---|
Future<void> initialize() |
Initialize VAPI native/WebRTC (call once in main) |
Future<List<MugibAgentSummary>> listAgents({apiKey, baseUrl}) |
GET /api/v1/voice-agents — includes provider |
MugibVoiceClient(...) #
| Param | Type | Default | Description |
|---|---|---|---|
apiKey |
String |
— | Project API key |
agentId |
int |
— | Voice agent id |
baseUrl |
String |
https://api.mugib.com |
API base URL |
| Method | Description |
|---|---|
Future<void> start() |
Fetches /token, connects via VAPI or Gemini Live |
Future<void> end() |
Ends the call |
void mute() / unmute() / bool toggleMute() |
Microphone control |
Future<void> dispose() |
Releases all resources |
MugibVoiceToken? get token |
Last resolved token (provider, agent name, …) |
Streams #
| Stream | Emits |
|---|---|
state |
MugibCallState |
transcripts |
MugibTranscript { role, text } |
errors |
String |
MugibAgentSummary (from list endpoint) #
| Field | Description |
|---|---|
id, name, language, dialect, voiceGender |
Display / picker |
provider |
"vapi" or "gemini_live" |
isActive |
Always true in list (inactive agents are filtered server-side) |
How it works #
App (apiKey + agentId)
→ GET /api/v1/voice-agents/{id}/token
→ provider = vapi → VapiClient.start(assistantId)
→ provider = gemini_live → WebSocket /stream + PCM mic/playback
Knowledge base, prompts, language, and voice are resolved server-side.
Publish / update (maintainers) #
cd sdk/flutter/mugib_voice
make login # once
make release-patch # bump patch + publish to pub.dev
# or: make update # publish current version only
make help
Verify (maintainers) #
cd sdk/flutter/mugib_voice
make check
License #
MIT — see LICENSE.