Skip to content
    ↑↓ select↵ openesc close
    pichenka007gd

    Openrouter Websearch

    opencode-openrouter-websearch·v1.0.0·Model Providers

    OpenCode plugin: web search via the OpenRouter web plugin, with in-TUI settings menu

    GitHub stars

    1

    Monthly installs

    322

    28 in 7 days

    Composite score

    37.9

    Multi-signal model

    Last commit

    3 days ago

    2026-10-17

    Install and configure

    opencode.json

    Writes to this project's opencode.json — applies to this repository only.

    opencode.json

    {
      "$schema": "https://opencode.ai/config.json",
      "plugin": ["opencode-openrouter-websearch@1.0.0"]
    }

    OpenCode loads npm dependencies through its embedded runtime on startup and caches them locally — no manual global install needed.

    npm version npm downloads npm total downloads node license GitHub stars GitHub issues last commit

    OpenCode plugin: web search through the OpenRouter web plugin (Exa by default).

    How it works

    sequenceDiagram
        participant Agent
        participant Plugin as OpenRouterWebsearch
        participant OpenRouter
        participant Summarizer
    
        Agent->>Plugin: websearch
        Plugin->>OpenRouter: Search via web plugin
        OpenRouter-->>Plugin: Search results
        opt Summarization enabled
            Plugin->>Summarizer: Summarize results
            Summarizer-->>Plugin: Brief with citations and sources
        end
        Plugin-->>Agent: Search response
    
    • Search call runs the configured model through OpenRouter's web plugin (Exa by default) and produces the raw answer plus results with page contents.
    • Summarize call (only when summarize: true, default) sends the answer plus all results — each truncated to summarizeMaxChars characters — back to the model with a preservation-focused prompt: it must keep every distinct fact, number, date and exception, mark conflicts with sources, and cite claims as [n]. The agent then sees only the brief and the list of sources, so a typical query costs a few hundred tokens instead of several thousand.
    • If the summarize call fails, the plugin logs the error and falls back to raw results — search never breaks because of summarization.

    Usage statistics

    Every search appends to stats.json next to the plugin:

    • calls / searchCalls / summarizeCalls — call counts
    • searchCost — web-plugin (search) part of the cost, from OpenRouter usage.cost_details
    • modelCost — rest of the search-call cost (model tokens)
    • summarizeCost — cost of the summarization call
    • totalCost, inputTokens, outputTokens — cumulative totals in USD / tokens

    View anytime:

    node settings.mjs --stats
    

    What it does

    • Registers an openrouter provider for OpenCode's built-in websearch tool and sets it as the default. All agents get one clean web search tool.
    • Adds a "Websearch: plugin settings" entry to the command palette (Ctrl+P): pick the model from the live OpenRouter list, set result/token limits, engine, search prompt, include/exclude domains.
    • Ships a CLI settings script as an alternative to the TUI menu.

    Package stats

    Install

    From npm (after publish):

    // opencode.jsonc
    {
      "plugins": ["opencode-openrouter-websearch"]
    }
    

    From a local path:

    {
      "plugins": [
        { "package": "/path/to/opencode-openrouter-websearch" }
      ]
    }
    

    Requires an OpenRouter connection (opencode auth login → openrouter) or OPENROUTER_API_KEY.

    Configuration

    Stored in the plugin's own config.json:

    {
      "model": "openai/gpt-6-luna",
      "maxResults": 5,
      "maxOutputTokens": 4000,
      "engine": "exa",  "includeDomains": [],
      "excludeDomains": []
    }
    

    Options from the plugins entry in opencode.jsonc (ctx.options) override config.json.

    Option Default Meaning
    model openai/gpt-6-luna Model used to run the search/answer
    maxResults 5 Max results (web.max_results)
    maxOutputTokens 4000 Answer token budget
    engine provider default exa | native | firecrawl | parallel | perplexity
    mode — OpenRouter web plugin mode
    searchPrompt — Custom search prompt
    summarize true Return a compact brief instead of full contents
    summarizeMaxChars 1200 Max chars per result fed to the summarizer
    includeDomains / excludeDomains — Domain filters

    Settings

    • TUI: Ctrl+P → "Websearch: plugin settings"
    • CLI: npm run settings in the plugin directory (or node settings.mjs)

    Restart OpenCode after changing settings.

    Layout

    • index.js — server plugin: websearch provider registration
    • tui.js — TUI plugin: settings menu in the command palette
    • settings.mjs — standalone CLI settings menu
    • config.json — plugin configuration

    Similar plugins