This document describes the native OpenWebUI citation support in the Azure AI Foundry Pipeline, which enables rich citation cards and source previews in the OpenWebUI frontend.
The Azure AI Foundry Pipeline supports native OpenWebUI citations for Azure AI Search (RAG) responses. This feature is automatically enabled when you configure Azure AI Search data sources (AZURE_AI_DATA_SOURCES). The OpenWebUI frontend will display:
- Citation cards with source information and relevance scores
- Source previews with content snippets
- Relevance percentage displayed on citation cards (requires
AZURE_AI_INCLUDE_SEARCH_SCORES=true) - Clickable
[docX]references that link directly to document URLs - Interactive citation UI with expandable source details
When Azure AI Search is configured, the pipeline automatically:
- Emits citation events via
__event_emitter__for the OpenWebUI frontend - Converts
[docX]references in the response to clickable markdown links - Filters citations to only show documents actually referenced in the response
- Extracts relevance scores from Azure Search when available
| Environment Variable | Default | Description |
|---|---|---|
AZURE_AI_DATA_SOURCES |
"" |
JSON configuration for Azure AI Search (required for citations) |
AZURE_AI_INCLUDE_SEARCH_SCORES |
true |
Enable relevance score extraction from Azure Search |
When Azure AI Search returns citations in a streaming response:
- The pipeline detects citations in the SSE (Server-Sent Events) stream
[docX]references in each chunk are converted to markdown links with document URLs- After the stream ends, citation events are emitted via
__event_emitter__ - Citations are filtered to only include documents referenced in the response
When Azure AI Search returns citations in a non-streaming response:
- The pipeline extracts citations from the response context
[docX]references in the content are converted to markdown links- Individual citation events are emitted via
__event_emitter__for each referenced source
Each citation is emitted as a separate event to ensure all sources appear in the UI. Citation events follow the official OpenWebUI specification (see OpenWebUI Events Documentation):
{
"type": "citation",
"data": {
"document": ["Document content..."], # Content from this citation
"metadata": [{"source": "https://..."}], # Metadata with source URL
"source": {
"name": "[doc1] Document Title", # Unique name with index
"url": "https://..." # Source URL if available
},
"distances": [0.95] # Relevance score (displayed as percentage)
}
}Key points:
- Each source document gets its own citation event
- The
source.nameincludes the doc index ([doc1],[doc2], etc.) to prevent grouping - The
distancesarray contains relevance scores from Azure AI Search, which OpenWebUI displays as a percentage on the citation cards
Azure AI Search returns citations in this format:
{
"title": "Document Title",
"content": "Full or partial content",
"url": "https://...",
"filepath": "/path/to/file",
"chunk_id": "chunk-123",
"score": 0.95,
"metadata": {}
}The pipeline automatically converts Azure citations to OpenWebUI format.
Configure Azure AI Search to enable citation support:
# Azure AI Search configuration (required for citations)
AZURE_AI_DATA_SOURCES='[{"type":"azure_search","parameters":{"endpoint":"https://YOUR-SEARCH-SERVICE.search.windows.net","index_name":"YOUR-INDEX-NAME","authentication":{"type":"api_key","key":"YOUR-SEARCH-API-KEY"}}}]'
# Enable relevance scores (default: true)
AZURE_AI_INCLUDE_SEARCH_SCORES=trueThe pipeline automatically converts [docX] references to clickable markdown links:
# Input from Azure AI
The answer can be found in [doc1] and [doc2].
# Output (converted by pipeline)
The answer can be found in [[doc1]](https://example.com/doc1.pdf) and [[doc2]](https://example.com/doc2.pdf).This works for both streaming and non-streaming responses.
When AZURE_AI_INCLUDE_SEARCH_SCORES=true (default), the pipeline:
- Automatically adds
include_contexts: ["citations", "all_retrieved_documents"]to Azure Search requests - Extracts scores based on the
filter_reasonfield:filter_reason="rerank"→ usesrerank_scorefilter_reason="score"or not present → usesoriginal_search_score
- Displays the score as a percentage on citation cards
The pipeline includes these helper functions for citation processing:
_extract_citations_from_response(): Extracts citations from Azure responses_normalize_citation_for_openwebui(): Converts Azure citations to OpenWebUI format_emit_openwebui_citation_events(): Emits citation events via__event_emitter___merge_score_data(): Matches citations with score data fromall_retrieved_documents_build_citation_urls_map(): Builds mapping of citation indices to URLs_format_citation_link(): Creates markdown links for[docX]references_convert_doc_refs_to_links(): Converts all[docX]references in content to markdown links
The pipeline uses intelligent title fallback:
- Use
titlefield if available - Fallback to filename extracted from
filepathorurl - Fallback to
"Unknown Document"if all are empty
This ensures every citation has a meaningful display name.
Citations are filtered to only show documents that are actually referenced in the response content. For example, if Azure returns 5 citations but the response only references [doc1] and [doc3], only those 2 citations will appear in the UI.
For citations to work correctly, your Azure AI Search index must contain the right fields with the right attributes. This section explains exactly which fields the pipeline reads and how they map to citation cards in OpenWebUI.
| Index Field | Type | Required? | Must Be Retrievable? | Citation Purpose |
|---|---|---|---|---|
content |
Edm.String |
Yes | Yes | Provides the text snippet shown in the citation preview |
title |
Edm.String |
Recommended | Yes | Displayed as the citation card title |
filepath |
Edm.String |
Recommended | Yes | Used as the citation name in the response; fallback for title |
url |
Edm.String |
Recommended | Yes | Makes [docX] references into clickable links |
chunk_id |
Edm.String |
Optional | Yes | Helps match citations with relevance scores |
contentVector |
Collection(Edm.Single) |
For vector search | N/A | Enables vector/hybrid search |
Key point: The
title,filepath, andurlfields must be marked as retrievable in your index schema. If they are not retrievable, Azure will not include them in the citation response, and the pipeline cannot display them.
The pipeline determines each citation's display title using this fallback chain:
titlefield → if present and non-emptyfilepathfield → if title is emptyurlfield → if both title and filepath are empty"Unknown Document"→ if all are empty
To avoid seeing "Unknown Document", ensure at least one of title, filepath, or url is populated in your index documents.
If your index uses different field names (e.g., body instead of content, or doc_title instead of title), you must tell Azure OpenAI how to map them using the fields_mapping parameter in your AZURE_AI_DATA_SOURCES configuration.
fields_mapping properties:
| Property | Type | Maps To |
|---|---|---|
content_fields |
string[] |
The index fields to use as document content |
title_field |
string |
The index field to use as the document title |
filepath_field |
string |
The index field to use as the file path/name |
url_field |
string |
The index field to use as the document URL |
vector_fields |
string[] |
The index fields containing vector embeddings |
content_fields_separator |
string |
Separator pattern between content fields (default: \n) |
Example with custom field names:
[
{
"type": "azure_search",
"parameters": {
"endpoint": "https://my-search.search.windows.net",
"index_name": "my-custom-index",
"authentication": {
"type": "api_key",
"key": "YOUR-SEARCH-API-KEY"
},
"fields_mapping": {
"content_fields": ["body", "summary"],
"title_field": "doc_title",
"filepath_field": "source_file",
"url_field": "source_url",
"vector_fields": ["embedding"]
}
}
}
]If you are creating a new index manually, here is a minimal schema that supports all citation features:
{
"name": "my-docs-index",
"fields": [
{ "name": "id", "type": "Edm.String", "key": true, "filterable": true },
{ "name": "content", "type": "Edm.String", "searchable": true, "retrievable": true },
{ "name": "title", "type": "Edm.String", "searchable": true, "retrievable": true, "filterable": true },
{ "name": "filepath", "type": "Edm.String", "retrievable": true, "filterable": true },
{ "name": "url", "type": "Edm.String", "retrievable": true },
{ "name": "chunk_id", "type": "Edm.String", "retrievable": true, "filterable": true }
]
}For vector/hybrid search, add a vector field:
{ "name": "contentVector", "type": "Collection(Edm.Single)", "searchable": true, "dimensions": 1536, "vectorSearchProfile": "my-vector-profile" }If you index documents from Azure Blob Storage using an indexer, you need to map blob metadata to your index fields. Common blob metadata fields:
| Blob Metadata Field | Description | Typical Index Mapping |
|---|---|---|
metadata_storage_name |
Blob filename (e.g., report.pdf) |
title |
metadata_storage_path |
Full blob URL (e.g., https://account.blob.core.windows.net/container/file.pdf) |
filepath and url |
metadata_storage_last_modified |
Last modified timestamp | last_modified (optional, useful for sorting) |
metadata_storage_content_type |
MIME type | (optional, useful for filtering) |
content |
Extracted text from the document | content (auto-mapped if names match) |
Example indexer with field mappings:
{
"name": "my-blob-indexer",
"dataSourceName": "my-blob-datasource",
"targetIndexName": "my-docs-index",
"fieldMappings": [
{
"sourceFieldName": "metadata_storage_name",
"targetFieldName": "title"
},
{
"sourceFieldName": "metadata_storage_path",
"targetFieldName": "filepath"
},
{
"sourceFieldName": "metadata_storage_path",
"targetFieldName": "url"
},
{
"sourceFieldName": "metadata_storage_last_modified",
"targetFieldName": "last_modified"
}
],
"parameters": {
"configuration": {
"dataToExtract": "contentAndMetadata"
}
}
}Note: The
contentfield is automatically mapped when the source and target field names match. The blob indexer also automatically mapsmetadata_storage_path(base64-encoded) to theidkey field — no explicit mapping is needed forid. Mappingmetadata_storage_name→titlegives citation cards a readable name from the blob filename.
When Azure OpenAI returns a response with citations, each citation object looks like this:
{
"title": "Architecture Overview",
"content": "The system uses a microservices architecture...",
"url": "https://storageaccount.blob.core.windows.net/docs/architecture.pdf",
"filepath": "architecture.pdf",
"chunk_id": "0",
"original_search_score": 12.5,
"rerank_score": 3.2,
"filter_reason": "rerank"
}The pipeline maps these fields to the OpenWebUI citation event:
| Azure Citation Field | OpenWebUI Citation Property | Display |
|---|---|---|
title |
source.name |
[doc1] - Architecture Overview |
content |
document[0] |
Preview text in citation card |
url / filepath |
source.url |
Clickable link |
rerank_score / original_search_score |
distances[0] |
Relevance percentage |
Problem: Citations don't appear in the OpenWebUI frontend
Solutions:
- Check that Azure AI Search is properly configured (
AZURE_AI_DATA_SOURCES) - Ensure you're using an Azure OpenAI endpoint (not a generic Azure AI endpoint)
- Verify the response contains
[docX]references - Check browser console and server logs for errors
Problem: Citation cards display "Unknown Document" instead of a meaningful title
Solutions:
- Verify your index has
title,filepath, orurlfields and that they are marked as retrievable - If using custom field names, add
fields_mappingwithtitle_field,filepath_field, andurl_fieldto yourAZURE_AI_DATA_SOURCESJSON - Verify the fields are actually populated in your indexed documents (empty fields cause fallback to "Unknown Document")
Problem: [docX] references appear as plain text, not clickable links
Solutions:
- Your index needs a
urlfield (or mappedurl_field) that contains valid URLs - If your index stores URLs in a field with a different name, map it using
"url_field": "your_field_name"infields_mapping - Verify that the
urlfield is marked as retrievable in your index schema
Problem: All citation cards show 0% relevance
Solutions:
- Verify
AZURE_AI_INCLUDE_SEARCH_SCORES=trueis set - Check that your Azure Search index supports scoring
- Enable DEBUG logging to see the raw score values from Azure
Problem: [docX] references are not clickable
Solutions:
- Ensure citations have valid
urlorfilepathfields - Check that the document URL is accessible
- Verify the markdown link format is being generated correctly
- OpenWebUI Pipelines Citation Feature Discussion
- OpenWebUI Event Emitter Documentation
- Azure AI Search Documentation
- Azure On Your Data API Reference
- Azure Search Fields Mapping Options
- Azure AI Search Indexer Field Mappings
- Azure OpenAI On Your Data - Index Field Mapping
- v2.6.0: Major refactor - removed
AZURE_AI_ENHANCE_CITATIONSandAZURE_AI_OPENWEBUI_CITATIONSvalves; citation support is now always enabled whenAZURE_AI_DATA_SOURCESis configured; added clickable[docX]markdown links; improved score extraction usingfilter_reasonfield - v2.5.x: Dual citation modes (OpenWebUI events + markdown/HTML)