> This is a page from the ElevenLabs documentation. For a complete page index, fetch https://elevenlabs.io/docs/llms.txt. For the full documentation in a single file, fetch https://elevenlabs.io/docs/llms-full.txt.

# チャットモード

> **Info**
>
> チャットモードでは、エージェントをチャットエージェントとして動作させられます。つまり、オーディオの入力／出力なしで
> テキストのみの会話を行えます。これは、チャットインターフェースの構築、エージェントのテスト、またはオーディオが
> 必要ない場合に便利です。

## 概要

チャットモードを有効にする主な方法は2つあります。

1. **エージェント設定**：API経由で作成する際に、エージェントをテキスト専用モードに設定
2. **実行時の上書き**：SDKの上書きを使用して、プログラムでテキスト専用の会話を強制

このガイドでは、両方のアプローチと、異なるSDKでチャットモードを実装する方法を説明します。

## テキスト専用エージェントの作成

エージェントをテキスト専用モードに設定すると、そのエージェントとのすべての会話でデフォルトになります。

#### ダッシュボードで更新

ダッシュボードでエージェントを開き、**Advanced**タブに移動して**Text only**トグルを有効にします。変更を保存してください。

#### CLIで更新

#### エージェント設定を取得

```bash
elevenlabs agents pull --agent "<agent-name>"
```

#### \`agent_configs/\<agent-name>.json\`を編集

`conversation_config.conversation.text_only`を設定します。

```json
{
  "conversation_config": {
    "conversation": {
      "text_only": true
    }
  }
}
```

#### 変更をプッシュ

```bash
elevenlabs agents push --agent "<agent-name>"
```

#### APIで更新

```python
from elevenlabs import ElevenLabs

elevenlabs = ElevenLabs()

elevenlabs.conversational_ai.agents.update(
    agent_id="agent_7101k5zvyjhmfg983brhmhkd98n6",
    conversation_config={
        "conversation": {"text_only": True},
    },
)
```

```typescript
import { ElevenLabsClient } from "@elevenlabs/elevenlabs-js";

const elevenlabs = new ElevenLabsClient();

await elevenlabs.conversationalAi.agents.update("agent_7101k5zvyjhmfg983brhmhkd98n6", {
  conversationConfig: {
    conversation: { textOnly: true },
  },
});
```

> **Info**
>
> 完全なAPIリファレンスと利用可能なすべての設定オプションについては、[Create Agent APIドキュメントの テキスト専用フィールド](/docs/ja/api-reference/agents/create#request.body.conversation_config.conversation.text_only)を参照してください。

## テキスト専用モードの実行時上書き

エージェントレベルで設定するのではなく、上書きを使用して実行時にチャットモードを有効にするには、会話設定で`textOnly`上書きを使用します。

```python
from elevenlabs.client import ElevenLabs
from elevenlabs.conversational_ai.conversation import Conversation, ConversationInitiationData

# Configure for text-only mode with proper structure
conversation_override = {
    "conversation": {
        "text_only": True
    }
}

config = ConversationInitiationData(
    conversation_config_override=conversation_override
)

conversation = Conversation(
    elevenlabs,
    agent_id,
    requires_auth=bool(api_key),
    config=config,
    # Important: Ensure agent_response callback is set
    callback_agent_response=lambda response: print(f"Agent: {response}"),
    callback_user_transcript=lambda transcript: print(f"User: {transcript}"),
)

conversation.start_session()
```

```javascript
const conversation = await Conversation.startSession({
  agentId: "<your-agent-id>",
  overrides: {
    conversation: {
      textOnly: true,
    },
  },
});
```

この設定により、以下が保証されます。

* オーディオ入力／出力を使用しない
* すべての通信がテキストメッセージで行われる
* 会話がチャットのようなインターフェースモードで動作する

## 重要な注意事項

> **Warning**
>
> **重要**：チャットモードを使用する場合は、`agent_response`イベント／コールバックが
> 有効化され、適切に設定されていることを確認する必要があります。これがない場合、エージェントのテキスト応答は送信も
> ユーザーへの表示もされません。

> **Info**
>
> **セキュリティ上書き**：実行時上書き（エージェントレベルの設定ではないもの）を使用する場合は、
> エージェントのセキュリティ設定で会話の上書きを有効にする必要があります。エージェントの
> **Security**タブに移動し、適切な上書きを有効にしてください。詳細は[上書きに関する ドキュメント](/docs/ja/eleven-agents/customization/personalization/overrides)を参照してください。

### 主な要件

1. **エージェント応答イベント**：エージェントのテキストメッセージを受信・表示するために、常に`agent_response`コールバックまたはイベントハンドラーを設定してください。

2. **エージェント設定**：エージェント設定でチャットモードを指定している場合、上書きを指定しなくても自動的にテキスト専用の会話が使用されます。

3. **オーディオインターフェースは不要**：テキスト専用モードでは、オーディオインターフェースの設定やマイク権限のリクエストは必要ありません。

### 例：エージェント応答の処理

```python
def handle_agent_response(response):
    """Critical handler for displaying agent messages"""
    print(f"Agent: {response}")  # Update your UI with the response
    update_chat_ui(response)

config = ConversationInitiationData(
    conversation_config_override={"conversation": {"text_only": True}}
)

conversation = Conversation(
  elevenlabs,
  agent_id,
  config=config,
  callback_agent_response=handle_agent_response,
)

conversation.start_session()
```

```javascript
const conversation = await Conversation.startSession({
  agentId: "<your-agent-id>",
  overrides: {
    conversation: {
      textOnly: true,
    },
  },
  // Critical: Handle agent responses
  onMessage: (message) => {
    if (message.type === "agent_response") {
      console.log("Agent:", message.text);
      // Display in your UI
      displayAgentMessage(message.text);
    }
  },
});
```

## テキストメッセージの送信

チャットモードでは、オーディオではなくプログラムでユーザーメッセージを送信する必要があります。

```python
# Send a text message to the agent
conversation.send_user_message("Hello, how can you help me today?")
```

```javascript
// Send a text message to the agent
conversation.sendUserMessage({
  text: "Hello, how can you help me today?",
});
```

## 同時実行のメリット

チャットモードは、音声会話と比較して大きな同時実行上のメリットがあります。

* **より高い上限**：チャット専用会話の同時実行上限は、音声会話の25倍です
* **独立したプール**：テキスト会話は、音声会話の上限とは独立した専用の同時実行プールを使用します
* **スケーラビリティ**：カスタマーサポート、チャットボット、自動テストなど、高スループットのアプリケーションに最適です

| プラン      | 音声の同時実行数 | チャット専用の同時実行数 |
| -------- | -------- | ------------ |
| 無料       | 4        | 100          |
| スターター    | 6        | 150          |
| クリエイター   | 10       | 250          |
| プロ       | 20       | 500          |
| スケール     | 30       | 750          |
| ビジネス     | 30       | 750          |
| エンタープライズ | 拡張       | 拡張（25倍）      |

> **Note**
>
> 接続開始時には、チャット専用会話はハンドシェイク処理中にまず合計同時実行上限に対して確認され、接続が確立されると
> 別のチャット専用同時実行プールに移されます。

## ユースケース

チャットモードは、以下の用途に最適です。

* **チャットインターフェース**：音声を使用しない従来型のチャットUIの構築
* **テスト**：オーディオ依存なしでエージェントロジックをテスト
* **アクセシビリティ**：ユーザーにテキストベースの代替手段を提供
* **静かな環境**：オーディオ入力／出力が適さない場合
* **統合テスト**：エージェント会話の自動テスト

## トラブルシューティング

### エージェントが応答しない

エージェントの応答が表示されない場合：

1. `agent_response`コールバックが適切に設定されていることを確認します。
2. エージェントがチャットモードに設定されているか、`textOnly`上書きが設定されていることを確認します。
3. WebSocket接続が正常に確立されていることを確認します。

## 次のステップ

* [エージェントの動作をカスタマイズする](/docs/ja/eleven-agents/customization/llm)
* 高度なインタラクションのための[クライアントイベント](/docs/ja/eleven-agents/customization/events/client-events)を確認する
* 安全な会話のための[認証設定](/docs/ja/eleven-agents/customization/authentication)を確認する