Python SDK

pip install glytos

Setup

import os
from glytos import Glytos

glytos = Glytos(api_key=os.environ["GLYTOS_API_KEY"])

To act in a specific environment, name it - dev, staging, prod, or an environment uuid. It defaults to Development.

prod = Glytos(api_key=os.environ["GLYTOS_API_KEY"], environment="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. See Chat.

thread = glytos.threads.create(agent=agent_uuid)
run = glytos.threads.runs.create(thread, "What are your opening hours?")

# Or stream it as it is written
for event in glytos.threads.runs.stream(thread, "Summarise the policy"):
    if event.type == "token":
        print(event.delta, end="", flush=True)

agents is an alias of workflows: the product calls them agents, the API path is /workflows. Either works.

Resources

glytos.workflows.list()
glytos.workflows.retrieve(workflow_uuid)
glytos.workflows.create(name="Receptionist", mode="prompt")

glytos.calls.create(transport="phone", workflow_uuid=workflow_uuid, to_number="+1...")
glytos.calls.list()

glytos.workflows.session(workflow_uuid, session_uuid)

The client covers agents (alias workflows), threads, folders, imports, chat, calls, phone_numbers, sip_trunks, campaigns, dnc, sessions, webhooks, tools, knowledge_base, vector_stores, integrations, automations, test_suites, analytics, billing, environments, providers, api_keys and organizations. An AsyncGlytos client mirrors the same surface with await, and async for over a stream.

Anything not wrapped

glytos.request("GET", "/audit")

Verifying webhooks

from glytos import verify_webhook

# `raw_body` must be the untouched request body - parsing and re-serialising it
# changes the bytes and the signature will not match.
ok = verify_webhook(raw_body, request.headers["X-Glytos-Signature"], secret)

See Webhooks.

Python SDK · Glytos Docs