Created
September 26, 2025 09:41
-
-
Save thdxr/7ffc16e0f4fcccc612d10ee409bb038c to your computer and use it in GitHub Desktop.
opencode websearch
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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