Skip to content

Instantly share code, notes, and snippets.

@thdxr
Created September 26, 2025 09:41
Show Gist options
  • Save thdxr/7ffc16e0f4fcccc612d10ee409bb038c to your computer and use it in GitHub Desktop.
Save thdxr/7ffc16e0f4fcccc612d10ee409bb038c to your computer and use it in GitHub Desktop.
opencode websearch
import { tool } from "@opencode-ai/plugin";
export default tool({
description:
"Run a search query to search the internet for results. Use this to look up latest information or find documentation.",
args: {
query: tool.schema.string().describe("search query"),
},
execute: async (args) => {
const url = "https://api.perplexity.ai/search";
const response = await fetch(url, {
method: "POST",
headers: {
Authorization: "Bearer " + process.env.PERPLEXITY_API_KEY,
"Content-Type": "application/json",
},
body: `{"query":"${args.query}"}`,
});
return response.text();
},
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment