Skip to content

AiProvider Global Config

AiProvider is the core configuration component of the AI component library, used to inject global settings at the top level of the application. It uses Vue's provide/inject mechanism to provide essential configurations such as base API URLs, authentication info, avatars, and typewriter effects to all downstream AI components (e.g., AiChat, AiBubble).

Basic Usage

It is recommended to wrap AiProvider at the root component of your application or at the outer-most level of an AI feature module.

Hello! I am the assistant configured by AiProvider.

Basic Usage

Global Identity Configuration

You can centrally set user and assistant avatars and names using AiProvider.

Who is configuring me?

It’s me, your global assistant.

Global Identity Configuration

API

Props

NameDescriptionTypeDefault
base-urlGlobal AI base URLstring-
tokenAuthentication Token (Bearer)string-
headersGlobal request headersRecord<string, string>-
user-avatarUser avatar URLstring-
assistant-avatarAssistant avatar URLstring-
user-nameUser display namestring-
assistant-nameAssistant display namestring-
system-promptGlobal system promptstring-
typewriterTypewriter effect configurationobject{ enabled: true, charsPerFrame: 2 }

typewriter property definition

NameDescriptionTypeDefault
enabledWhether to enable typewriter effectbooleantrue
chars_per_frameCharacters per frame to rendernumber2

Slots

NameDescription
defaultDownstream component content for configuration injection

Recommendations

  • Vite/Nuxt Projects: Typically used once in App.vue or layouts/default.vue.
  • Scope Isolation: If your application has multiple distinct AI modules (e.g., a support bot and a code assistant), you can wrap them in separate AiProvider instances for isolation.

Released under the MIT License.