How to use bing websearch API with Azure AI Studio

Divyansh Singh 20 Reputation points
2024-03-13T02:39:33.68+00:00

I am considerably new to the Azure AI Studio and I want to connect Bing web search API with my model as well so that it can search the web when needed!

What would work?

  1. Can we create a new connection within the AI Studio and attach the Bing WebSearch API there? I tried but couldn't figure out the connection, If it is possible then please assist with the detailed solution!
  2. Should we just code it inside a Python file (under prompt flow) and use that to call the Bing? In this case, how do we hide our API Keys and Endpoints and how do we add them as there is no .env file present?
  3. Also how do we add new packages like langchain, bs4 etc?

I have been doing all of this on the AI Studio and not the code on the VS code (because it starts a compute server in that case and is expensive)

Please guide me with the solution to this question and if you could provide some supporting documents then that would be much appreciated!

Bing Web Search
Bing Web Search
A Bing service that gives you enhanced search details from billions of web documents.
128 questions
Azure AI services
Azure AI services
A group of Azure services, SDKs, and APIs designed to make apps more intelligent, engaging, and discoverable.
2,382 questions
{count} votes

1 answer

Sort by: Most helpful
  1. romungi-MSFT 42,206 Reputation points Microsoft Employee
    2024-03-13T11:05:39.5266667+00:00

    @Divyansh Singh I would recommend to use custom connection and store the secret of your bing endpoint. I have tried adding the key or secret using these steps.

    Add your bing key or secret in the last key pair and mark it as a secret.

    Screenshot that shows add extra meta to custom connection in AI Studio.

    Before creating the connection select the appropriate Access type. Use Shared instead of Project if the project owner is different.

    Once connection is added, add a Python tool in your flow and update the code section to below:

    User's image

    Hit the Validate and Parse input button and then select the inputs of your python tool.

    User's image

    I used the name finaltesting.

    Select it and run the tool or flow.

    Here, I printed the key to check if it is correct and it should be available in your logs.

    Similarly, you can use the key to call the bing search endpoint. The bing search endpoint is global and you can probably add other key/pair with the endpoint value and set other parameters in your code before a POST request is called to search.

    With respect to other tools, I think more will be added soon along with guidance as this is still a preview service, use this page to check for any new tools are added in the future. Thanks!!

    0 comments No comments