Skip to main content

Go SDK API reference

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.


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

Constructor


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

Creates a new API client. All sub-clients share the same configuration.


_10
import (
_10
"github.com/AgoraIO/agora-agents-go/v2/agentkit"
_10
"github.com/AgoraIO/agora-agents-go/v2/option"
_10
)
_10
_10
c := agentkit.NewAgoraClient(agentkit.AgoraClientOptions{
_10
Area: option.AreaUS,
_10
AppID: "your-app-id",
_10
AppCertificate: "your-app-certificate",
_10
})

Request options

Request options configure transport, retries, and advanced authentication behavior. For new session integrations, prefer agentkit.NewAgoraClient with AppID and AppCertificate; AgentKit mints ConvoAI REST auth and RTC join tokens when session methods run.

option.WithArea


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

Enables regional routing with automatic DNS-based domain selection.


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

option.WithBaseURL


_1
func WithBaseURL(baseURL string) *core.BaseURLOption

Overrides the default API endpoint. Useful for testing.


_5
import Agora "github.com/AgoraIO/agora-agents-go/v2"
_5
_5
c := client.NewClient(
_5
option.WithBaseURL(Agora.Environments.Default),
_5
)

option.WithHTTPClient


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

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


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

option.WithMaxAttempts


_1
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.


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

option.WithHTTPHeader


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

Adds custom HTTP headers to every request.

option.WithBodyProperties


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

Adds extra properties to the JSON request body.

option.WithQueryParameters


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

Adds query parameters to the request URL.

option.WithPool


_1
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, 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:


_4
import Agora "github.com/AgoraIO/agora-agents-go/v2"
_4
_4
Agora.Environments.Default
_4
// "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".


_1
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.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.


_4
import (
_4
"github.com/AgoraIO-Conversational-AI/agent-server-sdk-go/agentkit"
_4
"github.com/AgoraIO-Conversational-AI/agent-server-sdk-go/agentkit/vendors"
_4
)

Constructor


_1
func NewAgent(opts ...AgentOption) *Agent

Pass AgentOption functions to configure the agent's name, instructions, greeting, and other properties.


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

AgentOption functions

AgentOption functions are passed to NewAgent. Each function has the signature func(*Agent).

FunctionParameter typeDescription
WithName(name)stringAgent name identifier
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 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

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, or NewGemini.


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

WithTts(vendor)

Sets the TTS vendor. Captures the vendor's sample rate for avatar validation.


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

WithStt(vendor)

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


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

WithMllm(vendor)

Sets the MLLM vendor for multimodal mode. Pass NewOpenAIRealtime, NewGeminiLive, or NewVertexAI. Requires AdvancedFeatures.EnableMllm = true.


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

WithAvatar(vendor)

Sets the avatar vendor. Panics if TTS is already configured with a sample rate that does not match the avatar's required rate.


_1
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.


_1
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
WithName(name)stringOverride the agent name
WithSal(sal)*SalConfigSet SAL configuration
WithAdvancedFeatures(af)*AdvancedFeaturesSet advanced features
WithTools(enabled)boolEnable or disable MCP 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.


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

Returns an error if:

  • Neither Token nor AppID + AppCertificate is provided
  • In cascading mode: LLM or TTS is not configured
  • Config marshaling fails

ToPropertiesOptions


_13
type ToPropertiesOptions struct {
_13
Channel string
_13
AgentUID string
_13
RemoteUIDs []string
_13
Token string
_13
AppID string
_13
AppCertificate string
_13
ExpiresIn int
_13
IdleTimeout *int
_13
EnableStringUID *bool
_13
SkipVendorValidation bool
_13
Warn func(string)
_13
}

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
Warnfunc(string)NoWarning sink for recoverable config issues

Getters

Getters

Read-only methods available on any *Agent instance.

MethodReturn typeDescription
Name()stringAgent name
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

agentkit.NewAgentSession

AgentSession manages the full lifecycle of a running agent. Create a session with NewAgentSession and call Start() to join the agent to the channel.


_1
import "github.com/AgoraIO-Conversational-AI/agent-server-sdk-go/agentkit"

Constructor


_1
func NewAgentSession(opts AgentSessionOptions) *AgentSession

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

AgentSessionOptions


_19
type AgentSessionOptions struct {
_19
Client *agents.Client
_19
Agent *Agent
_19
AppID string
_19
AppCertificate string
_19
Name string
_19
Channel string
_19
Token string
_19
AgentUID string
_19
RemoteUIDs []string
_19
IdleTimeout *int
_19
EnableStringUID *bool
_19
ExpiresIn int
_19
UseAppCredentialsForREST bool
_19
Preset []string
_19
PipelineID string
_19
Debug bool
_19
Warn func(string)
_19
}

FieldTypeRequiredDescription
Client*agents.ClientYesFern-generated agents sub-client (from c.Agents)
Agent*AgentYesAgent configuration built with NewAgent
AppIDstringYesAgora App ID
AppCertificatestringConditionalRequired if Token is not set
NamestringNoSession name. Default: agent-<unix_timestamp>
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. Leave unset 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 unset, AgentSession.Start() uses the agent-level value from WithPipelineID.

State machine

A session progresses through the following states:


_16
Start() API success
_16
┌──────┐ ┌──────────┐ ┌─────────┐
_16
│ idle │─────>│ starting │─────>│ running │
_16
└──┬───┘ └────┬─────┘ └────┬────┘
_16
│ │ │
_16
│ │ error │ Stop()
_16
│ ▼ ▼
_16
│ ┌─────────┐ ┌──────────┐
_16
│ │ error │ │ stopping │
_16
│ └────┬────┘ └────┬─────┘
_16
│ │ │
_16
│ │ │ success
_16
│ ▼ ▼
_16
│ ┌──────────┐ ┌─────────┐
_16
└─────────>│ (restart)│ │ stopped │
_16
└──────────┘ └─────────┘

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
running → errorUnrecoverable error during interaction

Start() can also be called from stopped or error state to restart the session.

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.


_1
func (s *AgentSession) Start(ctx context.Context) (string, error)

  • Valid from: idle, stopped, error
  • Transitions to: startingrunning 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

_4
agentID, err := session.Start(ctx)
_4
if err != nil {
_4
log.Fatalf("Failed to start session: %v", err)
_4
}

Stop(ctx)

Stops the running agent and removes it from the channel.


_1
func (s *AgentSession) Stop(ctx context.Context) error

  • Valid from: running
  • Transitions to: stoppingstopped on success, error on failure
  • Emits: "stopped" on success, "error" on failure

_4
err := session.Stop(ctx)
_4
if err != nil {
_4
log.Fatalf("Failed to stop session: %v", err)
_4
}

Say(ctx, text, priority, interruptable)

Instructs the agent to speak the given text.


_1
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

_1
err := session.Say(ctx, "One moment while I look that up.", nil, nil)

Interrupt(ctx)

Interrupts the agent's current speech.


_1
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.


_1
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.


_1
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.


_11
func (s *AgentSession) GetTurns(ctx context.Context, opts ...GetTurnsOptions) (*Agora.GetTurnsAgentsResponse, error)
_11
func (s *AgentSession) GetAllTurns(ctx context.Context, opts ...GetAllTurnsOptions) (*Agora.GetTurnsAgentsResponse, error)
_11
_11
type GetTurnsOptions struct {
_11
PageIndex *int
_11
PageSize *int
_11
}
_11
_11
type GetAllTurnsOptions struct {
_11
PageSize *int
_11
}

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.


_1
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 ThinkOnThinkingActionInterrupt, ThinkOnThinkingActionIgnore, ThinkOnSpeakingActionInterrupt, and ThinkOnSpeakingActionIgnore convenience constants.


_2
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)
_2
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.


_1
func (s *AgentSession) On(event string, handler EventHandler)


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

Off(event, handler)

Unregisters a previously registered event handler.


_1
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()SessionStatusCurrent session state
Agent()*AgentThe agent configuration
AppID()stringThe Agora App ID
Raw()*agents.ClientDirect access to the Fern-generated agents client for advanced operations

Using session.Raw()

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


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

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.


_1
import "github.com/AgoraIO-Conversational-AI/agent-server-sdk-go/agentkit/vendors"

Interfaces


_21
type LLM interface {
_21
ToConfig() map[string]interface{}
_21
}
_21
_21
type TTS interface {
_21
ToConfig() map[string]interface{}
_21
GetSampleRate() *SampleRate
_21
}
_21
_21
type STT interface {
_21
ToConfig() map[string]interface{}
_21
}
_21
_21
type MLLM interface {
_21
ToConfig() map[string]interface{}
_21
}
_21
_21
type Avatar interface {
_21
ToConfig() map[string]interface{}
_21
RequiredSampleRate() SampleRate
_21
}

LLM vendors

Use with WithLlm().

NewOpenAI


_1
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 onlyOpenAI API key. Optional for supported Agora-managed OpenAI models.
ModelstringYesModel identifier
BaseURLstringBYOK onlyAPI endpoint. Required when APIKey is set.
Temperature*float64NoSampling temperature
TopP*float64NoNucleus sampling
MaxTokens*intNoMaximum tokens in response
SystemMessages[]map[string]interface{}NoSystem messages
GreetingMessagestringNoAgent greeting message
FailureMessagestringNoMessage spoken when LLM fails
InputModalities[]stringNo["text"]Input modalities
OutputModalities[]stringNoOutput modalities
Paramsmap[string]interface{}NoAdditional model parameters
Headersmap[string]stringNoCustom HTTP headers forwarded to the LLM provider
GreetingConfigsmap[string]interface{}NoGreeting playback configuration
TemplateVariablesmap[string]stringNoTemplate variables for messages

NewAzureOpenAI


_1
func NewAzureOpenAI(opts AzureOpenAIOptions) *AzureOpenAI

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

FieldTypeRequiredDefaultDescription
APIKeystringYesAzure OpenAI API key
EndpointstringYesAzure endpoint URL
DeploymentNamestringYesAzure deployment name
ModelstringYesDeployment'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*float64NoSampling temperature
TopP*float64NoNucleus sampling
MaxTokens*intNoMaximum tokens
SystemMessages[]map[string]interface{}NoSystem messages
GreetingMessagestringNoAgent greeting message
FailureMessagestringNoMessage spoken when LLM fails
InputModalities[]stringNo["text"]Input modalities
OutputModalities[]stringNoOutput modalities
Paramsmap[string]interface{}NoAdditional model parameters
Headersmap[string]stringNoCustom HTTP headers forwarded to the LLM provider
GreetingConfigsmap[string]interface{}NoGreeting playback configuration
TemplateVariablesmap[string]stringNoTemplate variables for messages

NewAnthropic


_1
func NewAnthropic(opts AnthropicOptions) *Anthropic

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

FieldTypeRequiredDefaultDescription
APIKeystringYesAnthropic API key
ModelstringYesModel identifier
URLstringYesAnthropic messages endpoint URL
Headersmap[string]stringYesRequest headers, including Anthropic API version
MaxTokens*intYesMax tokens
Temperature*float64NoSampling temperature
TopP*float64NoNucleus sampling
SystemMessages[]map[string]interface{}NoSystem messages
GreetingMessagestringNoAgent greeting message
FailureMessagestringNoMessage spoken when LLM fails
InputModalities[]stringNo["text"]Input modalities
OutputModalities[]stringNoOutput modalities
Paramsmap[string]interface{}NoAdditional model parameters
GreetingConfigsmap[string]interface{}NoGreeting playback configuration
TemplateVariablesmap[string]stringNoTemplate variables for messages

NewGemini


_1
func NewGemini(opts GeminiOptions) *Gemini

Panics if APIKey or Model is empty.

FieldTypeRequiredDefaultDescription
APIKeystringYesGoogle AI API key
ModelstringNo"gemini-2.0-flash-exp"Model identifier
Temperature*float64NoSampling temperature
TopP*float64NoNucleus sampling
TopK*intNoTop-K sampling
MaxOutputTokens*intNoMaximum output tokens
SystemMessages[]map[string]interface{}NoSystem messages
GreetingMessagestringNoAgent greeting message
FailureMessagestringNoMessage spoken when LLM fails
InputModalities[]stringNo["text"]Input modalities
OutputModalities[]stringNoOutput modalities
Paramsmap[string]interface{}NoAdditional model parameters
Headersmap[string]stringNoCustom HTTP headers forwarded to the LLM provider
GreetingConfigsmap[string]interface{}NoGreeting playback configuration
TemplateVariablesmap[string]stringNoTemplate variables for messages

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

TTS vendors

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

NewElevenLabsTTS


_1
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


_1
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.


_1
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


_1
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


_1
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


_1
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


_1
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


_1
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


_1
func NewRimeTTS(opts RimeTTSOptions) *RimeTTS

Panics if Key, Speaker, or ModelID is empty.

FieldTypeRequiredDescription
KeystringYesRime API key
SpeakerstringYesSpeaker identifier
ModelIDstringYesModel identifier
BaseURLstringNoWebSocket URL
SkipPatterns[]intNoPatterns to skip

NewFishAudioTTS


_1
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


_1
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). BYOK still requires Key and GroupID, and preset-backed mode must not set GroupID, VoiceID, or URL.

FieldTypeRequiredDescription
KeystringNoMiniMax API key. Optional for supported preset-backed MiniMax models
GroupIDstringNoMiniMax group ID. Required for BYOK
ModelstringYesModel name, for example "speech-02-turbo"
VoiceIDstringNoVoice style identifier. BYOK only
URLstringNoWebSocket endpoint. BYOK only
SkipPatterns[]intNoPatterns to skip

NewMurfTTS


_1
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


_1
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

STT vendors

Use with WithStt().

NewDeepgramSTT


_1
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"
SmartFormat*boolNoEnable smart formatting
Punctuation*boolNoEnable punctuation
AdditionalParamsmap[string]interface{}NoAdditional vendor parameters

NewSpeechmaticsSTT


_1
func NewSpeechmaticsSTT(opts SpeechmaticsSTTOptions) *SpeechmaticsSTT

Panics if APIKey is empty.

FieldTypeRequiredDescription
APIKeystringYesSpeechmatics API key
LanguagestringNoLanguage code
URIstringNoSpeechmatics streaming WebSocket URL
AdditionalParamsmap[string]interface{}NoAdditional vendor params
ModelstringNoModel identifier

NewMicrosoftSTT


_1
func NewMicrosoftSTT(opts MicrosoftSTTOptions) *MicrosoftSTT

Panics if Key, Region, or Language is empty.

FieldTypeRequiredDescription
KeystringYesAzure Speech Services key
RegionstringYesAzure region
LanguagestringYesLanguage code

NewOpenAISTT


_1
func NewOpenAISTT(opts OpenAISTTOptions) *OpenAISTT

Panics if APIKey is empty.

FieldTypeRequiredDescription
APIKeystringYesOpenAI API key
ModelstringNoModel identifier
LanguagestringNoLanguage code
PromptstringNoPrompt for OpenAI transcription
InputAudioTranscriptionmap[string]interface{}NoOpenAI transcription settings
AdditionalParamsmap[string]interface{}NoAdditional vendor params

NewGoogleSTT


_1
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


_1
func NewAmazonSTT(opts AmazonSTTOptions) *AmazonSTT

Panics if AccessKey, SecretKey, or Region is empty.

FieldTypeRequiredDescription
AccessKeystringYesAWS access key
SecretKeystringYesAWS secret key
RegionstringYesAWS region
LanguagestringNoLanguage code

NewAssemblyAISTT


_1
func NewAssemblyAISTT(opts AssemblyAISTTOptions) *AssemblyAISTT

Panics if APIKey or Language is empty.

FieldTypeRequiredDescription
APIKeystringYesAssemblyAI API key
LanguagestringYesAssemblyAI language code
URIstringNoAssemblyAI streaming WebSocket URL
AdditionalParamsmap[string]interface{}NoAdditional vendor params

NewAresSTT


_1
func NewAresSTT(opts AresSTTOptions) *AresSTT

Ares is an Agora built-in STT service — no external API key required.

FieldTypeRequiredDescription
LanguagestringNoLanguage code
AdditionalParamsmap[string]interface{}NoAdditional vendor parameters

NewSarvamSTT


_1
func NewSarvamSTT(opts SarvamSTTOptions) *SarvamSTT

Panics if APIKey is empty.

FieldTypeRequiredDescription
APIKeystringYesSarvam API key
LanguagestringNoLanguage code
ModelstringNoModel identifier

MLLM vendors

Use with WithMllm() for multimodal end-to-end audio processing without separate STT or TTS steps. Requires AdvancedFeatures.EnableMllm = true via WithAdvancedFeatures() in NewAgent.

NewOpenAIRealtime


_1
func NewOpenAIRealtime(opts OpenAIRealtimeOptions) *OpenAIRealtime

Panics if APIKey is empty.

FieldTypeRequiredDefaultDescription
APIKeystringYesOpenAI API key
ModelstringNo"gpt-4o-realtime-preview"Model identifier
URLstringNoCustom WebSocket URL
GreetingMessagestringNoAgent greeting message
FailureMessagestringNoMessage played when the model call fails
InputModalities[]stringNoInput modalities
OutputModalities[]stringNoOutput modalities
Messages[]map[string]interface{}NoConversation messages for short-term memory
Paramsmap[string]interface{}NoAdditional parameters
TurnDetection*Agora.MllmTurnDetectionNoMLLM turn detection configuration; overrides top-level turn detection

NewGeminiLive


_1
func NewGeminiLive(opts GeminiLiveOptions) *GeminiLive

Panics if APIKey or Model is empty.

FieldTypeRequiredDefaultDescription
APIKeystringYesGoogle AI API key
ModelstringYesGemini Live model identifier
URLstringNoCustom WebSocket URL
InstructionsstringNoSystem instruction
VoicestringNoVoice name
GreetingMessagestringNoAgent greeting message
FailureMessagestringNoMessage played when the model call fails
InputModalities[]stringNoInput modalities
OutputModalities[]stringNoOutput modalities
Messages[]map[string]interface{}NoConversation messages for short-term memory
AdditionalParamsmap[string]interface{}NoAdditional parameters
TurnDetection*Agora.MllmTurnDetectionNoMLLM turn detection configuration; overrides top-level turn detection

NewVertexAI


_1
func NewVertexAI(opts VertexAIOptions) *VertexAI

Panics if ProjectID or ADCredentialsString is empty.

FieldTypeRequiredDefaultDescription
ProjectIDstringYesGoogle Cloud project ID
ADCredentialsStringstringYesApplication Default Credentials JSON string
LocationstringNo"us-central1"Google Cloud region
ModelstringNo"gemini-2.0-flash-exp"Model identifier
URLstringNoCustom WebSocket URL
VoicestringNoVoice name
InstructionsstringNoSystem instruction
GreetingMessagestringNoAgent greeting message
FailureMessagestringNoMessage played when the model call fails
InputModalities[]stringNoInput modalities
OutputModalities[]stringNoOutput modalities
Messages[]map[string]interface{}NoConversation messages for short-term memory
AdditionalParamsmap[string]interface{}NoAdditional parameters
TurnDetection*Agora.MllmTurnDetectionNoMLLM turn detection configuration; overrides top-level turn detection

NewXaiGrok


_1
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.

caution

NewXAIGrok / XAIGrokOptions are deprecated aliases.

XaiGrokOptions

Same fields as XAIGrokOptions below.

NewXAIGrok (deprecated)


_1
func NewXAIGrok(opts XAIGrokOptions) *XAIGrok

Deprecated. Use NewXaiGrok instead.

XAIGrokOptions
FieldTypeRequiredDefaultDescription
APIKeystringYesxAI API key
URLstringNo"wss://api.x.ai/v1/realtime"Realtime WebSocket URL
VoicestringNoVoice identifier
LanguagestringNoLanguage code
SampleRate*intNoAudio sample rate in Hz
GreetingMessagestringNoAgent greeting message
FailureMessagestringNoMessage played when the model call fails
InputModalities[]stringNoInput modalities
OutputModalities[]stringNoOutput modalities
Messages[]map[string]interface{}NoConversation messages for short-term memory
Paramsmap[string]interface{}NoAdditional xAI parameters
TurnDetection*Agora.MllmTurnDetectionNoagora_vad / server_vad turn detection

Avatar vendors

Use with WithAvatar(). Each avatar vendor requires a specific TTS sample rate — the constructor panics if the sample rate does not match.

NewHeyGenAvatar

Requires TTS at 24,000 Hz (SampleRate24kHz).


_1
func NewHeyGenAvatar(opts HeyGenAvatarOptions) *HeyGenAvatar

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

FieldTypeRequiredDescription
APIKeystringYesHeyGen API key
QualitystringYesVideo quality: "low", "medium", or "high"
AgoraUIDstringYesUID for the avatar's video stream
AgoraTokenstringNoRTC token for avatar authentication
AvatarIDstringNoHeyGen avatar ID
Enable*boolNoEnable or disable the avatar. Default: true
DisableIdleTimeout*boolNoDisable the idle timeout
ActivityIdleTimeout*intNoIdle timeout in seconds. Default: 120

NewAkoolAvatar

Requires TTS at 16,000 Hz (SampleRate16kHz).


_1
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


_1
func NewAnamAvatar(opts AnamAvatarOptions) *AnamAvatar

Panics if APIKey is empty.

NewGenericAvatar


_1
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

NewLiveAvatarAvatar

Requires TTS at 24,000 Hz (SampleRate24kHz).


_1
func NewLiveAvatarAvatar(opts LiveAvatarAvatarOptions) *LiveAvatarAvatar

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

NewAnamAvatar


_1
func NewAnamAvatar(opts AnamAvatarOptions) *AnamAvatar

Panics if APIKey is empty.

Token utilities

Helper functions for generating and managing tokens.


_1
import "github.com/AgoraIO-Conversational-AI/agent-server-sdk-go/agentkit"


_3
func GenerateRtcToken(opts GenerateTokenOptions) (string, error)
_3
func GenerateRtcTokenWithAccount(opts GenerateRtcTokenWithAccountOptions) (string, error)
_3
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 AppID and AppCertificate are provided on AgentSessionOptions.


_1
func GenerateConvoAIToken(opts GenerateConvoAITokenOptions) (string, error)

FieldTypeRequiredDescription
AppIDstringYesAgora App ID
AppCertificatestringYesAgora App Certificate
ChannelNamestringYesThe channel the token grants access to
AccountstringYesThe UID this token is issued for, as a string
TokenExpireintNoToken lifetime in seconds. Default: 86400. Valid range: 1–86400

_7
token, err := agentkit.GenerateConvoAIToken(agentkit.GenerateConvoAITokenOptions{
_7
AppID: os.Getenv("AGORA_APP_ID"),
_7
AppCertificate: os.Getenv("AGORA_APP_CERT"),
_7
ChannelName: "support-room-123",
_7
Account: "1",
_7
TokenExpire: agentkit.ExpiresInHours(12),
_7
})

GenerateRtcTokenWithAccount()

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


_1
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.


_1
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 (3600)

ExpiresInHours() / ExpiresInMinutes()

Helper functions for specifying token lifetimes. Use with 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.


_2
func ExpiresInHours(hours int) (int, error)
_2
func ExpiresInMinutes(minutes int) (int, error)


_9
expiresIn, err := agentkit.ExpiresInHours(12)
_9
if err != nil {
_9
log.Fatalf("Invalid expiry: %v", err)
_9
}
_9
_9
session := agentkit.NewAgentSession(agentkit.AgentSessionOptions{
_9
// ...
_9
ExpiresIn: expiresIn,
_9
})

Types and constants

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

SessionStatus

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


_10
type SessionStatus string
_10
_10
const (
_10
StatusIdle SessionStatus = "idle"
_10
StatusStarting SessionStatus = "starting"
_10
StatusRunning SessionStatus = "running"
_10
StatusStopping SessionStatus = "stopping"
_10
StatusStopped SessionStatus = "stopped"
_10
StatusError SessionStatus = "error"
_10
)

SampleRate

Typed integer constants for audio sample rates. Use with TTS vendor SampleRate fields and avatar sample rate validation.


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

Convenience constants for avatar sample rate requirements:


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

EventHandler

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


_1
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.


_5
option.AreaUS // United States (west + east)
_5
option.AreaEU // Europe (west + central)
_5
option.AreaAP // Asia-Pacific (southeast + northeast)
_5
option.AreaCN // Chinese Mainland (east + north)
_5
option.AreaUnknown // Default

Type aliases

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

AliasUnderlying type
TurnDetectionConfigAgora.StartAgentsRequestPropertiesTurnDetection
SalConfigAgora.StartAgentsRequestPropertiesSal
AdvancedFeaturesAgora.StartAgentsRequestPropertiesAdvancedFeatures
SessionParamsAgora.StartAgentsRequestPropertiesParameters
GeofenceConfigAgora.StartAgentsRequestPropertiesGeofence
RtcConfigAgora.StartAgentsRequestPropertiesRtc
FillerWordsConfigAgora.StartAgentsRequestPropertiesFillerWords
LlmConfigAgora.StartAgentsRequestPropertiesLlm
MllmConfigAgora.StartAgentsRequestPropertiesMllm
AsrConfigAgora.StartAgentsRequestPropertiesAsr
TtsConfigAgora.Tts
AvatarConfigAgora.StartAgentsRequestPropertiesAvatar
SttConfigAsrConfig
LlmStyleAgora.StartAgentsRequestPropertiesLlmStyle
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.

AgoraError

The Fern-generated error type returned when the API responds with a 4xx or 5xx status code. Use errors.As to inspect the error.


_11
import "github.com/AgoraIO-Conversational-AI/agent-server-sdk-go/core"
_11
_11
_, err := session.Start(ctx)
_11
if err != nil {
_11
var apiError *core.APIError
_11
if errors.As(err, &apiError) {
_11
log.Printf("Status: %d", apiError.StatusCode)
_11
log.Printf("Body: %s", apiError.Body)
_11
}
_11
return err
_11
}

FieldTypeDescription
StatusCodeintHTTP status code returned by the API
BodystringRaw response body from the API