Skip to main content

AIAvatarKit

🥰 Building AI-based conversational avatars lightning fast ⚡️💬

AIAvatarKit Architecture Overview

💎 What your avatar can be

  • Talking avatars in your app — a character in your web or mobile app that speaks, reacts with expressions and animations
  • Interactive signage and virtual store staff — reception, wayfinding, and product guidance that answers out loud while putting images and UI on the screen
  • Companion devices — Raspberry Pi, M5Stack, StackChan, and other hardware; add voice conversation to anything
  • Metaverse AI avatars — conversational characters on VRChat, cluster, and Vket Cloud
  • Phone operators — inbound and outbound calls handled through Twilio or Asterisk
  • Multi-channel AI assistants — one assistant your users reach through whichever channel fits the moment

✨ Features

  • ⚡️ Ultra-low latency — streaming and parallel throughout the pipeline, even running STT speculatively and giving a spoken nod before the answer itself. <1s from end of speech to first audio, measured.

  • 🧩 Modular architecture — VAD, STT, LLM, and TTS are swappable parts: popular providers are built in, and a small interface covers the rest. A more natural voice or a smarter model ships — your avatar levels up with it.

  • 🦜 AI Agent native — tool calls and MCP, of course. Tools load only when needed, so a large catalog never confuses the model, and slow ones never stall the conversation: background execution, or a reply straight from a template.

  • 🥳 Multimodal and expressive — accepts speech, text, images, and files; replies with voice, facial expressions, animations, and on-screen artifacts. A chart or a map appears just as the avatar mentions it.

  • 🌐 Omnichannel — web, phone, LINE, metaverse, and local devices all run off one pipeline, and the conversation follows the user rather than the channel: hang up the phone, open LINE, and it is still there.

  • 📦 Ready for production — Admin Panel for config, logs, metrics, and evaluation, plus Langfuse tracing. Retune a running pipeline without restarting. Guardrails run in parallel and can interrupt the avatar mid-sentence to correct what it just said.

🚀 Quick start

Requirements: Python 3.11+, an OpenAI API key, and a reachable VOICEVOX-compatible server at its default URL.

Install AIAvatarKit.

pip install aiavatar

Start the built-in default application.

export OPENAI_API_KEY=sk-xxx
aiavatar

The built-in application uses Namo Turn semantic VAD. When its optional dependencies are missing, the command asks whether to install them:

Additional dependencies are required to enable Semantic VAD. Install them now? [y/N]:

Answer y to install aiavatar[namo-turn] into the current Python environment and continue startup automatically. Answer n to start without the Namo Turn gate; Silero VAD and the filler gate remain enabled.

Open http://127.0.0.1:8000/ and enjoy the conversation! The Admin Panel is available at http://127.0.0.1:8000/admin/.

Or, write your own application script when you need full, fine-grained control over components, routes, and application lifecycle. Save the following as run.py.

import os

from fastapi import FastAPI
from fastapi.staticfiles import StaticFiles
from aiavatar.adapter.websocket.server import AIAvatarWebSocketServer
from aiavatar.admin import setup_admin_panel
from aiavatar.util import download_example

# Download example UI if not exists
html_dir = download_example("websocket/html")

# Build Speech-to-Speech pipeline with WebSocket adapter
aiavatar_app = AIAvatarWebSocketServer(
    openai_api_key=os.environ["OPENAI_API_KEY"]
)

app = FastAPI()
app.include_router(aiavatar_app.get_websocket_router())

# Admin panel (optional)
setup_admin_panel(app, adapter=aiavatar_app)

# Serve the UI at "/". This catch-all mount must come after the routes above.
app.mount("/", StaticFiles(directory=html_dir, html=True), name="ui")

Start the server. Don't forget to launch VOICEVOX beforehand.

python -m uvicorn run:app

Same URLs as before: http://127.0.0.1:8000/ for the avatar, /admin/ for the Admin Panel.

See Getting started for the CLI options, script mode, and every setting of the built-in application.

NOTE: If the steps in technical blogs don't work as expected, the blog may be based on a version prior to v0.6. Some features may be limited, but you can try downgrading with pip install aiavatar==0.5.8 to match the environment described in the blog.

🔭 Architecture

A single STSPipeline turns what the user says into what the avatar says and does. Each stage is a replaceable module, and each stage streams into the next.

flowchart LR
    CH["Web / App · Phone<br/>Metaverse · LINE · Device"]
    AD(["Channel<br/>Adapter"])
    CH <--> AD
    AD <--> STS
    subgraph STS ["Speech-to-Speech Pipeline"]
        direction LR
        VAD --> STT --> LLM["LLM / Tools / Agent"] --> TTS
        LLM --> ACT["face · animation<br/>artifacts"]
    end

An Adapter wraps the pipeline for one channel — WebSocket, HTTP, telephony, messaging — and owns only transport concerns. Multiple adapters can attach to the same pipeline instance, so a user can move between channels within one conversation.

Every component is a swappable module, and these are the implementations that ship with it:

Component Services
Voice Activity Detection Silero VAD · Silero VAD (streaming) · Azure Speech · Amazon Transcribe · Parapper · volume threshold
Turn-end gates (semantic VAD) Smart Turn · Namo Turn · filler-only · LLM-based · session hold · custom
Speech-to-Text Azure Speech · Google Cloud Speech-to-Text · OpenAI · AmiVoice, and any OpenAI-compatible endpoint
LLM OpenAI Chat Completions · Azure OpenAI · OpenAI Responses API · Anthropic Claude · Google Gemini · xAI Grok · OpenRouter · LM Studio · Dify · LiteLLM
Text-to-Speech VOICEVOX · AivisSpeech · Azure · Google · OpenAI · VOISONA · SpeechGateway · Style-Bert-VITS2 · Aivis Cloud API · ElevenLabs · Kotodama · CoeFont · Amazon Polly · COEIROINK
Channels WebSocket · HTTP (SSE) · LINE Bot · Twilio Voice and SMS · Asterisk · OpenAI-compatible endpoint · speech recognition only

Between OpenRouter and LiteLLM, practically any commercially available model — GPT, Claude, Gemini, Grok, Llama, Qwen, DeepSeek, Mistral, and others — can be used without writing an integration.

Any TTS service that exposes an HTTP endpoint can be added the same way, without writing a synthesizer class. Several of the services above are supported exactly like that.

🍳 Recipes

Use a different LLM

from aiavatar.sts.llm.claude import ClaudeService

llm = ClaudeService(
    anthropic_api_key=ANTHROPIC_API_KEY,
    model="claude-sonnet-4-5",
    system_prompt="You are my cat.",
)

aiavatar_app = AIAvatarWebSocketServer(
    llm=llm,
    openai_api_key=OPENAI_API_KEY,  # still used for STT
)

Or reach any model through an OpenAI-compatible endpoint such as OpenRouter:

from aiavatar.sts.llm.chatgpt import ChatGPTService

llm = ChatGPTService(
    openai_api_key=OPENROUTER_API_KEY,
    base_url="https://openrouter.ai/api/v1",
    model=OPENROUTER_MODEL,
    system_prompt="You are my cat.",
)

LLM guide

Use a different voice

from aiavatar.sts.tts.voicevox import VoicevoxSpeechSynthesizer

# AivisSpeech exposes a VOICEVOX-compatible API
tts = VoicevoxSpeechSynthesizer(
    base_url="http://127.0.0.1:10101",
    speaker="888753761",  # Anneli
    cache_dir="./tts_cache/aivisspeech",
)

aiavatar_app = AIAvatarWebSocketServer(tts=tts, openai_api_key=OPENAI_API_KEY)

Or wrap any HTTP TTS endpoint without writing a class:

from aiavatar.sts.tts import create_instant_synthesizer

tts = create_instant_synthesizer(
    method="POST",
    url=f"https://api.elevenlabs.io/v1/text-to-speech/{voice_id}",
    headers={"xi-api-key": ELEVENLABS_API_KEY},
    params={"output_format": "wav_16000"},   # Query parameter, not body
    json={
        "text": "{text}",  # Placeholder for processed text
        "model_id": "eleven_v3",
    },
)

TTS guide

Give the avatar a tool

weather_tool_spec = {
    "type": "function",
    "function": {
        "name": "get_weather",
        "description": "Get the current weather and forecast for a location",
        "parameters": {
            "type": "object",
            "properties": {"location": {"type": "string"}},
            "required": ["location"],
        },
    },
}

@aiavatar_app.sts.llm.tool(weather_tool_spec)
async def get_weather(location: str):
    return await weather_api(location=location)

@llm.tool() stores the spec as given, so it must already be in that provider's format. To write one spec and use it anywhere, register through add_tool() instead — it converts between the Chat Completions, Gemini, and Claude shapes for you:

from aiavatar.sts.llm import Tool

aiavatar_app.sts.llm.add_tool(
    Tool("get_weather", weather_tool_spec, get_weather)
)

Tools guide

Connect an MCP server

from contextlib import asynccontextmanager

from fastapi import FastAPI
from aiavatar.sts.llm.tools.mcp import StreamableHttpMCP

mcp = StreamableHttpMCP(url=MCP_URL)
mcp.for_each_tool = aiavatar_app.sts.llm.add_tool

@asynccontextmanager
async def lifespan(app: FastAPI):
    try:
        await mcp.initialize()   # Connects and registers the server's tools
        yield
    finally:
        await mcp.close()

app = FastAPI(lifespan=lifespan)
app.include_router(aiavatar_app.get_websocket_router())

for_each_tool is the callback; initialize() is what connects to the server and runs it. Setting the callback alone registers nothing.

MCP guide

Assemble the whole pipeline

Every stage chosen explicitly: Azure for recognition, streaming Silero for turn detection, GPT for generation, and Aivis Cloud for the voice.

import os

from fastapi import FastAPI
from aiavatar.sts import STSPipeline
from aiavatar.sts.stt.azure import AzureSpeechRecognizer
from aiavatar.sts.vad.stream import SileroStreamSpeechDetector
from aiavatar.sts.llm.openai_responses_websocket import OpenAIResponsesWebSocketService
from aiavatar.sts.tts import AudioConverter, create_instant_synthesizer
from aiavatar.adapter.websocket.server import AIAvatarWebSocketServer

# Speech-to-Text
stt = AzureSpeechRecognizer(
    azure_api_key=os.environ["AZURE_API_KEY"],
    azure_region=os.environ["AZURE_REGION"],
    language="ja-JP",
)

# Voice activity detection, recognizing segments while the user is still speaking
vad = SileroStreamSpeechDetector(
    speech_recognizer=stt,
    silence_duration_threshold=0.5,
    segment_silence_threshold=0.2,
)

# LLM
llm = OpenAIResponsesWebSocketService(
    openai_api_key=os.environ["OPENAI_API_KEY"],
    model="gpt-5.6-terra",
    system_prompt="You are my cat.",
    reasoning_effort="none",
)

# Text-to-Speech, wrapping the Aivis Cloud HTTP endpoint
tts = create_instant_synthesizer(
    method="POST",
    url="https://api.aivis-project.com/v1/tts/synthesize",
    headers={
        "Content-Type": "application/json",
        "Authorization": f"Bearer {os.environ['AIVIS_API_KEY']}",
    },
    json={
        "model_uuid": "22e8ed77-94fe-4ef2-871f-a86f94e9a579",   # Kohaku
        "text": "{text}",
    },
    response_parser=AudioConverter().convert,
)

# The pipeline owns the conversation; the adapter owns the transport
sts = STSPipeline(vad=vad, stt=stt, llm=llm, tts=tts)

aiavatar_app = AIAvatarWebSocketServer(sts=sts)

app = FastAPI()
app.include_router(aiavatar_app.get_websocket_router())

Aivis Cloud returns encoded audio, so AudioConverter().convert transcodes it — that path shells out to ffmpeg, which must be installed separately.

The recognizer is passed twice on purpose. SileroStreamSpeechDetector uses it to transcribe segments mid-utterance, and the pipeline keeps it for requests that arrive as audio rather than as already-recognised text.

Pipeline guide

Serve two channels from one pipeline

Take the sts built above and hand the same instance to every adapter. One conversation, one set of components, several ways in.

from aiavatar.adapter.websocket.server import AIAvatarWebSocketServer
from aiavatar.adapter.linebot.server import AIAvatarLineBotServer

websocket_adapter = AIAvatarWebSocketServer(
    sts=sts,
    channel="websocket",
)

line_adapter = AIAvatarLineBotServer(
    sts=sts,
    channel_access_token=os.environ["LINEBOT_CHANNEL_ACCESS_TOKEN"],
    channel_secret=os.environ["LINEBOT_CHANNEL_SECRET"],
    api_key=os.environ["LINEBOT_ADMIN_API_KEY"],
    channel="linebot",
)

app.include_router(websocket_adapter.get_websocket_router(path="/ws"))
app.include_router(line_adapter.get_api_router(), prefix="/line")

Sharing the pipeline shares its components and its conversation storage. To have the same person resume their conversation when they switch channels, add a channel context bridge.

Adapters guide

📚 Documentation

🚀 Start here

  • Getting started
    • Built-in application — the aiavatar command, .env settings, Admin Panel, script mode
    • Configuration — OpenAI and LLM configuration, per-component API keys and base URLs, built-in TTS routing
  • Pipeline
    • Turn lifecycle — sessions, contexts, and users, request merging, timestamp insertion
    • Queueing — invoke queue, invoke modes, per-request behavior
    • Opening moves — wake word, quick response, QuickResponderPro
    • Hooks and records — request validation, custom behavior, performance recording, voice recording

🎙️ Voice Activity Detection

  • Speech detector (VAD)
    • Detectors — Silero, Silero streaming, Azure Stream, AWS Amazon Transcribe Stream, Parapper, standard volume threshold (legacy)
    • Tuning — pre-roll buffer, muting and barge-in, minimum and maximum duration
    • Callbacks — segment recognition, text validation, on_recording_started, custom trigger conditions, custom detectors
  • Semantic turn end
    • Gates — Smart Turn, Namo Turn, filler-only, LLM turn gate, session hold, custom gates
    • Coordination — turn-end gate manager, wait timeouts, background gates
  • Audio filters — AGC, high-shelf EQ, near-field gate, session audio recorder

👂 Speech-to-Text

🎓 LLM

🦜 Agent and tools

  • Tools
    • Tool call — spec formats, @llm.tool versus add_tool, one definition across GPT, Gemini, and Claude
    • Long-running work — streaming progress, background tool execution, background timeout
    • Direct output — tool response formatter, continuing tool chains with continue_chain, structured content for the client
    • Dynamic tool call — registering dynamic tools, system prompt setup, custom tool repository, supported services
  • Built-in tools
    • Tools — web search (OpenAI, Gemini, Grok), web scraper, image generation
    • OpenClaw and Hermes — push and polling delivery, progress tracking, report channel routing, per-user configuration, custom harnesses
  • MCP — Streamable HTTP servers, stdio servers, authentication headers, tool filtering

🗣️ Text-to-Speech

🥳 Avatar and character

  • Avatar control — face expressions and animations, AvatarControlRequest, control tags, browser and Python clients
  • Artifacts — images, charts, slides, YouTube, sandboxed web apps, Google maps and directions, artifact catalog, URL validation
  • Vision — vision tags, get_image_url, sending camera or screen images with a request
  • Character
    • Character service — character prompts, weekly and daily schedules, diaries, automated daily updates, batch generation
    • Integration — binding to an adapter, long-term memory
    • CharacterLoader — single file mode, directory mode, hot reload, custom user name resolution, custom message formatting
  • Long-term memory — ChatMemory, MemorySearchTool, shared context

🌐 Channels

  • Adapters — choosing an adapter, connecting multiple channels, sharing context across channels, channel-aware processing, per-adapter control tags
  • WebSocket — wire protocol, browser and Python clients, connection and disconnection handling
  • HTTP (SSE) — streaming chat API, Dify-compatible /chat-messages endpoint, standalone STT and TTS endpoints
  • LINE Bot — webhooks, supported messages, push messages, customization hooks
  • Twilio — Voice over Media Streams, outbound calls, SMS, protecting the action endpoints
  • Asterisk — ARI call control, media WebSocket, transfer strategies, call lifecycle
  • OpenAI-compatible endpoint · Speech recognition server

💻 Environment

  • Database — SQLite and PostgreSQL, shared pool provider, conversation context, session state, performance records, speaker registry, channel context bridge
  • Platforms and devices — VRChat face expression and animation over OSC, Raspberry Pi, audio device selection

🎛️ Operations

  • Administration — Admin Panel, admin REST API, observability with Langfuse
  • Evaluation — scenario-based dialog evaluation, file-based evaluation, configuration options, the Config API, logic-based evaluation

🔖 Reference

  • Migration guide — v0.6.x to v0.7.0 and later
  • examples/ — WebSocket browser UI, local client, Twilio, Asterisk, speech recognition server

⚖️ License

Apache License 2.0. See LICENSE.

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

aiavatar-0.9.0.tar.gz (329.6 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

aiavatar-0.9.0-py3-none-any.whl (421.0 kB view details)

Uploaded Python 3

File details

Details for the file aiavatar-0.9.0.tar.gz.

File metadata

  • Download URL: aiavatar-0.9.0.tar.gz
  • Upload date:
  • Size: 329.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.11.9

File hashes

Hashes for aiavatar-0.9.0.tar.gz
Algorithm Hash digest
SHA256 11e0fed9973448d1b8b64591dc6d9b372b9ca57ff0357f3bb00a114376f297d0
MD5 4ce33ad4b57559d89ee2fe633f7f7e6e
BLAKE2b-256 63d0abe5f5838ea688bf6ba97b078b0d00dada82cce9b4d65a1bec314743aba9

See more details on using hashes here.

File details

Details for the file aiavatar-0.9.0-py3-none-any.whl.

File metadata

  • Download URL: aiavatar-0.9.0-py3-none-any.whl
  • Upload date:
  • Size: 421.0 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.11.9

File hashes

Hashes for aiavatar-0.9.0-py3-none-any.whl
Algorithm Hash digest
SHA256 211494b77eb0c350190c5d010e137033db30ac73ea4c63d536bb13e52bd1fb8e
MD5 d76f949e11c7427ad49b7808819fbb7d
BLAKE2b-256 59e54f899988e672b590aba9478312164e904293cc4d1c47b66890f25f973532

See more details on using hashes here.

Release history Release notifications | RSS feed

This release

0.9.0 This release

2 files

0.8.19

1 file

0.8.18

1 file

0.8.17

1 file

0.8.16

1 file

0.8.15

1 file

0.8.14

1 file

0.8.13

1 file

0.8.12

1 file

0.8.11

1 file

0.8.10

1 file

0.8.9

1 file

0.8.8

1 file

0.8.7

1 file

0.8.6

1 file

0.8.5

1 file

0.8.4

1 file

0.8.3

1 file

0.8.2

1 file

0.8.1

1 file

0.8.0

1 file

0.7.21

1 file

0.7.20

1 file

0.7.19

1 file

0.7.18

1 file

0.7.17

1 file

0.7.16

1 file

0.7.15

1 file

0.7.14

1 file

0.7.13

1 file

0.7.12

1 file

0.7.11

1 file

0.7.10

1 file

0.7.9

1 file

0.7.8

1 file

0.7.7

1 file

0.7.6

1 file

0.7.5

1 file

0.7.4

1 file

0.7.3

1 file

0.7.2

1 file

0.7.1

1 file

0.7.0

1 file

0.5.8

1 file

0.5.7

1 file

0.5.6

1 file

0.5.5

1 file

0.5.4

1 file

0.5.3

1 file

0.5.2

1 file

0.5.1

1 file

0.5.0

1 file

0.4.5

1 file

0.4.4

1 file

0.4.3

1 file

0.4.2

1 file

0.4.1

1 file

0.4.0

1 file

0.3.2

1 file

0.3.1

1 file

0.3.0

1 file

0.2.1

1 file

0.2.0

1 file

0.1.4

1 file

0.1.3

1 file

0.1.2

1 file

0.1.1

1 file

0.1.0

1 file

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page