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

The Power BI Data Visualization World Championships is back! It's time to submit your entry. Live now!

Reply
KimTutein
Advocate II
Advocate II

Using a data agent in a notebook

Hi community

Anyone have codesnippet for using a data agent inside a notebook. I found the link below on learn and I do get an answer – however I get warnings that it using functionality that is being depreciated .

I am having a hard time understanding the code. I had hoped the “fabric-data-agent-sdk” might help as this may test answers but I do not see how.

 

If anyone with a codesnippet for querying data agent in a notebook it would be appreciated.

 

The warning:

/tmp/ipykernel_10402/620714472.py:5: DeprecationWarning: The Assistants API is deprecated in favor of the Responses API

  thread = fabric_client.beta.threads.create()

 

Documentation on learn:

https://learn.microsoft.com/en-us/fabric/data-science/data-agent-end-to-end-tutorial

4 REPLIES 4
ssrithar
Advocate II
Advocate II

Hi @KimTutein ,

 

  • FabricClient does not exist in any public version of the fabric-data-agent-sdk.

  • The import will fail, and no documented client class exists under that module.The fabric.responses.create() approach mentioned in the response is from early preview version.

 

Can you try using 

Use the “Ask a data agent” cell in a Fabric notebook

  • No SDK installation or Python imports required

  • Fully integrated with Fabric’s identity and workspace context

  • Natural language query powered by the configured Data Agent

  • Best option for:

    • Interacting with Lakehouses, Warehouses, or Semantic Models

    • Exploring data using natural language

If this post helps, then please appreciate giving a Kudos or accepting as a Solution to help the other members find it more quickly.
If I misunderstand your needs or you still have problems on it, please feel free to let us know. Thanks a lot!

Hi  @ssrithar 

 

Thank you for your answer but want I am trying to is to ask a data agent in a notebook which my be schuled. That agent will return an answer in a html format I will send that answer to a user if certain conditions aply. One use case could be something like - "look at this data" - if you find this condition a is true - get some details and put togehter a response I will email the user (then schedule the notebook to run every night)

 

As far as I know the cell type in Fabric can only be pyspark, spark(scala), sparksql, spark r or HTML - not an option to chat with a data agent. I know there is an option to chat with copilot in a given cell - that is however not the data agent and moreover I need the respons in my pyspark cell during a run to use it.

KimTutein_0-1768540919748.png

 

ssrithar
Advocate II
Advocate II

 Hi @KimTutein ,

 

You're right — the tutorial you found on Microsoft Learn uses the deprecated Assistants API, which is why you're seeing the warning.

 

Microsoft Fabric has evolved its Data Agent API, and the recommended SDK (fabric-data-agent-sdk) now uses the Responses API instead.

 

Install the latest SDK -- !pip install --upgrade fabric-data-agent-sdk

 

Updated Code Snippet (using Responses API)

 

from fabric_data_agent_sdk import FabricClient

# Authenticate using current Fabric identity (within notebook)
fabric = FabricClient()

# Your data agent name (must already exist)
agent_name = "MyAgent"

# Ask a question or send a command
response = fabric.responses.create(
data_agent_name=agent_name,
query="What are the top 5 products by sales?"
)

# Display the response
print(response.answer)

 

 

 

  • This avoids the deprecated .beta.threads.create() syntax.

  • The SDK automatically authenticates using the Fabric notebook context (no secrets/tokens needed).

  • The query can be natural language or SQL, depending on your agent configuration.

 

Make sure you're using the latest SDK methods, especially since Fabric is still evolving fast.

 

If this post helps, then please appreciate giving a Kudos or accepting as a Solution to help the other members find it more quickly.
If I misunderstand your needs or you still have problems on it, please feel free to let us know. Thanks a lot!

 

Hi @ssrithar 

Thank you for your message


Install the latest SDK --

!pip install --upgrade fabric-data-agent-sdk

 

#This part does not work - I am not sure how to import the FabricClient?

from fabric_data_agent_sdk import FabricClient 

 

#I tried something like below - however this client

from fabric.dataagent import client

 

Helpful resources

Announcements
December Fabric Update Carousel

Fabric Monthly Update - December 2025

Check out the December 2025 Fabric Holiday Recap!

FabCon Atlanta 2026 carousel

FabCon Atlanta 2026

Join us at FabCon Atlanta, March 16-20, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.