Skip to main content

PilotKit

Core container component, integrates Provider and digital human rendering, is the root component for all Widget components.

Basic Usage

<script setup lang="ts">
import {PilotKit, ControlPanel} from '@bdky/aaas-pilot-kit-vue3-widget';
import '@bdky/aaas-pilot-kit-vue3-widget/styles.css';
</script>

<template>
<PilotKit
token="your-token"
figureId="your-figure-id"
ttsPer="your-tts-per"
:agentConfig="{robotId: 'your-robot-id'}"
>
<ControlPanel />
</PilotKit>
</template>

Using Ref

Through ref you can access controller methods:

<script setup lang="ts">
import {ref} from 'vue';
import {PilotKit, type IPilotKitRef} from '@bdky/aaas-pilot-kit-vue3-widget';
import '@bdky/aaas-pilot-kit-vue3-widget/styles.css';

const pilotKitRef = ref<IPilotKitRef | null>(null);

function handleSendMessage() {
pilotKitRef.value?.input('Hello');
}

function handleInterrupt() {
pilotKitRef.value?.interrupt();
}
</script>

<template>
<PilotKit ref="pilotKitRef" v-bind="props">
<button @click="handleSendMessage">Send Message</button>
<button @click="handleInterrupt">Interrupt</button>
</PilotKit>
</template>

Props

Required Properties

PropertyTypeDescription
tokenstringAuthentication Token
figureIdstringDigital human avatar ID
ttsPerstringTTS voice ID

Agent Configuration

PropertyTypeDescription
agentConfig{robotId: string; token?: string}Agent configuration, choose one with agentService
agentServicetypeof BaseAgentServiceCustom AgentService class
agentConfig vs agentService
  • Use Baidu default Agent: Configure agentConfig
  • Use private Agent API: Provide custom agentService, see Custom AgentService

Behavior Configuration

PropertyTypeDefaultDescription
prologuestring-Opening remark, automatically broadcast after SDK ready
interruptiblebooleanfalseWhether to allow interrupting broadcast
timeoutSecnumber120No operation timeout time (seconds)
typeDelaynumber100Chinese typewriter effect delay (ms)
enTypeDelaynumber50English typewriter effect delay (ms)
minSplitLennumber10Streaming text minimum split length

Rendering Configuration

PropertyTypeDefaultDescription
rendererMode'cloud-native' | 'standard''standard'Rendering mode
scaleXnumber1Horizontal scaling
scaleYnumber1Vertical scaling
translateXnumber0Horizontal offset
translateYnumber0Vertical offset

Internationalization Configuration

PropertyTypeDefaultDescription
localestring'zh'UI interface language (v1.1.2+)
messagesPartial<I18nMessages>-Custom translation messages (v1.1.2+)

For detailed configuration, see Internationalization (i18n)

Style Properties

PropertyTypeDescription
classstringCustom class name
styleCSSPropertiesCustom style
backgroundUrlstringBackground image URL
autoMountbooleanWhether to auto-mount, default true

Events

EventTypeDescription
@ready() => voidSDK ready
@needManualActivation() => voidNeed manual activation (iOS iframe)
@asrStart() => voidASR started
@asrMessage(payload) => voidASR recognition result
@renderStart(payload) => voidStarted broadcasting
@inactivity(payload) => voidUser inactivity timeout
@busy(payload) => voidSystem busy
@interrupt(payload) => voidBroadcast interrupted
@conversationChange(payload) => voidConversation content changed
@isRenderingChange(isRendering) => voidBroadcasting status changed
@replyStart(payload) => voidReply started
@ttft(payload) => voidFirst token latency metric
Event Payload Types

Event callback Payload type definitions are detailed in Vue 3 SDK Composables Documentation.

Ref Methods

Through ref you can access following methods:

MethodTypeDescription
input(text: string) => voidSend text input
mute(muted: boolean) => voidSet mute status
interrupt() => voidInterrupt current broadcast
dispose() => voidDestroy instance
playPrologue() => voidPlay opening remark
playFromFullText(text: string) => voidPlay complete text
playFromStreamText(text: string) => voidStream play text
keepAlive() => voidKeep connection active
checkAudioDevice() => Promise<Result>Check audio device
activateManually() => Promise<void>Manual activation (iOS)
getIsReady() => booleanGet ready status
getIsMuted() => booleanGet mute status
getIsRendering() => booleanGet broadcasting status

Provide/Inject

PilotKit internally creates PilotKitContext, child components can access through usePilotKitContext:

<script setup lang="ts">
import {usePilotKitContext} from '@bdky/aaas-pilot-kit-vue3-widget';

const pilotKit = usePilotKitContext();

function sendMessage() {
pilotKit?.input('Hello');
}
</script>

<template>
<button @click="sendMessage">Send Message</button>
</template>

Style Customization

CSS Class Names

Class NameDescription
.apk-pilot-kitRoot container
.apk-pilot-kit__maskMask layer (children rendering position)

Background Image

Use backgroundUrl to set background:

<template>
<PilotKit
backgroundUrl="https://example.com/background.jpg"
...
/>
</template>