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
| SpecStream | Bing Image Search API v7 | |
|---|---|---|
| `search_url` | https://api.specstream.ai/v7.0/images/search | https://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 before | The 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 400 | The default is 35 and the maximum is 150 |
| What the function returns | L(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 image | contentUrl, name, hostPageUrl and hostPageDisplayUrl, with thumbnailUrl, thumbnail, encodingFormat, width and height when the search engines give them | The same fields, plus contentSize, the image's file size |
| When a call fails | raise_for_status() raises on Bing's ErrorResponse. A busy call answers 429 with Retry-After and is not charged | When 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 images | No longer sold. Microsoft's named replacement, Grounding with Bing Search, costs $14 per 1,000 transactions |
| Daily limit | None. Calls spend from your balance, inside the spending limit you set on the key | Grounding with Bing Search: 1 million transactions a day, 150 a second |
fastbook's image search, on SpecStream
The function, before and after
This is search_images_bing in fastbook's utils.py, lines 54 to 61 at commit 971f0289c, as it is in the repo:
def search_images_bing(key, term, min_sz=128, max_images=150):
params = {'q':term, 'count':max_images, 'minHeight':min_sz, 'minWidth':min_sz, 'imageType':'photo'}
headers = {"Ocp-Apim-Subscription-Key":key}
search_url = "https://api.bing.microsoft.com/v7.0/images/search"
response = requests.get(search_url, headers=headers, params=params)
response.raise_for_status()
search_results = response.json()
return L(search_results['value'])And with the one line changed:
def search_images_bing(key, term, min_sz=128, max_images=150):
params = {'q':term, 'count':max_images, 'minHeight':min_sz, 'minWidth':min_sz, 'imageType':'photo'}
headers = {"Ocp-Apim-Subscription-Key":key}
search_url = "https://api.specstream.ai/v7.0/images/search"
response = requests.get(search_url, headers=headers, params=params)
response.raise_for_status()
search_results = response.json()
return L(search_results['value'])The params, the header, raise_for_status() and the return stay. The same function, with the same search_url line, is in fastai/course20's fastbook/__init__.py, and changes the same way.
Call it with max_images=100
The function sends max_images as count, and its default is 150, the most Bing took. SpecStream returns up to 100 images a call, so a call with 150 gets 400. Pass max_images=100, or set the default to 100 in the def line.
results = search_images_bing(key, 'grizzly bear', max_images=100)
ims = results.attrgot('contentUrl')
len(ims) # 100The book's own function returned 100 images
The book's own function, with that one line changed, returned 100 images on November 10, 2026, each with contentUrl, called as search_images_bing(key, "grizzly bear", max_images=100) with fastcore 2.2.41 and requests 2.34.2. download_images(dest, urls=results.attrgot('contentUrl')) then works as the book wrote it.
If your notebook calls search_images_serpapi
Today's fastbook calls search_images_serpapi in chapter 2. The function is in utils.py, lines 27 to 45 at commit 971f0289c, and one value in it changes, the url:
# before
url,params = 'https://serpapi.com/search', dict(engine=engine, q=term, api_key=key)
# after
url,params = 'https://api.specstream.ai/serpapi/search', dict(engine=engine, q=term, api_key=key)Call it with engine='google_images' and put a SpecStream key in key or in the SERPAPI_KEY environment variable. The function's default engine, bing_images, gets 400 today.
urls = search_images_serpapi('grizzly bear', engine='google_images', key=key, max_images=30)
len(urls) # 30The book's own function, with that one value changed, followed serpapi_pagination.next twice and returned 30 image addresses on November 10, 2026. Each page it asks for is one search of 10 images at $0.005, so 150 images are 15 searches, $0.075.
$0.059 for 100 images, with no plan
An image search of up to 10 results costs $0.005, the price of a web search, and each started block of 10 more adds $0.006. The book's call for 100 images is $0.059, so the chapter's three bear types cost $0.177. The $10 of credit a new account gets covers 169 calls of 100 images. There is no plan and no daily limit, credit you buy never expires, and a call stopped by a 429 is not charged.
You decide what is kept, on each key
Create the key with zero_retention and a search made with it keeps no request text and no answer after the reply. spend_cap_cents is the most the key can spend, which suits a key pasted into a notebook.
curl -X POST https://api.specstream.ai/v1/account/keys \
-H "Authorization: Bearer $SPECSTREAM_API_KEY" -H "Content-Type: application/json" \
-d '{"name": "notebook", "scopes": ["account:read", "finds:spend"], "spend_cap_cents": 1000, "zero_retention": true}'Images, web, news and pages on one key
SpecStream is the live web data engine. The key in your notebook also runs web search and news through GET /v1/web-search, scoring 97.9 F-score on all 1,000 SimpleQA Verified questions and 64.0 item F1 on all 200 WideSearch tasks; the method is on the benchmarks page. It reads pages with the Extract API at $0.80 per 1,000 pages, 0.908 F1 on WCXB, and Deep Search returns every match for a request in plain words as structured rows, at 5¢, 15¢ or $1 a row.
Every parameter and field of Bing's image call is in the Bing Image Search API migration guide, and every image API SpecStream answers is on the image search API page.
Other ways to get fastbook's images
SerpApi, in today's fastbook
fastbook's chapter 2 now says Microsoft has retired the Bing Image Search API the book relied on, and uses a new function, search_images_serpapi. SerpApi's free plan gives 250 searches a month, and each page of 35 Bing results is one search, so a 150 image query costs 5. Starter is $25 a month for 1,000 searches. SpecStream answers both functions: search_images_bing at $0.059 for 100 images, and search_images_serpapi, with its url changed and engine='google_images', at $0.005 for each page of 10.
Grounding with Bing Search
Microsoft's named replacement, a tool for Azure AI Agents at $14 per 1,000 transactions. Microsoft says developers and end users don't have access to the raw content it returns, so there is no value[] and no contentUrl for download_images. SpecStream returns both.
Google Custom Search JSON API
Its image search costs $5 per 1,000 queries, but the API is closed to new customers and Google discontinues it on January 1, 2027. SpecStream answers Google's image call too, on the same key.
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=1003. 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?
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?
key argument, and a new account gets $10 of credit with no card.Why does max_images=150 give a 400 error?
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?
contentUrl. results.attrgot('contentUrl') and download_images run as the book wrote them.Does search_images_serpapi work with SpecStream?
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?
How much does fastbook's image search cost on SpecStream?
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.
- fastai/fastbook on GitHubgithub.com/fastai/fastbook, read Nov 10, 2026
- fastbook utils.py at 971f0289craw.githubusercontent.com/fastai/fastbook/971f0289c/utils.py, read Nov 10, 2026
- fastbook 02_production.ipynb at 971f0289craw.githubusercontent.com/fastai/fastbook/971f0289c/02_production.ipynb, read Nov 10, 2026
- Microsoft, Bing Search APIs retiring on August 11, 2025learn.microsoft.com/en-us/lifecycle/announcements/bing-search-api-retirement, read Nov 10, 2026
- Bing Image Search API v7, query parameterslearn.microsoft.com/en-us/bing/search-apis/bing-image-search/reference/query-parameters, read Nov 10, 2026
- Bing Image Search API v7, response objectslearn.microsoft.com/en-us/bing/search-apis/bing-image-search/reference/response-objects, read Nov 10, 2026
- Bing Image Search API v7, headerslearn.microsoft.com/en-us/bing/search-apis/bing-image-search/reference/headers, read Nov 10, 2026
- Microsoft, Bing APIs and Grounding with Bing pricingmicrosoft.com/en-us/bing/apis, read Nov 10, 2026
- Microsoft, Grounding with Bing toolslearn.microsoft.com/en-us/azure/foundry/agents/how-to/tools/bing-tools, read Nov 10, 2026
- SerpApi pricingserpapi.com/pricing, read Nov 10, 2026
- Google Custom Search JSON API overviewdevelopers.google.com/custom-search/v1/overview, read Nov 10, 2026
- SpecStream benchmarksspecstream.ai/benchmarks, read Nov 10, 2026
- SpecStream for agentsspecstream.ai/agents.md, read Nov 10, 2026




