Skip to main content

Overview

The Search API returns ranked web results as JSON for your own code to filter, store, or pass to a model. Each result has the page title, URL, text extracted from the page that is relevant to your query, and dates. There is no generated answer: for an answer with citations, use the Agent API. Search is billed per successful request, with no token charges. See Search API pricing.

Authentication

Create an API key in the API Console and set it as an environment variable. Both libraries read PERPLEXITY_API_KEY automatically, and direct HTTP requests send it as Authorization: Bearer $PERPLEXITY_API_KEY.
Confirm the key is set without printing it:
Do not print the key or any part of it. Commands like env or echo "$PERPLEXITY_API_KEY" can expose it in terminal output and logs. Do not paste a real key into code, fixtures, or commit messages.

Installation

Make a request

Send a query and the number of results you want in max_results (1 to 20, default 10):

Response fields

Every result has title, url, and snippet. Read date with a fallback, for example result.date or "unknown" in Python.

Next Steps

How Search Works

Multiple queries in one request, search types, request controls, and limits.

Filters

Restrict results by date, language, and domain.

Use Search in Your Agent

Call Search as a tool from the OpenAI, Anthropic, or Gemini SDK.

API Reference

Every request parameter, the response schema, and error responses.