Skip to content

Instantly share code, notes, and snippets.

@remorses
Created September 19, 2025 11:45
Show Gist options
  • Save remorses/9255e4f120cf47497173fc21a06a9263 to your computer and use it in GitHub Desktop.
Save remorses/9255e4f120cf47497173fc21a06a9263 to your computer and use it in GitHub Desktop.
Google web search for opencode
import { tool } from "@opencode-ai/plugin";
import { createGoogleGenerativeAI } from "@ai-sdk/google";
import { generateText } from "ai";
const google = createGoogleGenerativeAI({
apiKey: process.env.GEMINI_API_KEY!,
});
export default tool({
description: "Search for something in the internet",
args: {
query: tool.schema.string().describe("Keyword or phrase to search for"),
},
async execute(args) {
const { text } = await generateText({
model: google("gemini-2.5-flash"),
tools: {
google_search: google.tools.googleSearch({}),
},
prompt: `Search the web for "${args.query}". Summarize in concise bullets points. Include code snippets. The search results will be used by a coding agent, so provide example usage implementation for code.`,
});
return text;
},
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment