API Reference

Complete reference documentation for the Voxin framework. Find detailed information about classes, methods, configurations, and type definitions.

Agent Class

The core class for creating and managing AI agents:

agent.py
123456789101112131415161718
from voxin import Agentagent = Agent( name="Example Agent", model="gpt-4", # Base language model temperature=0.7, # Response creativity (0-1) max_tokens=150, # Maximum response length voice_config=voice_config, # Optional voice configuration behaviors=[], # Optional list of behaviors metadata={} # Optional metadata)# Available methodsawait agent.think(message) # Process message and generate responseawait agent.speak(text) # Convert text to speechawait agent.listen() # Start voice recognitionawait agent.stop() # Stop all processingawait agent.reset() # Reset agent state

Properties

  • name: str - Agent identifier
  • model: str - Language model identifier
  • behaviors: List[Behavior] - Active behaviors
  • voice_config: Optional[VoiceConfig] - Voice settings
  • state: Dict[str, Any] - Current agent state

Voice Configuration

Configure voice synthesis and recognition settings:

voice_config.py
1234567891011
from voxin import VoiceConfigconfig = VoiceConfig( voice_id="clara-v1", # Voice identifier language="en-US", # Language code speaking_rate=1.0, # Speech rate (0.5-2.0) pitch=0.0, # Voice pitch (-10 to 10) volume_gain_db=0.0, # Volume adjustment sample_rate_hz=24000, # Audio sample rate audio_encoding="LINEAR16" # Audio encoding format)

Available Voices

English Voices

  • clara-v1 - Professional female
  • james-v1 - Professional male
  • sophie-v1 - Young female
  • alex-v1 - Young male

Other Languages

  • maria-v1 - Spanish female
  • hans-v1 - German male
  • yuki-v1 - Japanese female
  • li-v1 - Chinese male

Behavior Interface

Base interface for implementing custom behaviors:

behavior.py
123456789101112131415161718
from voxin import Behaviorclass CustomBehavior(Behavior): async def on_message(self, message: str) -> None: """Handle incoming messages""" pass async def on_error(self, error: Exception) -> None: """Handle errors""" pass async def on_state_change(self, state: dict) -> None: """Handle state changes""" pass def get_state(self) -> dict: """Get behavior state""" return {}

Type Definitions

Core Types

  • Context - Interaction context
  • Message - Communication unit
  • State - Agent state type
  • Event - System event type

Configuration Types

  • AgentConfig - Agent settings
  • VoiceConfig - Voice settings
  • BehaviorConfig - Behavior settings
  • SystemConfig - System settings

Error Handling

Exception Classes

  • VoxinError - Base error class
  • ConfigurationError - Invalid configuration
  • ConnectionError - Network issues
  • AuthenticationError - Invalid credentials
  • BehaviorError - Behavior-related issues