Skip to the page

fastai search_images_bing without a Bing key

Change one line.

Microsoft retired the Bing Search APIs on August 11, 2025, so no new Bing key exists for fastbook's search_images_bing. SpecStream answers the same Bing image call at its own address, in Bing's JSON.

Change the search_url line to https://api.specstream.ai/v7.0/images/search and pass a SpecStream key as key. Then call the function with max_images=100. The book's own function, with that one line changed, returned 100 images on November 10, 2026.

A call for 100 images costs $0.059, and the $10 of credit a new account gets, with no card, covers 169 of them. Web search on the same key scores 97.9 F-score on all 1,000 SimpleQA Verified questions.

New accounts get $10 of credit, no card. It covers 2,000 searches.

search_images_bing on SpecStream and on Bing, parameter by parameter and field by field

SpecStreamBing Image Search API v7
`search_url`https://api.specstream.ai/v7.0/images/searchhttps://api.bing.microsoft.com/v7.0/images/search. Retired on August 11, 2025, with existing instances decommissioned
`key`A SpecStream key, sent by the function in the Ocp-Apim-Subscription-Key header as beforeThe subscription key from a Bing resource in the Azure Portal. Microsoft takes no new signups
`count` (the function's `max_images`)1 to 100. Call the function with max_images=100; its default of 150 gets 400The default is 35 and the maximum is 150
What the function returnsL(search_results['value']), a list of images, read by the book as results.attrgot('contentUrl')The same value[] list, each item with contentUrl, a URL to the image on the source website
Fields on each imagecontentUrl, name, hostPageUrl and hostPageDisplayUrl, with thumbnailUrl, thumbnail, encodingFormat, width and height when the search engines give themThe same fields, plus contentSize, the image's file size
When a call failsraise_for_status() raises on Bing's ErrorResponse. A busy call answers 429 with Retry-After and is not chargedWhen a request fails, the top level object in the response is the ErrorResponse object
Price$0.005 for up to 10 images, and $0.006 for each started block of 10 more: $0.059 for 100 imagesNo longer sold. Microsoft's named replacement, Grounding with Bing Search, costs $14 per 1,000 transactions
Daily limitNone. Calls spend from your balance, inside the spending limit you set on the keyGrounding with Bing Search: 1 million transactions a day, 150 a second

fastbook's image search, on SpecStream

Other ways to get fastbook's images

How SpecStream scores

The same numbers as the benchmarks page, from the official tasks and scorers.

How to run search_images_bing on SpecStream

1. Create a key under Agents & API in the SpecStream workspace. A new account gets $10 of credit, no card.

2. Check the key with the call the function sends. A 200 with value means the notebook gets the same.

curl -G https://api.specstream.ai/v7.0/images/search \
  -H "Ocp-Apim-Subscription-Key: $SPECSTREAM_KEY" \
  --data-urlencode "q=grizzly bear" -d count=100

3. In utils.py (or fastbook/__init__.py), set search_url = "https://api.specstream.ai/v7.0/images/search". In the notebook, set key to your SpecStream key:

key = os.environ.get('SPECSTREAM_KEY', 'XXX')

4. Call the function with max_images=100 and run the chapter's download loop as it is:

results = search_images_bing(key, f'{o} bear', max_images=100)
download_images(dest, urls=results.attrgot('contentUrl'))

5. The same call from JavaScript, for a page or a Node script:

const params = new URLSearchParams({ q: "grizzly bear", count: "100" });
const res = await fetch(`https://api.specstream.ai/v7.0/images/search?${params}`, {
  headers: { "Ocp-Apim-Subscription-Key": process.env.SPECSTREAM_KEY },
});
const { value } = await res.json();
console.log(value.map((image) => image.contentUrl));

6. On a 429, wait the seconds in Retry-After and run the cell again; nothing was charged.

Frequently asked questions

Something we didn't answer? Talk to a human

Why is search_images_bing not working?
Microsoft retired the Bing Search APIs on August 11, 2025 and decommissioned existing instances, so the function's address and key no longer answer. Set its search_url to https://api.specstream.ai/v7.0/images/search, pass a SpecStream key, and call it with max_images=100.
How do I get a Bing Image Search API key for fastai?
You cannot: since August 11, 2025 Microsoft takes no new signups for the Bing Search APIs. A SpecStream key works in the function's key argument, and a new account gets $10 of credit with no card.
Why does max_images=150 give a 400 error?
SpecStream returns up to 100 images a call, and 150 is the function's default, the most Bing took. Call search_images_bing(key, term, max_images=100), or change the default in the def line.
Does the rest of fastbook's chapter 2 change?
No: the book's own function, with one line changed, returned 100 images on November 10, 2026, each with contentUrl. results.attrgot('contentUrl') and download_images run as the book wrote them.
Does search_images_serpapi work with SpecStream?
Yes, with one changed value. Set the function's url to https://api.specstream.ai/serpapi/search, pass a SpecStream key and call it with engine='google_images'. The book's own function then followed its paging links and returned 30 image addresses on November 10, 2026.
What is the best Bing image search alternative for fastai?
SpecStream, at $0.059 for 100 images, with the function your notebook already calls. fastbook's current chapter uses SerpApi, where a 150 image query costs 5 of the 250 searches its free plan gives a month.
How much does fastbook's image search cost on SpecStream?
$0.059 for a call of 100 images, and $0.005 for up to 10. The $10 of credit a new account gets covers 169 calls of 100 images, and a call stopped by a 429 is not charged.

Sources

SpecStream wrote this page. fastbook's code and text come from its repo on GitHub at commit 971f0289c, each Microsoft figure from Microsoft's own pages, and each other provider's figure from that company's own page. The route's behavior is taken from its code.

  1. fastai/fastbook on GitHubgithub.com/fastai/fastbook, read Nov 10, 2026
  2. fastbook utils.py at 971f0289craw.githubusercontent.com/fastai/fastbook/971f0289c/utils.py, read Nov 10, 2026
  3. fastbook 02_production.ipynb at 971f0289craw.githubusercontent.com/fastai/fastbook/971f0289c/02_production.ipynb, read Nov 10, 2026
  4. Microsoft, Bing Search APIs retiring on August 11, 2025learn.microsoft.com/en-us/lifecycle/announcements/bing-search-api-retirement, read Nov 10, 2026
  5. Bing Image Search API v7, query parameterslearn.microsoft.com/en-us/bing/search-apis/bing-image-search/reference/query-parameters, read Nov 10, 2026
  6. Bing Image Search API v7, response objectslearn.microsoft.com/en-us/bing/search-apis/bing-image-search/reference/response-objects, read Nov 10, 2026
  7. Bing Image Search API v7, headerslearn.microsoft.com/en-us/bing/search-apis/bing-image-search/reference/headers, read Nov 10, 2026
  8. Microsoft, Bing APIs and Grounding with Bing pricingmicrosoft.com/en-us/bing/apis, read Nov 10, 2026
  9. Microsoft, Grounding with Bing toolslearn.microsoft.com/en-us/azure/foundry/agents/how-to/tools/bing-tools, read Nov 10, 2026
  10. SerpApi pricingserpapi.com/pricing, read Nov 10, 2026
  11. Google Custom Search JSON API overviewdevelopers.google.com/custom-search/v1/overview, read Nov 10, 2026
  12. SpecStream benchmarksspecstream.ai/benchmarks, read Nov 10, 2026
  13. SpecStream for agentsspecstream.ai/agents.md, read Nov 10, 2026