Skip to main content

Official SDK-style usage

This package supports a pure PHP style that mirrors the official SDK while still giving you a Laravel-friendly developer experience.
This only explains that “under Facade, the official SDK is replicated and can be used in the same way,” so it is generally recommended to use Facade.
use Revolution\Copilot\Client;
use Revolution\Copilot\Session;
use Revolution\Copilot\Types\SessionEvent;

$client = new Client([
    'cli_path' => 'copilot',
    'cli_args' => [],
    'cwd' => base_path(),
    'log_level' => 'info',
    'env' => null,
]);

$client->start();

/** @var Session $session */
$session = $client->createSession([
    'model' => 'gpt-5',
]);

$done = $session->on(function (SessionEvent $event) {
    if($event->isAssistantMessage()) {
        echo $event->content();
    }
});

$session->send(prompt: 'Tell me something about Laravel.');
$session->wait(timeout: 60.0); // Force waiting with wait() until true async support is officially implemented.

$done();

$session->disconnect();
$client->stop();
For the latest updates, see the GitHub repository.
Last modified on April 20, 2026