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 ¶
- func NewProviderFromConfig(cfg registry.ProviderConfig) (avatar.Provider, error)
- type Client
- type ClientConfig
- type Config
- type CreateSessionRequest
- type CreateSessionResponse
- type Provider
- type Session
- func (s *Session) AgentID() string
- func (s *Session) AudioOutput() avatar.AudioDestination
- func (s *Session) Close(ctx context.Context) error
- func (s *Session) EmitError(err error)
- func (s *Session) EmitPlaybackFinished(position float64, interrupted bool)
- func (s *Session) EmitPlaybackStarted()
- func (s *Session) Identity() string
- func (s *Session) Provider() string
- func (s *Session) Room() *lksdk.Room
- func (s *Session) SessionID() string
- func (s *Session) SetAudioOutput(out avatar.AudioDestination)
- func (s *Session) SetCallbacks(callbacks *avatar.SessionCallbacks)
- func (s *Session) Start(ctx context.Context, opts any) error
- func (s *Session) WaitForJoin(ctx context.Context, timeout time.Duration) error
- type SessionConfig
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 ¶
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 ¶
NewProvider creates a new bitHuman avatar provider.
func (*Provider) CreateSession ¶
CreateSession creates a new bitHuman avatar session.
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) AudioOutput ¶
func (s *Session) AudioOutput() avatar.AudioDestination
AudioOutput returns the audio destination for streaming TTS audio.
func (*Session) EmitPlaybackFinished ¶
EmitPlaybackFinished emits a playback finished event.
func (*Session) EmitPlaybackStarted ¶
func (s *Session) EmitPlaybackStarted()
EmitPlaybackStarted emits a playback started event.
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.
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.