PHP SDK

composer require glytos/glytos

Any PSR-18 HTTP client works and is discovered automatically; most frameworks already ship one. If yours does not:

composer require guzzlehttp/guzzle

Setup

use Glytos\Client;

$glytos = new Client(getenv('GLYTOS_API_KEY'));

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

$prod = new Client(getenv('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($agentUuid);
$run = $glytos->threads->runs->create($thread, 'What are your opening hours?');

// Or stream it as it is written
foreach ($glytos->threads->runs->stream($thread, 'Summarise the policy') as $event) {
    if ($event->type === 'token') {
        echo $event->delta;
    }
}

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($workflowUuid);
$glytos->workflows->create(name: 'Receptionist', mode: 'prompt');

$glytos->calls->create([
    'transport' => 'phone',
    'workflow_uuid' => $workflowUuid,
    'to_number' => '+1...',
]);
$glytos->calls->list();

$glytos->workflows->session($workflowUuid, $sessionUuid);

Laravel

Set GLYTOS_API_KEY in .env; the service provider and Glytos facade are auto-discovered. Inject the client anywhere:

use Glytos\Client;

public function __construct(private Client $glytos) {}

$agents = $this->glytos->workflows->list();

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

$glytos->request('GET', '/audit');

Verifying webhooks

use Glytos\Webhook;

// `$rawBody` must be the untouched request body - parsing and re-serialising it
// changes the bytes and the signature will not match.
$ok = Webhook::verify($rawBody, $_SERVER['HTTP_X_GLYTOS_SIGNATURE'] ?? '', $secret);

See Webhooks.

PHP SDK · Glytos Docs