# Perplexity AI on boxd

> Perplexity AI provides conversational AI models for generating human-like text responses.

- Page: https://boxd.sh/integrations/perplexityai/
- CLI: `run perplexityai` (9 commands)
- SDK: `import { perplexityai } from "@boxd/run"`; every parameter and response type is at `@boxd/run/perplexityai`
- Triggers: none
- Connect: `run auth perplexityai` (API key), or https://app.boxd.sh/integrations/detail/perplexityai
- All integrations: https://boxd.sh/integrations/ (Markdown: https://boxd.sh/integrations/index.md)

## From the shell

```sh
run auth perplexityai      # once: prints a link to connect your account
run perplexityai           # list its commands
run perplexityai list-models
```

Parameters are flags (`--flag value`); object and array parameters take a JSON string. Output is YAML, or JSON with `--json`. Calls use your own connection; `--scope <name>` uses a connection shared with your team.

## From a script

```ts
import { every, perplexityai } from "@boxd/run";

every("1 hour", async () => {
  const result = await perplexityai.listModels();
  console.log(result);
});
```

Run it with `run perplexityai.run.ts`. Perplexity AI has no triggers; `every()` polls on a schedule, keeps the script running as a job, and wakes the machine when it is due.

## Commands

Required flags are listed; `run perplexityai <command> --help` lists the optional ones. "common" marks what `run perplexityai` shows without `--all`.

| Command | SDK method | Required flags | Optional | Description |
|---|---|---|---|---|
| `create-async-chat-completion` | `perplexityai.createAsyncChatCompletion()` | `--request` | 1 | Create Async Chat Completion (POST /v1/async/sonar) |
| `create-chat-completion` | `perplexityai.createChatCompletion()` | `--messages` | 25 | Perplexity Sonar Chat Completions (POST /v1/sonar) |
| `create-contextualized-embeddings` | `perplexityai.createContextualizedEmbeddings()` | `--input` `--model` | 2 | Create Contextualized Embeddings (POST /v1/contextualizedembeddings) |
| `create-embeddings` | `perplexityai.createEmbeddings()` | `--input` `--model` | 2 | Generate vector embeddings for independent texts (queries, sentences, documents) |
| `execute-agent` | `perplexityai.executeAgent()` | `--input` | 10 | Create Agent Response (POST /v1/agent) |
| `get-async-chat-completion` | `perplexityai.getAsyncChatCompletion()` | `--request-id` | 0 | Get Async Chat Completion (GET /v1/async/sonar/{id}) |
| `list-async-chat-completions` | `perplexityai.listAsyncChatCompletions()` | — | 0 | List Async Chat Completions (GET /v1/async/sonar) |
| `list-models` | `perplexityai.listModels()` | — | 0 | List Models (GET /v1/models) |
| `search` | `perplexityai.search()` | `--query` | 11 | Search the Web (POST /search) |

## Docs

- [run CLI](https://docs.boxd.sh/cli/run): Call connected integrations from the shell, connect new ones, and run automations.
- [Quickstart](https://docs.boxd.sh/guides/integrations/quickstart): Connect an integration, call it from the shell, and turn a script into an automation.
- [Connections](https://docs.boxd.sh/guides/integrations/connections): Connect an account once, for yourself or for your whole organization.
- [Scripts](https://docs.boxd.sh/guides/automations/scripts): Typed integrations, triggers, schedules and state in a .run.ts file.
- [Jobs](https://docs.boxd.sh/guides/automations/jobs): How a script becomes a background job: states, retries, sleep and wake.
- [Beyond the catalog](https://docs.boxd.sh/guides/automations/beyond-the-catalog): Reach your own APIs, databases and cloud accounts from a script.
