> For the complete documentation index, see [llms.txt](https://whitepaper.aitech.io/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://whitepaper.aitech.io/agentforge/tools/perplexity.md).

# perplexity

### Usage Instructions

Generate completions using Perplexity AI models with real-time knowledge and search capabilities. Create responses, answer questions, and generate content with customizable parameters.

### Where to Get Your Perplexity API Key

To get an API key for Perplexity, you need to manage it through your account settings in the web interface.

Here is the step-by-step process:

{% stepper %}
{% step %}

### Log in to your account

If you don't have one, you'll need to create one first.
{% endstep %}

{% step %}

### Go to your account settings

This is usually located in the bottom-left corner of the interface and can often be accessed by clicking on your **profile picture** or a **gear icon**.
{% endstep %}

{% step %}

### Navigate to the API Tab

In your settings menu, look for the **API** tab or a section specifically for API keys.
{% endstep %}

{% step %}

### Add Payment and Purchase Credits

Perplexity's API is a paid service. You must have a **non-zero balance** or be on a **Pro plan** to generate a key.
{% endstep %}

{% step %}

### Generate a New API Key

In the API section, you'll find an option to **"Generate API Key"** or **"Create API Key."**
{% endstep %}

{% step %}

### Copy and Save the Key

Once generated, **copy the key and store it securely.** For security reasons, it is often only shown once.
{% endstep %}
{% endstepper %}

### Tools

#### `perplexity_chat`

Generate completions using Perplexity AI chat models

**Input**

| Parameter      | Type   | Required | Description                                              |
| -------------- | ------ | -------- | -------------------------------------------------------- |
| `systemPrompt` | string | No       | System prompt to guide the model behavior                |
| `content`      | string | Yes      | The user message content to send to the model            |
| `model`        | string | Yes      | Model to use for chat completions (e.g., sonar, mistral) |
| `max_tokens`   | number | No       | Maximum number of tokens to generate                     |
| `temperature`  | number | No       | Sampling temperature between 0 and 1                     |
| `apiKey`       | string | Yes      | Perplexity API key                                       |

**Output**

| Parameter | Type   | Description        |
| --------- | ------ | ------------------ |
| `content` | string | Generated response |
| `model`   | string | Model used         |
| `usage`   | json   | Token usage        |

### Notes

* Category: `tools`
* Type: `perplexity`


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://whitepaper.aitech.io/agentforge/tools/perplexity.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
