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

Join us for an expert-led overview of the tools and concepts you'll need to become a Certified Power BI Data Analyst and pass exam PL-300. 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

4 REPLIES 4
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
Join our Fabric User Panel

Join our Fabric User Panel

This is your chance to engage directly with the engineering team behind Fabric and Power BI. Share your experiences and shape the future.

June 2025 Power BI Update Carousel

Power BI Monthly Update - June 2025

Check out the June 2025 Power BI update to learn about new features.

June 2025 community update carousel

Fabric Community Update - June 2025

Find out what's new and trending in the Fabric community.