<!-- twin of https://specstream.ai/migrate/fastai-search-images-bing -->
# fastai search_images_bing without a Bing key: change one line

Compared on Nov 10, 2026. The page: https://specstream.ai/migrate/fastai-search-images-bing

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.

[Get an API key](https://specstream.ai/signup?src=alternatives-fastai-search-images-bing&utm_source=alternatives-md&utm_campaign=fastai-search-images-bing&returnTo=%2Fworkspace%2Fsearch%3Froute%3Dbing) 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)  # 100
```

### The 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)  # 30
```

The 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](https://specstream.ai/benchmarks?utm_source=alternatives&utm_campaign=fastai-search-images-bing) page. It reads pages with the [Extract API](https://specstream.ai/extract-api?utm_source=alternatives&utm_campaign=fastai-search-images-bing) at $0.80 per 1,000 pages, 0.908 F1 on WCXB, and [Deep Search](https://specstream.ai/deep-search?utm_source=alternatives&utm_campaign=fastai-search-images-bing) 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](https://specstream.ai/migrate/bing-image-search?utm_source=alternatives&utm_campaign=fastai-search-images-bing), and every image API SpecStream answers is on the [image search API](https://specstream.ai/image-search-api?utm_source=alternatives&utm_campaign=fastai-search-images-bing) 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 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

### 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.

- [fastai/fastbook on GitHub](https://github.com/fastai/fastbook), read Nov 10, 2026
- [fastbook utils.py at 971f0289c](https://raw.githubusercontent.com/fastai/fastbook/971f0289c/utils.py), read Nov 10, 2026
- [fastbook 02_production.ipynb at 971f0289c](https://raw.githubusercontent.com/fastai/fastbook/971f0289c/02_production.ipynb), read Nov 10, 2026
- [Microsoft, Bing Search APIs retiring on August 11, 2025](https://learn.microsoft.com/en-us/lifecycle/announcements/bing-search-api-retirement), read Nov 10, 2026
- [Bing Image Search API v7, query parameters](https://learn.microsoft.com/en-us/bing/search-apis/bing-image-search/reference/query-parameters), read Nov 10, 2026
- [Bing Image Search API v7, response objects](https://learn.microsoft.com/en-us/bing/search-apis/bing-image-search/reference/response-objects), read Nov 10, 2026
- [Bing Image Search API v7, headers](https://learn.microsoft.com/en-us/bing/search-apis/bing-image-search/reference/headers), read Nov 10, 2026
- [Microsoft, Bing APIs and Grounding with Bing pricing](https://www.microsoft.com/en-us/bing/apis), read Nov 10, 2026
- [Microsoft, Grounding with Bing tools](https://learn.microsoft.com/en-us/azure/foundry/agents/how-to/tools/bing-tools), read Nov 10, 2026
- [SerpApi pricing](https://serpapi.com/pricing), read Nov 10, 2026
- [Google Custom Search JSON API overview](https://developers.google.com/custom-search/v1/overview), read Nov 10, 2026
- [SpecStream benchmarks](https://specstream.ai/benchmarks), read Nov 10, 2026
- [SpecStream for agents](https://specstream.ai/agents.md), read Nov 10, 2026
