Skip to main content

Generating an API Key

Get your Perplexity API Key

Navigate to the API Keys tab in the API Portal and generate a new key.
See the API Groups page to learn more about API groups.

Overview

The Perplexity API provides five APIs for different use cases: Agent API for accessing OpenAI, Anthropic, Google, and xAI models with unified search tools and transparent pricing, Search for ranked web search results, Sonar for web-grounded AI responses with Sonar models, Browser for remote browser automation, and Embeddings for generating text embeddings. All APIs support both REST and SDK access with streaming, filtering, and advanced controls.

Available APIs

Agent API

Third-party models from OpenAI, Anthropic, Google, and more with presets and web search tools.

Search

Ranked web search results with filtering, multi-query support, and domain controls.

Sonar

Web-grounded AI responses with citations, conversation context, and streaming support.

Browser

Remote browser automation via Chrome DevTools Protocol (CDP).

Embeddings

Generate high-quality text embeddings for semantic search and RAG.

Choosing the Right API

  • You need multi-provider access to OpenAI, Anthropic, Google, and more models through one API
  • You want granular control over model selection, reasoning, token budgets, and tools
  • You want presets for common use configurations or full customization for advanced workflows
Best for: Agentic workflows, custom AI applications, multi-model experimentation
  • You need raw search results without LLM processing
  • You want to build custom AI workflows with your own models
  • You need search data for indexing, analysis, or training
Best for: Custom AI pipelines, data collection, search integration
  • You want Perplexity’s Sonar models optimized for research and Q&A
  • You need built-in citations and conversation context
  • You prefer simplicity—just send a message and get a researched answer
Best for: AI assistants, research tools, Q&A applications

Installation

Install the SDK for your preferred language:

Authentication

Set your API key as an environment variable:
OpenAI SDK Compatible: Perplexity’s API supports the OpenAI Chat Completions format. You can use OpenAI client libraries by pointing to our endpoint. See the OpenAI Compatibility Guide for examples.

Making Your First API Call

Choose your API based on your use case:
Use for third-party models with web search tools and presets:
The response includes structured output with tool usage and citations:

Streaming Responses

Enable streaming for real-time output with either API:
For a full guide on streaming, including parsing, error handling, citation management, and best practices, see our streaming guide.

Next Steps

Now that you’ve made your first API call, explore each API in depth:

Agent API

Get started with third-party models and presets

Search API

Get started with web search results

Sonar API

Get started with web-grounded AI responses

Browser API

Get started with browser automation

Embeddings API

Get started with text embeddings

Perplexity SDK

Learn about the official Perplexity SDK with type safety and async support

Models

Explore available models and their capabilities

API Reference

View complete API documentation with detailed endpoint specifications

Examples

Explore code examples, tutorials, and integration patterns
Need help? Check out our community for support and discussions with other developers.