> ## Documentation Index
> Fetch the complete documentation index at: https://docs.perplexity.ai/llms.txt
> Use this file to discover all available pages before exploring further.

# Quickstart

> Learn how to use the official Perplexity SDKs for Python and TypeScript to access the Perplexity APIs with type safety and async support.

## Overview

The official Perplexity SDKs provide convenient access to the Perplexity APIs from Python 3.10+ and Node.js 20+ applications. Both SDKs include type definitions for all request parameters and response fields, with both synchronous and asynchronous clients.

Use the SDKs with the **Agent API** for third-party models with web search tools and effort levels, **Search** for ranked web search results, **Embeddings** for standard and contextualized text embeddings, and **Decisions** for typed answers with probabilities. The client also covers Agent API batches, files, skills, and models, plus the legacy Sonar API (`chat.completions` and async chat completions).

> [!NOTE]
>
> Building a coding agent that writes its own retrieval code? The [Search SDK](https://docs.perplexity.ai/docs/search-sdk/overview.md) is a separate, agents-first Python package for batched web search and page snippets. Use this SDK for general app integrations.

## Available APIs

> [card] [Agent API](https://docs.perplexity.ai/docs/agent-api/quickstart.md)
>
> Third-party models from OpenAI, Anthropic, Google, and more with effort levels and web search tools.

> [card] [Search](https://docs.perplexity.ai/docs/search/quickstart.md)
>
> Ranked web search results with filtering, multi-query support, and domain controls.

> [card] [Embeddings](https://docs.perplexity.ai/docs/embeddings/quickstart.md)
>
> Generate high-quality text embeddings for semantic search and RAG.

> [card] [Decisions](https://docs.perplexity.ai/docs/decisions/quickstart.md)
>
> Get yes/no, choice, and score answers with probabilities.

## Installation

Install the SDK for your preferred language:

```bash Python theme={null}
pip install perplexityai
```

```bash TypeScript theme={null}
npm install @perplexity-ai/perplexity_ai
```

## Authentication

> [card] [Get your Perplexity API Key](https://console.perplexity.ai/project/keys)
>
> Generate a new key on the **API Keys** page in the API Console.

After generating the key, set it as an environment variable in your terminal:

> [tab] Windows
>
> ```bash theme={null}
> setx PERPLEXITY_API_KEY "your_api_key_here"
> ```

> [tab] MacOS/Linux
>
> ```bash theme={null}
> export PERPLEXITY_API_KEY="your_api_key_here"
> ```

### Using Environment Variables

You can use the environment variable directly:

```python Python theme={null}
import os
from perplexity import Perplexity

client = Perplexity() # Automatically uses PERPLEXITY_API_KEY
```

```typescript TypeScript theme={null}
import Perplexity from '@perplexity-ai/perplexity_ai';

const client = new Perplexity({
  apiKey: process.env['PERPLEXITY_API_KEY'], // This is the default and can be omitted
});
```

Or use [python-dotenv](https://pypi.org/project/python-dotenv/) (Python) or [dotenv](https://www.npmjs.com/package/dotenv) (Node.js) to load the environment variable from a `.env` file:

```python Python theme={null}
import os
from dotenv import load_dotenv
from perplexity import Perplexity

load_dotenv()

client = Perplexity() # Uses PERPLEXITY_API_KEY from .env file
```

```typescript TypeScript theme={null}
import Perplexity from '@perplexity-ai/perplexity_ai';
import dotenv from 'dotenv';

dotenv.config();

const client = new Perplexity(); // Uses PERPLEXITY_API_KEY from .env file
```

> [!TIP]
>
> Now you're ready to start using the Perplexity APIs! Choose your API below for step-by-step usage guides.

> [card] [Agent API](https://docs.perplexity.ai/docs/agent-api/quickstart.md)
>
> Get started with third-party models

> [card] [Search](https://docs.perplexity.ai/docs/search/quickstart.md)
>
> Get started with web search

> [card] [Embeddings](https://docs.perplexity.ai/docs/embeddings/quickstart.md)
>
> Get started with text embeddings

> [card] [Decisions](https://docs.perplexity.ai/docs/decisions/quickstart.md)
>
> Get started with decisions

## Resources

> [card] [Python Package](https://pypi.org/project/perplexityai/)
>
> Install from PyPI with pip

> [card] [Node.js and TypeScript Package](https://www.npmjs.com/package/@perplexity-ai/perplexity_ai)
>
> Install from npm registry
