---
title: "Regenerate AI response"
method: POST
path: "/conversations/{conversationId}/message/{messageId}/regenerate"
tags: ["Conversations"]
---

# Regenerate AI response

`POST /conversations/{conversationId}/message/{messageId}/regenerate`

Regenerate the AI response for a specific message and stream the new
answer over Server-Sent Events.

**Overview:**

If you're not satisfied with an AI response, use this endpoint to generate
a new answer. The original user query is re-processed and a new bot
response replaces the previous one in place.

**Constraints:**

- Only the *last* message of the conversation can be regenerated.
- The target message must be of type `bot_response`.

**Use Cases:**

- Response was incomplete or unclear
- Want to try a different AI model
- New documents have been indexed since original response

**Model Override:**

Specify `modelKey` to use a different model for regeneration.

**Streaming:**

The response is delivered as an AG-UI `text/event-stream` stream.
Routing still depends on `chatMode`: `internal_search` and
`web_search` use the assistant backend, while `agent` uses the
universal agent loop. See `SSEEvent` for the event vocabulary.

## Path parameters

- `conversationId` string, objectId, required
- `messageId` string, objectId, required

## Request body

- RegenerateRequest — Request body for regenerating an AI response. All fields are optional; when omitted the model selection and execution context from the original message are reused. Supported fields: - `filters` — optional `{ apps?, kb? }` filter object - `chatMode` — optional non-empty chat mode string - `modelKey`, `modelName`, `modelFriendlyName` — optional non-empty model override fields - `timezone` — optional non-empty client timezone string - `currentTime` — optional ISO 8601 / RFC 3339 datetime string with UTC `Z` or a numeric offset - `tools` — optional array of non-empty tool identifiers - `protocol` — optional inert compatibility field; when present it must be `agui`, which is also the protocol used when the field is omitted - `agentCapabilities` — optional per-request agent capability toggles
  - `filters` Filters — App connector instance ids and knowledge-base / record-group ids that narrow retrieval for a turn. For **org assistant** chat streams, send explicit `apps` / `kb` lists. For **agent** chat streams, send explicit id lists, or **omit** `filters` (and `tools`) to let the service use the agent’s stored knowledge and tool configuration. Sending `{ "apps": [], "kb": [] }` on an agent stream means **no** knowledge sources for that turn (it is not “full org default”).
    - `apps` string[] — Connector instance ids to scope retrieval for this turn. Each element must be a valid UUID (connector app id, KB app id, record-group id, etc.). Gateway validation matches Zod `appOrKbIdSchema`.
    - `kb` string[] — Knowledge-base app ids to scope retrieval for this turn. Each element must be a valid UUID.
  - `modelKey` string — Identifier of the AI model configuration to use for regeneration. Typically a UUID returned by the model-management endpoints. When omitted, the model used for the original message is reused.
  - `modelName` string — Provider model name (e.g. the underlying LLM identifier).
  - `modelFriendlyName` string — Friendly display name of the selected model.
  - `chatMode` string — Chat mode used for regeneration (for example `internal_search`, `web_search`, or the universal `agent` mode).
  - `timezone` string — IANA timezone identifier from the client. Used to provide time-aware context to the AI during regeneration.
  - `currentTime` string, date-time — ISO 8601 / RFC 3339 datetime from the client (UTC `Z` or numeric offset). Used to anchor any relative time references in the query.
  - `tools` string[] — Optional list of tool identifiers (fully-qualified action names such as `jira.create_issue`) the agent may invoke when regenerating. Applicable only in agent chat modes.
  - `protocol` 'agui' — AG-UI is the only supported wire protocol. When present must be `"agui"`. Omitting the field is equivalent — the server always uses the AG-UI vocabulary. Kept in the schema for backward compatibility with callers that already send it.
  - `agentCapabilities` AgentCapabilities — Per-request agent capability toggles. Only meaningful when `chatMode` selects an agent mode; ignored otherwise. Each field falls back to its own `default` below when omitted — a missing flag is not uniformly `true`. Omitting the whole object applies every default.
    - `internalSearch` boolean — Whether the agent may search internal knowledge bases for this turn.
    - `webSearch` boolean — Whether the agent may perform web search for this turn.
    - `deepSearch` boolean — Whether the agent may use deeper, higher-latency retrieval for this turn.

## Response `200`

SSE stream established. The body is a sequence of
`text/event-stream` frames using the event vocabulary described
on `SSEEvent`. The exact subset of events emitted depends on
`chatMode` (see the route description for routing rules).

The gateway emits a root `RUN_FINISHED` as `{ type, result }`
after persistence and a root `RUN_ERROR` as
`{ type, message, code? }` on failure. Forwarded lifecycle and
child-run events may contain `runId`, `threadId`, and
`parentRunId`. Clients should ignore unknown event names.

## Other responses

- `400` — Cannot regenerate. Common causes: target message is not the last message in the conversation, target message is not of type `bot_response`, or no preceding `user_query` exists.
- `401` — Unauthorized
- `404` — Conversation or message not found

---

[API](https://skmtc.net/pipeshub-ai/apis/pipeshub-api.md) · [All operations](https://skmtc.net/pipeshub-ai/apis/pipeshub-api/llms.txt) · [OpenAPI document](https://skmtc-service-staging.skmtc.workers.dev/v1/apis/pipeshub-ai/pipeshub-api/revisions/11f5086fcbb8/schema)
