Go

Updated

Full API reference for the Agora Agent Go SDK.

Full API reference for the Agora Conversational AI Go SDK.

client.NewClient

The entry point for the SDK. Creates a new API client with the given request options. All sub-clients share the same configuration.

import (
    "github.com/AgoraIO/agora-agents-go/v2/client"
    "github.com/AgoraIO/agora-agents-go/v2/option"
)

Constructor

func NewClient(opts ...option.RequestOption) *Client

Creates a new API client. All sub-clients share the same configuration. For AgentKit integrations, use agentkit.NewAgoraClient instead.

Request options

Request options configure transport, retries, and advanced authentication behavior. For session integrations, prefer agentkit.NewAgoraClient with AppID and AppCertificate. AgentKit generates Conversational AI REST authentication and RTC join tokens when session methods run.

option.WithArea

func WithArea(area core.Area) *core.AreaRequestOption

Enables regional routing with automatic DNS-based domain selection.

c := client.NewClient(
    option.WithArea(option.AreaUS),
)

option.WithBaseURL

func WithBaseURL(baseURL string) *core.BaseURLOption

Overrides the default API endpoint. Useful for testing.

import Agora "github.com/AgoraIO/agora-agents-go/v2"

c := client.NewClient(
    option.WithBaseURL(Agora.Environments.Default),
)

option.WithHTTPClient

func WithHTTPClient(httpClient core.HTTPClient) *core.HTTPClientOption

Provides a custom *http.Client. Recommended for production to set timeouts.

c := client.NewClient(
    option.WithHTTPClient(&http.Client{
        Timeout: 10 * time.Second,
    }),
)

option.WithMaxAttempts

func WithMaxAttempts(attempts uint) *core.MaxAttemptsOption

Sets the maximum number of retry attempts. Default: 2. Retries use exponential backoff for status codes 408, 429, and 5xx.

c := client.NewClient(
    option.WithMaxAttempts(3),
)

option.WithHTTPHeader

func WithHTTPHeader(httpHeader http.Header) *core.HTTPHeaderOption

Adds custom HTTP headers to every request.

option.WithBodyProperties

func WithBodyProperties(bodyProperties map[string]interface{}) *core.BodyPropertiesOption

Adds extra properties to the JSON request body.

option.WithQueryParameters

func WithQueryParameters(queryParameters url.Values) *core.QueryParametersOption

Adds query parameters to the request URL.

option.WithPool

func WithPool(pool *core.Pool) *core.AreaRequestOption

Uses a pre-configured Pool for regional routing.

Sub-clients

client.NewClient exposes Fern-generated sub-clients for direct REST API access. You typically do not need these when using the agentkit layer.

FieldTypeDescription
c.Agents*agents.ClientAgent lifecycle (start, list, stop, speak, interrupt, update, get, getHistory, getTurns)
c.AgentManagement*agentmanagement.ClientManagement actions: agent-think
c.Telephony*telephony.ClientTelephony operations (call, hangup)
c.PhoneNumbers*phonenumbers.ClientPhone number management

All sub-client methods take context.Context as their first argument. See the generated reference for full method signatures.

Environments

The root Agora package exposes the default API endpoint:

import Agora "github.com/AgoraIO/agora-agents-go/v2"

Agora.Environments.Default
// "https://api.agora.io/api/conversational-ai-agent"

Pointer helpers

The root Agora package provides helper functions for creating pointers to literal values. These are required for optional fields in Fern-generated request structs, which use pointer types to distinguish between "not set" and "set to zero value".

import Agora "github.com/AgoraIO/agora-agents-go/v2"
FunctionSignatureExample
Agora.Boolfunc(bool) *boolEnable: Agora.Bool(true)
Agora.Intfunc(int) *intIdleTimeout: Agora.Int(120)
Agora.Stringfunc(string) *stringAPIKey: Agora.String("<key>")
Agora.Float64func(float64) *float64Threshold: Agora.Float64(0.5)
Agora.Float32func(float32) *float32—
Agora.Int8/16/32/64func(intN) *intN—
Agora.Uint/8/16/32/64func(uintN) *uintN—
Agora.UUIDfunc(uuid.UUID) *uuid.UUID—
Agora.Timefunc(time.Time) *time.Time—

agentkit.NewAgoraClient

The AgentKit client. NewAgent requires it, and sessions created from the agent inherit the client's App ID, App Certificate, and REST authentication mode.

import (
    "github.com/AgoraIO/agora-agents-go/v2/agentkit"
    "github.com/AgoraIO/agora-agents-go/v2/option"
)

Constructor

func NewAgoraClient(opts AgoraClientOptions) *AgoraClient

Creates an AgentKit client with the given options.

c := agentkit.NewAgoraClient(agentkit.AgoraClientOptions{
    Area:           option.AreaUS,
    AppID:          "your-app-id",
    AppCertificate: "your-app-certificate",
})

AgoraClientOptions

FieldTypeRequiredDescription
Areaoption.AreaYesGeographic region for regional routing, for example option.AreaUS. Panics if not set
AppIDstringYesAgora App ID, used as the REST API path parameter and for token generation
AppCertificatestringConditionalUsed to sign tokens. Required for App credentials mode. Keep this value secret
CustomerIDstringNoCustomer ID for Basic authentication. Use with CustomerSecret
CustomerSecretstringNoCustomer secret for Basic authentication
TokenstringNoToken for token authentication. Can't be combined with CustomerID or CustomerSecret
HTTPClientcore.HTTPClientNoCustom HTTP transport

The authentication mode is AuthModeAppCredentials by default, AuthModeBasic when CustomerID is set, or AuthModeToken when Token is set.

Methods and fields

Methods and fields available on any *AgoraClient instance.

MemberTypeDescription
StopAgent(ctx, agentID)errorStops an agent by ID. Treats a 404 response as success
AppID()stringThe configured App ID
AppCertificate()stringThe configured App Certificate
IsAppCredentialsMode()boolWhether the client uses App credentials mode
HTTPClient()core.HTTPClientThe configured HTTP transport
AgentsClient()*agents.ClientThe agents sub-client
AgentManagementClient()*agentmanagement.ClientThe agent management sub-client
Agents, AgentManagement, Telephony, PhoneNumbersSub-clientsDirect REST API access. See Sub-clients

agentkit.NewAgent

Agent is an immutable configuration object. Each vendor chaining method returns a new *Agent — the original is never modified. Define one agent at startup and create sessions from it for each user conversation.

import (
    "github.com/AgoraIO/agora-agents-go/v2/agentkit"
    "github.com/AgoraIO/agora-agents-go/v2/agentkit/vendors"
)

Constructor

func NewAgent(client *AgoraClient, opts ...AgentOption) *Agent

Pass an AgoraClient and AgentOption functions to configure the agent's instructions, greeting, and other properties. Panics with NewAgent requires AgoraClient if client is nil. To name an agent instance, set Name in CreateSessionOptions.

agent := agentkit.NewAgent(c,
    agentkit.WithInstructions("You are a helpful voice assistant."), // LLM system prompt
    agentkit.WithGreeting("Hello! How can I help you today?"),       // first words spoken on session start
    agentkit.WithMaxHistory(10),
)

AgentOption functions

AgentOption functions are passed to NewAgent. AgentOption is func(*core.BaseAgent).

FunctionParameter typeDescription
WithPipelineID(pipelineID)stringPublished pipeline ID
WithInstructions(instructions)stringLLM system prompt
WithGreeting(greeting)stringFirst message the agent speaks
WithFailureMessage(msg)stringMessage spoken when the LLM fails
WithMaxHistory(n)intMaximum conversation turns to retain
WithTurnDetectionConfig(td)*TurnDetectionConfigCascading-flow turn detection configuration. Use Config.StartOfSpeech and Config.EndOfSpeech for SOS/EOS detection. Use interruption config for interruption behavior and MLLM vendor TurnDetection for MLLM turn detection
WithInterruptionConfig(interruption)*InterruptionConfigUnified interruption control using the top-level interruption object
WithGreetingConfigs(configs)*LlmGreetingConfigsSets llm.greeting_configs, including v2.7 interruptable
WithSalConfig(sal)*SalConfigSpeech analytics configuration
WithAdvancedFeatures(af)*AdvancedFeaturesAdvanced feature flags, for example EnableMllm, EnableAivad
WithTools(enabled)boolEnable or disable MCP tool and custom tool invocation
WithParameters(params)*SessionParamsAdditional session parameters
WithAudioScenario(audioScenario)ParametersAudioScenarioSets parameters.audio_scenario (default, chorus, or aiserver)
WithGeofence(gf)*GeofenceConfigRegional access restriction
WithLabels(labels)map[string]stringCustom key-value labels returned in notification callbacks
WithRtc(rtc)*RtcConfigRTC media encryption
WithFillerWords(fw)*FillerWordsConfigFiller words played while waiting for the LLM response
WithGreetingAudioURL(url)stringSets llm.greeting_audio_url
WithSessionOptOut(optOut)boolSets parameters.opt_out

Vendor chaining methods

Vendor methods are called on the *Agent returned by NewAgent. Each method returns a new *Agent — the original is never modified.

WithLlm(vendor)

Sets the LLM vendor. Pass an instance of NewOpenAI, NewAzureOpenAI, NewAnthropic, NewGemini, or any other LLM vendor.

func (a *Agent) WithLlm(vendor vendors.LLM) *Agent

WithTts(vendor)

Sets the TTS vendor. Captures the vendor's sample rate for avatar validation. Panics if an avatar is already configured and its required sample rate differs from the TTS sample rate.

func (a *Agent) WithTts(vendor vendors.TTS) *Agent

WithStt(vendor)

Sets the STT vendor. Pass an instance of any STT vendor constructor.

func (a *Agent) WithStt(vendor vendors.STT) *Agent

WithMllm(vendor)

Sets the MLLM vendor for multimodal mode. Pass NewOpenAIRealtime, NewAzureOpenAIRealtime, NewGeminiLive, NewVertexAI, NewXaiGrok, or NewOpenAIGPTLive. Automatically sets mllm.enable = true.

func (a *Agent) WithMllm(vendor vendors.MLLM) *Agent

WithAvatar(vendor)

Sets the avatar vendor. For LiveAvatar and HeyGen avatars, panics if TTS is already configured with a sample rate that doesn't match the avatar's required rate. For other avatars, a mismatch causes WithTts() to panic or Start() to return an error.

func (a *Agent) WithAvatar(vendor vendors.Avatar) *Agent

WithTurnDetection(config)

Configures cascading-flow turn detection. Use Config.StartOfSpeech and Config.EndOfSpeech for SOS/EOS detection. Use interruption config for interruption behavior and MLLM vendor TurnDetection for MLLM turn detection.

func (a *Agent) WithTurnDetection(td *TurnDetectionConfig) *Agent

Other builder methods

The following methods follow the same pattern — each returns a new *Agent with the updated configuration.

MethodParameter typeDescription
WithInstructions(instructions)stringOverride the LLM system prompt
WithGreeting(greeting)stringOverride the greeting message
WithInterruption(interruption)*InterruptionConfigSet interruption configuration
WithGreetingConfigs(configs)*LlmGreetingConfigsSet greeting playback configuration
WithGreetingAudioURL(url)stringSet llm.greeting_audio_url
WithSessionOptOut(optOut)boolSet parameters.opt_out
WithAudioScenario(audioScenario)ParametersAudioScenarioSet parameters.audio_scenario
WithSal(sal)*SalConfigSet SAL configuration
WithAdvancedFeatures(af)*AdvancedFeaturesSet advanced features
WithTools(enabled)boolEnable or disable MCP tool and custom tool invocation
WithParameters(params)*SessionParamsSet session parameters
WithFailureMessage(msg)stringSet the failure message
WithMaxHistory(n)intSet the maximum conversation history length
WithGeofence(gf)*GeofenceConfigSet geofence configuration
WithLabels(labels)map[string]stringSet custom labels
WithRtc(rtc)*RtcConfigSet RTC configuration
WithFillerWords(fw)*FillerWordsConfigSet filler words configuration

ToProperties()

Converts the agent configuration to a *Agora.StartAgentsRequestProperties for direct use with the low-level client. Called internally by AgentSession.Start(). Use this directly when building custom request bodies.

func (a *Agent) ToProperties(opts ToPropertiesOptions) (*Agora.StartAgentsRequestProperties, error)

Returns an error if:

  • Neither Token nor AppID + AppCertificate is provided
  • AgentUID isn't numeric when a token must be generated
  • RemoteUIDs is empty
  • ExpiresIn is invalid
  • MLLM is combined with an enabled avatar
  • In cascading mode: LLM or TTS isn't configured
  • Config marshaling fails

ToPropertiesOptions

type ToPropertiesOptions struct {
    Channel         string
    AgentUID        string
    RemoteUIDs      []string
    Token           string
    AppID           string
    AppCertificate  string
    ExpiresIn       int
    IdleTimeout     *int
    EnableStringUID *bool
    SkipVendorValidation           bool
    SkipVendorValidationCategories []string
    AllowMissingVendorCategories   []string
    Warn            func(string)
}
FieldTypeRequiredDescription
ChannelstringYesAgora channel name
AgentUIDstringYesAgent's UID in the channel
RemoteUIDs[]stringYesRemote participant UIDs
TokenstringConditionalPre-generated RTC+RTM token. Skips generation if set
AppIDstringConditionalAgora App ID. Required if Token is not set
AppCertificatestringConditionalAgora App Certificate. Required if Token is not set
ExpiresInintNoToken lifetime in seconds. Default: 86400. Valid range: 1–86400
IdleTimeout*intNoSession idle timeout in seconds
EnableStringUID*boolNoEnable string UID mode
SkipVendorValidationboolNoAdvanced option for pipeline-backed starts without explicit LLM/TTS
SkipVendorValidationCategories[]stringNoSkip request-shape validation for the listed vendor categories (asr, llm, tts)
AllowMissingVendorCategories[]stringNoAllow the listed vendor categories to be omitted from properties
Warnfunc(string)NoWarning sink for recoverable config issues

Getters

Read-only methods available on any *Agent instance.

MethodReturn typeDescription
PipelineID()stringPublished pipeline ID
Instructions()stringLLM system prompt
Greeting()stringGreeting message
FailureMessage()stringMessage spoken when LLM fails
MaxHistory()*intMaximum conversation history length
LlmConfig()map[string]interface{}LLM configuration
TtsConfig()map[string]interface{}TTS configuration
SttConfig()map[string]interface{}STT configuration
MllmConfig()map[string]interface{}MLLM configuration
TtsSampleRate()*vendors.SampleRateTTS sample rate
AvatarRequiredSampleRate()*vendors.SampleRateAvatar required sample rate
Avatar()map[string]interface{}Avatar configuration
TurnDetection()*TurnDetectionConfigTurn detection configuration
Interruption()*InterruptionConfigInterruption configuration
GreetingConfigs()*LlmGreetingConfigsGreeting playback configuration
Sal()*SalConfigSAL configuration
AdvancedFeatures()*AdvancedFeaturesAdvanced features
Parameters()*SessionParamsSession parameters
Geofence()*GeofenceConfigGeofence configuration
Labels()map[string]stringCustom labels
Rtc()*RtcConfigRTC configuration
FillerWords()*FillerWordsConfigFiller words configuration

agent.CreateSession

Creates an AgentSession from the agent configuration. This is the recommended way to create a session. The session's REST client, App ID, App Certificate, and REST authentication mode come from the agent's AgoraClient. Call Start() on the returned session to join the agent to the channel.

func (a *Agent) CreateSession(opts CreateSessionOptions) *AgentSession
session := agent.CreateSession(agentkit.CreateSessionOptions{
    Name:       "support-assistant",
    Channel:    "support-room-123",
    AgentUID:   "1",
    RemoteUIDs: []string{"100"},
})

CreateSessionOptions

FieldTypeRequiredDescription
NamestringNoAgent instance identifier, sent as the top-level /join field name. Auto-generated when empty
ChannelstringYesAgora channel name
TokenstringConditionalPre-generated RTC+RTM token. Skips auto-generation if set
AgentUIDstringYesAgent's UID in the channel
RemoteUIDs[]stringYesRemote participant UIDs
IdleTimeout*intNoIdle timeout in seconds
EnableStringUID*boolNoEnable string UID mode
ExpiresInintNoAuto-generated token lifetime in seconds
Preset[]stringNoAdvanced preset value for project-specific routing. Don't set for standard AgentKit usage
PipelineIDstringNoPublished pipeline ID to send on session start
DebugboolNoEnable debug logging of the start request
Warnfunc(string)NoCustom warning sink; defaults to logger

agentkit.NewAgentSession

AgentSession manages the full lifecycle of a running agent. In most cases, use agent.CreateSession. Use NewAgentSession only when you need to supply the session's clients and agent yourself, then call Start() to join the agent to the channel.

import "github.com/AgoraIO/agora-agents-go/v2/agentkit"

Constructor

func NewAgentSession(opts AgentSessionOptions) *AgentSession

If Name is empty, defaults to agent-<unix_timestamp_ms>. The session starts in AgentSessionLifecycleIdle.

AgentSessionOptions

type AgentSessionOptions struct {
    Client                *agents.Client
    HTTPClient            core.HTTPClient
    AgentManagementClient *agentmanagement.Client
    Agent                 agentcore.AgentRuntime
    AppID           string
    AppCertificate  string
    Name            string
    Channel         string
    Token           string
    AgentUID        string
    RemoteUIDs      []string
    IdleTimeout     *int
    EnableStringUID *bool
    ExpiresIn       int
    UseAppCredentialsForREST bool
    Preset          []string
    PipelineID      string
    Debug           bool
    Warn            func(string)
}
FieldTypeRequiredDescription
Client*agents.ClientYesFern-generated agents sub-client (from c.Agents)
HTTPClientcore.HTTPClientNoCustom HTTP transport
AgentManagementClient*agentmanagement.ClientConditionalAgent management sub-client (from c.AgentManagement). Required for Think()
Agentagentcore.AgentRuntimeYesAgent configuration. A *Agent built with NewAgent satisfies this interface
AppIDstringYesAgora App ID
AppCertificatestringConditionalRequired if Token is not set or UseAppCredentialsForREST is true
NamestringNoAgent instance identifier. Default: agent-<unix_timestamp_ms>
ChannelstringYesAgora channel name
TokenstringConditionalPre-generated RTC+RTM token. Skips auto-generation if set
AgentUIDstringYesAgent's UID in the channel
RemoteUIDs[]stringYesRemote participant UIDs
IdleTimeout*intNoIdle timeout in seconds
EnableStringUID*boolNoEnable string UID mode
ExpiresInintNoAuto-generated token lifetime in seconds
UseAppCredentialsForRESTboolNoGenerate ConvoAI REST auth headers per request
Preset[]stringNoAdvanced preset value for project-specific routing. Do not set for normal builder usage.
PipelineIDstringNoPublished pipeline ID to send on session start
DebugboolNoEnable debug logging of the start request
Warnfunc(string)NoCustom warning sink; defaults to logger

PipelineID is sent as the top-level /join field pipeline_id, not inside properties. If not set, AgentSession.Start() uses the agent-level value from WithPipelineID.

State machine

A session progresses through the following states:

         Start()           API success
  ┌──────┐      ┌──────────┐      ┌─────────┐
  │ idle │─────>│ starting │─────>│ running │
  └──┬───┘      └────┬─────┘      └────┬────┘
     │               │                  │
     │               │ error            │ Stop()
     │               ▼                  ▼
     │          ┌─────────┐      ┌──────────┐
     │          │  error  │      │ stopping │
     │          └────┬────┘      └────┬─────┘
     │               │                │
     │               │                │ success
     │               ▼                ▼
     │          ┌──────────┐     ┌─────────┐
     └─────────>│ (restart)│     │ stopped │
                └──────────┘     └─────────┘
TransitionTrigger
idle → startingStart() called
starting → runningAPI responds with agent ID
starting → errorAPI request fails
running → stoppingStop() called
stopping → stoppedAPI confirms agent stopped
stopping → errorStop request fails and agent was not already stopped

Start() can also be called from stopped or error state to restart the session. If you call Start() from an invalid state, or if it fails avatar validation, it returns an error without changing the status or emitting the error event. If Say(), Interrupt(), Update(), or Think() fails, it returns an error but doesn't change the session status.

Methods

All methods take context.Context as the first argument. Register event handlers before calling Start() to avoid missing the started event.

Start(ctx)

Starts the agent session. Validates avatar/TTS configuration, generates a token if not provided, and calls the Agora API. Returns the agent ID.

func (s *AgentSession) Start(ctx context.Context) (string, error)
  • Valid from: idle, stopped, error
  • Transitions to: starting → running on success, error on failure
  • Emits: "started" on success, "error" on failure
  • Validates avatar config and avatar/TTS sample rate match before making the API call
agentID, err := session.Start(ctx)
if err != nil {
    log.Fatalf("Failed to start session: %v", err)
}

Stop(ctx)

Stops the running agent and removes it from the channel.

func (s *AgentSession) Stop(ctx context.Context) error
  • Valid from: running
  • Transitions to: stopping → stopped on success, error on failure
  • Emits: "stopped" on success, "error" on failure
err := session.Stop(ctx)
if err != nil {
    log.Fatalf("Failed to stop session: %v", err)
}

Say(ctx, text, priority, interruptable)

Instructs the agent to speak the given text.

func (s *AgentSession) Say(ctx context.Context, text string, priority *Agora.SpeakAgentsRequestPriority, interruptable *bool) error
  • Valid from: running
  • Pass nil for priority or interruptable to use defaults
ParameterTypeDescription
textstringThe text for the agent to speak
priority*Agora.SpeakAgentsRequestPriorityOptional priority level. Pass nil for default. Use agentkit.SpeakPriorityInterrupt.Ptr(), agentkit.SpeakPriorityAppend.Ptr(), or agentkit.SpeakPriorityIgnore.Ptr() convenience constants instead of the raw generated enum
interruptable*boolWhether this message can be interrupted. Pass nil for default
err := session.Say(ctx, "One moment while I look that up.", nil, nil)

Interrupt(ctx)

Interrupts the agent's current speech.

func (s *AgentSession) Interrupt(ctx context.Context) error
  • Valid from: running

Update(ctx, properties)

Updates the agent's properties mid-session without restarting. Accepts a typed properties struct in REST API format.

func (s *AgentSession) Update(ctx context.Context, properties *Agora.UpdateAgentsRequestProperties) error
  • Valid from: running

GetHistory(ctx)

Retrieves the conversation history. Requires a valid agent ID — Start() must have been called successfully.

func (s *AgentSession) GetHistory(ctx context.Context) (*Agora.GetHistoryAgentsResponse, error)

GetTurns(ctx) / GetAllTurns(ctx)

Retrieves turn-by-turn analytics for the session. Requires a valid agent ID — Start() must have been called successfully.

func (s *AgentSession) GetTurns(ctx context.Context, opts ...GetTurnsOptions) (*Agora.GetTurnsAgentsResponse, error)
func (s *AgentSession) GetAllTurns(ctx context.Context, opts ...GetAllTurnsOptions) (*Agora.GetTurnsAgentsResponse, error)

type GetTurnsOptions struct {
    PageIndex *int
    PageSize  *int
}

type GetAllTurnsOptions struct {
    PageSize *int
}

PageIndex starts at 1. Use GetAllTurns to iterate through every page with a default page size of 50 and return the final response with aggregated Turns.

  • Requires: Valid agent ID

When you consume server notifications, event 112 means all turns for the session have finished and are ready to query.

GetInfo(ctx)

Gets the current agent status from the API. Requires a valid agent ID.

func (s *AgentSession) GetInfo(ctx context.Context) (*Agora.GetAgentsResponse, error)

Think(ctx)

Injects a thought or instruction into a running agent. In v2.7, omitting on_listening_action uses the server default interrupt. Set agentkit.ThinkOnListeningActionInject.Ptr() if you need legacy inject behavior. AgentKit also exposes ThinkOnListeningActionInterrupt, ThinkOnListeningActionIgnore, ThinkOnThinkingActionInterrupt, ThinkOnThinkingActionIgnore, ThinkOnSpeakingActionInterrupt, and ThinkOnSpeakingActionIgnore convenience constants.

All three state actions also accept append. Pass Agora.AgentThinkAgentManagementRequestOnListeningActionAppend.Ptr(), Agora.AgentThinkAgentManagementRequestOnThinkingActionAppend.Ptr(), or Agora.AgentThinkAgentManagementRequestOnSpeakingActionAppend.Ptr(). With append, the instruction doesn't interrupt the current interaction. The agent waits for the current user turn, LLM inference, or TTS playback to finish, then appends the instruction to the context as a separate user message and starts a new turn.

func (s *AgentSession) Think(ctx context.Context, text string, onListeningAction *Agora.AgentThinkAgentManagementRequestOnListeningAction, onThinkingAction *Agora.AgentThinkAgentManagementRequestOnThinkingAction, onSpeakingAction *Agora.AgentThinkAgentManagementRequestOnSpeakingAction, interruptable *bool, metadata map[string]string) (*Agora.AgentThinkAgentManagementResponse, error)
func (s *AgentSession) ThinkWithOptions(ctx context.Context, text string, opts *ThinkOptions) (*Agora.AgentThinkAgentManagementResponse, error)
  • Valid from: running

On(event, handler)

Registers an event handler. Multiple handlers can be registered for the same event. Handlers run synchronously; panics in handlers are recovered and reported through the session warning sink.

func (s *AgentSession) On(event string, handler EventHandler)
session.On("started", func(data interface{}) {
    info := data.(map[string]string)
    fmt.Println("Agent is live:", info["agent_id"])
})
session.On("stopped", func(data interface{}) {
    fmt.Println("Agent has left")
})
session.On("error", func(data interface{}) {
    log.Println("Session error:", data)
})

Off(event, handler)

Unregisters a previously registered event handler.

func (s *AgentSession) Off(event string, handler EventHandler)

Events

EventData typeDescription
"started"map[string]string{"agent_id": "..."}Agent successfully joined the channel
"stopped"map[string]string{"agent_id": "..."}Agent left the channel
"error"errorAn unrecoverable error occurred

Getters

Read-only methods available on any *AgentSession instance.

MethodReturn typeDescription
ID()stringAgent ID. Empty string before Start() succeeds
Status()AgentSessionLifecycleCurrent session state
Agent()AgentRuntimeThe agent configuration
AppID()stringThe Agora App ID
Raw()*agents.ClientDirect access to the Fern-generated agents client for advanced operations
RawAgentManagement()*agentmanagement.ClientDirect access to the Fern-generated agent management client

Using session.Raw()

Use session.Raw() to call REST API endpoints not yet exposed by the agentkit layer.

response, err := session.Raw().List(ctx, &Agora.ListAgentsRequest{
    Appid: session.AppID(),
})

Thread safety

All state access is protected by sync.RWMutex. The session is safe for concurrent use across go routines.

Vendors

All vendor constructors are in the agentkit/vendors package. Constructors panic if required fields are empty — this is Go-idiomatic behavior for programmer configuration errors.

import "github.com/AgoraIO/agora-agents-go/v2/agentkit/vendors"

Interfaces

type LLM interface {
    ToConfig() map[string]interface{}
}

type TTS interface {
    ToConfig() map[string]interface{}
    GetSampleRate() *SampleRate
}

type STT interface {
    ToConfig() map[string]interface{}
}

type MLLM interface {
    ToConfig() map[string]interface{}
}

type Avatar interface {
    ToConfig() map[string]interface{}
    RequiredSampleRate() SampleRate
}

LLM vendors

Use with WithLlm().

NewOpenAI

func NewOpenAI(opts OpenAIOptions) *OpenAI

Panics if Model is empty. Panics if APIKey is empty unless Model is one of the supported Agora-managed OpenAI models (gpt-4o-mini, gpt-4.1-mini, gpt-5-nano, gpt-5-mini) and BaseURL / Vendor are not set.

FieldTypeRequiredDefaultDescription
APIKeystringBYOK only—OpenAI API key. Optional for supported Agora-managed OpenAI models.
ModelstringYes—Model identifier
BaseURLstringBYOK only—API endpoint. Required when APIKey is set.
Temperature*float64No—Sampling temperature
TopP*float64No—Nucleus sampling
MaxTokens*intNo—Maximum tokens in response
SystemMessages[]map[string]interface{}No—System messages
GreetingMessagestringNo—Agent greeting message
FailureMessagestringNo—Message spoken when LLM fails
InputModalities[]stringNo["text"]Input modalities
OutputModalities[]stringNo—Output modalities
Paramsmap[string]interface{}No—Additional model parameters
Headersmap[string]stringNo—Custom HTTP headers forwarded to the LLM provider
GreetingConfigsmap[string]interface{}No—Greeting playback configuration
TemplateVariablesmap[string]stringNo—Template variables for messages. Custom tools can reference them with {{template_variables.<name>}}
MaxHistory*intNo—Maximum number of conversation history messages to cache
VendorstringNo—Vendor override
McpServers[]map[string]interface{}No—MCP server connections
Tools[]*Agora.LlmToolNo—Synchronous custom tool definitions the LLM can call. Requires WithTools(true)

NewAzureOpenAI

func NewAzureOpenAI(opts AzureOpenAIOptions) *AzureOpenAI

Panics if APIKey, Model, Endpoint, or DeploymentName is empty.

FieldTypeRequiredDefaultDescription
APIKeystringYes—Azure OpenAI API key
EndpointstringYes—Azure endpoint URL
DeploymentNamestringYes—Azure deployment name
ModelstringYes—Deployment's base model name (e.g., "gpt-4o"). Emitted as params.model for parity with the TypeScript SDK.
APIVersionstringNo"2024-08-01-preview"API version
Temperature*float64No—Sampling temperature
TopP*float64No—Nucleus sampling
MaxTokens*intNo—Maximum tokens
SystemMessages[]map[string]interface{}No—System messages
GreetingMessagestringNo—Agent greeting message
FailureMessagestringNo—Message spoken when LLM fails
InputModalities[]stringNo["text"]Input modalities
OutputModalities[]stringNo—Output modalities
Paramsmap[string]interface{}No—Additional model parameters
Headersmap[string]stringNo—Custom HTTP headers forwarded to the LLM provider
GreetingConfigsmap[string]interface{}No—Greeting playback configuration
TemplateVariablesmap[string]stringNo—Template variables for messages. Custom tools can reference them with {{template_variables.<name>}}
MaxHistory*intNo—Maximum number of conversation history messages to cache
VendorstringNo—Vendor override
McpServers[]map[string]interface{}No—MCP server connections
Tools[]*Agora.LlmToolNo—Synchronous custom tool definitions the LLM can call. Requires WithTools(true)

NewAnthropic

func NewAnthropic(opts AnthropicOptions) *Anthropic

Panics if APIKey, Model, URL, Headers, or MaxTokens is empty.

FieldTypeRequiredDefaultDescription
APIKeystringYes—Anthropic API key
ModelstringYes—Model identifier
URLstringYes—Anthropic messages endpoint URL
Headersmap[string]stringYes—Request headers, including Anthropic API version
MaxTokens*intYes—Max tokens
Temperature*float64No—Sampling temperature
TopP*float64No—Nucleus sampling
SystemMessages[]map[string]interface{}No—System messages
GreetingMessagestringNo—Agent greeting message
FailureMessagestringNo—Message spoken when LLM fails
InputModalities[]stringNo["text"]Input modalities
OutputModalities[]stringNo—Output modalities
Paramsmap[string]interface{}No—Additional model parameters
GreetingConfigsmap[string]interface{}No—Greeting playback configuration
TemplateVariablesmap[string]stringNo—Template variables for messages. Custom tools can reference them with {{template_variables.<name>}}
MaxHistory*intNo—Maximum number of conversation history messages to cache
VendorstringNo—Vendor override
McpServers[]map[string]interface{}No—MCP server connections
Tools[]*Agora.LlmToolNo—Synchronous custom tool definitions the LLM can call. Requires WithTools(true)

NewGemini

func NewGemini(opts GeminiOptions) *Gemini

Panics if APIKey or Model is empty.

FieldTypeRequiredDefaultDescription
APIKeystringYes—Google AI API key
ModelstringYes—Model identifier
URLstringNo—Custom API endpoint URL
Temperature*float64No—Sampling temperature
TopP*float64No—Nucleus sampling
TopK*intNo—Top-K sampling
MaxOutputTokens*intNo—Maximum output tokens
SystemMessages[]map[string]interface{}No—System messages
GreetingMessagestringNo—Agent greeting message
FailureMessagestringNo—Message spoken when LLM fails
InputModalities[]stringNo["text"]Input modalities
OutputModalities[]stringNo—Output modalities
Paramsmap[string]interface{}No—Additional model parameters
Headersmap[string]stringNo—Custom HTTP headers forwarded to the LLM provider
GreetingConfigsmap[string]interface{}No—Greeting playback configuration
TemplateVariablesmap[string]stringNo—Template variables for messages. Custom tools can reference them with {{template_variables.<name>}}
MaxHistory*intNo—Maximum number of conversation history messages to cache
VendorstringNo—Vendor override
McpServers[]map[string]interface{}No—MCP server connections
Tools[]*Agora.LlmToolNo—Synchronous custom tool definitions the LLM can call. Requires WithTools(true)

Other LLM vendors

The SDK also includes named helpers for the remaining Agora-supported LLM providers. These helpers choose the correct request format internally.

ConstructorOptions StructRequired Fields
NewGroqGroqOptionsAPIKey, Model, BaseURL
NewVertexAILLMVertexAILLMOptionsAPIKey, Model, ProjectID, Location
NewAmazonBedrockAmazonBedrockOptionsAccessKey, SecretKey, Region, Model
NewDifyDifyOptionsAPIKey, URL, Model
NewCustomLLMCustomLLMOptionsAPIKey, BaseURL, Model
NewXaiLLMXaiLLMOptionsAPIKey, Model, BaseURL

The Tools field in LLM vendor options declares custom tools the LLM can choose to call. Each tool includes a model-visible function definition and the server configuration for a synchronous GET or POST request. WithTools(true) applies to both Tools and McpServers. For more information, see Call custom tools.

TTS vendors

Use with WithTts(). The SampleRate field determines avatar compatibility — see WithAvatar(). Use SampleRate constants for the SampleRate field.

NewElevenLabsTTS

func NewElevenLabsTTS(opts ElevenLabsTTSOptions) *ElevenLabsTTS

Panics if Key, ModelID, VoiceID, or BaseURL is empty.

FieldTypeRequiredDescription
KeystringYesElevenLabs API key
ModelIDstringYesModel identifier, for example "eleven_flash_v2_5"
VoiceIDstringYesVoice identifier
BaseURLstringYesWebSocket base URL
SampleRate*SampleRateNoOutput sample rate
OptimizeStreamingLatency*intNoLatency optimization level (0–4)
Stability*float64NoVoice stability (0.0–1.0)
SimilarityBoost*float64NoVoice similarity boost (0.0–1.0)
Style*float64NoVoice style exaggeration (0.0–1.0)
UseSpeakerBoost*boolNoEnable speaker boost
SkipPatterns[]intNoPatterns to skip in TTS output

NewMicrosoftTTS

func NewMicrosoftTTS(opts MicrosoftTTSOptions) *MicrosoftTTS

Panics if Key, Region, or VoiceName is empty.

FieldTypeRequiredDescription
KeystringYesAzure Speech Services key
RegionstringYesAzure region, for example "eastus"
VoiceNamestringYesVoice name, for example "en-US-JennyNeural"
SampleRate*SampleRateNoOutput sample rate
Speed*float64NoSpeaking rate multiplier
Volume*float64NoAudio volume
SkipPatterns[]intNoPatterns to skip

NewOpenAITTS

Fixed sample rate: SampleRate24kHz.

func NewOpenAITTS(opts OpenAITTSOptions) *OpenAITTS

Panics if Voice is empty. APIKey, Model, and BaseURL are required together for BYOK. APIKey is optional for the Agora-managed tts-1 path. Always returns SampleRate24kHz from GetSampleRate().

FieldTypeRequiredDescription
APIKeystringBYOK onlyOpenAI API key. Optional for the Agora-managed tts-1 path.
VoicestringYesVoice name: "alloy", "echo", "fable", "onyx", "nova", or "shimmer"
ModelstringBYOK onlyModel identifier
BaseURLstringBYOK onlyOpenAI TTS endpoint URL
InstructionsstringNoCustom instructions for voice style, accent, pace, and tone
Speed*float64NoSpeech speed multiplier
SkipPatterns[]intNoPatterns to skip

NewCartesiaTTS

func NewCartesiaTTS(opts CartesiaTTSOptions) *CartesiaTTS

Panics if APIKey, VoiceID, or ModelID is empty.

FieldTypeRequiredDescription
APIKeystringYesCartesia API key
VoiceIDstringYesVoice identifier (serialized as {"mode":"id","id":"..."})
ModelIDstringYesModel identifier
BaseURLstringNoWebSocket URL for the Cartesia streaming API
LanguagestringNoTarget language for speech synthesis
SampleRate*SampleRateNoOutput sample rate
SkipPatterns[]intNoPatterns to skip

NewGoogleTTS

func NewGoogleTTS(opts GoogleTTSOptions) *GoogleTTS

Panics if Key or VoiceName is empty.

FieldTypeRequiredDescription
KeystringYesGoogle Cloud API key
VoiceNamestringYesVoice name
LanguageCodestringNoLanguage code
SampleRate*SampleRateNoOutput sample rate
SkipPatterns[]intNoPatterns to skip

NewAmazonTTS

func NewAmazonTTS(opts AmazonTTSOptions) *AmazonTTS

Panics if AccessKey, SecretKey, Region, VoiceID, or Engine is empty.

FieldTypeRequiredDescription
AccessKeystringYesAWS access key
SecretKeystringYesAWS secret key
RegionstringYesAWS region
VoiceIDstringYesAmazon Polly voice ID
EnginestringYesPolly engine type
SkipPatterns[]intNoPatterns to skip

NewDeepgramTTS

func NewDeepgramTTS(opts DeepgramTTSOptions) *DeepgramTTS

Panics if APIKey or Model is empty.

FieldTypeRequiredDescription
APIKeystringYesDeepgram API key
ModelstringYesDeepgram TTS model, for example "aura-2-thalia-en"
BaseURLstringNoWebSocket endpoint. Defaults server-side to wss://api.deepgram.com/v1/speak
SampleRate*SampleRateNoOutput sample rate
AdditionalParamsmap[string]interface{}NoAdditional Deepgram TTS parameters, flattened into params
SkipPatterns[]intNoPatterns to skip

NewHumeAITTS

func NewHumeAITTS(opts HumeAITTSOptions) *HumeAITTS

Panics if Key, VoiceID, or Provider is empty.

FieldTypeRequiredDescription
KeystringYesHume AI API key
VoiceIDstringYesHume AI voice ID
ProviderstringYesVoice provider type, such as CUSTOM_VOICE or HUME_AI
ConfigIDstringNoConfiguration ID
BaseURLstringNoBase URL
Speed*float64NoPlayback speed
TrailingSilence*float64NoTrailing silence in seconds
SkipPatterns[]intNoPatterns to skip

NewRimeTTS

func NewRimeTTS(opts RimeTTSOptions) *RimeTTS

In BYOK mode (default), panics if Key, Speaker, or ModelID is empty. In managed mode, panics if BaseURL or ModelID is empty.

FieldTypeRequiredDescription
CredentialModeCredentialModeNo"managed" or "byok". Defaults to BYOK
KeystringBYOK onlyRime API key
SpeakerstringBYOK onlySpeaker identifier
ModelIDstringYesModel identifier
BaseURLstringManaged onlyWebSocket URL
SkipPatterns[]intNoPatterns to skip

NewFishAudioTTS

func NewFishAudioTTS(opts FishAudioTTSOptions) *FishAudioTTS

Panics if Key, ReferenceID, or Backend is empty.

FieldTypeRequiredDescription
KeystringYesFish Audio API key
ReferenceIDstringYesReference audio ID
BackendstringYesBackend model version
SkipPatterns[]intNoPatterns to skip

NewMiniMaxTTS

func NewMiniMaxTTS(opts MiniMaxTTSOptions) *MiniMaxTTS

Panics if Model is empty. Key is optional for supported preset-backed MiniMax models (speech-2.6-turbo, speech_2_6_turbo, speech-2.8-turbo, speech_2_8_turbo). In BYOK mode (Key set), GroupID and URL are also required. In preset-backed mode, don't set GroupID, VoiceID, or URL.

FieldTypeRequiredDescription
KeystringNoMiniMax API key. Optional for supported preset-backed MiniMax models
GroupIDstringBYOK onlyMiniMax group ID
ModelstringYesModel name, for example "speech-02-turbo"
VoiceIDstringNoVoice style identifier. BYOK only
URLstringBYOK onlyWebSocket endpoint
AdditionalParamsmap[string]interface{}NoAdditional MiniMax parameters, flattened into params
SkipPatterns[]intNoPatterns to skip

NewMurfTTS

func NewMurfTTS(opts MurfTTSOptions) *MurfTTS

Panics if Key is empty.

FieldTypeRequiredDescription
KeystringYesMurf API key
VoiceIDstringNoVoice ID, for example "Ariana" or "Natalie"
BaseURLstringNoWebSocket endpoint
LocalestringNoVoice locale
Rate*float64NoSpeech rate
Pitch*float64NoPitch adjustment
ModelstringNoTTS model
SampleRate*intNoAudio sample rate
SkipPatterns[]intNoPatterns to skip

NewSarvamTTS

func NewSarvamTTS(opts SarvamTTSOptions) *SarvamTTS

Panics if Key, Speaker, or TargetLanguageCode is empty.

FieldTypeRequiredDescription
KeystringYesSarvam API key
SpeakerstringYesSpeaker name
TargetLanguageCodestringYesTarget language code
Pitch*float64NoPitch adjustment
Pace*float64NoSpeed of speech
Loudness*float64NoVolume level
SampleRate*intNoAudio sample rate
SkipPatterns[]intNoPatterns to skip

NewTypecastTTS

func NewTypecastTTS(opts TypecastTTSOptions) *TypecastTTS

Panics if APIKey, VoiceID, or Model is empty.

FieldTypeRequiredDescription
APIKeystringYesTypecast API key
VoiceIDstringYesTypecast voice identifier
ModelstringYesTypecast TTS model name, for example "ssfm-v30"
AdditionalParamsmap[string]interface{}NoAdditional Typecast parameters
SkipPatterns[]intNoPatterns to skip

NewGradiumTTS

func NewGradiumTTS(opts GradiumTTSOptions) *GradiumTTS

Panics if APIKey is empty.

FieldTypeRequiredDescription
APIKeystringYesGradium API key
URLstringNoWebSocket endpoint for streaming TTS output
ModelNamestringNoGradium TTS model name
VoiceIDstringNoGradium voice identifier
SampleRate*SampleRateNoOutput sample rate
AdditionalParamsmap[string]interface{}NoAdditional Gradium TTS parameters, flattened into params
SkipPatterns[]intNoPatterns to skip

NewMistralTTS

func NewMistralTTS(opts MistralTTSOptions) *MistralTTS

Panics if APIKey is empty.

FieldTypeRequiredDescription
APIKeystringYesMistral API key
ModelstringNoMistral TTS model name
VoicestringNoMistral voice identifier
AdditionalParamsmap[string]interface{}NoAdditional Mistral TTS parameters, flattened into params
SkipPatterns[]intNoPatterns to skip

NewGenericTTS

func NewGenericTTS(opts GenericTTSOptions) *GenericTTS

Custom OpenAI-compatible HTTP TTS. URL is required and must be an absolute HTTP or HTTPS address that includes a host — this panics if URL is missing, badly formatted, or uses a non-HTTP(S) scheme such as ws, wss, or ftp. A valid URL is serialized as tts.vendor = "generic_http".

FieldTypeRequiredDescription
URLstringYesThe HTTP(S) endpoint of your custom TTS service
Headersmap[string]stringNoCustom HTTP headers to forward to the TTS service. Omitted from the request if not set
APIKeystringNoThe API key used to authenticate with the TTS service
ModelstringNoThe TTS model name
VoicestringNoThe voice name
Speed*float64NoThe speech rate
SampleRate*SampleRateNoThe sample rate, in Hz, of the output audio. If your TTS service doesn't support multiple sample rates, make sure the returned audio's sample rate matches this value
ResponseFormatstringNoThe output audio format. Conversational AI Engine currently supports pcm
InstructionstringNoInstructions for voice style, emotion, or other playback directives
AdditionalParamsmap[string]interface{}NoAdditional parameters passed through to the TTS service. Explicit fields with the same name take precedence
SkipPatterns[]intNoPatterns to skip

NewXaiTTS

func NewXaiTTS(opts XaiTTSOptions) *XaiTTS

Panics if APIKey or Language is empty.

FieldTypeRequiredDescription
APIKeystringYesxAI API key
LanguagestringYesBCP-47 language code for speech synthesis
VoiceIDstringNoxAI voice identifier
SampleRate*SampleRateNoAudio sample rate
SkipPatterns[]intNoPatterns to skip

NewSmallestAITTS

func NewSmallestAITTS(opts SmallestAITTSOptions) *SmallestAITTS

Panics if APIKey is empty.

FieldTypeRequiredDescription
APIKeystringYesSmallest AI API key
URLstringNoStreaming TTS endpoint
ModelstringNoTTS model name, for example "lightning_v3.1_pro"
VoiceIDstringNoVoice identifier, for example "hazel"
SampleRate*intNoOutput audio sample rate in Hz
Speed*float64NoSpeech rate multiplier
LanguagestringNoLanguage code for speech synthesis
NumberPronunciationLanguagestringNoLanguage code used when reading numbers aloud
MathNotation*boolNoRead mathematical notation as spoken mathematics
PronunciationDicts[]stringNoPronunciation dictionaries to apply
SessionIDstringNoCaller-supplied session identifier
RequestIDstringNoCaller-supplied request identifier
SkipPatterns[]intNoPatterns to skip
AdditionalParamsmap[string]interface{}NoAdditional Smallest AI parameters

Voice identifiers are model-specific, so VoiceID must belong to the model set in Model. For details, see Smallest AI.

STT vendors

Use with WithStt().

NewDeepgramSTT

func NewDeepgramSTT(opts DeepgramSTTOptions) *DeepgramSTT

Panics if APIKey is empty unless Model is one of the supported Agora-managed Deepgram models (nova-2, nova-3).

FieldTypeRequiredDescription
APIKeystringBYOK onlyDeepgram API key. Optional only for Agora-managed nova-2 and nova-3.
ModelstringNoModel, for example "nova-2"
LanguagestringNoLanguage code, for example "en-US"
KeytermstringNoKey term to boost recognition (serialized as keyterm)
SmartFormat*boolNoEnable smart formatting
Punctuation*boolNoEnable punctuation
AdditionalParamsmap[string]interface{}NoAdditional vendor parameters

NewSpeechmaticsSTT

func NewSpeechmaticsSTT(opts SpeechmaticsSTTOptions) *SpeechmaticsSTT

Panics if Key or Language is empty.

FieldTypeRequiredDescription
KeystringYesSpeechmatics API key. APIKey is a deprecated alias
LanguagestringYesLanguage code
URIstringNoSpeechmatics streaming WebSocket URL
AdditionalParamsmap[string]interface{}NoAdditional vendor params
ModelstringNoModel identifier

NewMicrosoftSTT

func NewMicrosoftSTT(opts MicrosoftSTTOptions) *MicrosoftSTT

Panics if Key, Region, or Language is empty.

FieldTypeRequiredDescription
KeystringYesAzure Speech Services key
RegionstringYesAzure region
LanguagestringYesLanguage code
AdditionalParamsmap[string]interface{}NoAdditional vendor params

NewOpenAISTT

func NewOpenAISTT(opts OpenAISTTOptions) *OpenAISTT

Panics if APIKey is empty. WithStt() also panics if the transcription prompt or language isn't set through the Prompt and Language fields or within InputAudioTranscription. model defaults to gpt-4o-mini-transcribe.

FieldTypeRequiredDescription
APIKeystringYesOpenAI API key
ModelstringNoTranscription model. Defaults to gpt-4o-mini-transcribe.
LanguagestringNoLanguage code
PromptstringNoPrompt for OpenAI transcription
InputAudioTranscriptionmap[string]interface{}NoOpenAI transcription settings
AdditionalParamsmap[string]interface{}NoAdditional vendor params

NewGoogleSTT

func NewGoogleSTT(opts GoogleSTTOptions) *GoogleSTT

Panics if ProjectID, Location, ADCCredentialsString, or Language is empty.

FieldTypeRequiredDescription
ProjectIDstringYesGoogle Cloud project ID
LocationstringYesGoogle Cloud region
ADCCredentialsStringstringYesGoogle service account credentials JSON string
LanguagestringYesGoogle recognition language
ModelstringNoModel identifier
AdditionalParamsmap[string]interface{}NoAdditional vendor params

NewAmazonSTT

func NewAmazonSTT(opts AmazonSTTOptions) *AmazonSTT

Panics if AccessKey, SecretKey, Region, or Language is empty.

FieldTypeRequiredDescription
AccessKeystringYesAWS access key
SecretKeystringYesAWS secret key
RegionstringYesAWS region
LanguagestringYesLanguage code
AdditionalParamsmap[string]interface{}NoAdditional vendor params

NewAssemblyAISTT

func NewAssemblyAISTT(opts AssemblyAISTTOptions) *AssemblyAISTT

Panics if APIKey or Language is empty.

FieldTypeRequiredDescription
APIKeystringYesAssemblyAI API key
LanguagestringYesAssemblyAI language code
WsURLstringNoAssemblyAI streaming WebSocket URL, serialized as ws_url
AdditionalParamsmap[string]interface{}NoAdditional vendor params

NewGeminiSTT

func NewGeminiSTT(opts GeminiSTTOptions) *GeminiSTT

Panics if APIKey is empty, if Mode is set to a value other than SMART or VERBATIM, if CustomVocabulary is combined with WordTimestamp, or if SMART mode is combined with WordTimestamp or Diarization.

FieldTypeRequiredDescription
APIKeystringYesGoogle AI API key
ModelstringNoTranscription model
LanguagestringNoRecognition language
LanguageHints[]stringNoCandidate transcription languages. LanguageCodes is a deprecated alias
CustomVocabulary[]stringNoWords and phrases to bias recognition toward
SampleRateintNoAudio sample rate in Hz. Defaults to 16000
WordTimestamp*boolNoEnable word-level timestamps
ModeGeminiTranscriptionModeNoTranscript formatting mode: SMART or VERBATIM. Service default: VERBATIM
Diarization*boolNoEnable speaker labels
AdditionalParamsmap[string]interface{}NoAdditional vendor params

NewXaiSTT

func NewXaiSTT(opts XaiSTTOptions) *XaiSTT

Panics if APIKey is empty.

FieldTypeRequiredDescription
APIKeystringYesxAI API key
BaseURLstringNoAPI endpoint URL
LanguagestringNoLanguage code
SampleRate*SampleRateNoAudio sample rate
AdditionalParamsmap[string]interface{}NoAdditional vendor params

NewAresSTT

func NewAresSTT(options ...AresSTTOptions) *AresSTT

Agora-managed global ASR provider. options is variadic so callers can select Ares without configuring keyword hints; panics if more than one options value is passed.

FieldTypeRequiredDescription
Keywords[]stringNoKeywords that improve ASR accuracy
AdditionalParamsmap[string]interface{}NoAdditional vendor params

NewSarvamSTT

func NewSarvamSTT(opts SarvamSTTOptions) *SarvamSTT

Panics if APIKey or Language is empty.

FieldTypeRequiredDescription
APIKeystringYesSarvam API key
LanguagestringYesLanguage code
ModelstringNoModel identifier
AdditionalParamsmap[string]interface{}NoAdditional vendor params

NewSmallestAISTT

func NewSmallestAISTT(opts SmallestAISTTOptions) *SmallestAISTT

Panics if APIKey is empty.

FieldTypeRequiredDescription
APIKeystringYesSmallest AI API key
URLstringNoStreaming ASR WebSocket endpoint
LanguagestringNoLanguage code for speech recognition
SampleRate*intNoInput audio sample rate in Hz
EncodingstringNoInput audio encoding, for example "linear16"
WordTimestampsboolNoInclude word-level timestamps
SentenceTimestampsboolNoInclude sentence-level timestamps
DiarizeboolNoEnable speaker diarization
VADEventsboolNoEmit voice activity detection events
EndpointingboolNoEnable automatic end-of-utterance detection
EOUTimeoutMs*intNoEnd-of-utterance timeout in milliseconds
FormatboolNoEnable Smallest AI's transcript formatting
FinalizeOnWordsboolNoFinalize results based on word count
MaxWordsstringNoMaximum words per result, as a string
PunctuateboolNoAdd punctuation to results
CapitalizeboolNoApply capitalization to results
ITNNormalizeboolNoApply inverse text normalization
FullTranscriptboolNoReturn the full accumulated transcript
KeywordsstringNoKeyword boosts, comma-separated in keyword:weight format
RedactPIIboolNoRedact personally identifiable information
RedactPCIboolNoRedact payment card information
AdditionalParamsmap[string]interface{}NoAdditional Smallest AI parameters

Boolean options are serialized as the strings "true" or "false" for the Smallest AI wire protocol. Unlike the other SDKs, these fields are plain bool rather than pointers, so every one of them is sent on each request. For details, see Smallest AI.

MLLM vendors

Use with WithMllm() for multimodal end-to-end audio processing without separate STT, LLM, or TTS steps. WithMllm() automatically sets mllm.enable = true; you do not need to set the deprecated AdvancedFeatures.EnableMllm flag.

NewOpenAIRealtime

func NewOpenAIRealtime(opts OpenAIRealtimeOptions) *OpenAIRealtime

Panics if APIKey is empty.

FieldTypeRequiredDefaultDescription
APIKeystringYes—OpenAI API key
ModelstringNo"gpt-4o-realtime-preview"Model identifier
VoicestringNo—Voice name
InstructionsstringNo—System instructions
InputAudioTranscriptionmap[string]interface{}No—Input audio transcription settings
URLstringNo—Custom WebSocket URL
GreetingMessagestringNo—Agent greeting message
FailureMessagestringNo—Message played when the model call fails
InputModalities[]stringNo—Input modalities
OutputModalities[]stringNo—Output modalities
Messages[]map[string]interface{}No—Conversation messages for short-term memory
Paramsmap[string]interface{}No—Additional parameters
TurnDetection*Agora.MllmTurnDetectionNo—MLLM turn detection configuration; overrides top-level turn detection

NewAzureOpenAIRealtime

func NewAzureOpenAIRealtime(opts AzureOpenAIRealtimeOptions) *AzureOpenAIRealtime

Panics if APIKey, URL, or TurnDetection is empty.

FieldTypeRequiredDefaultDescription
APIKeystringYes—Azure OpenAI API key
URLstringYes—Azure OpenAI Realtime WebSocket URL
TurnDetection*Agora.MllmTurnDetectionYes—MLLM turn detection configuration; overrides top-level turn detection
ModelstringNo—Azure OpenAI Realtime model or deployment name
VoicestringNo—Voice identifier
InstructionsstringNo—System instructions
MaxHistory*intNo—Number of conversation history messages to cache
GreetingMessagestringNo—Agent greeting message
OutputModalities[]stringNo—Output modalities
Messages[]map[string]interface{}No—Conversation messages for short-term memory

NewGeminiLive

func NewGeminiLive(opts GeminiLiveOptions) *GeminiLive

Panics if APIKey or Model is empty.

FieldTypeRequiredDefaultDescription
APIKeystringYes—Google AI API key
ModelstringYes—Gemini Live model identifier
ThinkingLevelstringNo—Reasoning budget ("low", "medium", or "high"), supported only by "models/gemini-3.8-live-extended-thinking"
URLstringNo—Custom WebSocket URL
InstructionsstringNo—System instruction
VoicestringNo—Voice name
AffectiveDialog*boolNo—Enable affective (emotion-aware) dialog
ProactiveAudio*boolNo—Enable proactive audio
TranscribeAgent*boolNo—Enable transcription of agent audio
TranscribeUser*boolNo—Enable transcription of user audio
HttpOptionsmap[string]interface{}No—Custom HTTP client options
GreetingMessagestringNo—Agent greeting message
FailureMessagestringNo—Message played when the model call fails
InputModalities[]stringNo—Input modalities
OutputModalities[]stringNo—Output modalities
Messages[]map[string]interface{}No—Conversation messages for short-term memory
AdditionalParamsmap[string]interface{}No—Additional parameters
TurnDetection*Agora.MllmTurnDetectionNo—MLLM turn detection configuration; overrides top-level turn detection

NewVertexAI

func NewVertexAI(opts VertexAIOptions) *VertexAI

Panics if ProjectID or ADCredentialsString is empty.

FieldTypeRequiredDefaultDescription
ProjectIDstringYes—Google Cloud project ID
ADCredentialsStringstringYes—Application Default Credentials JSON string
LocationstringNo"us-central1"Google Cloud region
ModelstringNo"gemini-2.0-flash-exp"Model identifier
URLstringNo—Custom WebSocket URL
VoicestringNo—Voice name
InstructionsstringNo—System instruction
AffectiveDialog*boolNo—Enable affective (emotion-aware) dialog
ProactiveAudio*boolNo—Enable proactive audio
TranscribeAgent*boolNo—Enable transcription of agent audio
TranscribeUser*boolNo—Enable transcription of user audio
HttpOptionsmap[string]interface{}No—Custom HTTP client options
GreetingMessagestringNo—Agent greeting message
FailureMessagestringNo—Message played when the model call fails
InputModalities[]stringNo—Input modalities
OutputModalities[]stringNo—Output modalities
Messages[]map[string]interface{}No—Conversation messages for short-term memory
AdditionalParamsmap[string]interface{}No—Additional parameters
TurnDetection*Agora.MllmTurnDetectionNo—MLLM turn detection configuration; overrides top-level turn detection

NewXaiGrok

func NewXaiGrok(opts XaiGrokOptions) *XaiGrok

xAI Grok MLLM vendor (mllm.vendor: "xai"). Panics if APIKey is empty. Defaults URL to wss://api.x.ai/v1/realtime.

NewXAIGrok / XAIGrokOptions are deprecated aliases.

XaiGrokOptions

Same fields as XAIGrokOptions below.

NewXAIGrok (deprecated)

func NewXAIGrok(opts XAIGrokOptions) *XAIGrok

Deprecated. Use NewXaiGrok instead.

XAIGrokOptions
FieldTypeRequiredDefaultDescription
APIKeystringYes—xAI API key
URLstringNo"wss://api.x.ai/v1/realtime"xAI Realtime WebSocket URL
VoicestringNo—Voice identifier
LanguagestringNo—Language code
SampleRate*intNo—Audio sample rate in Hz
GreetingMessagestringNo—Agent greeting message
FailureMessagestringNo—Message played when the model call fails
InputModalities[]stringNo—Input modalities
OutputModalities[]stringNo—Output modalities
Messages[]map[string]interface{}No—Conversation messages for short-term memory
Paramsmap[string]interface{}No—Additional xAI parameters
TurnDetection*Agora.MllmTurnDetectionNo—agora_vad / server_vad turn detection

NewOpenAIGPTLive

func NewOpenAIGPTLive(opts OpenAIGPTLiveOptions) *OpenAIGPTLive

OpenAI GPT-Live MLLM vendor (mllm.vendor: "openai_gpt_live"). Panics if APIKey is empty. WithMllm() also panics if URL isn't a full ws:// or wss:// endpoint, Headers isn't a JSON object string, Delegation isn't client or responses, or SessionParams overrides a protected field.

Early access

OpenAI GPT-Live is available in early access and isn't intended for production traffic. The SDK automatically routes sessions that use this vendor to the preview endpoint. GPT-Live doesn't support turn detection or input audio transcription.

mllm := vendors.NewOpenAIGPTLive(vendors.OpenAIGPTLiveOptions{
    APIKey:          "your-openai-key",
    GreetingMessage: "Hello! I'm GPT-live. How can I help you today?",
    Model:           "gpt-live-1",
    Voice:           "marin",
    Prompt:          "your-system-prompt",
})
OpenAIGPTLiveOptions
FieldTypeRequiredDefaultDescription
APIKeystringYes—OpenAI API key
ModelstringNo"gpt-live-1"Model name
VoicestringNo—Output voice. Provider default: marin
PromptstringNo—Session instructions that define the assistant's behavior
GreetingMessagestringNo—Greeting the agent speaks when a user joins. Serialized as greeting_message
FailureMessagestringNo—Message played when the model call fails
URLstringNo"wss://api.openai.com/v1/live/sessions"Full ws:// or wss:// endpoint
BaseURLstringNo"wss://api.openai.com"Host used when URL isn't set
PathstringNo"/v1/live/sessions"WebSocket path used when URL isn't set
InputModalities[]stringNo—Input modalities
OutputModalities[]stringNo—Output modalities
Messages[]map[string]interface{}No—Conversation history passed to the model as context
McpServers[]map[string]interface{}No—MCP servers whose tools GPT-Live can call. Requires WithTools(true)
ToolEnabled*boolNo—Advertise the agent's tools to GPT-Live. Provider default: false
DelegationstringNo—Tool delegation mode: client or responses. Provider default: responses. Can't be changed during the session
ResponsesModelstringNo—Model used for delegated tool calls
InterruptOnUserTurn*boolNo—Interrupt playback when the user speaks. Provider default: false
OutputIdleEndMs*intNo—Agent silence boundary in milliseconds. Provider default: 600. 0 disables inference
InputIdleEndMs*intNo—User silence boundary in milliseconds. Provider default: 1500
OutputSilencePeak*intNo—Speech amplitude threshold on the 16-bit scale. Provider default: 50
OutputSampleRate*intNo—Output PCM sample rate in Hz. Provider default: 24000
OutputBufferMs*intNo—Initial audio cushion in milliseconds. Provider default: 0. A negative value disables pacing
InputBatchMs*intNo—Microphone audio batching interval in milliseconds
AlphaSelectorstringNo—OpenAI-Alpha selector for preview contracts. Omitted when not set
HeadersstringNo—Extra provider request headers, as a JSON object string
SessionParamsmap[string]interface{}No—Additional session fields. Can't override model, delegation, audio, instructions, or input
Paramsmap[string]interface{}No—Additional provider parameters. Explicit options take precedence
InstructionsstringNo—Deprecated. Use Prompt instead

InputAudioTranscription and TurnDetection are deprecated. GPT-Live doesn't support them: setting InputAudioTranscription panics, and the SDK ignores TurnDetection and logs a warning.

Avatar vendors

Use with WithAvatar(). Some avatar vendors require a specific TTS sample rate. To learn when a mismatch panics or returns an error, see WithAvatar().

NewLiveAvatarAvatar

Requires TTS at 24,000 Hz (SampleRate24kHz).

func NewLiveAvatarAvatar(opts LiveAvatarAvatarOptions) *LiveAvatarAvatar

Panics if APIKey or AgoraUID is empty, or if Quality is not "low", "medium", or "high".

FieldTypeRequiredDescription
APIKeystringYesLiveAvatar API key
QualitystringYesVideo quality: "low", "medium", or "high"
AgoraUIDstringYesUID for the avatar's video stream
AgoraTokenstringNoRTC token for avatar authentication
AvatarIDstringNoLiveAvatar avatar ID
Enable*boolNoEnable or disable the avatar. Default: true
DisableIdleTimeout*boolNoDisable the idle timeout
ActivityIdleTimeout*intNoIdle timeout in seconds
AdditionalParamsmap[string]interface{}NoAdditional vendor params

NewAkoolAvatar

Requires TTS at 16,000 Hz (SampleRate16kHz).

func NewAkoolAvatar(opts AkoolAvatarOptions) *AkoolAvatar

Panics if APIKey is empty.

FieldTypeRequiredDescription
APIKeystringYesAkool API key
AvatarIDstringNoAvatar ID
Enable*boolNoEnable or disable the avatar
AdditionalParamsmap[string]interface{}NoAdditional vendor parameters

NewAnamAvatar

Anam avatars do not enforce a fixed TTS sample rate.

func NewAnamAvatar(opts AnamAvatarOptions) *AnamAvatar

Panics if APIKey is empty.

FieldTypeRequiredDescription
APIKeystringYesAnam API key
AvatarIDstringNoAnam avatar identifier (serialized as avatar_id)
Enable*boolNoEnable or disable the avatar
AdditionalParamsmap[string]interface{}NoAdditional vendor params

NewGenericAvatar

func NewGenericAvatar(opts GenericAvatarOptions) *GenericAvatar

Panics if APIKey, APIBaseURL, AvatarID, or AgoraUID is empty. AgoraAppID, AgoraChannel, and AgoraToken are optional; AgentKit fills them from the session on Start() when omitted.

Generic avatars do not enforce a fixed TTS sample rate. Use the sample rate required by your avatar provider.

FieldTypeRequiredDescription
APIKeystringYesGeneric avatar vendor API key
APIBaseURLstringYesGeneric avatar API endpoint
AvatarIDstringYesAvatar identifier
AgoraUIDstringYesUID for avatar video stream; use a different UID from AgentUID
AgoraTokenstringNoAvatar token; auto-generated with the same token format as agent tokens when omitted
AgoraAppIDstringNoOverrides session App ID
AgoraChannelstringNoOverrides session channel
Enable*boolNoEnable or disable the avatar
AdditionalParamsmap[string]interface{}NoAdditional vendor params

NewTavus

func NewTavus(opts TavusOptions) *Tavus

Panics if APIKey, APIBaseURL, AvatarID, or AgoraUID is empty. AgoraAppID, AgoraChannel, and AgoraToken are optional; AgentKit fills them from the session on Start() when omitted. Serializes vendor: "generic". For the endpoint and a full example, see Tavus.

Tavus avatars do not enforce a fixed TTS sample rate.

FieldTypeRequiredDescription
APIKeystringYesTavus API key
APIBaseURLstringYesTavus API endpoint
AvatarIDstringYesTavus avatar identifier
AgoraUIDstringYesUID for avatar video stream; use a different UID from AgentUID
AgoraTokenstringNoAvatar token; auto-generated with the same token format as agent tokens when omitted
AgoraAppIDstringNoOverrides session App ID
AgoraChannelstringNoOverrides session channel
Enable*boolNoEnable or disable the avatar
AdditionalParamsmap[string]interface{}NoAdditional vendor params

NewProtoface

func NewProtoface(opts ProtofaceOptions) *Protoface

Panics if APIKey, APIBaseURL, AvatarID, or AgoraUID is empty. AgoraAppID, AgoraChannel, and AgoraToken are optional; AgentKit fills them from the session on Start() when omitted. Serializes vendor: "generic". For the endpoint and a full example, see Protoface.

Protoface avatars do not enforce a fixed TTS sample rate.

FieldTypeRequiredDescription
APIKeystringYesProtoface API key
APIBaseURLstringYesProtoface API endpoint
AvatarIDstringYesProtoface avatar identifier
AgoraUIDstringYesUID for avatar video stream; use a different UID from AgentUID
AgoraTokenstringNoAvatar token; auto-generated with the same token format as agent tokens when omitted
AgoraAppIDstringNoOverrides session App ID
AgoraChannelstringNoOverrides session channel
Enable*boolNoEnable or disable the avatar
AdditionalParamsmap[string]interface{}NoAdditional vendor params

NewLemonSlice

func NewLemonSlice(opts LemonSliceOptions) *LemonSlice

Panics if APIKey, APIBaseURL, AvatarID, or AgoraUID is empty. AgoraAppID, AgoraChannel, and AgoraToken are optional; AgentKit fills them from the session on Start() when omitted. Serializes vendor: "generic". For the endpoint and a full example, see LemonSlice.

LemonSlice avatars do not enforce a fixed TTS sample rate.

FieldTypeRequiredDescription
APIKeystringYesLemonSlice API key
APIBaseURLstringYesLemonSlice API endpoint
AvatarIDstringYesAlways lemonslice
AgoraUIDstringYesUID for avatar video stream; use a different UID from AgentUID
AgoraTokenstringNoAvatar token; auto-generated with the same token format as agent tokens when omitted
AgoraAppIDstringNoOverrides session App ID
AgoraChannelstringNoOverrides session channel
Enable*boolNoEnable or disable the avatar
AdditionalParamsmap[string]interface{}NoAdditional vendor params

NewHeyGenAvatar (deprecated)

Requires TTS at 24,000 Hz (SampleRate24kHz).

func NewHeyGenAvatar(opts HeyGenAvatarOptions) *HeyGenAvatar

NewHeyGenAvatar and HeyGenAvatarOptions are deprecated. Use NewLiveAvatarAvatar instead. HeyGenAvatarOptions is an alias of LiveAvatarAvatarOptions and the fields are identical; the emitted vendor remains "heygen".

Panics if APIKey or AgoraUID is empty, or if Quality is not "low", "medium", or "high".

Token utilities

Helper functions for generating and managing tokens.

import "github.com/AgoraIO/agora-agents-go/v2/agentkit"
func GenerateRtcToken(opts GenerateTokenOptions) (string, error)
func GenerateRtcTokenWithAccount(opts GenerateRtcTokenWithAccountOptions) (string, error)
func GenerateConvoAIToken(opts GenerateConvoAITokenOptions) (string, error)

GenerateConvoAIToken()

Generates a combined RTC+RTM Conversational AI token. This is the same token the SDK generates automatically when the session has an App ID and App Certificate.

func GenerateConvoAIToken(opts GenerateConvoAITokenOptions) (string, error)
FieldTypeRequiredDescription
AppIDstringYesAgora App ID
AppCertificatestringYesAgora App Certificate
ChannelNamestringYesThe channel the token grants access to
UIDintYesNumeric UID this token is issued for
TokenExpireintNoToken lifetime in seconds. Default: 86400. Valid range: 1–86400
PrivilegeExpireintNoPrivilege lifetime in seconds. 0 means the same as TokenExpire
token, err := agentkit.GenerateConvoAIToken(agentkit.GenerateConvoAITokenOptions{
    AppID:          os.Getenv("AGORA_APP_ID"),
    AppCertificate: os.Getenv("AGORA_APP_CERT"),
    ChannelName:    "support-room-123",
    UID:            1,
    TokenExpire:    12 * 3600,
})

GenerateRtcTokenWithAccount()

Generates an RTC token for a string account (user ID). Use GenerateConvoAIToken() instead for most Conversational AI use cases.

func GenerateRtcTokenWithAccount(opts GenerateRtcTokenWithAccountOptions) (string, error)
FieldTypeRequiredDescription
AppIDstringYesAgora App ID
AppCertificatestringYesAgora App Certificate
ChannelstringYesChannel name
AccountstringYesString user account
RoleintNoRTC role: RolePublisher (1) or RoleSubscriber (2). Default: RolePublisher
ExpirySecondsintNoToken lifetime in seconds. Default: DefaultExpirySeconds (86400)

GenerateRtcToken()

Generates an RTC-only token. Use GenerateConvoAIToken() instead for most Conversational AI use cases.

func GenerateRtcToken(opts GenerateTokenOptions) (string, error)
FieldTypeRequiredDescription
AppIDstringYesAgora App ID
AppCertificatestringYesAgora App Certificate
ChannelstringYesChannel name
UIDuint32YesUser ID. Use 0 for any user
RoleintNoRTC role: RolePublisher (1) or RoleSubscriber (2). Default: RolePublisher
ExpirySecondsintNoToken lifetime in seconds. Default: DefaultExpirySeconds (86400)

ExpiresInHours() / ExpiresInMinutes()

Helper functions for specifying token lifetimes. Use with CreateSessionOptions.ExpiresIn, AgentSessionOptions.ExpiresIn, or token generation functions. Returns an error if the value is ≤ 0; warns and caps at 86400 if the result exceeds 24 hours.

func ExpiresInHours(hours float64) (int, error)
func ExpiresInMinutes(minutes float64) (int, error)
expiresIn, err := agentkit.ExpiresInHours(12)
if err != nil {
    log.Fatalf("Invalid expiry: %v", err)
}

session := agent.CreateSession(agentkit.CreateSessionOptions{
    // ...
    ExpiresIn: expiresIn,
})

Types and constants

Shared types, constants, and enums used across the SDK.

AgentSessionLifecycle

Typed string constants representing the session lifecycle states. Read with session.Status().

type AgentSessionLifecycle string

const (
    AgentSessionLifecycleIdle     AgentSessionLifecycle = "idle"
    AgentSessionLifecycleStarting AgentSessionLifecycle = "starting"
    AgentSessionLifecycleRunning  AgentSessionLifecycle = "running"
    AgentSessionLifecycleStopping AgentSessionLifecycle = "stopping"
    AgentSessionLifecycleStopped  AgentSessionLifecycle = "stopped"
    AgentSessionLifecycleError    AgentSessionLifecycle = "error"
)

StatusIdle, StatusStarting, StatusRunning, StatusStopping, StatusStopped, and StatusError are deprecated aliases of these constants. agentkit.SessionStatus is a different type: the agent status returned by the REST API endpoint that lists agents.

SampleRate

Typed integer constants for audio sample rates, defined in the vendors package (vendors.SampleRate). Use with TTS vendor SampleRate fields and avatar sample rate validation.

type SampleRate int

const (
    SampleRate8kHz  SampleRate = 8000
    SampleRate16kHz SampleRate = 16000
    SampleRate22kHz SampleRate = 22050
    SampleRate24kHz SampleRate = 24000
    SampleRate44kHz SampleRate = 44100
    SampleRate48kHz SampleRate = 48000
)

Convenience constants for avatar sample rate requirements:

const (
    LiveAvatarRequiredSampleRate = SampleRate24kHz
    AkoolRequiredSampleRate  = SampleRate16kHz  // 16000 Hz
)

EventHandler

The function signature for session event handlers. Pass implementations to session.On().

type EventHandler func(data interface{})
Eventdata typeCast example
"started"map[string]stringdata.(map[string]string)["agent_id"]
"stopped"map[string]stringdata.(map[string]string)["agent_id"]
"error"errordata.(error)

Area constants

Used with option.WithArea() to select the regional API endpoint.

option.AreaUS      // United States (west + east)
option.AreaEU      // Europe (west + central)
option.AreaAP      // Asia-Pacific (southeast + northeast)
option.AreaCN      // Chinese Mainland (east + north)
option.AreaUnknown // Zero value; not a valid region

Passing option.AreaUnknown to WithArea, or not setting Area in NewAgoraClient, causes a panic.

Type aliases

The agentkit package defines type aliases for common Fern-generated types. Use these in place of the full Agora.* names when building configuration objects.

TurnDetectionConfig isn't an alias. It's an AgentKit struct that mirrors Agora.StartAgentsRequestPropertiesTurnDetection and adds a Language field.

AliasUnderlying type
SalConfigAgora.StartAgentsRequestPropertiesSal
AdvancedFeaturesAgora.StartAgentsRequestPropertiesAdvancedFeatures
SessionParamsAgora.StartAgentsRequestPropertiesParameters
GeofenceConfigAgora.StartAgentsRequestPropertiesGeofence
RtcConfigAgora.StartAgentsRequestPropertiesRtc
FillerWordsConfigAgora.StartAgentsRequestPropertiesFillerWords
FillerWordsContentModeAgora.StartAgentsRequestPropertiesFillerWordsContentMode
FillerWordsContentGeneratedConfigAgora.StartAgentsRequestPropertiesFillerWordsContentGeneratedConfig
LlmToolAgora.LlmTool
LlmToolFunctionAgora.LlmToolFunction
LlmToolFunctionParametersAgora.LlmToolFunctionParameters
LlmToolExecutionAgora.LlmToolExecution
LlmToolServerAgora.LlmToolServer
LlmConfigAgora.Llm
MllmConfigAgora.Mllm
AsrConfigAgora.Asr
TtsConfigAgora.Tts
AvatarConfigAgora.StartAgentsRequestPropertiesAvatar
SttConfigAsrConfig
LlmStyleAgora.LlmStyle
SessionInfoAgora.GetAgentsResponse
ThinkResponseAgora.AgentThinkAgentManagementResponse

Additional SOS/EOS turn detection aliases: TurnDetectionNestedConfig, StartOfSpeechConfig, EndOfSpeechConfig, and related sub-types. Session/conversation aliases: SessionListResponse, ConversationHistory, ConversationTurns, etc. Think type aliases: ThinkOnListeningAction, ThinkOnThinkingAction, ThinkOnSpeakingAction.

FillerWordsConfig supports static and generated filler words. Generated mode requires static fallback phrases, while GeneratedConfig and Prompt are optional. Agora hosts the generation service, so you can't configure its model endpoint, API key, or model parameters. For the field structure, see Configure generated filler words.

FillerWordsContentGeneratedConfig sets the conversation context for generated filler words. Use ContextMessageLimit (*int, 1 to 6, defaults to 1) to set how many of the most recent conversation messages to use, counting the current turn's message, and HistoryCharacterLimit (*int, 0 to 10000, defaults to 1000) to cap the combined characters of the earlier messages. For details, see Talking while waiting.

core.APIError

The Fern-generated error type returned when the API responds with a 4xx or 5xx status code. Use errors.As to inspect the error. apiError.Error() returns "<status>: <body>", and apiError.Unwrap() returns the wrapped error containing the response body.

import "github.com/AgoraIO/agora-agents-go/v2/core"

_, err := session.Start(ctx)
if err != nil {
    var apiError *core.APIError
    if errors.As(err, &apiError) {
        log.Printf("Status: %d", apiError.StatusCode)
        log.Printf("Body: %v", apiError.Unwrap())
    }
    return err
}
FieldTypeDescription
StatusCodeintHTTP status code returned by the API
Headerhttp.HeaderResponse headers from the API