Tutorial

How to Add Search to Pi Coding Agent

Pi Coding Agent ships with only read, write, edit, and bash. Add real-time web search via Scavio as a TypeScript extension in under five minutes.

Pi Coding Agent is the minimal terminal harness from Mario Zechner's pi-mono project. The design choice is four tools only (read, write, edit, bash) and extensions for everything else. The first extension most Pi users write is web search. This tutorial shows how to add Scavio as a Pi extension so the agent can search Google, Reddit, YouTube, and retail platforms during a session.

Prerequisites

  • Node.js 20+
  • Pi Coding Agent installed (npm install -g @mariozechner/pi-coding-agent)
  • A Scavio API key (free 500 credits at scavio.dev)
  • Basic TypeScript familiarity

Walkthrough

Step 1: Install the Scavio SDK

Add the Scavio TypeScript client to your Pi extensions directory.

Bash
cd ~/.pi/extensions
npm init -y
npm install scavio

Step 2: Create the extension file

Pi extensions are TypeScript modules that export a tool registration function.

// ~/.pi/extensions/scavio-search.ts
import { Scavio } from 'scavio';

export const scavioSearch = {
  name: 'web_search',
  description: 'Search Google, Reddit, YouTube, Amazon via Scavio',
  parameters: {
    query: { type: 'string', required: true },
    platform: { type: 'string', default: 'google' }
  },
  handler: async ({ query, platform }) => {
    const client = new Scavio({ apiKey: process.env.SCAVIO_API_KEY });
    const results = await client.search({ query, platform });
    return results.organic_results?.slice(0, 5) || results;
  }
};

Step 3: Register the extension with Pi

Add to your Pi config so it loads on every session.

// ~/.pi/config.ts
import { scavioSearch } from './extensions/scavio-search';

export default {
  extensions: [scavioSearch]
};

Step 4: Set your Scavio API key

Export the key so Pi sessions pick it up automatically.

Bash
echo 'export SCAVIO_API_KEY=sk_live_...' >> ~/.zshrc
source ~/.zshrc

Step 5: Use the tool in a Pi session

Start Pi and ask it to search. The agent now has a web_search tool alongside read, write, edit, and bash.

Bash
pi
> Find the latest Next.js 16 app router breaking changes

Python Example

Python
# Pi is TypeScript-native. For Python parity, use the Scavio Python SDK in your own harness:
import os
from scavio import Scavio

client = Scavio(api_key=os.environ['SCAVIO_API_KEY'])
results = client.search(query='Next.js 16 app router breaking changes')
for r in results['organic_results'][:5]:
    print(r['title'], '-', r['link'])

JavaScript Example

JavaScript
import { Scavio } from 'scavio';

export const scavioSearch = {
  name: 'web_search',
  description: 'Search Google via Scavio',
  parameters: { query: { type: 'string', required: true } },
  handler: async ({ query }) => {
    const client = new Scavio({ apiKey: process.env.SCAVIO_API_KEY });
    return (await client.search({ query })).organic_results.slice(0, 5);
  }
};

Expected Output

JSON
Pi session returns the top 5 Google results inline, ready to feed into the next agent step. The extension persists across every future Pi session and adds ~30 credits per call on Scavio.

Related Tutorials

Frequently Asked Questions

Most developers complete this tutorial in 15 to 30 minutes. You will need a Scavio API key (free tier works) and a working Python or JavaScript environment.

Node.js 20+. Pi Coding Agent installed (npm install -g @mariozechner/pi-coding-agent). A Scavio API key (free 500 credits at scavio.dev). Basic TypeScript familiarity. A Scavio API key gives you 500 free credits per month.

Yes. The free tier includes 500 credits per month, which is more than enough to complete this tutorial and prototype a working solution.

Scavio has a native LangChain package (langchain-scavio), an MCP server, and a plain REST API that works with any HTTP client. This tutorial uses the raw REST API, but you can adapt to your framework of choice.

Start Building

Pi Coding Agent ships with only read, write, edit, and bash. Add real-time web search via Scavio as a TypeScript extension in under five minutes.