Bing Image Search API Key

Sorry if this is such a newbie question here.

I signed up with Bing Image Search and cannot seem to find an API key anywhere. Can anyone direct me on how to navigate in Bing to access this API key please?

1 Like

I started here and got a key, but still getting Permission denied when running the notebook code :frowning:

ok well I ended up having to slightly modify the code in utils.py to include the region (westus) in the endpoint ā€¦ then it workedā€¦

You can try logging into Azure Portal and search for the yoru Bing Search Cognitive service you create. There you can find the keys in Quick start of in Keys. Here is screenshot (with sensitive info masked)

3 Likes

Hello all,

Just to give some signal boost to this because it can be confusing. If you start from the beginning and you are within the 7 day free trial, you can easily get the key from the try for free page I believe. However, if you try to go to the page after your free 7 days like I did because I wanted to re-do things, then it will give an error because the free trial is up.

You do have to set up your account and enter your credit card credentials and other things. There are some solutions on the forums on alternative ways to get the images if you donā€™t want to do this.

However, even after signing up, it can be confusing on how to get it working. If you search in the Azure console, Bing Image Search does not show up.

So:

  1. Sign up for Azure. If you ever encounter any payment step, select free for support tier or others.
  2. Log into the home page of the Azure portal
  3. Click ā€œCognitive Servicesā€
  4. Click ā€œ+addā€ or create resource. Something like that.
  5. Click on BING SEARCH (it has the image search in it too. Seems obvious but I overlooked it and others might too.) Create this.
  6. You will need to fill out some forms and name some things. If it asks you for the payment tier, you can select Free (F1). It is the one with 3 transactions per second / 1000 transactions per month as Jeremy mentioned.
  7. After that. You just basically have to click next and fill in the forms until it says it is deploying.
  8. After it is deployed, click on ā€œGo to Resourceā€.
  9. There it will display your key which you can copy paste into the notebooks.

Hope this helps make things clearer for anyone wondering like I was.

28 Likes

Thank you, James. I find the resource setup tasks very time consuming, and this helps expedite the process of setting up image search on azure.

Hello guys,

I have been trying to create the API key for two hours now, but to no avail. I followed @jmeteā€™s instructions, and I manage to get to point 6.) on your list. But for some reason I cannot enter any value for the pricing tier. When I click on the down button to select a tier, it just says ā€œNo available itemsā€. I have tried different browsers, but nothing changes.

Has anyone had similar problems and could help me with this?

Thank you very much in advance!

Cheers,

Jan

Hi there,
Iā€™m not sure about that issue, but make sure the subscription is created and selected.
The pricing tier is linked to that. You will notice for me that it says F1 is already created but for you it should show up:

When I first logged back in to test it, it showed no options (like what you are experiencing). I let it load for a few seconds and made sure to re-select the subscription box and then it started showing me the pricing options.

Hope you get it working!

James

Thanks a lot, James! I got it working now.

Cheers,

Jan

Iā€™m having the same permission denied issue despite generating the API key and pasting in. Can you explain further where you updated this code in utils.py? My selected region is also different so think it could be my problem too. Hope that makes sense!

Thanks so much @jmete, because I was stuck on this.

At this point in 2020, hereā€™s the steps that worked for me.

Jamesā€™ steps 1-2.
3. + for ā€˜create a resourceā€™.
4. use the search box to type ā€œBing searchā€, click create once it is found.
5. Then you need to fill out some forms (similar to Jamesā€™ step 6, looks like this ā€“

of course I am choosing free.
6. After deployed, ā€œGo to resource.ā€
7. Thereā€™s some text about the keys and endpoint on the main page, but the links to the keys are located on the left side of the screen, under the ā€œResource Managementā€ heading.

Thank you to everyone that contributed to this thread. I was able to get it set up without too many problems. I would have never figured it out.

I got the same thing, but found that if you ā€˜upgradeā€™ (which requires CC card info) you can still select a free tier, but just have to be careful you donā€™t go over the limits (if you do itā€™s pay for what you use)

I donā€™t know what is wrong, but Iā€™m still getting this issue ā€œErrorResponseException: Operation returned an invalid status code ā€˜PermissionDeniedā€™ā€ and donā€™t know what should I do with it

if you donā€™t want to waste your time on the bing api, there are alternatives. see Any Alternative to bing_search_image

The whole Bing API has changed, you need to write your own search-method. I wrote this one, which gets the job done:

def search_images_bing_new(key, term, customConfigId, min_sz=128):
	url = 'https://api.bing.microsoft.com/v7.0/custom/images/search?' + 'q=' + searchTerm + '&' + 'customconfig=' + customConfigId + '&' + 'count=150'
	r = requests.get(url, headers={'Ocp-Apim-Subscription-Key': key})
	search_results = r.json()
	return L([img["thumbnailUrl"] for img in search_results["value"][:150]])

And then call it with the three parameters: search_images_bing_new(apikey, searchterm, customConfigId) where the parameters apikey and customconfigid are acquired from azure

@SimonStochholm have you tried to add a pull-request to fast.ai to fix those?

@oduvan Iā€™ll look into it, but I havenā€™t made a PR before, so it may take a while.