Voice Platform — SDK Reference

    Branofy provides official client SDKs for both Node.js and Python to streamline launching calls, managing agents, and configuring webhooks programmatically.


    🟢 Node.js SDK

    Installation

    Add the SDK to your dependencies:

    yarn add @branofy/voice-sdk-node
    

    Instantiation

    Create a new client instance:

    import { BranofyVoiceSdk } from "@branofy/voice-sdk-node";
    
    const voiceSdk = new BranofyVoiceSdk({
      apiKey: "your_voice_api_key_here",
      baseUrl: "https://api.branofy.cloud"
    });
    

    Example: Dispatching an Outbound Call

    Start an automated call using a pre-configured Agent ID:

    async function run() {
      try {
        const call = await voiceSdk.calls.start("agent_12345", {
          name: "Ravi Kumar",
          phone: "+919876543210"
        });
        
        console.log("Call Dispatched successfully:", call.callId);
        console.log("Room Name:", call.roomName);
      } catch (error) {
        console.error("Failed to start call:", error);
      }
    }
    
    run();
    

    Example: Creating a Voice Agent

    async function createAgent() {
      const agent = await voiceSdk.agents.create({
        name: "Feedback Collector",
        callingProvider: "local_voice",
        firstMessage: "Hi, I am calling to gather your feedback on our service.",
        language: "en",
        model: "gpt-4o-realtime-preview",
        systemPrompt: "You are a customer feedback collector. Ask 3 simple questions.",
        temperature: 70,
        ttsVoice: "af_heart",
        voiceId: "alloy",
        toolIds: []
      });
    
      console.log("Agent Created:", agent.id);
    }
    

    🟡 Python SDK

    Installation

    Install the SDK using pip:

    pip install branofy-voice-sdk
    

    Instantiation

    from branofy_voice_sdk import BranofyVoiceClient
    
    client = BranofyVoiceClient(
        base_url="https://api.branofy.cloud",
        api_key="your_voice_api_key_here"
    )
    

    Example: Dispatching a Call

    try:
        response = client.start_call(
            agent_id="agent_12345",
            phone="+919876543210",
            name="Ravi Kumar"
        )
        print(f"Call started! ID: {response['callId']}, Status: {response['status']}")
    except Exception as e:
        print(f"Error starting call: {e}")
    

    Example: Fetching Overview Metrics

    overview = client.overview()
    print(f"Active calls count: {overview['activeCalls']}")
    print(f"Wallet balance: INR {overview['walletBalancePaise'] / 100:.2f}")