Why Use the Agentic Research API?
Multi-Provider Access
Access OpenAI, Anthropic, Google, xAI, and more through one unified API, no need to manage multiple API keys.
Transparent Pricing
See exact token counts and costs per request, no markup, just direct provider pricing.
Granular Control
Change models, reasoning, tokens, and tools with consistent syntax.
We recommend using our official SDKs for a more convenient and type-safe way to interact with the Agentic Research API.
Installation
Install the SDK for your preferred language:Authentication
Set your API key as an environment variable. The SDK will automatically read it:- macOS/Linux
- Windows
.env file in your project:
.env
All SDK examples below automatically use the
PERPLEXITY_API_KEY environment variable. You can also pass the key explicitly if needed.Generating an API Key
Get your Perplexity API Key
Navigate to the API Keys tab in the API Portal and generate a new key.
Basic Usage
Using a Third-Party Model
Use third-party models from OpenAI, Anthropic, Google, X.AI, and other providers for specific capabilities:Using a Preset
Presets provide optimized defaults for specific use cases. Start with a preset for quick setup:With Web Search Tool
Enable web search capabilities using theweb_search tool:
Input Formats
Theinput parameter accepts either a string or an array of message objects.
String Input
Simple string input for straightforward queries:Message Array Input
Use message arrays for multi-turn conversations:Instructions Parameter
Theinstructions parameter provides system instructions or guidelines for the model. This is particularly useful for:
- Tool usage instructions: Guide the model on when and how to use available tools
- Response style guidelines: Control the tone and format of responses
- Behavior constraints: Set boundaries and constraints for model behavior
Tools
The Agentic Research API provides two powerful tools for accessing real-time web information:web_search- Performs web searches to retrieve current information and newsfetch_url- Fetches and extracts content from specific URLs
web_search tool can optionally include user location for localized results:
Generation Parameters
Control response generation with standard parameters:Reasoning Effort
Control the reasoning effort level for reasoning models:low: Minimal reasoning effortmedium: Moderate reasoning efforthigh: Maximum reasoning effort
The
reasoning parameter is only supported by models with reasoning capabilities. Models without reasoning support will ignore this parameter.Streaming Responses
The Agentic Research API supports streaming responses using Server-Sent Events (SSE). Enable streaming by settingstream=True:
For comprehensive streaming documentation, see the Streaming Guide.
Error Handling
Handle errors gracefully:Response Structure
Response Structure Example
Response Structure Example
Responses from the Agentic Research API have a structured format:
Next Steps
Model Fallback
Specify multiple models for automatic failover and higher availability.
Presets
Explore available presets and their configurations.
Models
Explore available presets and third-party models for the Agentic Research API.
API Reference
View complete endpoint documentation and parameters.
Structured Outputs
Generate formatted responses with JSON schema or regex.
Chat Completions API
Need web-grounded responses with built-in search? Check out the Chat Completions API.
Search API
Get raw search results with the Search API.
Need help? Check out our community for support and discussions with other developers.