Skip to main content

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 bithuman wheel 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 sibling bithuman-cli wheel (pip install bithuman-cli, with bithuman-cli[local] for the on-device brain). This wheel exports the avatar runtime only: AsyncBithuman (streaming) and Bithuman (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 libessence engine core (2.3.6, ABI v7) via pybind11.
  • Auth: ships with live heartbeat against api.bithuman.ai baked into libessence. Bithuman.load(api_secret=...) / AsyncBithuman.create(api_secret=...) is the entry point; BITHUMAN_API_SECRET env 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/QNN is accepted but currently no-ops to CPU in the current build.

License

Commercial. Contact hello@bithuman.ai.

See also

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

No source distribution files available for this release.See tutorial on generating distribution archives.

Built Distributions

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

bithuman-2.3.3.post1-cp314-cp314-manylinux_2_28_x86_64.whl (18.0 MB view details)

Uploaded CPython 3.14manylinux: glibc 2.28+ x86-64

bithuman-2.3.3.post1-cp314-cp314-manylinux_2_28_aarch64.whl (16.9 MB view details)

Uploaded CPython 3.14manylinux: glibc 2.28+ ARM64

bithuman-2.3.3.post1-cp314-cp314-macosx_26_0_arm64.whl (26.8 MB view details)

Uploaded CPython 3.14macOS 26.0+ ARM64

bithuman-2.3.3.post1-cp313-cp313-manylinux_2_28_x86_64.whl (18.0 MB view details)

Uploaded CPython 3.13manylinux: glibc 2.28+ x86-64

bithuman-2.3.3.post1-cp313-cp313-manylinux_2_28_aarch64.whl (16.9 MB view details)

Uploaded CPython 3.13manylinux: glibc 2.28+ ARM64

bithuman-2.3.3.post1-cp313-cp313-macosx_26_0_arm64.whl (26.8 MB view details)

Uploaded CPython 3.13macOS 26.0+ ARM64

bithuman-2.3.3.post1-cp312-cp312-manylinux_2_28_x86_64.whl (18.0 MB view details)

Uploaded CPython 3.12manylinux: glibc 2.28+ x86-64

bithuman-2.3.3.post1-cp312-cp312-manylinux_2_28_aarch64.whl (16.9 MB view details)

Uploaded CPython 3.12manylinux: glibc 2.28+ ARM64

bithuman-2.3.3.post1-cp312-cp312-macosx_26_0_arm64.whl (26.8 MB view details)

Uploaded CPython 3.12macOS 26.0+ ARM64

bithuman-2.3.3.post1-cp311-cp311-manylinux_2_28_x86_64.whl (18.0 MB view details)

Uploaded CPython 3.11manylinux: glibc 2.28+ x86-64

bithuman-2.3.3.post1-cp311-cp311-manylinux_2_28_aarch64.whl (16.9 MB view details)

Uploaded CPython 3.11manylinux: glibc 2.28+ ARM64

bithuman-2.3.3.post1-cp311-cp311-macosx_26_0_arm64.whl (26.8 MB view details)

Uploaded CPython 3.11macOS 26.0+ ARM64

bithuman-2.3.3.post1-cp310-cp310-manylinux_2_28_x86_64.whl (18.0 MB view details)

Uploaded CPython 3.10manylinux: glibc 2.28+ x86-64

bithuman-2.3.3.post1-cp310-cp310-manylinux_2_28_aarch64.whl (16.9 MB view details)

Uploaded CPython 3.10manylinux: glibc 2.28+ ARM64

bithuman-2.3.3.post1-cp310-cp310-macosx_26_0_arm64.whl (26.8 MB view details)

Uploaded CPython 3.10macOS 26.0+ ARM64

File details

Details for the file bithuman-2.3.3.post1-cp314-cp314-manylinux_2_28_x86_64.whl.

File metadata

File hashes

Hashes for bithuman-2.3.3.post1-cp314-cp314-manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 b583349417b1f3236e6fab043652e66ce10af7a6209d63620ae0e1f5ff944a01
MD5 1af2a64a892df6a330358151f03d6df3
BLAKE2b-256 bc07b4bbe984fd6417b44c04fc51c7a2fc7fc20e4ffc3610d0762090434779aa

See more details on using hashes here.

File details

Details for the file bithuman-2.3.3.post1-cp314-cp314-manylinux_2_28_aarch64.whl.

File metadata

File hashes

Hashes for bithuman-2.3.3.post1-cp314-cp314-manylinux_2_28_aarch64.whl
Algorithm Hash digest
SHA256 14634e1ed25920b6a85b127bb2627446bea50fdfab90c93c80da3e1cd307b53c
MD5 ae6562707733715d995251e133004663
BLAKE2b-256 ee0a69241c35d7f7553a076189b583cb804ccf5fb7c91534092dbe3655cf988d

See more details on using hashes here.

File details

Details for the file bithuman-2.3.3.post1-cp314-cp314-macosx_26_0_arm64.whl.

File metadata

File hashes

Hashes for bithuman-2.3.3.post1-cp314-cp314-macosx_26_0_arm64.whl
Algorithm Hash digest
SHA256 d16849a2fa0041301a50d3f2b99eec90fecaf60ec90d45251bdc07adc4b50273
MD5 d445cac894e7214b3768d5402f494af3
BLAKE2b-256 551b03e010597724a0b1a064bf15d4ce71755c5ba67b79bc618f4f2d648762fb

See more details on using hashes here.

File details

Details for the file bithuman-2.3.3.post1-cp313-cp313-manylinux_2_28_x86_64.whl.

File metadata

File hashes

Hashes for bithuman-2.3.3.post1-cp313-cp313-manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 305da09a2081742ae4ae064c54861473b0298f82bf3f857c21dbf8cbabdc0c35
MD5 46baf4b43a0485d65e3d5d227a8de507
BLAKE2b-256 77095e485762d1a955a493884bd85ba7dc1b7f3e8088f5085ba2e108664ca2ec

See more details on using hashes here.

File details

Details for the file bithuman-2.3.3.post1-cp313-cp313-manylinux_2_28_aarch64.whl.

File metadata

File hashes

Hashes for bithuman-2.3.3.post1-cp313-cp313-manylinux_2_28_aarch64.whl
Algorithm Hash digest
SHA256 acb3b1740c93f7766188e19f3aa8153508ba67873522ef2ad32fc54e6700026d
MD5 cf0336f7a338bd6d7ff7a0861a55f41a
BLAKE2b-256 2f9e594116af37ad098cf415d6cf8a515b59cb47869cd4a508e1e93c718b8c29

See more details on using hashes here.

File details

Details for the file bithuman-2.3.3.post1-cp313-cp313-macosx_26_0_arm64.whl.

File metadata

File hashes

Hashes for bithuman-2.3.3.post1-cp313-cp313-macosx_26_0_arm64.whl
Algorithm Hash digest
SHA256 94a0c359cba56e2ad085d7ae47cd866415a8e65240762a409aa6c3ecc68184d9
MD5 4207189be3dbc09669d10dda0748e00c
BLAKE2b-256 81242901e2cdb73ffd796b1640687679ba807ad0ec8debda73505aa430bf4df5

See more details on using hashes here.

File details

Details for the file bithuman-2.3.3.post1-cp312-cp312-manylinux_2_28_x86_64.whl.

File metadata

File hashes

Hashes for bithuman-2.3.3.post1-cp312-cp312-manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 b9c6a82c6cd5a1b525b72e066d63599a631f4e7feb0a6df5b9c9f8562e3fb0cd
MD5 e0572dc8130a55667fde2a09401ab0fa
BLAKE2b-256 413cd8be65debca7cba67001809aaf19595506ccef06cec5fa990983184550af

See more details on using hashes here.

File details

Details for the file bithuman-2.3.3.post1-cp312-cp312-manylinux_2_28_aarch64.whl.

File metadata

File hashes

Hashes for bithuman-2.3.3.post1-cp312-cp312-manylinux_2_28_aarch64.whl
Algorithm Hash digest
SHA256 c6cb8d10fc29d2f6d5a3c6b86b48237a655acaf10389c90acf5f622d5e1cca42
MD5 6c1a4b70b548546a5e4aad83a1f2763a
BLAKE2b-256 1efe5c5cb4b667e05f5fb186d39dbfda4ddfa3359d8ef82739992a9885364710

See more details on using hashes here.

File details

Details for the file bithuman-2.3.3.post1-cp312-cp312-macosx_26_0_arm64.whl.

File metadata

File hashes

Hashes for bithuman-2.3.3.post1-cp312-cp312-macosx_26_0_arm64.whl
Algorithm Hash digest
SHA256 ab5eeb8a20a85506ad6d1f54d672da2ab4852b80aab7544417aa92e805524340
MD5 a6449fe0e08b59e2d20a841c37eda683
BLAKE2b-256 3ac90f7cad1612dde6b1858144eb3c3820c95c681bcadbcdaa2cb3421cf9c6f1

See more details on using hashes here.

File details

Details for the file bithuman-2.3.3.post1-cp311-cp311-manylinux_2_28_x86_64.whl.

File metadata

File hashes

Hashes for bithuman-2.3.3.post1-cp311-cp311-manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 04a3f6c17aad057ba3d1045190d87e611a2cfb56dd038065b7c976c4b207fe93
MD5 3aa7f3bf016487ba0a18be5398e16d59
BLAKE2b-256 b73c307f717a00d066d2eb9002126f6647cdad6ab5d62c2409e4fd0be4128b0d

See more details on using hashes here.

File details

Details for the file bithuman-2.3.3.post1-cp311-cp311-manylinux_2_28_aarch64.whl.

File metadata

File hashes

Hashes for bithuman-2.3.3.post1-cp311-cp311-manylinux_2_28_aarch64.whl
Algorithm Hash digest
SHA256 4557928f3e4791feaef040f84f75a5418e3aaebd99e44471d035fa72b900b2b4
MD5 84d38c48e9d7b208f4eeeb55761d39b5
BLAKE2b-256 2b6006030fc2395ccafe40d7624091994cc403f6d843fd5287b62f53a66a01c4

See more details on using hashes here.

File details

Details for the file bithuman-2.3.3.post1-cp311-cp311-macosx_26_0_arm64.whl.

File metadata

File hashes

Hashes for bithuman-2.3.3.post1-cp311-cp311-macosx_26_0_arm64.whl
Algorithm Hash digest
SHA256 f8773547e3653ac55a23ed08a10b13fd5d57f8cf46c83db20ee4988490a69f8e
MD5 70f068dfb583bfa42c614fab39b13f8d
BLAKE2b-256 494554b9794743da119b0d5b5769e162dc7e3b41f5db6db1a8ad4e0343b3ce3a

See more details on using hashes here.

File details

Details for the file bithuman-2.3.3.post1-cp310-cp310-manylinux_2_28_x86_64.whl.

File metadata

File hashes

Hashes for bithuman-2.3.3.post1-cp310-cp310-manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 a6bb35bf232498fff106ddc4af991c7dbfe0145d34974ca6dfd79c55b576e6d1
MD5 96e7370a873c10f8df5db26d1d86428e
BLAKE2b-256 704f9aeaba261a9f79f15a53ababfcf7cad12b347a4c652f365b1ae47db28b82

See more details on using hashes here.

File details

Details for the file bithuman-2.3.3.post1-cp310-cp310-manylinux_2_28_aarch64.whl.

File metadata

File hashes

Hashes for bithuman-2.3.3.post1-cp310-cp310-manylinux_2_28_aarch64.whl
Algorithm Hash digest
SHA256 b35fddec6940b5a726fb0d95e05ac52e41ad414e23d5347592ffcee552df7057
MD5 2b186232f3778e7b5d5044112f744e79
BLAKE2b-256 d78a76357c75e67d6a0725ddaa91401e468c1caf3838df73fae0e2fdc1f54610

See more details on using hashes here.

File details

Details for the file bithuman-2.3.3.post1-cp310-cp310-macosx_26_0_arm64.whl.

File metadata

File hashes

Hashes for bithuman-2.3.3.post1-cp310-cp310-macosx_26_0_arm64.whl
Algorithm Hash digest
SHA256 c0f72e0508d59ab18114a5fde7a1ecb01a9fff3377f0478c95b52029c9ee284f
MD5 4026c5fb53dfed7d95dfc09f6c6da165
BLAKE2b-256 d4197c1c56085aa84f909f08f0f98f87d7bc166efeba25ebfb9538d3d9adc59b

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page