When you enable the rich text feature, answers from large language models (LLMs) can include images, tables, and code blocks extracted from your source documents—not just plain text.
How it works
During indexing, the RAG pipeline extracts rich text elements (images, tables, and code) from each document and saves them as rich text tags alongside the corresponding text chunks. When a query is submitted through the SearchKnowledge API:
-
Open Search retrieves the relevant chunks, including any embedded rich text tags.
-
The LLM generates an answer using the retrieved chunks. Rich text tags are preserved in the answer.
-
Depending on the
rich_text_strategyvalue you set, Open Search either renders the tags inline (Markdown) or returns the raw content separately for your app to render.
Enable the rich text feature
Set the rich_text_strategy parameter on the Other Parameters tab of the Q&A Test page. Leave the field blank to disable rich text.
The rich_text_strategy drop-down list provides two options: inside_response (embeds rich text content inline in the response body) and extend_response (returns rich text content as an extension).
Thedataarray in the response may include items with"type": "IMAGE". These are image results from the retrieval phase—not output from the rich text feature. Rich-text-generated images appear indata.answer(forinside_response) or indata.rich_text_ref(forextend_response), and have better contextual relevance than retrieval-phase images.
Choose a strategy
The rich_text_strategy parameter accepts two values. Choose based on how your app renders content:
| Strategy | Response format | Rich text delivery | Best for |
|---|---|---|---|
inside_response |
Markdown | Inline in data.answer |
Apps that render Markdown natively |
extend_response |
Plain text | Separately in data.rich_text_ref |
Apps with custom rendering logic |
Configure the parameter
Add rich_text_strategy to the options.chat object in your SearchKnowledge API request:
{
"question": {
"text": "How do I configure a sensitive data identification rule?",
"type": "TEXT"
},
"options": {
"chat": {
"rich_text_strategy": "inside_response"
}
}
}
API parameter reference
This parameter belongs to the SearchKnowledge API operation.
| Parameter | Type | Required | Description |
|---|---|---|---|
options.chat.rich_text_strategy |
String | No | The rich text processing strategy. If absent or blank, rich text is disabled and the default processing method is used. Valid values: inside_response, extend_response. |
Parse the response
inside_response
Parse data.answer as Markdown. Rich text tags are resolved inline—tables appear as HTML within the Markdown. Ignore the rich_text_ref field.
extend_response
Parse data.answer as plain text. The answer contains rich text placeholders in the format [^<id>^]. Look up each placeholder ID in the data.rich_text_ref array and replace it with the corresponding content.