elevenlabs-go

module
v0.0.1 Latest Latest
Warning

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

Go to latest
Published: Apr 28, 2026 License: MIT

README

ElevenLabs Go SDK (Conversational AI)

Go Report Card GoDoc License GitHub last commit Visitors

Go SDK for interacting with the ElevenLabs API, specifically focusing on the new ElevenAgents (Conversational AI) module.

Features

  • Real-time WebSockets: Connect to ElevenLabs Conversational AI agents via WebSocket.
  • Custom Client Tools: Register Go functions that the agent can execute during conversations.
  • Audio Interfaces: Easy abstractions (AudioInterface) for bringing your own audio input/output handlers.
  • Event Callbacks: Handle transcripts, agent responses, audio alignments, and latency metrics via easy-to-use callbacks.

Installation

go get github.com/iyashjayesh/elevenlabs-go

Quick Start

See the example/main.go file for a fully working text-based example of spinning up a conversational agent and registering a custom tool.

package main

import (
	"log"
	"github.com/iyashjayesh/elevenlabs-go/conversationalai"
)

func main() {
    agentID := "YOUR_AGENT_ID"
    apiKey := "YOUR_API_KEY" // Optional if not requires_auth

    // Register a tool
    tools := conversationalai.NewClientTools()
    tools.Register("get_weather", func(params map[string]interface{}) (interface{}, error) {
        return "It's sunny and 72 degrees.", nil
    })

    // Listen to callbacks
    callbacks := conversationalai.Callbacks{
        OnAgentResponse: func(resp string) {
            log.Printf("Agent: %s\n", resp)
        },
    }

    config := &conversationalai.ConversationConfig{ AgentID: agentID }

    conversation := conversationalai.NewConversation(
        agentID, apiKey, nil, tools, callbacks, config,
    )

    if err := conversation.StartSession(); err != nil {
        log.Fatal(err)
    }

    conversation.SendUserMessage("Hello, what's the weather?")
    conversation.Wait()
}

License

MIT License. See LICENSE for more information.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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