Skip to main content

Agent Research Assistant

A command-line research tool that leverages Perplexity’s Agent API with the medium preset to conduct thorough, multi-step web research on any topic. The tool produces structured reports with sections, cited sources, and confidence scores.

Features

  • Multi-step web research powered by the medium preset
  • Structured JSON output with sections, sources, and confidence scores using response_format with json_schema
  • Configurable model selection (defaults to openai/gpt-5.2 via the medium preset)
  • Clean CLI interface that accepts a topic and outputs a formatted report
  • Source tracking with URLs and relevance annotations
  • Exportable reports in JSON or plain text

Installation

API Key Setup

Set your Perplexity API key as an environment variable. The SDK reads it automatically:

Usage

How It Works

  1. The CLI accepts a research topic as input.
  2. A structured JSON schema is defined for the report format using Pydantic (Python) or a TypeScript interface.
  3. The tool calls the Agent API with preset="medium", which configures the model (openai/gpt-5.2), enables web_search and fetch_url tools, and allows up to 10 reasoning steps.
  4. The response_format parameter with json_schema enforces structured output matching the report schema.
  5. The response is parsed and displayed as a formatted research report.
The medium preset is optimized for complex, in-depth analysis. It uses openai/gpt-5.2 with up to 10K max tokens and 10 reasoning steps. You can override the model by passing --model to the CLI.

Full Code

Example Output

For shorter, faster research tasks, consider using the low preset instead. It uses openai/gpt-5.4 with up to 3 reasoning steps — a good balance of speed and thoroughness.
The first request with a new JSON Schema may take 10 to 30 seconds to prepare. Subsequent requests with the same schema will not see this delay. See the structured outputs guide for details.

Limitations

  • Deep research requests consume more tokens and cost more than standard requests due to multi-step reasoning and tool usage.
  • Structured output with JSON schema requires the model to adhere to the schema. Very complex schemas may reduce output quality.
  • Confidence scores are model-generated estimates and should be treated as relative indicators, not absolute measures.
  • The quality of research depends on the availability and quality of web sources for the given topic.