Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

Next up in the FabCon + SQLCon recap series: The roadmap for Microsoft SQL and Maximizing Developer experiences in Fabric. All sessions are available on-demand after the live show. Register now

Reply
jesikamaurya
Frequent Visitor

Custom visual in Power BI for integration of GPT or Gemini with Power BI

I’m working on integrating ChatGPT or Google Gemini into Power BI using a custom visual to enable interactive AI responses directly from the report, based on the dataset contents.

Everything works fine when I test the API in Postman, but Power BI blocks the API call from the custom visual due to security restrictions, most likely related to Content Security Policy (CSP) or cross-origin (CORS) issues.

I have Tried So Far

  1. Built a custom visual in Power BI using React and TypeScript

  2. Integrated OpenAI/Gemini API logic inside the visual

  3. Created a proxy API server to forward the API requests

  4. Used tunneling tools like:

    • localtunnel

    • ngrok

    • Cloudflare Tunnel

I Need Help With

  • How can I successfully connect Power BI custom visual to OpenAI/Gemini API through a proxy or tunnel?

  • Is there a recommended tunneling or reverse proxy approach that works with Power BI visuals?

  • Any other approaches to solve the same problem?

 

Any guidance or step-by-step solution would be greatly appreciated!

 

Thanks!

1 ACCEPTED SOLUTION
v-nmadadi-msft
Community Support
Community Support

Hi @jesikamaurya  ,
Thanks for reaching out to the Microsoft fabric community forum.

Power BI imposes several restrictions on custom visuals by running them in a sandboxed environment with the least amount of privilege. As a result, any content hosted inside the visual that requires elevated permissions is unlikely to function correctly. This sandboxing also strips away the domain context from custom visuals, preventing them from impersonating powerbi.com. Consequently, attempting to access services or embed content from sites that enforce CORS restrictions will fail within the visual. Since CORS policies are enforced by the target server, they cannot be overridden from the client side, including within the visual itself.
If your endpoint enforces a CORS policy, it won’t be accessible from a Power BI custom visual. Microsoft sandbox custom visuals, which results in requests being sent with a null origin. Even if your code is correct, the target server will block the request due to this null origin unless explicitly allowed, making direct API calls from the visual unsuccessful.
If the ability to call third-party services is important to your use case, we recommend submitting a suggestion in the Power BI Ideas forum.
Fabric Ideas - Microsoft Fabric Community
 This platform is actively monitored by the product team, and highly supported posts are often implemented to Power BI.


If you find this post helpful, please mark it as an "Accept as Solution" and consider giving a KUDOS. Feel free to reach out if you need further assistance.
Thank you

View solution in original post

5 REPLIES 5
querixa
Helper IV
Helper IV

I've faced similar CSP/CORS issues when building AI integrations for Power BI. The challenge is that Power BI's security model restricts direct API calls from custom visuals, which is why your proxy approach is on the right track.

One thing that worked for me was setting up a lightweight Azure Function as a secure proxy, it handles the API call and returns the response to the visual without tripping Power BI’s security policies.

If you're looking for a ready-made solution that avoids these integration headaches, you might find PowerMind interesting. It’s a custom AI assistant built specifically for Power BI that embeds directly into dashboards without needing Copilot licenses or dealing with API blockers. You can see a quick demo of how it works here: 

https://www.linkedin.com/posts/querixa_powerbi-microsoftfabric-dataanalytics-activity-74394511856963... 

 

https://www.youtube.com/watch?v=JPscIa7SNZw  

v-nmadadi-msft
Community Support
Community Support

Hi @jesikamaurya ,

Could you please confirm if you've submitted this as an idea in the Ideas Forum? If so, sharing the link here would be helpful for other community members who may have similar feedback.

If we don’t hear back, we’ll go ahead and close this thread. For any further discussions or questions, please start a new thread in the Microsoft Fabric Community Forum  we’ll be happy to assist.

Thank you for being part of the Microsoft Fabric Community.

v-nmadadi-msft
Community Support
Community Support

Hi @jesikamaurya 

I wanted to check if you had the opportunity to review the information provided. Please feel free to contact us if you have any further questions. If our responses has addressed your query, please accept it as a solution and give a 'Kudos' so other members can easily find it.


Thank you.

v-nmadadi-msft
Community Support
Community Support

Hi @jesikamaurya 

May I ask if you have resolved this issue? If so, please mark the helpful reply and accept it as the solution. This will be helpful for other community members who have similar problems to solve it faster.

Thank you.

 

v-nmadadi-msft
Community Support
Community Support

Hi @jesikamaurya  ,
Thanks for reaching out to the Microsoft fabric community forum.

Power BI imposes several restrictions on custom visuals by running them in a sandboxed environment with the least amount of privilege. As a result, any content hosted inside the visual that requires elevated permissions is unlikely to function correctly. This sandboxing also strips away the domain context from custom visuals, preventing them from impersonating powerbi.com. Consequently, attempting to access services or embed content from sites that enforce CORS restrictions will fail within the visual. Since CORS policies are enforced by the target server, they cannot be overridden from the client side, including within the visual itself.
If your endpoint enforces a CORS policy, it won’t be accessible from a Power BI custom visual. Microsoft sandbox custom visuals, which results in requests being sent with a null origin. Even if your code is correct, the target server will block the request due to this null origin unless explicitly allowed, making direct API calls from the visual unsuccessful.
If the ability to call third-party services is important to your use case, we recommend submitting a suggestion in the Power BI Ideas forum.
Fabric Ideas - Microsoft Fabric Community
 This platform is actively monitored by the product team, and highly supported posts are often implemented to Power BI.


If you find this post helpful, please mark it as an "Accept as Solution" and consider giving a KUDOS. Feel free to reach out if you need further assistance.
Thank you

Helpful resources

Announcements
New to Fabric survey Carousel

New to Fabric Survey

If you have recently started exploring Fabric, we'd love to hear how it's going. Your feedback can help with product improvements.

Power BI DataViz World Championships carousel

Power BI DataViz World Championships - June 2026

A new Power BI DataViz World Championship is coming this June! Don't miss out on submitting your entry.

Join our Fabric User Panel

Join our Fabric User Panel

Share feedback directly with Fabric product managers, participate in targeted research studies and influence the Fabric roadmap.

March Power BI Update Carousel

Power BI Community Update - March 2026

Check out the March 2026 Power BI update to learn about new features.