MetaGPT
Give MetaGPT's Researcher and Searcher live web search from SpecStream. MetaGPT's custom search engine takes one async function. This guide gives you that function, the two lines that wire it in, and what each search costs.
SpecStream for MetaGPTAgent frameworks & buildersWhat you need
- MetaGPT, with an LLM set in
~/.metagpt/config2.yaml. The Researcher reads the pages it finds with a browser engine, so install one too:pip install "metagpt[playwright]". - A SpecStream account. New accounts get $10 of credit, no card. Create one.
- 1
1. Create an API key
In your SpecStream workspace, open Agents & API, choose API keys, then Create API key, and set a total limit. Copy the key from the next screen. SpecStream shows it once.
Keep it in an environment variable where MetaGPT runs:
Terminal - 2
2. Write the search function
MetaGPT calls a custom engine as
run_func(query, max_results=max_results, as_string=as_string). Withas_string=Falseit expects a list of dicts withtitle,linkandsnippet. Withas_string=Trueit takes one string.This function sends the query to the Search API and returns both shapes. It uses
aiohttp, which MetaGPT already installs:specstream_search.py - 3
3. Point MetaGPT's search at it
Set
api_typetoSearchEngineType.CUSTOM_ENGINEandsearch_functo the function, before you create a role. MetaGPT builds each role's search engine fromconfig.search, so the Researcher'sCollectLinksaction now searches through SpecStream.A YAML file cannot hold a function, so this setting lives in code. Leave the
searchblock ofconfig2.yamlas it is, or remove it.research.py - 4
4. Run it
Run
python research.py. The Researcher writes its search questions, searches each one through SpecStream, reads the top pages with its browser engine and writes the report as a Markdown file indata/researchunder the MetaGPT root.To see the calls, open the Search API screen of your workspace. Each search is listed with its query and price.
What MetaGPT sends and gets back
SearchEngine.run asks for 8 results by default, and CollectLinks keeps that default. Each call of the function is one POST /v1/web-search:
| MetaGPT | SpecStream |
|---|---|
query | q, in everyday words, any language, 1 to 2,000 characters |
max_results | num, 1 to 100 |
title | data.sources[].title |
link | data.sources[].url |
snippet | data.sources[].snippet |
Use it for one Searcher only
To keep the global config as it is, pass the engine to one role. SearchEngine.from_search_func builds a custom engine from the function:
Or change one setting: the Bing engine
MetaGPT's Bing engine reads its address from bing_url, and the search block passes extra keys through to it. SpecStream answers Bing Web Search API v7 calls in Bing's shape, so this works with no code. In ~/.metagpt/config2.yaml:
Searches through the Bing address run on the fast tier. Its price is on the Search API page. Microsoft retired the Bing Search APIs on August 11, 2025, so a config that still points at Bing gets no results today. Moving off Bing Web Search v7 has the other settings.
Search quality
The SpecStream Search API scores 97.9 F-score on all 1,000 SimpleQA Verified questions and 64.0 item F1 on all 200 WideSearch tasks. Scores and method are on the benchmarks page.
Cost
Each call of the function is one Search API call at $5 per 1,000 searches of up to 10 results, from your balance, with no quote and no approval. A call that returns no results costs nothing.
A Researcher topic makes one search for each keyword the model writes, then one for each research question, four by default. New accounts start with $10 of credit, no card. Balance and billing has the details.
Remove
Delete the two config.search lines, or set api_type back to the engine you used before. To stop the key working everywhere, revoke it in Agents & API. Other ways to build with SpecStream are in agent frameworks. Questions go to [email protected].
More
SpecStream for MetaGPT covers what it does in MetaGPT on one page. Every other tool has its guide in Connect your tools. You see the most a request can cost before it starts, and the matches are paid from your balance. Billing has the details. For help, email [email protected].