vapi

package
v0.11.0 Latest Latest
Warning

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

Go to latest
Published: Jul 6, 2025 License: MIT Imports: 10 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type APIClient

type APIClient struct {
	BaseURL    string
	Token      string
	HTTPClient *http.Client
}

APIClient handles communication with the remote provider.

func (*APIClient) CreateAssistant added in v0.5.0

func (c *APIClient) CreateAssistant(requestData CreateAssistantRequest) ([]byte, int, error)

CreateAssistant creates a new assistant.

func (*APIClient) CreateSIPTrunk added in v0.10.0

func (c *APIClient) CreateSIPTrunk(requestData ImportSIPTrunkRequest) ([]byte, int, error)

CreateSIPTrunk creates a new assistant.

func (*APIClient) CreateToolFunction added in v0.4.0

func (c *APIClient) CreateToolFunction(requestData ToolFunctionRequest) ([]byte, int, error)

CreateToolFunction method.

func (*APIClient) CreateToolQueryFunction added in v0.7.0

func (c *APIClient) CreateToolQueryFunction(requestData ToolQueryFunctionRequest) ([]byte, int, error)

CreateToolQueryFunction method.

func (*APIClient) DeleteAssistant added in v0.5.0

func (c *APIClient) DeleteAssistant(id string) ([]byte, int, error)

DeleteAssistant deletes an existing assistant by ID.

func (*APIClient) DeleteFile added in v0.3.0

func (c *APIClient) DeleteFile(id string) ([]byte, int, error)

DeleteFile deletes a specific phone number by ID.

func (*APIClient) DeletePhoneNumber added in v0.3.0

func (c *APIClient) DeletePhoneNumber(id string) ([]byte, int, error)

DeletePhoneNumber deletes a specific phone number by ID.

func (*APIClient) DeleteSIPTrunk added in v0.10.0

func (c *APIClient) DeleteSIPTrunk(id string) ([]byte, int, error)

DeleteSIPTrunk deletes an existing assistant by ID.

func (*APIClient) DeleteToolFunction added in v0.4.0

func (c *APIClient) DeleteToolFunction(id string) ([]byte, int, error)

DeleteToolFunction deletes a specific tool by ID.

func (*APIClient) DeleteToolQueryFunction added in v0.7.0

func (c *APIClient) DeleteToolQueryFunction(id string) ([]byte, int, error)

DeleteToolQueryFunction deletes a specific tool by ID.

func (*APIClient) GetAssistant added in v0.5.0

func (c *APIClient) GetAssistant(id string) ([]byte, int, error)

GetAssistant retrieves the details of a specific assistant by ID.

func (*APIClient) GetFile added in v0.3.0

func (c *APIClient) GetFile(id string) ([]byte, int, error)

GetFile retrieves the details of a specific phone number by ID.

func (*APIClient) GetPhoneNumber added in v0.3.0

func (c *APIClient) GetPhoneNumber(id string) ([]byte, int, error)

GetPhoneNumber retrieves the details of a specific phone number by ID.

func (*APIClient) GetSIPTrunk added in v0.10.0

func (c *APIClient) GetSIPTrunk(id string) ([]byte, int, error)

GetSIPTrunk retrieves the details of a specific assistant by ID.

func (*APIClient) GetToolFunction added in v0.4.0

func (c *APIClient) GetToolFunction(id string) ([]byte, int, error)

GetToolFunction retrieves the details of a specific tool by ID.

func (*APIClient) GetToolQueryFunction added in v0.7.0

func (c *APIClient) GetToolQueryFunction(id string) ([]byte, int, error)

GetToolQueryFunction retrieves the details of a specific tool by ID.

func (*APIClient) ImportSIPTrunkPhoneNumber added in v0.11.0

func (c *APIClient) ImportSIPTrunkPhoneNumber(requestData ImportSIPTrunkPhoneNumberRequest) ([]byte, int, error)

ImportSIPTrunkPhoneNumber requests the creation of a new phone number.

func (*APIClient) ImportTwilioPhoneNumber added in v0.3.0

func (c *APIClient) ImportTwilioPhoneNumber(requestData ImportTwilioRequest) ([]byte, int, error)

ImportTwilioPhoneNumber requests the creation of a new phone number.

func (*APIClient) SendRequest

func (c *APIClient) SendRequest(method, endpoint string, body interface{}) ([]byte, int, error)

func (*APIClient) UpdateAssistant added in v0.5.5

func (c *APIClient) UpdateAssistant(id string, requestData CreateAssistantRequest) ([]byte, int, error)

UpdateAssistant updates assistant.

func (*APIClient) UpdateSIPTrunk added in v0.10.0

func (c *APIClient) UpdateSIPTrunk(id string, requestData ImportSIPTrunkRequest) ([]byte, int, error)

UpdateSIPTrunk updates assistant.

func (*APIClient) UpdateToolQueryFunction added in v0.7.0

func (c *APIClient) UpdateToolQueryFunction(id string, requestData ToolQueryFunctionRequest) ([]byte, int, error)

UpdateToolQueryFunction method.

func (*APIClient) UploadData added in v0.3.3

func (c *APIClient) UploadData(fieldName, filename string, content []byte) ([]byte, int, error)

UploadData Uploads a file using multipart/form-data.

type AnalysisPlan added in v0.5.0

type AnalysisPlan struct {
	SummaryPrompt           string                `json:"summaryPrompt"`
	StructuredDataPrompt    string                `json:"structuredDataPrompt"`
	StructuredDataSchema    *StructuredDataSchema `json:"structuredDataSchema"`
	SuccessEvaluationPrompt string                `json:"successEvaluationPrompt"`
	SuccessEvaluationRubric string                `json:"successEvaluationRubric"`
}

AnalysisPlan struct.

type ArtifactPlan added in v0.8.2

type ArtifactPlan struct {
	RecordingFormat string `json:"recordingFormat,omitempty"`
}

type Assistant added in v0.5.0

type Assistant struct {
	ID                           string             `json:"id,omitempty"`
	OrgID                        string             `json:"orgId,omitempty"`
	Name                         string             `json:"name,omitempty"`
	FirstMessageMode             string             `json:"firstMessageMode,omitempty"`
	HipaaEnabled                 bool               `json:"hipaaEnabled,omitempty"`
	BackgroundSound              string             `json:"backgroundSound,omitempty"`
	BackgroundDenoising          bool               `json:"backgroundDenoisingEnabled,omitempty"`
	ModelOutputEnabled           bool               `json:"modelOutputInMessagesEnabled,omitempty"`
	Language                     string             `json:"language,omitempty"`
	ForwardingPhoneNumber        string             `json:"forwardingPhoneNumber,omitempty"`
	InterruptionsEnabled         bool               `json:"interruptionsEnabled,omitempty"`
	EndCallFunctionEnabled       bool               `json:"endCallFunctionEnabled,omitempty"`
	DialKeypadFunctionEnabled    bool               `json:"dialKeypadFunctionEnabled,omitempty"`
	FillersEnabled               bool               `json:"fillersEnabled,omitempty"`
	SilenceTimeoutSeconds        *float64           `json:"silenceTimeoutSeconds,omitempty"`
	ResponseDelaySeconds         *float64           `json:"responseDelaySeconds,omitempty"`
	NumWordsToInterruptAssistant *int64             `json:"numWordsToInterruptAssistant,omitempty"`
	LiveTranscriptsEnabled       *bool              `json:"liveTranscriptsEnabled,omitempty"`
	Keywords                     []string           `json:"keywords,omitempty"`
	ParentID                     *string            `json:"parentId,omitempty"`
	Voice                        *Voice             `json:"voice,omitempty"`
	Model                        *Model             `json:"model,omitempty"`
	RecordingEnabled             bool               `json:"recordingEnabled,omitempty"`
	FirstMessage                 string             `json:"firstMessage,omitempty"`
	VoicemailMessage             string             `json:"voicemailMessage,omitempty"`
	EndCallMessage               string             `json:"endCallMessage,omitempty"`
	Transcriber                  *Transcriber       `json:"transcriber,omitempty"`
	ClientMessages               []string           `json:"clientMessages,omitempty"`
	ServerMessages               []string           `json:"serverMessages,omitempty"`
	EndCallPhrases               []string           `json:"endCallPhrases,omitempty"`
	MaxDurationSeconds           int64              `json:"maxDurationSeconds,omitempty"`
	AnalysisPlan                 *AnalysisPlan      `json:"analysisPlan,omitempty"`
	MessagePlan                  *MessagePlan       `json:"messagePlan,omitempty"`
	StartSpeakingPlan            *StartSpeakingPlan `json:"startSpeakingPlan,omitempty"`
	StopSpeakingPlan             *StopSpeakingPlan  `json:"StopSpeakingPlan,omitempty"`
	Server                       *Server            `json:"server,omitempty"`
	ArtifactPlan                 *ArtifactPlan      `json:"artifactPlan,omitempty"`
}

Assistant struct.

type CreateAssistantRequest added in v0.5.0

type CreateAssistantRequest struct {
	Name                         string             `json:"name"`
	FirstMessageMode             string             `json:"firstMessageMode,omitempty"`
	HipaaEnabled                 bool               `json:"hipaaEnabled,omitempty"`
	ClientMessages               []string           `json:"clientMessages,omitempty"`
	ServerMessages               []string           `json:"serverMessages,omitempty"`
	BackgroundSound              string             `json:"backgroundSound,omitempty"`
	BackgroundDenoising          bool               `json:"backgroundDenoisingEnabled,omitempty"`
	ModelOutputEnabled           bool               `json:"modelOutputInMessagesEnabled,omitempty"`
	Language                     string             `json:"language,omitempty"`
	ForwardingPhoneNumber        string             `json:"forwardingPhoneNumber,omitempty"`
	InterruptionsEnabled         bool               `json:"interruptionsEnabled,omitempty"`
	EndCallFunctionEnabled       bool               `json:"endCallFunctionEnabled,omitempty"`
	DialKeypadFunctionEnabled    bool               `json:"dialKeypadFunctionEnabled,omitempty"`
	FillersEnabled               bool               `json:"fillersEnabled,omitempty"`
	SilenceTimeoutSeconds        *float64           `json:"silenceTimeoutSeconds,omitempty"`
	ResponseDelaySeconds         *float64           `json:"responseDelaySeconds,omitempty"`
	NumWordsToInterruptAssistant *int64             `json:"numWordsToInterruptAssistant,omitempty"`
	LiveTranscriptsEnabled       *bool              `json:"liveTranscriptsEnabled,omitempty"`
	Keywords                     []string           `json:"keywords,omitempty"`
	Voice                        *Voice             `json:"voice,omitempty"`
	Model                        *Model             `json:"model,omitempty"`
	RecordingEnabled             bool               `json:"recordingEnabled,omitempty"`
	FirstMessage                 string             `json:"firstMessage,omitempty"`
	VoicemailMessage             string             `json:"voicemailMessage,omitempty"`
	EndCallMessage               string             `json:"endCallMessage,omitempty"`
	Transcriber                  *Transcriber       `json:"transcriber,omitempty"`
	EndCallPhrases               []string           `json:"endCallPhrases,omitempty"`
	MaxDurationSeconds           int64              `json:"maxDurationSeconds,omitempty"`
	AnalysisPlan                 *AnalysisPlan      `json:"analysisPlan,omitempty"`
	MessagePlan                  *MessagePlan       `json:"messagePlan,omitempty"`
	StartSpeakingPlan            *StartSpeakingPlan `json:"startSpeakingPlan,omitempty"`
	StopSpeakingPlan             *StopSpeakingPlan  `json:"stopSpeakingPlan,omitempty"`
	Server                       *Server            `json:"server,omitempty"`
	ArtifactPlan                 *ArtifactPlan      `json:"artifactPlan,omitempty"`
}

CreateAssistantRequest represents the request body for creating an assistant.

type Customer added in v0.5.1

type Customer struct {
	Number string `json:"number"`
}

Customer struct.

type Destination added in v0.8.0

type Destination struct {
	Type                   string `json:"type"`
	Number                 string `json:"number"`
	Extension              string `json:"extension,omitempty"`
	Message                string `json:"message,omitempty"`
	Description            string `json:"description,omitempty"`
	NumberE164CheckEnabled bool   `json:"numberE164CheckEnabled"`
}

type FallbackDestination added in v0.3.0

type FallbackDestination struct {
	Type                   string `json:"type,omitempty"`
	NumberE164CheckEnabled bool   `json:"numberE164CheckEnabled,omitempty"`
	Number                 string `json:"number,omitempty"`
	Extension              string `json:"extension,omitempty"`
	Message                string `json:"message,omitempty"`
	Description            string `json:"description,omitempty"`
}

FallbackDestination struct.

type FileResponse

type FileResponse struct {
	ID           string                 `json:"id"`
	Name         string                 `json:"name"`
	OriginalName string                 `json:"originalName"`
	Bytes        int64                  `json:"bytes"`
	Mimetype     string                 `json:"mimetype"`
	Path         string                 `json:"path"`
	URL          string                 `json:"url"`
	Metadata     map[string]interface{} `json:"metadata"`
	OrgID        string                 `json:"orgId"`
	CreatedAt    string                 `json:"createdAt"`
	UpdatedAt    string                 `json:"updatedAt"`
	Status       string                 `json:"status"`
	Purpose      string                 `json:"purpose"`
	Bucket       string                 `json:"bucket"`
}

FileResponse represents the structure of the API response.

func (*FileResponse) UnmarshalJSON

func (fr *FileResponse) UnmarshalJSON(data []byte) error

UnmarshalJSON implements custom unmarshaling for FileResponse.

type Function added in v0.4.0

type Function struct {
	Description string          `json:"description"`
	Async       bool            `json:"async,omitempty"`
	Name        string          `json:"name,omitempty"`
	Parameters  *FunctionParams `json:"parameters,omitempty"`
}

type FunctionParams added in v0.4.0

type FunctionParams struct {
	Type       string              `json:"type"`
	Properties map[string]Property `json:"properties,omitempty"`
	Required   []string            `json:"required,omitempty"`
}

type ImportSIPTrunkPhoneNumberRequest added in v0.11.0

type ImportSIPTrunkPhoneNumberRequest struct {
	Provider               string `json:"provider"`               // always "byo-phone-number"
	Number                 string `json:"number"`                 // e.g., "+14031234567"
	NumberE164CheckEnabled bool   `json:"numberE164CheckEnabled"` // true/false
	CredentialID           string `json:"credentialId"`           // e.g., UUID for SIP credentials
	Name                   string `json:"name"`                   // descriptive name
}

ImportSIPTrunkPhoneNumberRequest represents the payload to import a SIP trunk phone number.

type ImportSIPTrunkPhoneNumberResponse added in v0.11.0

type ImportSIPTrunkPhoneNumberResponse struct {
	ID                     string `json:"id"`                     // system-generated phone number ID
	OrgID                  string `json:"orgId"`                  // owning organization ID
	Number                 string `json:"number"`                 // phone number
	CreatedAt              string `json:"createdAt"`              // RFC3339 timestamp
	UpdatedAt              string `json:"updatedAt"`              // RFC3339 timestamp
	Provider               string `json:"provider"`               // "byo-phone-number"
	Name                   string `json:"name"`                   // same as request
	NumberE164CheckEnabled bool   `json:"numberE164CheckEnabled"` // same as request
	CredentialID           string `json:"credentialId"`           // same as request
}

ImportSIPTrunkPhoneNumberResponse represents the response structure after import.

type ImportSIPTrunkRequest added in v0.10.0

type ImportSIPTrunkRequest struct {
	Provider                   string                      `json:"provider"`
	Name                       string                      `json:"name"`
	Gateways                   []SIPGateway                `json:"gateways"`
	OutboundAuthenticationPlan *OutboundAuthenticationPlan `json:"outboundAuthenticationPlan,omitempty"`
	OutboundLeadingPlusEnabled bool                        `json:"outboundLeadingPlusEnabled"`
	TechPrefix                 string                      `json:"techPrefix,omitempty"`
	SIPDiversionHeader         string                      `json:"sipDiversionHeader,omitempty"`
}

ImportSIPTrunkRequest struct represents a request to import a BYO SIP trunk.

type ImportTwilioRequest added in v0.3.0

type ImportTwilioRequest struct {
	Provider         string               `json:"provider"`
	Name             string               `json:"name"`
	Number           string               `json:"number"`
	TwilioAccountSID string               `json:"twilioAccountSid"`
	TwilioAuthToken  string               `json:"twilioAuthToken"`
	AssistantID      string               `json:"assistantId,omitempty"`
	Fallback         *FallbackDestination `json:"fallbackDestination,omitempty"`
}

ImportTwilioRequest struct.

type KnowledgeBase added in v0.5.1

type KnowledgeBase struct {
	TopK     int64    `json:"topK"`
	FileIDs  []string `json:"fileIds"`
	Provider string   `json:"provider"`
}

KnowledgeBase struct.

type Message added in v0.5.1

type Message struct {
	Role    string `json:"role"`
	Content string `json:"content"`
}

Message struct.

type MessagePlan added in v0.5.1

type MessagePlan struct {
	IdleMessages []string `json:"idleMessages"`
}

MessagePlan struct.

type Model added in v0.5.0

type Model struct {
	Model         string         `json:"model"`
	SystemPrompt  string         `json:"systemPrompt"`
	Provider      string         `json:"provider"`
	MaxTokens     int64          `json:"maxTokens,omitempty"`
	Temperature   float64        `json:"temperature,omitempty"`
	ToolIDs       []string       `json:"toolIds,omitempty"`
	Messages      []Message      `json:"messages,omitempty"`
	KnowledgeBase *KnowledgeBase `json:"knowledgeBase,omitempty"`
}

Model struct.

type OutboundAuthenticationPlan added in v0.10.0

type OutboundAuthenticationPlan struct {
	AuthUsername    string           `json:"authUsername"`
	AuthPassword    string           `json:"authPassword"`
	SIPRegisterPlan *SIPRegisterPlan `json:"sipRegisterPlan,omitempty"`
}

OutboundAuthenticationPlan struct represents outbound SIP authentication details.

type Property added in v0.4.0

type Property struct {
	Type        string   `json:"type"`
	Description string   `json:"description"`
	Enum        []string `json:"enum,omitempty"`
}

type ResponseFunction added in v0.4.0

type ResponseFunction struct {
	Name        string                 `json:"name"`
	Async       bool                   `json:"async"`
	Description string                 `json:"description"`
	Parameters  ResponseFunctionParams `json:"parameters"`
}

type ResponseFunctionParams added in v0.4.0

type ResponseFunctionParams struct {
	Type       string                      `json:"type"`
	Properties map[string]ResponseProperty `json:"properties"`
	Required   []string                    `json:"required"`
}

type ResponseProperty added in v0.4.0

type ResponseProperty struct {
	Description string   `json:"description"`
	Type        string   `json:"type"`
	Enum        []string `json:"enum,omitempty"`
}

type ResponseServer added in v0.4.0

type ResponseServer struct {
	URL string `json:"url"`
}

type SIPGateway added in v0.10.0

type SIPGateway struct {
	IP string `json:"ip"`
}

SIPGateway struct represents an individual SIP gateway.

type SIPRegisterPlan added in v0.10.0

type SIPRegisterPlan struct {
	Domain   string `json:"domain"`
	Username string `json:"username"`
	Realm    string `json:"realm"`
}

SIPRegisterPlan struct represents the SIP registration plan details.

type Server added in v0.4.0

type Server struct {
	URL            string `json:"url,omitempty"`
	Secret         string `json:"secret,omitempty"`
	TimeoutSeconds int64  `json:"timeoutSeconds,omitempty"`
}

type StartSpeakingPlan added in v0.5.0

type StartSpeakingPlan struct {
	WaitSeconds                  float64                       `json:"waitSeconds,omitempty"`
	SmartEndpointingEnabled      bool                          `json:"smartEndpointingEnabled,omitempty"`
	TranscriptionEndpointingPlan *TranscriptionEndpointingPlan `json:"transcriptionEndpointingPlan,omitempty"`
}

StartSpeakingPlan struct.

type StopSpeakingPlan added in v0.5.0

type StopSpeakingPlan struct {
	NumWords       float64 `json:"numWords,omitempty"`
	VoiceSeconds   float64 `json:"voiceSeconds,omitempty"`
	BackoffSeconds float64 `json:"backoffSeconds,omitempty"`
}

StopSpeakingPlan struct.

type StructuredDataSchema added in v0.5.0

type StructuredDataSchema struct {
	Type       string               `json:"type"`
	Properties map[string]*Property `json:"properties"`
}

StructuredDataSchema struct.

type TQKnowledgeBase added in v0.7.0

type TQKnowledgeBase struct {
	Provider    string   `json:"provider"`
	Name        string   `json:"name"`
	Model       string   `json:"model"`
	Description string   `json:"description"`
	FileIDs     []string `json:"fileIds"`
}

type ToolFunctionRequest added in v0.7.0

type ToolFunctionRequest struct {
	Destinations []Destination `json:"destinations,omitempty"`
	Server       *Server       `json:"server"`
	Function     Function      `json:"function"`
	Type         string        `json:"type"`
	Async        bool          `json:"async"`
}

ToolFunctionRequest struct.

type ToolFunctionResponse added in v0.7.0

type ToolFunctionResponse struct {
	ID        string           `json:"id"`
	CreatedAt string           `json:"createdAt"`
	UpdatedAt string           `json:"updatedAt"`
	Type      string           `json:"type"`
	Function  ResponseFunction `json:"function"`
	OrgID     string           `json:"orgId"`
	Server    ResponseServer   `json:"server"`
	Async     bool             `json:"async"`
}

ToolFunctionResponse struct.

type ToolQueryFunctionRequest added in v0.7.0

type ToolQueryFunctionRequest struct {
	Function       Function          `json:"function"`
	KnowledgeBases []TQKnowledgeBase `json:"knowledgeBases"`
	Type           string            `json:"type,omitempty"`
}

ToolQueryFunctionRequest struct.

type ToolQueryFunctionResponse added in v0.7.0

type ToolQueryFunctionResponse struct {
	ID             string            `json:"id"`
	CreatedAt      string            `json:"createdAt"`
	UpdatedAt      string            `json:"updatedAt"`
	Type           string            `json:"type"`
	OrgID          string            `json:"orgId"`
	Function       Function          `json:"function"`
	KnowledgeBases []TQKnowledgeBase `json:"knowledgeBases"`
}

type Transcriber added in v0.5.0

type Transcriber struct {
	Model    string `json:"model"`
	Language string `json:"language"`
	Provider string `json:"provider"`
}

Transcriber struct.

type TranscriptionEndpointingPlan added in v0.5.0

type TranscriptionEndpointingPlan struct {
	OnPunctuationSeconds   float64 `json:"onPunctuationSeconds,omitempty"`
	OnNoPunctuationSeconds float64 `json:"onNoPunctuationSeconds,omitempty"`
	OnNumberSeconds        float64 `json:"onNumberSeconds,omitempty"`
}

TranscriptionEndpointingPlan struct.

type TwilioPhoneNumber added in v0.3.0

type TwilioPhoneNumber struct {
	ID               string               `json:"id"`
	OrgID            string               `json:"orgId"`
	Number           string               `json:"number"`
	CreatedAt        string               `json:"createdAt"`
	UpdatedAt        string               `json:"updatedAt"`
	TwilioAccountSid string               `json:"twilioAccountSid"`
	TwilioAuthToken  string               `json:"twilioAuthToken"`
	Name             string               `json:"name"`
	Provider         string               `json:"provider"`
	AssistantID      string               `json:"assistantId"`
	Fallback         *FallbackDestination `json:"fallbackDestination,omitempty"`
}

TwilioPhoneNumber represents the structure of a Twilio phone number API response.

type Voice added in v0.5.0

type Voice struct {
	Model           string  `json:"model,omitempty"`
	VoiceID         string  `json:"voiceId,omitempty"`
	Provider        string  `json:"provider,omitempty"`
	Stability       float64 `json:"stability,omitempty"`
	SimilarityBoost float64 `json:"similarityBoost,omitempty"`
}

Voice struct.

Jump to

Keyboard shortcuts

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