PHP SDK
composer require glytos/glytosAny PSR-18 HTTP client works and is discovered automatically; most frameworks already ship one. If yours does not:
composer require guzzlehttp/guzzleSetup
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. Without it, requests use the organization's default environment. A value that
matches no environment falls back to the default rather than failing.
$prod = new Client(getenv('GLYTOS_API_KEY'), environment: 'prod');Timeouts and streaming
The SDK sets no timeout of its own - that belongs to the PSR-18 client it sends through.
A text turn can take a while when the model writes a long reply, so give the client a
limit that leaves room for it. Pass a configured client as httpClient:
$glytos = new Client(
getenv('GLYTOS_API_KEY'),
httpClient: new \GuzzleHttp\Client(['timeout' => 120, 'stream' => true]),
);'stream' => true matters for runs->stream(...): without it Guzzle downloads the whole
response before returning it, so the events all arrive at once when the reply is
finished rather than as it is written.
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->calls->say($callUuid, 'One moment, please.');
$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.