---
title: "Insert a synthetic user-question + AI-reply pair into chat history."
method: POST
path: "/chats/{session_id}/synth_message_pair"
tags: ["Chat"]
---

# Insert a synthetic user-question + AI-reply pair into chat history.

`POST /chats/{session_id}/synth_message_pair`

## Request

- Base URL: `https://h2ogpte.genai.h2o.ai/api/v1`
- URL: `https://h2ogpte.genai.h2o.ai/api/v1/chats/{session_id}/synth_message_pair`
- Auth: HTTP bearer
- TypeScript: <https://skmtc.dev/h2o/apis/h2ogpte-rest-api/docs/chats/:session_id/synth_message_pair/post.ts> (a function with typed inputs; its response is checked against the schema)

Used by slash-command flows (e.g. /schedule, /create-assistant) that
produce an LLM response outside the normal streaming pipeline and need
the resulting prompt/response pair to show up in the chat history on
reload. The pair is tagged with chat_message_meta(message_type="command_synth",
content=command_name) so UIs can identify these turns later.

## Path parameters

- `session_id` string, required

## Request body

- object
  - `user_prompt` string, required: The user-authored prompt (the question turn).
  - `ai_response` string, required: The LLM-generated response (the reply turn).
  - `command_name` string, required: Slash-command identifier (e.g. "schedule", "create-assistant").

## Response `201`

Pair inserted.

- object
  - `question_id` string: ID of the inserted question turn.
  - `reply_id` string: ID of the inserted reply turn.

## Other responses

- `400`: Bad request
- `401`: Unauthorized - Invalid or missing API key
- `404`: Chat session not found or not owned by the caller.
- `default`: Unexpected error

---

[API](https://skmtc.dev/h2o/apis/h2ogpte-rest-api.md) - [All operations](https://skmtc.dev/h2o/apis/h2ogpte-rest-api/llms.txt) - [OpenAPI document](https://skmtc.dev/h2o/apis/h2ogpte-rest-api/revisions/a82a117320f4?raw)
