bitHuman Python SDK — libessence-backed avatar runtime. `from bithuman import AsyncBithuman`.
Project description
bithuman
This is the Python flavor of L2: a platform-specific SDK for app developers. It wraps the L1 libessence engine. For the CLI tool — an L3 app — see the CLI docs.
┌─────────────────────────────────────────────────────────────┐
│ L3: Apps (bithuman-apps — separate repo) │
│ - bithuman CLI brew / pip install bithuman-cli │
│ - Flutter plugin · Mac/iPad reference apps │
└─────────────────────────────────────────────────────────────┘
▼ consumes
┌─────────────────────────────────────────────────────────────┐
│ L2: Platform SDKs (app developers) │
│ - Python wheel pip install bithuman ◄──── you are here
│ - Swift package SwiftPM Bithuman │
│ - Kotlin AAR ai.bithuman:sdk │
│ - Rust crate (in-tree) │
└─────────────────────────────────────────────────────────────┘
▼ wraps
┌─────────────────────────────────────────────────────────────┐
│ L1: libessence engine (cross-platform C++ core) │
│ - portable C ABI, same source on every target │
│ - macOS · iOS · Android · Linux · Windows │
│ - never imported directly by app developers │
└─────────────────────────────────────────────────────────────┘
Library only — the CLI moved out
This wheel ships the library only. The bithuman command-line tool
(bithuman run model.imx, bithuman render, bithuman doctor) lives in
the sibling bithuman-cli PyPI wheel (an L3 app); bithuman-cli
depends on this bithuman wheel for the in-process avatar runtime, and
both share the same libessence native engine.
# Library — embed the runtime in your own app
from bithuman import AsyncBithuman
avatar = await AsyncBithuman.create(model_path="model.imx", api_secret="bh-...")
# CLI — separate wheel
pip install bithuman-cli
bithuman run model.imx
Python bindings for the bitHuman SDK — the portable C++ avatar engine
(libessence) that powers our cross-platform lipsync pipeline. The wheel
ships a native pybind11 module that talks directly to libessence,
so you get the same per-frame cost as our Swift and Kotlin clients with
none of the GIL noise.
On an Apple M5 with 24 GB unified memory we measure ~640 FPS sustained compose (1.56 ms/frame mean, 2.03 ms p99) for a 1248×704 avatar, with ~206 MB peak RSS end-to-end. Cold load is ~14 ms for the fixture and ~400 ms for the first compose tick (lazy ONNX init).
This package is namespace-isolated from the v0 bithuman SDK; you can
install both side-by-side.
Install
pip install bithuman # the library (slim wheel — no CLI, no brain)
Status. As of 2.3, the PyPI
bithumanwheel is a slim library-only wheel. The bundled Rust CLI and conversation brain that 2.0–2.2.x shipped have been extracted into the siblingbithuman-cliwheel (pip install bithuman-cli, withbithuman-cli[local]for the on-device brain). This wheel exports the avatar runtime only:AsyncBithuman(streaming) andBithuman(sync single-shot).
Compatibility
- Platforms: macOS arm64, Linux x86_64, Linux arm64 — all ship as wheels. Windows is tracked for a follow-up.
- Python: 3.10 – 3.14 (cp310 through cp314). CPython only.
- ABI: wraps the
libessenceengine core (2.3.6, ABI v7) via pybind11. - Auth: ships with live heartbeat against
api.bithuman.aibaked intolibessence.Bithuman.load(api_secret=...)/AsyncBithuman.create(api_secret=...)is the entry point;BITHUMAN_API_SECRETenv var works too.
What you get
The package exposes three API tiers (all importable from bithuman):
| Tier | Types | Use when… |
|---|---|---|
| Async | AsyncBithuman (alias AsyncAvatar), AudioChunk, VideoControl, VideoFrame |
Streaming a live conversation / hosting a service |
| Sync facade | Bithuman (alias Avatar), ComposedFrame, EP |
Offline / batch single-shot rendering |
| Low-level | Fixture, Runtime, EP_CPU/EP_AUTO/EP_COREML/EP_NNAPI/EP_QNN |
Direct C ABI access, custom audio pipeline |
Error types: BithumanError (base), TokenError /
TokenExpiredError / TokenValidationError / TokenRequestError /
AccountStatusError (auth), ModelError / ModelNotFoundError /
ModelLoadError / ModelSecurityError / ExpressionModelNotSupported
(fixture), RuntimeNotReadyError.
Version info: bithuman.__version__ (Python package),
bithuman.__core_version__ (linked libessence), bithuman.__abi_version__.
Quickstart (async streaming — AsyncBithuman)
Build the runtime with AsyncBithuman.create(...), feed PCM with
push_audio, mark end-of-speech with flush(), and drain composed
frames from the run() async iterator.
import asyncio
from bithuman import AsyncBithuman
async def main():
avatar = await AsyncBithuman.create(
model_path="model.imx",
api_secret="bh-...", # or BITHUMAN_API_SECRET env var
)
await avatar.push_audio(pcm_16k_mono_int16_bytes,
sample_rate=16000, last_chunk=True)
await avatar.flush() # end-of-speech marker
async for frame in avatar.run():
# frame.bgr_image is (H, W, 3) uint8 in BGR order
...
await avatar.stop()
asyncio.run(main())
PCM accepted is int16 little-endian bytes; sample_rate is resampled to
16 kHz mono internally. WAV / MP3 / FLAC / OGG decoding is the caller's
responsibility (use soundfile).
Quickstart (sync single-shot — Bithuman)
For offline / batch rendering, Bithuman.load(...) then iterate
compose(audio), which yields one ComposedFrame per 40 ms (25 fps)
of input:
from bithuman import Bithuman
avatar = Bithuman.load("model.imx", api_secret="bh-...")
for frame in avatar.compose("speech.wav"): # ndarray or WAV/MP3/FLAC path
# frame.bgr is (H, W, 3) uint8 BGR; frame.frame_idx / frame.cluster_idx
...
Live avatar / CLI — bithuman-cli (separate wheel)
The bithuman run / bithuman render command-line tool and the
conversation brain (bithuman-cli[local] for the fully on-device
whisper.cpp + llama.cpp + Supertonic stack) are no longer bundled in
this wheel. They ship as the sibling bithuman-cli PyPI wheel,
which depends on this bithuman runtime:
pip install bithuman-cli # cloud brain (OpenAI Realtime)
pip install 'bithuman-cli[local]' # fully on-device brain
bithuman run avatar.imx # live avatar (browser-to-talk)
See the CLI docs and the bithuman-cli README
for the full command surface and brain modes. Both wheels share the same
libessence native engine.
Low-level API
If you need finer control or want to swap in a custom audio pipeline, the C ABI is exposed directly:
import numpy as np
from bithuman import Fixture, Runtime, EP_CPU
fx = Fixture("model.imx", preferred_ep=EP_CPU, intra_op_threads=1)
rt = Runtime(fx)
pcm = np.fromfile("speech.f32", dtype=np.float32) # 16 kHz mono float32
cluster_idx, bgr = rt.tick_compose(pcm, frame_idx_hint=-1)
# bgr.shape == (fx.frame_height, fx.frame_width, 3), dtype uint8
Pass the entire pcm buffer to each tick_compose call; the runtime
maintains an internal cursor and advances one tick per call until the
audio is exhausted.
Zero-alloc hot path (since 1.12.4)
For tight render loops, pre-allocate the BGR buffer once and pass it
via out=. The runtime writes into it in place and returns just the
cluster_idx. This drops wrapper overhead to within ~3 % of raw
libessence (vs ~8 % for the alloc-per-tick path):
out = np.empty((fx.frame_height, fx.frame_width, 3), dtype=np.uint8)
for _ in range(num_ticks):
cluster_idx = rt.tick_compose(pcm, -1, out=out)
# `out` now holds this tick's frame; read it before the next call.
The same out= keyword works on tick_compose_to_size. See
docs/ARCHITECTURE.md §9 for the cross-wrapper perf table.
Build from source
You need the prebuilt parent C++ archive at
engine/essence/build/libessence.a (run the parent CMake build first), plus
the runtime deps from Homebrew (onnxruntime, webp, ffmpeg,
hdf5, jpeg-turbo).
cd sdks/python
uv pip install -e '.[test]' --no-build-isolation # only the `test` extra ships
The CMake glue links the prebuilt static archive directly — it does NOT re-run the parent build, so iterate on bindings without paying the C++ rebuild cost.
Performance
Measured with tests/bench.py against the v1 compose path
(audio → composited BGR frame) on Apple M5 24 GB, libessence 1.16.0:
| Metric | Alloc per tick | out= reuse buffer |
|---|---|---|
| Steady-state mean | 1.53 ms / frame | 1.45 ms / frame |
| p99 | 1.66 ms | 1.53 ms |
| Sustained throughput | 655 FPS | 692 FPS |
| Overhead vs raw libessence | +8.3 % | +2.6 % |
| Peak RSS (proc) | 192 MB | 182 MB |
Wrapper overhead is within 5 % of raw libessence on the out= path;
see docs/ARCHITECTURE.md §9 for the apples-to-apples methodology and
the cross-wrapper comparison. Reproduce with:
scripts/bench-wrappers.sh
Linux wheels
Pre-built manylinux_2_28 wheels ship for x86_64 + aarch64 across cp310
through cp314 — 10 wheels in total, all auditwheel-repaired with the
full dep tree bundled (ORT, FFmpeg, HDF5, libjpeg-turbo, libwebp,
libcurl, OpenSSL).
To rebuild them locally:
# One-time: build the dep-baked Docker images (~10 min each).
docker build --platform linux/amd64 -t libessence/manylinux-x86_64:0.1 \
-f scripts/Dockerfile.manylinux-x86_64 scripts/
docker build --platform linux/arm64/v8 -t libessence/manylinux-aarch64:0.1 \
-f scripts/Dockerfile.manylinux-aarch64 scripts/
# Per wheel build (~2 min):
docker run --rm --platform linux/amd64 -v "$REPO":/src \
-e PYTAG=cp311 -e ARCH_INSIDE=x86_64 \
libessence/manylinux-x86_64:0.1 \
bash /src/sdks/python/scripts/build-wheel-in-container.sh
Limitations
- Windows wheels not yet built — tracked for a follow-up.
compose()emits a fixed 25 fps frame stream to match the model's internal rate; resample downstream if you need a different cadence.preferred_ep=COREML/NNAPI/QNNis accepted but currently no-ops to CPU in the current build.
License
Commercial. Contact hello@bithuman.ai.
See also
- docs.bithuman.ai — full product + SDK docs
- docs.bithuman.ai/cli —
bithumanCLI reference - bithuman-sdk-public — examples (Python, Swift, CLI, REST) + Swift package
bithuman-clion PyPI — the sibling CLI wheel- In-repo (private monorepo):
engine/essence/README.md(engine internals),sdks/swift/README.md,sdks/kotlin/README.md,docs/BUILD_AND_RELEASE.md
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distributions
Built Distributions
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file bithuman-2.3.8-cp314-cp314-manylinux_2_28_x86_64.whl.
File metadata
- Download URL: bithuman-2.3.8-cp314-cp314-manylinux_2_28_x86_64.whl
- Upload date:
- Size: 18.1 MB
- Tags: CPython 3.14, manylinux: glibc 2.28+ x86-64
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.12.3
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
aac502e6bdc1bbcf2677ad5d5ad1a4d192a6f88e468077fce8477310a733e03c
|
|
| MD5 |
c2b87105cb79057225c23b592c3eb1dc
|
|
| BLAKE2b-256 |
c73c95b342600d13124c76e2b4d74581a2d30dfd521bd09c772f795f8bbff3a4
|
File details
Details for the file bithuman-2.3.8-cp314-cp314-manylinux_2_28_aarch64.whl.
File metadata
- Download URL: bithuman-2.3.8-cp314-cp314-manylinux_2_28_aarch64.whl
- Upload date:
- Size: 16.9 MB
- Tags: CPython 3.14, manylinux: glibc 2.28+ ARM64
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.12.3
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
2b31c4b5c57034f119d2a8a88610ae00805ca7e9b17ed2985b50a994b39889ed
|
|
| MD5 |
b8907fdd07b147eb537abafa42187dfd
|
|
| BLAKE2b-256 |
99185a79120d54a8ce1eb387ec364754fe15e10789c328844f3e12a0a13f68ae
|
File details
Details for the file bithuman-2.3.8-cp314-cp314-macosx_26_0_arm64.whl.
File metadata
- Download URL: bithuman-2.3.8-cp314-cp314-macosx_26_0_arm64.whl
- Upload date:
- Size: 26.8 MB
- Tags: CPython 3.14, macOS 26.0+ ARM64
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.14.5
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
66e08a6f811f88540e6079264c5e08d797d24874760368dea6fb4ce784819105
|
|
| MD5 |
943b2f52184d0ca9e0432cb24fe52151
|
|
| BLAKE2b-256 |
62bb4b8e958c9b4742d6c6eafb9cdf788bd755f7746e83022474fa6d6b9d3c0e
|
File details
Details for the file bithuman-2.3.8-cp313-cp313-manylinux_2_28_x86_64.whl.
File metadata
- Download URL: bithuman-2.3.8-cp313-cp313-manylinux_2_28_x86_64.whl
- Upload date:
- Size: 18.1 MB
- Tags: CPython 3.13, manylinux: glibc 2.28+ x86-64
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.12.3
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
84873676ab47f2055e14e1d49c34d1909e6d24efc13c74e064d15c77e390e687
|
|
| MD5 |
b0e2cd95d9cd9390fcd717dd372abc8a
|
|
| BLAKE2b-256 |
17fca127a964bcf0857c78194e71668e27a972ac590a693d97d6de5b01a18dc2
|
File details
Details for the file bithuman-2.3.8-cp313-cp313-manylinux_2_28_aarch64.whl.
File metadata
- Download URL: bithuman-2.3.8-cp313-cp313-manylinux_2_28_aarch64.whl
- Upload date:
- Size: 16.9 MB
- Tags: CPython 3.13, manylinux: glibc 2.28+ ARM64
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.12.3
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
361ae7c965fb4b5234aacccbb6a23d01ac5393b1c8612f1db82f511a95fb73f7
|
|
| MD5 |
b034cc685116d71904a0dc4a900eb808
|
|
| BLAKE2b-256 |
15f5f4e006ba8aa8456c3da69406c8172720318c23710bf9d7322c60a5265195
|
File details
Details for the file bithuman-2.3.8-cp313-cp313-macosx_26_0_arm64.whl.
File metadata
- Download URL: bithuman-2.3.8-cp313-cp313-macosx_26_0_arm64.whl
- Upload date:
- Size: 26.8 MB
- Tags: CPython 3.13, macOS 26.0+ ARM64
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.13.13
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
378a2f11638d871c86d0361ccea63c8b169a80d52f05c20817862867de78ebb1
|
|
| MD5 |
f55bce3249a7890f9c2c8c3be15962fb
|
|
| BLAKE2b-256 |
acf3c8e0b13e43a47e00eefbc69cee4e7e5f19c0c7bb49767b78b459927c9243
|
File details
Details for the file bithuman-2.3.8-cp312-cp312-manylinux_2_28_x86_64.whl.
File metadata
- Download URL: bithuman-2.3.8-cp312-cp312-manylinux_2_28_x86_64.whl
- Upload date:
- Size: 18.1 MB
- Tags: CPython 3.12, manylinux: glibc 2.28+ x86-64
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.12.3
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
88223c4f984c1354f5fe35b6141ea1c4cc1961bfc36d11565909c4d7c06787c2
|
|
| MD5 |
c898c83cdf2786731b09c0e4f17137b9
|
|
| BLAKE2b-256 |
7a3791eda53297840c8e0073d4a55e53c73d0fdf704e7b686d51ef71e8d800c4
|
File details
Details for the file bithuman-2.3.8-cp312-cp312-manylinux_2_28_aarch64.whl.
File metadata
- Download URL: bithuman-2.3.8-cp312-cp312-manylinux_2_28_aarch64.whl
- Upload date:
- Size: 16.9 MB
- Tags: CPython 3.12, manylinux: glibc 2.28+ ARM64
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.12.3
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
ca337b3a929fd51f9305610ddadbad8797954f752d5491e1db796f3559b673da
|
|
| MD5 |
65b7739facefa8929fa7a0640859427a
|
|
| BLAKE2b-256 |
94e317dea332263da00f54bbbcdc26e55eb501b52b9a86b20be61ac083529c22
|
File details
Details for the file bithuman-2.3.8-cp312-cp312-macosx_26_0_arm64.whl.
File metadata
- Download URL: bithuman-2.3.8-cp312-cp312-macosx_26_0_arm64.whl
- Upload date:
- Size: 26.8 MB
- Tags: CPython 3.12, macOS 26.0+ ARM64
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.12.10
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
1d1e78fe60283dccece1906b558176b17806d96864f2b9b6fabf694c24bdc8f6
|
|
| MD5 |
54f10bebab058988ba63bcfe6d68c96f
|
|
| BLAKE2b-256 |
77bf83ce822fdb9f11da5ad01179437bdcd559460d3e4a9a8f509c010ff41787
|
File details
Details for the file bithuman-2.3.8-cp311-cp311-manylinux_2_28_x86_64.whl.
File metadata
- Download URL: bithuman-2.3.8-cp311-cp311-manylinux_2_28_x86_64.whl
- Upload date:
- Size: 18.1 MB
- Tags: CPython 3.11, manylinux: glibc 2.28+ x86-64
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.12.3
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
561a865f341f0290886dca85d993439a12fc224b4ebe727d4a2f3c35b0f91ee5
|
|
| MD5 |
e74bba192a91dd6cdb22f6684d53583d
|
|
| BLAKE2b-256 |
dbcd59dccdb774aabf97de2ca0378068281822ba73d46ba4b837cb9008ddf72d
|
File details
Details for the file bithuman-2.3.8-cp311-cp311-manylinux_2_28_aarch64.whl.
File metadata
- Download URL: bithuman-2.3.8-cp311-cp311-manylinux_2_28_aarch64.whl
- Upload date:
- Size: 16.9 MB
- Tags: CPython 3.11, manylinux: glibc 2.28+ ARM64
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.12.3
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
86f831c9444963b2a9a68a6bab419c5e4de80a5f52024c85501834e5b0985991
|
|
| MD5 |
61ff901fa1d4bf1395bc585b62a64001
|
|
| BLAKE2b-256 |
496fecad1f54137db2a8ad4dc076eb580d74ac7f1fdd677506170a2f09357bcc
|
File details
Details for the file bithuman-2.3.8-cp311-cp311-macosx_26_0_arm64.whl.
File metadata
- Download URL: bithuman-2.3.8-cp311-cp311-macosx_26_0_arm64.whl
- Upload date:
- Size: 26.8 MB
- Tags: CPython 3.11, macOS 26.0+ ARM64
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.11.9
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
a58fdecea90113d0e67a928cb6a58e2b0e37547d954b260614667a82147ec234
|
|
| MD5 |
81fd0d1ecf380ea1d1b07afcb58f9967
|
|
| BLAKE2b-256 |
bd09e1d6d9fa4b8dc26ac649a79ecdf36d1619016b7a6a753c34c7246f35a3e4
|
File details
Details for the file bithuman-2.3.8-cp310-cp310-manylinux_2_28_x86_64.whl.
File metadata
- Download URL: bithuman-2.3.8-cp310-cp310-manylinux_2_28_x86_64.whl
- Upload date:
- Size: 18.1 MB
- Tags: CPython 3.10, manylinux: glibc 2.28+ x86-64
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.12.3
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
1e03ed6a0658a626cea3efcbf41379171c6b1888cb94e618ba25b057ddbf3556
|
|
| MD5 |
cd5baae5a08f372327a1c192f120a23e
|
|
| BLAKE2b-256 |
8e9f0771320206a2cbc8fbf6802b401671d9f568cc62a70430405c4ddb29c2cf
|
File details
Details for the file bithuman-2.3.8-cp310-cp310-manylinux_2_28_aarch64.whl.
File metadata
- Download URL: bithuman-2.3.8-cp310-cp310-manylinux_2_28_aarch64.whl
- Upload date:
- Size: 16.9 MB
- Tags: CPython 3.10, manylinux: glibc 2.28+ ARM64
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.12.3
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
0d0d94f20649790dcd5c30494f842682370487dd7821ad282d62b1169401af60
|
|
| MD5 |
45fbe63ecc7c68610253e938b74e2511
|
|
| BLAKE2b-256 |
f2539eff352907ebd373db8e6427876b4ce1fd97d1a0b8f51812859dfaa3a5b8
|
File details
Details for the file bithuman-2.3.8-cp310-cp310-macosx_26_0_arm64.whl.
File metadata
- Download URL: bithuman-2.3.8-cp310-cp310-macosx_26_0_arm64.whl
- Upload date:
- Size: 26.8 MB
- Tags: CPython 3.10, macOS 26.0+ ARM64
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.10.11
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
160333c0f2eb9b93f7cf5e57ad2c2c2fb3a96d5e63af4dd1292d15216bb2495d
|
|
| MD5 |
b39ac4ed73c1d4cef0ace1ed27dd8660
|
|
| BLAKE2b-256 |
fcab50d83fec72cb80e3b39da9e384ca08083daff96d72fcfe9bb0de9a410fc0
|