Skip to main content

Try the Agent API Playground

Test Agent API requests and parameters interactively in the API console.

Pricing

Pay-as-you-go pricing for all APIs. No subscription required.

Why Use the Agent API?

Web-Grounded Answers

Get accurate, up-to-date answers grounded in real-time web search, with inline citations in a single call, and conversation context across turns.

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 Agent API.
Endpoint: The Agent API is available at POST https://api.perplexity.ai/v1/agent. For OpenAI SDK compatibility, POST /v1/responses is also accepted as an alias. See the OpenAI Compatibility Guide for details on using OpenAI SDKs with Perplexity.

Installation

Install the SDK for your preferred language:

Authentication

Set your API key as an environment variable. The SDK will automatically read it:
All SDK examples below automatically use the PERPLEXITY_API_KEY environment variable. You can also pass the key explicitly if needed.

Basic Usage

Convenience Property: Both Python and Typescript SDKs provide an output_text property that aggregates all text content from response outputs. Instead of iterating through response.output, simply use response.output_text for cleaner code.

Using a Third-Party Model

Use third-party models from OpenAI, Anthropic, Google, xAI, and other providers for specific capabilities:

Using a Preset

Presets provide optimized defaults for specific use cases. Start with a preset for quick setup:
Learn more about presets to explore pre-configured setups optimized for different use cases with specific models, token limits, and tool access.
The Agent API provides access to a number of tools that can be used to extend the capabilities of the model. Enable web search capabilities using the web_search tool:
Retrieve structured financial and market data using the finance_search tool. See the Finance Search guide for capabilities and recommended configurations.

Next Steps

Web Search

Use web search for source-grounded, current context.

Agent API Models

Browse available models and pricing across all supported providers.

Presets

Explore pre-configured setups for common use cases like low and medium.

Output Control

Configure streaming responses and structured outputs with JSON schema.

Model Fallback

Specify multiple models for automatic failover and higher availability.

Prompt Guide

Best practices for effective prompting with web search models.

Search Filters

Control search results with domain, date, and location filters.

API Reference

View complete endpoint documentation and parameters.
Need help? Check out our community for support and discussions with other developers.