Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
105 changes: 70 additions & 35 deletions docs/ja/examples.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,104 +4,139 @@ search:
---
# コード例

[repo](https://github.com/openai/openai-agents-python/tree/main/examples) の examples セクションで、 SDK のさまざまなサンプル実装を確認できます。examples は、異なるパターンと機能を示す複数のカテゴリーに整理されています。
[repo](https://github.com/openai/openai-agents-python/tree/main/examples) の examples セクションで、 SDK のさまざまなサンプル実装を確認できます。これらのコード例は、異なるパターンと機能を示す複数のカテゴリーに整理されています。

## カテゴリー

- **[agent_patterns](https://github.com/openai/openai-agents-python/tree/main/examples/agent_patterns):**
このカテゴリーのコード例では、一般的なエージェント設計パターンを示しています。例:
このカテゴリーのコード例では、次のような一般的なエージェント設計パターンを示します。

- 決定論的ワークフロー
- Agents as tools
- エージェントの並列実行
- ストリーミングイベントを伴う Agents as tools (`examples/agent_patterns/agents_as_tools_streaming.py`)
- 構造化入力パラメーターを伴う Agents as tools (`examples/agent_patterns/agents_as_tools_structured.py`)
- 並列エージェント実行
- 条件付きツール使用
- 入力/出力ガードレール
- 審判としての LLM
- 異なる挙動でツール使用を強制する (`examples/agent_patterns/forcing_tool_use.py`)
- 入力 / 出力ガードレール
- 審査者としての LLM
- ルーティング
- ストリーミングガードレール
- ツール承認と状態シリアライズを伴う Human-in-the-loop (`examples/agent_patterns/human_in_the_loop.py`)
- ストリーミングを伴う Human-in-the-loop (`examples/agent_patterns/human_in_the_loop_stream.py`)
- 承認フロー向けのカスタム拒否メッセージ (`examples/agent_patterns/human_in_the_loop_custom_rejection.py`)

- **[basic](https://github.com/openai/openai-agents-python/tree/main/examples/basic):**
これらのコード例では、 SDK の基礎的な機能を紹介しています。例:
これらのコード例では、次のような SDK の基本機能を紹介します。

- Hello world のコード例 (デフォルトモデル、 GPT-5 、 open-weight モデル)
- Hello world のコード例 (デフォルトモデル、 GPT-5、 open-weight モデル)
- エージェントライフサイクル管理
- Run hooks と agent hooks のライフサイクル例 (`examples/basic/lifecycle_example.py`)
- 動的システムプロンプト
- 基本的なツール使用 (`examples/basic/tools.py`)
- ツール入力 / 出力ガードレール (`examples/basic/tool_guardrails.py`)
- 画像ツール出力 (`examples/basic/image_tool_output.py`)
- ストリーミング出力 (テキスト、項目、関数呼び出し引数)
- ターン間で共有セッションヘルパーを使う Responses websocket トランスポート (`examples/basic/stream_ws.py`)
- 複数ターンで共有セッションヘルパーを使用する Responses websocket transport (`examples/basic/stream_ws.py`)
- プロンプトテンプレート
- ファイル処理 (ローカル/リモート、画像/PDF)
- 使用状況トラッキング
- Runner 管理のリトライ設定 (`examples/basic/retry.py`)
- サードパーティアダプターを介した Runner 管理のリトライ (`examples/basic/retry_litellm.py`)
- ファイル処理 (ローカルとリモート、画像と PDF)
- 使用状況追跡
- Runner 管理の再試行設定 (`examples/basic/retry.py`)
- サードパーティアダプター経由の Runner 管理再試行 (`examples/basic/retry_litellm.py`)
- 非 strict な出力型
- 前回レスポンス ID の使用
- 以前の response ID の使用

- **[customer_service](https://github.com/openai/openai-agents-python/tree/main/examples/customer_service):**
航空会社向けのカスタマーサービスシステムのコード例です。

- **[financial_research_agent](https://github.com/openai/openai-agents-python/tree/main/examples/financial_research_agent):**
金融データ分析のためのエージェントとツールを使った構造化リサーチワークフローを示す、金融リサーチエージェントです
金融データ分析のためのエージェントとツールを用いた、構造化された調査ワークフローを示す金融リサーチエージェントです

- **[handoffs](https://github.com/openai/openai-agents-python/tree/main/examples/handoffs):**
メッセージフィルタリングを伴うエージェントハンドオフの実践的なコード例をご覧ください。
メッセージフィルタリングを含む、エージェントのハンドオフの実践的なコード例です。

- メッセージフィルター例 (`examples/handoffs/message_filter.py`)
- ストリーミングを伴うメッセージフィルター (`examples/handoffs/message_filter_streaming.py`)

- **[hosted_mcp](https://github.com/openai/openai-agents-python/tree/main/examples/hosted_mcp):**
hosted MCP (Model Context Protocol) コネクターと承認の使い方を示すコード例です。
OpenAI Responses API で hosted MCP (Model Context Protocol) を使用する方法を示すコード例です。以下を含みます。

- 承認なしのシンプルな hosted MCP (`examples/hosted_mcp/simple.py`)
- Google Calendar などの MCP コネクター (`examples/hosted_mcp/connectors.py`)
- 割り込みベース承認を伴う Human-in-the-loop (`examples/hosted_mcp/human_in_the_loop.py`)
- MCP ツール呼び出しの on-approval コールバック (`examples/hosted_mcp/on_approval.py`)

- **[mcp](https://github.com/openai/openai-agents-python/tree/main/examples/mcp):**
MCP (Model Context Protocol) を使ってエージェントを構築する方法を学べます。内容:
以下を含め、 MCP (Model Context Protocol) でエージェントを構築する方法を学べます。

- ファイルシステムのコード例
- Filesystem のコード例
- Git のコード例
- MCP プロンプトサーバーのコード例
- MCP prompt server のコード例
- SSE (Server-Sent Events) のコード例
- ストリーミング可能な HTTP のコード例
- SSE リモートサーバー接続 (`examples/mcp/sse_remote_example`)
- Streamable HTTP のコード例
- Streamable HTTP リモート接続 (`examples/mcp/streamable_http_remote_example`)
- Streamable HTTP 向けカスタム HTTP client factory (`examples/mcp/streamablehttp_custom_client_example`)
- `MCPUtil.get_all_function_tools` による全 MCP ツールの事前取得 (`examples/mcp/get_all_mcp_tools_example`)
- FastAPI を使用した MCPServerManager (`examples/mcp/manager_example`)
- MCP ツールフィルタリング (`examples/mcp/tool_filter_example`)

- **[memory](https://github.com/openai/openai-agents-python/tree/main/examples/memory):**
エージェント向けのさまざまなメモリ実装のコード例です。内容:
エージェント向けのさまざまなメモリ実装のコード例です。以下を含みます。

- SQLite セッションストレージ
- 高度な SQLite セッションストレージ
- Redis セッションストレージ
- SQLAlchemy セッションストレージ
- Dapr ステートストアセッションストレージ
- Dapr state store セッションストレージ
- 暗号化セッションストレージ
- OpenAI Conversations セッションストレージ
- Responses compaction セッションストレージ
- `ModelSettings(store=False)` を使ったステートレスな Responses compaction (`examples/memory/compaction_session_stateless_example.py`)
- `ModelSettings(store=False)` を使用したステートレスな Responses compaction (`examples/memory/compaction_session_stateless_example.py`)
- ファイルベースのセッションストレージ (`examples/memory/file_session.py`)
- Human-in-the-loop を伴うファイルベースセッション (`examples/memory/file_hitl_example.py`)
- Human-in-the-loop を伴う SQLite インメモリセッション (`examples/memory/memory_session_hitl_example.py`)
- Human-in-the-loop を伴う OpenAI Conversations セッション (`examples/memory/openai_session_hitl_example.py`)
- セッションをまたぐ HITL 承認 / 拒否シナリオ (`examples/memory/hitl_session_scenario.py`)

- **[model_providers](https://github.com/openai/openai-agents-python/tree/main/examples/model_providers):**
カスタムプロバイダーやサードパーティアダプターを含め、 SDK で非 OpenAI モデルを使う方法を確認できます
カスタムプロバイダーやサードパーティアダプターを含め、 SDK で非 OpenAI モデルを使用する方法を確認できます

- **[realtime](https://github.com/openai/openai-agents-python/tree/main/examples/realtime):**
SDK を使ってリアルタイム体験を構築する方法を示すコード例です。内容:
SDK を使用してリアルタイム体験を構築する方法を示すコード例です。以下を含みます。

- 構造化テキストおよび画像メッセージを使った Web アプリケーションパターン
- 構造化されたテキストおよび画像メッセージによる Web アプリケーションパターン
- コマンドライン音声ループと再生処理
- WebSocket 経由の Twilio Media Streams 統合
- Realtime Calls API attach フローを使用した Twilio SIP 統合

- **[reasoning_content](https://github.com/openai/openai-agents-python/tree/main/examples/reasoning_content):**
reasoning content と structured outputs の扱い方を示すコード例です。
reasoning content の扱い方を示すコード例です。以下を含みます。

- Runner API、ストリーミング、非ストリーミングでの reasoning content (`examples/reasoning_content/runner_example.py`)
- OpenRouter 経由で OSS モデルを使用した reasoning content (`examples/reasoning_content/gpt_oss_stream.py`)
- 基本的な reasoning content のコード例 (`examples/reasoning_content/main.py`)

- **[research_bot](https://github.com/openai/openai-agents-python/tree/main/examples/research_bot):**
複雑なマルチエージェントのディープリサーチワークフローを示す、シンプルなディープリサーチクローンです。
複雑なマルチエージェント調査ワークフローを示す、シンプルなディープリサーチクローンです。

- **[tools](https://github.com/openai/openai-agents-python/tree/main/examples/tools):**
OpenAI がホストするツールと、次のような実験的な Codex ツール機能の実装方法を学べます。
以下のような OpenAI がホストするツールと実験的な Codex ツール機能の実装方法を学べます。

- Web 検索 とフィルター付き Web 検索
- ファイル検索
- Code Interpreter
- インラインスキル付き hosted container shell (`examples/tools/container_shell_inline_skill.py`)
- スキル参照付き hosted container shell (`examples/tools/container_shell_skill_reference.py`)
- ローカルスキル付きローカル shell (`examples/tools/local_shell_skill.py`)
- 名前空間と遅延ツールを使ったツール検索 (`examples/tools/tool_search.py`)
- Code interpreter
- ファイル編集と承認を伴う apply patch ツール (`examples/tools/apply_patch.py`)
- 承認コールバックを伴う shell ツール実行 (`examples/tools/shell.py`)
- Human-in-the-loop 割り込みベース承認を伴う shell ツール (`examples/tools/shell_human_in_the_loop.py`)
- インラインスキルを伴う hosted container shell (`examples/tools/container_shell_inline_skill.py`)
- スキル参照を伴う hosted container shell (`examples/tools/container_shell_skill_reference.py`)
- ローカルスキルを伴う local shell (`examples/tools/local_shell_skill.py`)
- 名前空間と遅延ツールを伴うツール検索 (`examples/tools/tool_search.py`)
- コンピュータ操作
- 画像生成
- 実験的な Codex ツールワークフロー (`examples/tools/codex.py`)
- 実験的な Codex 同一スレッドワークフロー (`examples/tools/codex_same_thread.py`)

- **[voice](https://github.com/openai/openai-agents-python/tree/main/examples/voice):**
ストリーミング音声のコード例を含む、 TTS / STT モデルを使用した音声エージェントのコード例をご覧ください
ストリーミング音声のコード例を含む、 TTS および STT モデルを使用した音声エージェントのコード例を確認できます
Loading