> For the complete documentation index, see [llms.txt](https://docs.maiagent.ai/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.maiagent.ai/tech/maiagent-tech-ja/api-integration/dui-hua-yu-xun-xi-hui-fu-chuan-liu-tong-bu.md).

# 会話とメッセージ応答（ストリーミング／同期）

AI アシスタントにメッセージを送信し、応答を取得します。

```bash
curl -X POST \
  'https://api.maiagent.ai/api/v1/chatbots/{chatbot_id}/completions/' \
  -H 'Authorization: Api-Key YOUR_API_KEY' \
  -H 'Content-Type: application/json' \
  -d '{
    "conversation": "string|null",
    "message": {
      "content": "string",
      "attachments": []
    },
    "is_streaming": boolean
  }'
```

**パラメータ:**

* `chatbot_id`（パスパラメータ）: チャットボット ID
* `conversation`（リクエストボディ）: 会話を継続するために使用する、任意指定の会話 ID
* `message.content`（リクエストボディ）: 送信するメッセージの内容
* `message.attachments`（リクエストボディ）: 添付ファイルの配列（ある場合）
* `is_streaming`（リクエストボディ）: ストリーミング応答を使用するかどうか

**応答（非ストリーミング）:**

```json
{
  "content": "string",
  "conversationId": "string"
}
```

**応答（ストリーミング）:**

サーバー送信イベントの形式は以下のとおりです。

```
data: {
  "content": "string",
  "conversation_id": "string",
  "done": boolean
}
```

注意事項:

* ストリーミング応答の場合、サーバーは応答が完了するまで、部分的な内容を含む複数のイベントを送信します
* 応答で返される会話 ID は、後続のリクエストで会話を継続するために使用できます

## 連携の成果

{% embed url="<https://drive.google.com/file/d/1sCIoxxASZ-SnHPAmkjDT270B3dz0LyHo/view?usp=sharing>" %}


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter, and the optional `goal` query parameter:

```
GET https://docs.maiagent.ai/tech/maiagent-tech-ja/api-integration/dui-hua-yu-xun-xi-hui-fu-chuan-liu-tong-bu.md?ask=<question>&goal=<endgoal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
