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.
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: 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
- 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)