Tools
Independent Openrouter Perplexity Search
OpenClaw plugin that provides an independent OpenRouter Perplexity Search tool.
Install
npm install
npm
Configuration Example
{
"plugins": {
"entries": {
"independent-openrouter-perplexity-search": {
"config": {
"timeout_ms": 120000
}
}
}
}
}
README
# independent-openrouter-perplexity-search
OpenClaw tool plugin that exposes `openrouter_perplexity_search`, an independent OpenRouter Perplexity Search tool.
This tool consumes OpenRouter credits, but the search quality is strong. It can work independently of OpenClaw's built-in `web_search`. Use it when the built-in `web_search` results are not satisfactory and better search results are needed.
## Install
```bash
openclaw plugins install npm:@jwongart/[email protected]
```
## Configuration
The tool input mirrors OpenRouter request fields, so request timeout is configured at plugin level:
```json
{
"plugins": {
"entries": {
"independent-openrouter-perplexity-search": {
"config": {
"timeout_ms": 120000
}
}
}
}
}
```
- `timeout_ms`: request timeout in milliseconds, from `15000` to `300000`. Default is `120000`.
## Tool
- `openrouter_perplexity_search`: calls OpenRouter Chat Completions with `model=perplexity/sonar-pro-search`.
### Inputs
Inputs mirror the OpenRouter `perplexity/sonar-pro-search` Chat Completions API fields that OpenRouter currently reports for this model. The plugin fixes `model` to `perplexity/sonar-pro-search`.
- `messages` (required): OpenRouter Chat Completions messages array.
- `max_tokens`: maximum output tokens. OpenRouter currently reports `max_completion_tokens=8000` for this model.
- `temperature`, `top_p`, `top_k`, `frequency_penalty`, `presence_penalty`: OpenRouter request parameters.
- `reasoning`, `include_reasoning`, `response_format`: OpenRouter request parameters for reasoning and structured output behavior.
- `web_search_options`: Perplexity/OpenRouter native web search options, including `search_context_size` and `user_location`.
OpenRouter model metadata currently lists these supported parameters for this model: `frequency_penalty`, `include_reasoning`, `max_tokens`, `presence_penalty`, `reasoning`, `structured_outputs`, `temperature`, `top_k`, `top_p`, and `web_search_options`. Perplexity direct-API fields such as `search_domain_filter` and `search_recency_filter` are not exposed here unless OpenRouter adds them to this model's supported parameters.
### Output
The tool returns natural-language `content` for OpenClaw plus structured `details`:
- `content`: the full Perplexity answer, a compact `Resources` list, plus model and any returned usage/cost summary such as `Usage: 23 prompt + 28 completion = 51 tokens` and `Estimated cost: $0.00649`. Resources prefer OpenRouter `search_results` when returned, then fall back to citations/annotations. Each resource uses a natural display style: title plus URL when a title exists, optional snippet text only when OpenRouter returns a real snippet-like field (`snippet`, `content`, `text`, or `description`), and URL-only citations stay URL-only. Snippets are capped to keep tool output compact.
- `details.openrouterRequest`: the exact JSON body sent to OpenRouter.
- `details.openrouterResponse`: the raw OpenRouter Chat Completions response, including fields such as `id`, `model`, `created`, `choices`, `usage`, and provider-specific fields such as citations when returned.
- `details.retryCount`: retry count for transient 429/5xx/network failures.
## API Key
The plugin reads the OpenRouter API key in this order:
1. `OPENROUTER_API_KEY` from the Gateway process environment.
2. `env.OPENROUTER_API_KEY` from `~/.openclaw/openclaw.json`.
3. `models.providers.openrouter.apiKey` from `~/.openclaw/openclaw.json`.
The API key is never returned in tool output.
## Build
```bash
npm install
npm run plugin:build
npm run plugin:validate
npm test
```
## License
MIT
tools
Comments
Sign in to leave a comment