<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Re: Genie Agent response Export to PDF via API in Generative AI</title>
    <link>https://community.databricks.com/t5/generative-ai/genie-agent-response-export-to-pdf-via-api/m-p/167941#M2062</link>
    <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://community.databricks.com/t5/user/viewprofilepage/user-id/179874"&gt;@GunaR&lt;/a&gt;,&lt;/P&gt;
&lt;P&gt;You are right. There is no API endpoint to export an Agent mode response as a PDF. The "Download PDF" button is a UI-only feature. But since the Agent Mode API provides a fully structured response, you can generate the PDF yourself on the client side.&lt;/P&gt;
&lt;P&gt;When the SSE stream completes, the &lt;EM&gt;response.completed&lt;/EM&gt;&amp;nbsp;event contains all output items. The final report lives in the &lt;EM&gt;message&lt;/EM&gt; out&lt;SPAN&gt;put item. You can also retrieve it after the fact using the&amp;nbsp;&lt;A class="du-bois-light-typography css-1zhnxz" role="link" href="https://docs.databricks.com/aws/en/genie-agents/api" rel="noopener noreferrer" data-component-type="typography_link" data-component-id="codegen_webapp_js_genai_util_markdown.tsx_71" aria-disabled="false" target="_blank"&gt;List conversation items&amp;nbsp;&lt;/A&gt;endpoint:&lt;/SPAN&gt;&lt;/P&gt;
&lt;LI-CODE lang="markup"&gt;GET /api/2.0/genie/agents/{agent_id}/conversations/{conversation_id}/items
&lt;/LI-CODE&gt;
&lt;P&gt;Loop through the output and grab the&amp;nbsp;&lt;EM&gt;message&lt;/EM&gt;&amp;nbsp;type item, that's your report text.&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;Once you have the report content, convert it to PDF using a Python&lt;/SPAN&gt; library.weasyprint&amp;nbsp;works well for this because the report is essentially markdown that you can render through HTML:&lt;/P&gt;
&lt;LI-CODE lang="python"&gt;import markdown
from weasyprint import HTML

html = markdown.markdown(report_text, extensions=['tables'])
HTML(string=f"&amp;lt;html&amp;gt;&amp;lt;body&amp;gt;{html}&amp;lt;/body&amp;gt;&amp;lt;/html&amp;gt;").write_pdf("report.pdf")&lt;/LI-CODE&gt;
&lt;P&gt;&lt;SPAN&gt;If you want something lighter with no system dependencies,&amp;nbsp;&lt;/SPAN&gt;&lt;EM&gt;fpdf2&lt;/EM&gt;&lt;SPAN&gt;&amp;nbsp;is a good alternative.&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;From there, attach the generated file and send it using&lt;/SPAN&gt;&amp;nbsp;smtplib, Se&lt;SPAN&gt;ndGrid, or whatever email service you already use.&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;Just remember that&amp;nbsp;if you s&lt;/SPAN&gt;et &lt;EM&gt;enable_viz:&lt;/EM&gt; &lt;EM&gt;true&lt;/EM&gt; in your request, the API returns visualisation specs but not rendered images. You would need to render those separately (for example with matplotlib or plotly) before embedding them in the PDF.&lt;/P&gt;
&lt;P&gt;Hope this helps.&lt;/P&gt;
&lt;P class="p1"&gt;&lt;FONT size="2" color="#FF6600"&gt;&lt;STRONG&gt;&lt;I&gt;If this answer resolves your question, could you mark it as “Accept as Solution”? That helps other users quickly find the correct fix.&lt;/I&gt;&lt;/STRONG&gt;&lt;/FONT&gt;&lt;I&gt;&lt;/I&gt;&lt;/P&gt;</description>
    <pubDate>Tue, 08 Sep 2026 13:08:10 GMT</pubDate>
    <dc:creator>Ashwin_DSA</dc:creator>
    <dc:date>2026-09-08T13:08:10Z</dc:date>
    <item>
      <title>Genie Agent response Export to PDF via API</title>
      <link>https://community.databricks.com/t5/generative-ai/genie-agent-response-export-to-pdf-via-api/m-p/167892#M2061</link>
      <description>&lt;P&gt;Hello,&lt;/P&gt;&lt;P&gt;Got a need to invoke the Genie Agent chat (in agent mode) via API, and on the request completion, export the agent response in PDF and share the exported PDF in email.&amp;nbsp;&amp;nbsp;&lt;BR /&gt;&lt;SPAN&gt;&lt;BR /&gt;Am already using 'Agent Mode Create Response' endpoint to invoke the chat programmatically.&amp;nbsp;&lt;/SPAN&gt;&lt;SPAN&gt;&lt;A href="https://docs.databricks.com/api/genie/v1/agent-mode-create-response" target="_blank"&gt;https://docs.databricks.com/api/genie/v1/agent-mode-create-response&lt;/A&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;What's the best way to export the response in PDF? I know there is no explicit endpoint to achieve the same.&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks,&lt;BR /&gt;Guna.&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 08 Sep 2026 09:39:19 GMT</pubDate>
      <guid>https://community.databricks.com/t5/generative-ai/genie-agent-response-export-to-pdf-via-api/m-p/167892#M2061</guid>
      <dc:creator>GunaR</dc:creator>
      <dc:date>2026-09-08T09:39:19Z</dc:date>
    </item>
    <item>
      <title>Re: Genie Agent response Export to PDF via API</title>
      <link>https://community.databricks.com/t5/generative-ai/genie-agent-response-export-to-pdf-via-api/m-p/167941#M2062</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://community.databricks.com/t5/user/viewprofilepage/user-id/179874"&gt;@GunaR&lt;/a&gt;,&lt;/P&gt;
&lt;P&gt;You are right. There is no API endpoint to export an Agent mode response as a PDF. The "Download PDF" button is a UI-only feature. But since the Agent Mode API provides a fully structured response, you can generate the PDF yourself on the client side.&lt;/P&gt;
&lt;P&gt;When the SSE stream completes, the &lt;EM&gt;response.completed&lt;/EM&gt;&amp;nbsp;event contains all output items. The final report lives in the &lt;EM&gt;message&lt;/EM&gt; out&lt;SPAN&gt;put item. You can also retrieve it after the fact using the&amp;nbsp;&lt;A class="du-bois-light-typography css-1zhnxz" role="link" href="https://docs.databricks.com/aws/en/genie-agents/api" rel="noopener noreferrer" data-component-type="typography_link" data-component-id="codegen_webapp_js_genai_util_markdown.tsx_71" aria-disabled="false" target="_blank"&gt;List conversation items&amp;nbsp;&lt;/A&gt;endpoint:&lt;/SPAN&gt;&lt;/P&gt;
&lt;LI-CODE lang="markup"&gt;GET /api/2.0/genie/agents/{agent_id}/conversations/{conversation_id}/items
&lt;/LI-CODE&gt;
&lt;P&gt;Loop through the output and grab the&amp;nbsp;&lt;EM&gt;message&lt;/EM&gt;&amp;nbsp;type item, that's your report text.&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;Once you have the report content, convert it to PDF using a Python&lt;/SPAN&gt; library.weasyprint&amp;nbsp;works well for this because the report is essentially markdown that you can render through HTML:&lt;/P&gt;
&lt;LI-CODE lang="python"&gt;import markdown
from weasyprint import HTML

html = markdown.markdown(report_text, extensions=['tables'])
HTML(string=f"&amp;lt;html&amp;gt;&amp;lt;body&amp;gt;{html}&amp;lt;/body&amp;gt;&amp;lt;/html&amp;gt;").write_pdf("report.pdf")&lt;/LI-CODE&gt;
&lt;P&gt;&lt;SPAN&gt;If you want something lighter with no system dependencies,&amp;nbsp;&lt;/SPAN&gt;&lt;EM&gt;fpdf2&lt;/EM&gt;&lt;SPAN&gt;&amp;nbsp;is a good alternative.&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;From there, attach the generated file and send it using&lt;/SPAN&gt;&amp;nbsp;smtplib, Se&lt;SPAN&gt;ndGrid, or whatever email service you already use.&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;Just remember that&amp;nbsp;if you s&lt;/SPAN&gt;et &lt;EM&gt;enable_viz:&lt;/EM&gt; &lt;EM&gt;true&lt;/EM&gt; in your request, the API returns visualisation specs but not rendered images. You would need to render those separately (for example with matplotlib or plotly) before embedding them in the PDF.&lt;/P&gt;
&lt;P&gt;Hope this helps.&lt;/P&gt;
&lt;P class="p1"&gt;&lt;FONT size="2" color="#FF6600"&gt;&lt;STRONG&gt;&lt;I&gt;If this answer resolves your question, could you mark it as “Accept as Solution”? That helps other users quickly find the correct fix.&lt;/I&gt;&lt;/STRONG&gt;&lt;/FONT&gt;&lt;I&gt;&lt;/I&gt;&lt;/P&gt;</description>
      <pubDate>Tue, 08 Sep 2026 13:08:10 GMT</pubDate>
      <guid>https://community.databricks.com/t5/generative-ai/genie-agent-response-export-to-pdf-via-api/m-p/167941#M2062</guid>
      <dc:creator>Ashwin_DSA</dc:creator>
      <dc:date>2026-09-08T13:08:10Z</dc:date>
    </item>
    <item>
      <title>Re: Genie Agent response Export to PDF via API</title>
      <link>https://community.databricks.com/t5/generative-ai/genie-agent-response-export-to-pdf-via-api/m-p/167951#M2063</link>
      <description>&lt;P&gt;&lt;a href="https://community.databricks.com/t5/user/viewprofilepage/user-id/179874"&gt;@GunaR&lt;/a&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Adding to the above mentioned from&amp;nbsp;&lt;a href="https://community.databricks.com/t5/user/viewprofilepage/user-id/216690"&gt;@Ashwin_DSA&lt;/a&gt;,&amp;nbsp;I tested this from Databricks and can confirm the client side PDF approach works.&lt;/P&gt;&lt;P&gt;A couple of useful observations from the test:&lt;/P&gt;&lt;UL&gt;&lt;LI&gt;The completed Agent response can be extracted from the assistant message / output_text.&lt;/LI&gt;&lt;LI&gt;The returned report is already Markdown-like, including headings, bullets, inline code and source citation links.&lt;/LI&gt;&lt;LI&gt;Converting that Markdown → HTML → PDF with weasyprint preserved the formatting and clickable source links in my test.&lt;/LI&gt;&lt;LI&gt;One small issue I encountered was UTF-8 rendering (€, en-dash, etc.). Normalizing the response text and including &amp;lt;meta charset="utf-8"&amp;gt; fixed it.&lt;/LI&gt;&lt;/UL&gt;&lt;LI-CODE lang="markup"&gt;html_body = markdown.markdown(report_text, extensions=["tables"])

HTML(
    string=f"""
    &amp;lt;html&amp;gt;
      &amp;lt;head&amp;gt;&amp;lt;meta charset="utf-8"&amp;gt;&amp;lt;/head&amp;gt;
      &amp;lt;body&amp;gt;{html_body}&amp;lt;/body&amp;gt;
    &amp;lt;/html&amp;gt;
    """
).write_pdf("/tmp/genie_agent_report.pdf")&lt;/LI-CODE&gt;&lt;P&gt;The flow I validated :&lt;/P&gt;&lt;P&gt;Agent Mode API → response.completed → output_text → Markdown → HTML → PDF&lt;/P&gt;&lt;P&gt;So while there is no dedicated PDF export API currently, generating it client side from the completed Agent response works well.&amp;nbsp;The report content, headings, formatting, and source citation links were retained in the generated PDF.&lt;/P&gt;</description>
      <pubDate>Tue, 08 Sep 2026 14:52:44 GMT</pubDate>
      <guid>https://community.databricks.com/t5/generative-ai/genie-agent-response-export-to-pdf-via-api/m-p/167951#M2063</guid>
      <dc:creator>data_pulse</dc:creator>
      <dc:date>2026-09-08T14:52:44Z</dc:date>
    </item>
  </channel>
</rss>

