smolagents
smolagents' ApiWebSearchTool calls the Brave Search API by default. Set its endpoint to SpecStream's Brave address and your agents search through SpecStream's Search API, with no other code change.
SpecStream for smolagentsAgent frameworks & buildersWhat you need
- Python with smolagents installed. ApiWebSearchTool is in the current release, 1.26.0.
- A SpecStream API key. New accounts get $10 of credit on sign up, no card. Get your key on the Search API screen of your workspace.
- 1
1. Put your key in the environment
ApiWebSearchTool reads its key from an environment variable,
BRAVE_API_KEYunless you name another one. Give the SpecStream key its own name, so it is never mixed up with a Brave key:Shell - 2
2. Set the endpoint
Pass SpecStream's address as
endpointand the variable's name asapi_key_name. The tool sends the key in theX-Subscription-Tokenheader and the question asq, the way Brave takes them, and SpecStream answers in Brave's shape:web.results[]withtitle,urlanddescription, which is what the tool reads.rate_limit=Noneturns off the tool's own wait of one query per second. Leave it out to keep that wait.agent.py - 3
3. Check it
Call the tool once on its own. It prints
## Search Resultsand a numbered list of titles, links and descriptions. The tool's name staysweb_search, so prompts written for the default tool keep working.Python
What the tool sends, and what comes back
| ApiWebSearchTool sends | SpecStream |
|---|---|
GET to the endpoint you set | https://api.specstream.ai/res/v1/web/search, Brave's path on SpecStream's host |
q, the agent's query | Searched as written |
count=10, the tool's default params | 10 results, at the price of one search |
X-Subscription-Token | Your SpecStream key |
Reads web.results[] | title, url and description on each result |
More results per search
params replaces the tool's default {"count": 10}, so name the count when you pass it. params={"count": 20} brings 20 results, and the call is priced as a search of 20 results, as Search API lists.
Read pages with the Extract API
smolagents' VisitWebpageTool fetches a page itself with requests, so a page that refuses a plain read comes back as an error. This tool, with the same name, reads pages through SpecStream's Extract API instead. A page that refuses a plain read is tried again as a browser, then from the site's feed, then from its newest public archive capture, and the reply is the page's main text as Markdown, without menus and ads:
If a search fails
The tool raises the HTTP error it gets. 401 means SpecStream got no valid key: check that SPECSTREAM_API_KEY is set in the environment the agent runs in, and that the key was made on the Search API screen. A key made with no scopes can read and cannot search.
Cost
Each search is one Search API call on the fast tier, which costs a fifth of the default search's $5 per 1,000 searches of up to 10 results. Each page read through the Extract API is $0.80 per 1,000 pages, and a page with no text is not charged. Both come out of your balance, with no quote and no approval. New accounts start with $10 of credit, no card. Questions go to [email protected].
More
SpecStream for smolagents covers what it does in smolagents 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].