> SpecStream is the live web data engine for teams and agents. This is the Markdown copy of https://specstream.ai/migrate/google-cse/langchain. Every page, with what SpecStream does and costs: https://specstream.ai/llms.txt

# Replace the Google Custom Search JSON API in LangChain

Google ends the Custom Search JSON API on January 1, 2027. Move your LangChain code to SpecStream today: the same search in one call, $1 per 1,000 searches against $5, and no daily limit.

[Get an API key](https://specstream.ai/signup?src=migrate-google-cse-langchain&returnTo=%2Fworkspace%2Fsearch)[Test your query in the migrator](https://specstream.ai/tools/google-cse-migrator.md)

A new account gets $2 of credit, no card: 2,000 free test searches. [Start the Starter plan at $49 a month](https://specstream.ai/v1/billing/credit-plans/checkout?plan=starter) for 49,000 searches.

$1

per 1,000 searches on SpecStream, fast tier

$5

per 1,000 queries on Google Custom Search, until it closes

80%

lower search cost from the first call

Jan 1, 2027

the day Google ends the Custom Search JSON API

## Before and after in LangChain

One LangChain class accounts for 8,368 files on GitHub: `GoogleSearchAPIWrapper`, counted on November 20, 2026. Every agent built on it stops searching on January 1, 2027. A ten line tool on SpecStream replaces it and returns the source URL with every result.

Before: tools.py, GoogleSearchAPIWrapperCopy

```
from langchain_core.tools import Tool
from langchain_google_community import GoogleSearchAPIWrapper

# Reads GOOGLE_API_KEY and GOOGLE_CSE_ID from the environment.
search = GoogleSearchAPIWrapper(k=10)

web_search = Tool(
    name="web_search",
    description="Search the web for recent results.",
    func=search.run,
)
```

After: tools.py, SpecStreamCopy

```
import os

import requests
from langchain_core.tools import tool


@tool
def web_search(query: str) -> str:
    """Search the live web. Returns the top results with their source URLs."""
    res = requests.get(
        "https://api.specstream.ai/v1/web-search",
        headers={"Authorization": "Bearer " + os.environ["SPECSTREAM_API_KEY"]},
        params={"q": query, "num": 10, "speed": "fast"},
        timeout=30,
    )
    res.raise_for_status()
    sources = res.json()["data"]["sources"]
    return "\n".join(s["title"] + " (" + s["url"] + "): " + s["snippet"] for s in sources)
```

## The shortest path: keep your code

Replace `GoogleSearchAPIWrapper()` with `SearxSearchWrapper(searx_host=...)` pointed at `https://api.specstream.ai/searxng/<key>/search`. `run()`, `results()` and your tool list stay as they are, and you remove `GOOGLE_API_KEY` and `GOOGLE_CSE_ID`.

Keep run() and results(): swap the wrapperCopy

```
import os

from langchain_community.utilities import SearxSearchWrapper

# The same run() and results() methods your chain already calls.
search = SearxSearchWrapper(
    searx_host="https://api.specstream.ai/searxng/" + os.environ["SPECSTREAM_API_KEY"] + "/search"
)
```

## $1 per 1,000 searches against $5

SpecStream costs 80% less than Google Custom Search from the first call, with no daily limit and no plan to choose.

SpecStream

Google Custom Search JSON API

**Price per 1,000 searches**

$1 on the fast tier, up to 10 results a search

$5, after 100 free queries a day

**Price per call**

$0.001

$0.005

**Daily limit**

None

10,000 queries a day

**Status**

Open to new accounts

Closed to new customers. Ends January 1, 2027

**Results per search**

Up to 100 with `num`

Up to 10 with `num`

**What a search returns**

Title, URL, site and snippet for each result. `passages=true` adds the best passages of each page, and the Extract API returns any page as Markdown at $0.80 per 1,000 pages

Title, link and snippet for each result

**What it searches**

The whole live web, with no engine to configure

The sites of a Programmable Search Engine you set up, named by `cx`

**Accuracy**

#1 across 15 public web search and extraction benchmarks

No score on these boards

**Pay per call with no account**

$0.002 a search in USDC on Base, with x402

Not offered

## What changes in the request and the reply

Each Google field, where it goes on the Search API, and what the Google compatible address keeps.

Google Custom Search

SpecStream /v1/web-search

SpecStream /customsearch/v1

**The key**

`Authorization: Bearer` header

`key` query parameter, as on Google

**`cx`**

Left out

Accepted and not used

**`q`**

`q`, with `site:` and `filetype:` written inside it

`q`, plus `siteSearch`, `exactTerms` and `orTerms`

**`num`**

`num`, 1 to 100

`num`

**`start`**

`page`, 1 to 10

`start`

**`items[].title`**

`data.sources[].title`

`items[].title`

**`items[].link`**

`data.sources[].url`

`items[].link`

**`items[].snippet`**

`data.sources[].snippet`

`items[].snippet`

**`queries.nextPage`**

`data.next_page`

`queries.nextPage`

## Move LangChain code in five steps

About ten minutes for one call site.

-   Create a SpecStream keyStep 1Sign up with no card. A new account gets $2 of credit, which covers 2,000 fast searches.

-   Store the keyStep 2Set `SPECSTREAM_API_KEY` where your LangChain code runs. Keep `GOOGLE_API_KEY` until the switch is live, then remove it together with `GOOGLE_CSE_ID`.

-   Change the requestStep 3Replace the `GoogleSearchAPIWrapper` tool with a `@tool` function that calls `https://api.specstream.ai/v1/web-search` with `speed=fast`, and pass it in your agent's tool list.

-   Read the replyStep 4Read `data.sources` in place of `items`. `link` becomes `url`, and `title` and `snippet` keep their names.

-   Test before January 1, 2027Step 5Run your own queries in the Google CSE migrator and compare both replies before you remove the Google key.

## Start now

Test your own query, start on free credit, or prepay for production.

-   [Google CSE migratorRun a query and see the Google shaped reply beside the SpecStream reply, with the code for your call.](https://specstream.ai/tools/google-cse-migrator.md)
-   [Start with $2 of creditNo card. It covers 2,000 fast searches, and the key works on the API and over MCP.](https://specstream.ai/signup?src=migrate-google-cse-langchain&returnTo=%2Fworkspace%2Fsearch)
-   [$1,000 prepay packPay once by card and get $1,200 of credit. It does not expire.](https://buy.stripe.com/7sY3cn57l0jxedO9EmbAs0c)
-   [$5,000 prepay packFor production volume. Pay once by card and search from the same balance.](https://buy.stripe.com/aFadR12Zd1nB4De8AibAs0b)

## The same move in other stacks

-   [Python](https://specstream.ai/migrate/google-cse/python.md)
-   [TypeScript](https://specstream.ai/migrate/google-cse/typescript.md)
-   [Node.js](https://specstream.ai/migrate/google-cse/nodejs.md)
-   [Go](https://specstream.ai/migrate/google-cse/go.md)
-   [PHP](https://specstream.ai/migrate/google-cse/php.md)
-   [Ruby](https://specstream.ai/migrate/google-cse/ruby.md)
-   [Java](https://specstream.ai/migrate/google-cse/java.md)
-   [C#](https://specstream.ai/migrate/google-cse/csharp.md)
-   [curl](https://specstream.ai/migrate/google-cse/curl.md)
-   [LlamaIndex](https://specstream.ai/migrate/google-cse/llamaindex.md)
-   [Vercel AI SDK](https://specstream.ai/migrate/google-cse/vercel-ai-sdk.md)
-   [OpenAI Agents SDK](https://specstream.ai/migrate/google-cse/openai-agents.md)
-   [n8n](https://specstream.ai/migrate/google-cse/n8n.md)
-   [Cloudflare Workers](https://specstream.ai/migrate/google-cse/cloudflare-workers.md)
-   [All stacks](https://specstream.ai/migrate/google-cse.md)
-   [Google Custom Search in LangChain](https://specstream.ai/google-pse/langchain.md)

## Questions

Something we didn't answer? [Talk to a human](https://specstream.ai/talk-to-a-human.md)

When does the Google Custom Search JSON API shut down?

Google's documentation says existing customers have until January 1, 2027 to move to another solution. The API is already closed to new customers.

What is the fastest way to replace Google Custom Search in LangChain?

Replace `GoogleSearchAPIWrapper()` with `SearxSearchWrapper(searx_host=...)` pointed at `https://api.specstream.ai/searxng/<key>/search`. `run()`, `results()` and your tool list stay as they are, and you remove `GOOGLE_API_KEY` and `GOOGLE_CSE_ID`.

What does SpecStream cost against Google Custom Search?

Google charges $5 per 1,000 queries after 100 free queries a day and stops at 10,000 queries a day. SpecStream costs $1 per 1,000 searches of up to 10 results on the fast tier, 80% lower, with no daily limit. A new account gets $2 of credit with no card.

Do I need a Programmable Search Engine ID?

No. SpecStream searches the whole live web, so there is no engine to configure. On `/v1/web-search` you leave `cx` out, and on the Google compatible address it is accepted and not used. To keep a search inside one site, write `site:example.com` in `q`.

Is the reply the same as Google's?

On `https://api.specstream.ai/customsearch/v1` the reply keeps Google's JSON: `items` with `title`, `link`, `snippet` and `displayLink`, `searchInformation.totalResults` and `queries.nextPage`. On `/v1/web-search` each result is in `data.sources` with `title`, `url`, `site` and `snippet`, and `passages=true` adds the best passages of each page.

How accurate is SpecStream search?

SpecStream is #1 across 15 public web search and extraction benchmarks from one frozen build, with 99 on SimpleQA Verified and first place on WideSearch. Scores and method are on the benchmarks page.

Can an agent pay per call with no account?

Yes. With x402 an agent pays $0.002 for one fast search in USDC on Base, with no account and no key. With a key the same search costs $0.001.

What is the best alternative to the Google Custom Search JSON API?

SpecStream is the drop in alternative. It answers the same `customsearch/v1` request with Google's JSON reply, costs $1 per 1,000 searches against Google's $5, has no daily limit, and is #1 across 15 public web search and extraction benchmarks.

Is there a drop in replacement for customsearch.googleapis.com?

Yes. Send the request you send to `https://www.googleapis.com/customsearch/v1` or `https://customsearch.googleapis.com/customsearch/v1` to `https://api.specstream.ai/customsearch/v1`, with a SpecStream key in `key`. `q`, `num`, `start`, `siteSearch`, `exactTerms`, `excludeTerms`, `orTerms`, `dateRestrict`, `fileType`, `lr`, `gl`, `safe` and `searchType=image` carry over, and `cx` is accepted and not used.

Is there a cheaper API than Google Custom Search?

Yes. Google charges $5 per 1,000 queries. SpecStream charges $1 per 1,000 searches, 80% lower. A new account gets $2 of credit with no card, which covers 2,000 test searches, and the Starter plan is $49 a month for 49,000 searches.

What happens to my code on January 1, 2027?

Google's documentation gives existing customers until January 1, 2027 to move to another solution, and the API already takes no new customers. A call your product still sends to Google after that date has no service behind it. Moving to SpecStream is one changed base URL.

Does this work with LangGraph and LangChain.js?

Yes. The `@tool` function goes into `create_react_agent` or any LangGraph node as it is. In LangChain.js, wrap the same `fetch` call with `tool()` from `@langchain/core/tools`.

## Keep your search working after January 1

One call changed. $1 per 1,000 searches, no daily limit, and $2 of credit to start.

[Get an API key](https://specstream.ai/signup?src=migrate-google-cse-langchain&returnTo=%2Fworkspace%2Fsearch)[Talk to a human](https://specstream.ai/talk-to-a-human.md)
