Go SDK
go get github.com/Glytos/glytos-sdk-goRequires Go 1.21 or newer. Zero dependencies - the standard library only.
Setup
import glytos "github.com/Glytos/glytos-sdk-go"
client := glytos.New("gly_...")To act in a specific environment, pass an option - dev, staging, prod, or an
environment uuid. It defaults to Development.
client := glytos.New("gly_...", glytos.WithEnvironment("prod"))Text conversations
A thread holds a conversation; a run is one turn on it. The reply is in the result - there is no run to poll. Streaming takes a callback, so it works on Go 1.21 without range-over-func. See Chat.
thread, err := client.Threads.Create(ctx, agentUUID, nil)
run, err := client.Threads.Runs.Create(ctx, *thread, &glytos.TurnParams{
Content: "What are your opening hours?",
})
err = client.Threads.Runs.Stream(ctx, *thread,
&glytos.TurnParams{Content: "Summarise the policy"},
func(e glytos.StreamEvent) error {
if e.Type == "token" {
fmt.Print(e.Delta)
}
return nil
})Agents is an alias of Workflows: the product calls them agents, the API path is
/workflows. Either works.
Resources
Every call takes a context.Context, and typed params structs for creates:
ctx := context.Background()
agents, err := client.Workflows.List(ctx, nil)
agent, err := client.Workflows.Create(ctx, glytos.WorkflowCreateParams{
Name: "Receptionist",
Mode: "prompt",
})
// Mint a web-call token for the browser (never ship the API key there).
token, err := client.Calls.WebToken(ctx, glytos.WebTokenParams{WorkflowUUID: agent.UUID})The client covers Agents (alias Workflows), Threads, Folders, Imports,
Chat, Calls, PhoneNumbers, SipTrunks, Campaigns, Dnc, Sessions,
Webhooks, Tools, KnowledgeBase, VectorStores, Integrations,
Automations, TestSuites, Analytics, Billing, Environments, Providers,
APIKeys and Organizations.
Anything not wrapped
Reach any endpoint directly, with auth and error handling applied:
var out map[string]any
err := client.Do(ctx, "GET", "/audit", nil, nil, &out)Verifying webhooks
ok := glytos.VerifyWebhook(rawBody, signatureHeader, secret, glytos.DefaultWebhookTolerance)rawBody must be the untouched request body - parsing and re-serialising it changes the
bytes and the signature will not match. It is also on the client as
client.Webhooks.Verify(...). See Webhooks.