Skip to content

Call Vexly from PHP

<?php
$baseUrl = getenv('VEXLY_BASE_URL') ?: 'https://api.vexly.io/api/v1/public';
$token = getenv('VEXLY_ACCESS_TOKEN');

$opts = [
  'http' => [
    'method' => 'POST',
    'header' => "Authorization: Bearer $token\r\nContent-Type: application/json\r\n",
    'content' => json_encode(['prompt' => 'Reply with exactly: hello from php'])
  ]
];

$run = json_decode(file_get_contents("$baseUrl/agent/runs", false, stream_context_create($opts)), true);
echo json_encode($run, JSON_PRETTY_PRINT) . PHP_EOL;