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

# 使い方

> PHP Agent SDKでツールループ、人によるレビュー、再試行、再開可能なエージェントを実行します。

## ランタイムを準備する

Agent SDKパッケージはまだPackagistにありません。[ソースからのインストール手順](./agent-sdk-installation.mdx)に従ってください。

## クイックスタート

```php theme={null}
<?php
require "vendor/autoload.php";

use Phaseo\AgentSdk\AgentDefinition;
use Phaseo\AgentSdk\AgentSdk;

$agent = AgentSdk::createAgent(new AgentDefinition(
    id: "quickstart-agent",
    model: "openai/gpt-5.4-nano",
    instructions: "Answer concisely and helpfully."
));

$result = $agent->run(
    input: "Give me one fun fact about cURL.",
    client: AgentSdk::createGatewayAgentClient()
);

echo $result->output . PHP_EOL;
```

## 提供される機能

* `AgentSdk::createAgent(...)`
* `AgentSdk::defineTool(...)`
* `AgentSdk::createGatewayAgentClient(...)`
* Phaseoの`responses` APIを使った、上限付きツールループ

## 高度なランタイム機能

PHPは、検証・承認コールバック、HITL・手動ツール、進捗、回復可能なエラー、再生可能なイテレーター、停止ヘルパー、動的ターン、次のターン用の永続化パラメーター、正規化された使用量とコスト、`StateAccessor`に対応します。

## ストリーミングとキャンセル

`Agent::stream(...)`と`Agent::continueStream(...)`は、返されたイテレーターの消費に合わせてFiber経由でゲートウェイのResponses SSEストリームを処理します。`textStream()`、`reasoningStream()`、`itemStream()`、`fullStream()`を使います。`cancel()`を呼び出すとFiberを停止し、ジェネレーターを閉じます。完了したステップには、リクエストID、プロバイダーメタデータ、終了理由、警告、使用量、コストが保持されます。

## 関連情報

* [Agent SDKの概要](../agent-sdk/overview.mdx)
* [TypeScript Agent SDK](../typescript/agent-sdk.mdx)


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.