> ## Documentation Index
> Fetch the complete documentation index at: https://kawax.biz/llms.txt
> Use this file to discover all available pages before exploring further.

# 官方 SDK 相容層的使用方式

> 說明如何以官方 SDK 風格使用 Laravel Copilot SDK，並一併確認 Laravel 中的建議風格。

## 以官方 SDK 風格使用

本套件也支援複製官方 SDK 使用方式的 pure PHP 風格。
同時提供 Laravel 風格的開發體驗。

<Info>
  本頁的目的是說明「Facade 內部再現了官方 SDK，因此也可以用相同方式使用」。
  一般建議使用 Facade 的方式。
</Info>

```php theme={null}
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); // 在 True async 正式實作前，先以 wait() 等待。

$done();

$session->disconnect();
$client->stop();
```

<Info>
  最新資訊請參考 [GitHub 儲存庫](https://github.com/invokable/laravel-copilot-sdk)。
</Info>


## Related topics

- [GitHub Copilot SDK for Laravel](/zh-TW/packages/laravel-copilot-sdk/index.md)
- [Laravel Agent Detector — AI Agent 偵測套件](/zh-TW/blog/agent-detector-introduction.md)
- [打包 Copilot CLI](/zh-TW/packages/laravel-copilot-sdk/bundle-cli.md)
- [Client 模式 - 使用者字典 - VOICEVOX for Laravel](/zh-TW/packages/laravel-voicevox/client-user-dict.md)
- [Socialite(LINE Login)- LINE SDK for Laravel](/zh-TW/packages/laravel-line-sdk/socialite.md)
