bithuman

package
v0.1.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jul 12, 2026 License: MIT Imports: 13 Imported by: 0

Documentation

Overview

Package bithuman provides a bitHuman Real-time Avatars provider for omniavatar.

bitHuman enables real-time AI avatar video generation that integrates with LiveKit for audio streaming and video output.

Quick Start

Import this package to auto-register the bithuman provider:

import (
    "github.com/plexusone/omniavatar"
    _ "github.com/plexusone/omniavatar/providers/bithuman"
)

func main() {
    provider, err := omniavatar.GetAvatarProvider("bithuman",
        omniavatar.WithAPIKey(os.Getenv("BITHUMAN_API_KEY")),
        omniavatar.WithExtension("agent_id", agentID))
}

Configuration

The bithuman provider accepts the following extensions:

  • agent_id (string, required): bitHuman agent ID to use for the session.

API Key

Get your bitHuman API key from https://www.bithuman.ai

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func NewProviderFromConfig

func NewProviderFromConfig(cfg registry.ProviderConfig) (avatar.Provider, error)

NewProviderFromConfig creates a bitHuman provider from registry config.

Types

type Client

type Client struct {
	// contains filtered or unexported fields
}

Client wraps the bithuman-go SDK for avatar session management.

func NewClient

func NewClient(cfg ClientConfig) (*Client, error)

NewClient creates a new bitHuman API client using the bithuman-go SDK.

func (*Client) CreateSession

func (c *Client) CreateSession(ctx context.Context, req CreateSessionRequest) (*CreateSessionResponse, error)

CreateSession creates a new real-time session with the bitHuman API.

func (*Client) EndSession

func (c *Client) EndSession(ctx context.Context, sessionID string) error

EndSession ends an active session.

func (*Client) SDK

func (c *Client) SDK() *bithumansdk.Client

SDK returns the underlying bithuman-go SDK client for advanced usage.

type ClientConfig

type ClientConfig struct {
	// APIKey is the bitHuman API key.
	// Required.
	APIKey string

	// BaseURL is the bitHuman API base URL.
	// Default: https://api.bithuman.ai
	BaseURL string

	// HTTPClient is an optional custom HTTP client.
	// Default: http.Client with 30s timeout
	HTTPClient *http.Client
}

ClientConfig configures the bitHuman API client.

type Config

type Config struct {
	// APIKey is the bitHuman API key.
	// Required.
	APIKey string

	// BaseURL is the bitHuman API base URL.
	// Default: https://api.bithuman.ai
	BaseURL string

	// AgentID is the bitHuman agent to use for sessions.
	// Required.
	AgentID string
}

Config configures the bitHuman avatar provider.

type CreateSessionRequest

type CreateSessionRequest struct {
	// AgentID is the bitHuman agent to use for this session.
	// Required.
	AgentID string

	// LiveKitURL is the LiveKit WebSocket URL for the avatar to connect to.
	// Optional - if provided, avatar will join the specified LiveKit room.
	LiveKitURL string

	// LiveKitToken is the JWT token for the avatar to join the room.
	// Optional - if provided with LiveKitURL, avatar uses external LiveKit.
	LiveKitToken string
}

CreateSessionRequest is the request to create a real-time session.

type CreateSessionResponse

type CreateSessionResponse struct {
	// SessionID is the unique identifier for the session.
	SessionID string

	// LiveKitURL is the LiveKit WebSocket URL (if using bitHuman's LiveKit).
	LiveKitURL string

	// LiveKitToken is the JWT token for the avatar (if using bitHuman's LiveKit).
	LiveKitToken string
}

CreateSessionResponse is the response from creating a session.

type Provider

type Provider struct {
	// contains filtered or unexported fields
}

Provider implements avatar.Provider for bitHuman.

func NewProvider

func NewProvider(cfg Config) (*Provider, error)

NewProvider creates a new bitHuman avatar provider.

func (*Provider) CreateSession

func (p *Provider) CreateSession(cfg avatar.SessionConfig) (avatar.Session, error)

CreateSession creates a new bitHuman avatar session.

func (*Provider) Name

func (p *Provider) Name() string

Name returns the provider name.

type Session

type Session struct {
	// contains filtered or unexported fields
}

Session implements avatar.Session for bitHuman avatars.

func NewSession

func NewSession(cfg SessionConfig) (*Session, error)

NewSession creates a new bitHuman avatar session.

func (*Session) AgentID

func (s *Session) AgentID() string

AgentID returns the bitHuman agent ID.

func (*Session) AudioOutput

func (s *Session) AudioOutput() avatar.AudioDestination

AudioOutput returns the audio destination for streaming TTS audio.

func (*Session) Close

func (s *Session) Close(ctx context.Context) error

Close disconnects the avatar and cleans up resources.

func (*Session) EmitError

func (s *Session) EmitError(err error)

EmitError emits an error event.

func (*Session) EmitPlaybackFinished

func (s *Session) EmitPlaybackFinished(position float64, interrupted bool)

EmitPlaybackFinished emits a playback finished event.

func (*Session) EmitPlaybackStarted

func (s *Session) EmitPlaybackStarted()

EmitPlaybackStarted emits a playback started event.

func (*Session) Identity

func (s *Session) Identity() string

Identity returns the avatar participant identity.

func (*Session) Provider

func (s *Session) Provider() string

Provider returns the provider name.

func (*Session) Room

func (s *Session) Room() *lksdk.Room

Room returns the LiveKit room reference.

func (*Session) SessionID

func (s *Session) SessionID() string

SessionID returns the bitHuman session ID.

func (*Session) SetAudioOutput

func (s *Session) SetAudioOutput(out avatar.AudioDestination)

SetAudioOutput sets the audio destination.

func (*Session) SetCallbacks

func (s *Session) SetCallbacks(callbacks *avatar.SessionCallbacks)

SetCallbacks registers event callbacks for the session.

func (*Session) Start

func (s *Session) Start(ctx context.Context, opts any) error

Start initializes the bitHuman avatar session.

The opts parameter must be *omniavatar.LiveKitStartOptions.

func (*Session) WaitForJoin

func (s *Session) WaitForJoin(ctx context.Context, timeout time.Duration) error

WaitForJoin blocks until the avatar participant joins the room.

type SessionConfig

type SessionConfig struct {
	// Client is the bitHuman API client.
	// Required.
	Client *Client

	// AgentID is the bitHuman agent to use for this session.
	// Required.
	AgentID string

	// AudioConfig configures the audio format.
	AudioConfig avatar.AudioConfig
}

SessionConfig configures a bitHuman avatar session.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL