KosmoKrator

ai

Perplexity AI CLI for AI Agents

Use the Perplexity AI CLI from KosmoKrator to call Perplexity AI tools headlessly, return JSON, inspect schemas, and automate workflows from coding agents, scripts, and CI.

4 functions 4 read 0 write API key auth

Perplexity AI CLI Setup

Perplexity AI can be configured headlessly with `kosmokrator integrations:configure perplexity`.

# Install KosmoKrator first if it is not available on PATH.
curl -fsSL https://raw.githubusercontent.com/OpenCompanyApp/kosmokrator/main/install.sh | bash

# Configure and verify this integration.
kosmokrator integrations:configure perplexity --set api_key="$PERPLEXITY_API_KEY" --enable --read allow --write ask --json
kosmokrator integrations:doctor perplexity --json
kosmokrator integrations:status --json

Credentials

Authentication type: API key api_key. Configure credentials once, then use the same stored profile from scripts, coding CLIs, Lua code mode, and the MCP gateway.

KeyEnv varTypeRequiredLabel
api_key PERPLEXITY_API_KEY Secret secret yes API Key
url PERPLEXITY_URL URL url no API Base URL

Call Perplexity AI Headlessly

Use the generic call form when another coding CLI or script needs a stable universal interface.

kosmo integrations:call perplexity.perplexity_chat '{
  "messages": "example_messages",
  "model": "example_model",
  "temperature": 1,
  "max_tokens": 1,
  "search_domain_filter": "example_search_domain_filter",
  "return_images": true,
  "return_related_questions": true,
  "search_recency_filter": "example_search_recency_filter"
}' --json

Use the provider shortcut form for shorter human-facing commands.

kosmo integrations:perplexity perplexity_chat '{
  "messages": "example_messages",
  "model": "example_model",
  "temperature": 1,
  "max_tokens": 1,
  "search_domain_filter": "example_search_domain_filter",
  "return_images": true,
  "return_related_questions": true,
  "search_recency_filter": "example_search_recency_filter"
}' --json

Agent Discovery Commands

These commands return structured output for coding agents that need to inspect capabilities before choosing a function.

kosmo integrations:docs perplexity --json
kosmo integrations:docs perplexity.perplexity_chat --json
kosmo integrations:schema perplexity.perplexity_chat --json
kosmo integrations:search "Perplexity AI" --json
kosmo integrations:list --json

All CLI Functions

Every function below can be called headlessly. The generic form is stable across all integrations; the provider shortcut is shorter but specific to Perplexity AI.

perplexity.perplexity_chat

Read read

Send messages to Perplexity AI for a chat completion response. Supports multi-turn conversations with message history. Returns the assistant response with optional citations and search results.

Parameters
messages, model, temperature, max_tokens, search_domain_filter, return_images, return_related_questions, search_recency_filter

Generic CLI call

kosmo integrations:call perplexity.perplexity_chat '{"messages":"example_messages","model":"example_model","temperature":1,"max_tokens":1,"search_domain_filter":"example_search_domain_filter","return_images":true,"return_related_questions":true,"search_recency_filter":"example_search_recency_filter"}' --json

Provider shortcut

kosmo integrations:perplexity perplexity_chat '{"messages":"example_messages","model":"example_model","temperature":1,"max_tokens":1,"search_domain_filter":"example_search_domain_filter","return_images":true,"return_related_questions":true,"search_recency_filter":"example_search_recency_filter"}' --json

perplexity.perplexity_ask

Read read

Ask Perplexity AI a question and get a concise answer with cited sources. Best for factual queries, research, and knowledge questions.

Parameters
query, model, temperature, max_tokens, search_domain_filter, return_images, return_related_questions, search_recency_filter

Generic CLI call

kosmo integrations:call perplexity.perplexity_ask '{"query":"example_query","model":"example_model","temperature":1,"max_tokens":1,"search_domain_filter":"example_search_domain_filter","return_images":true,"return_related_questions":true,"search_recency_filter":"example_search_recency_filter"}' --json

Provider shortcut

kosmo integrations:perplexity perplexity_ask '{"query":"example_query","model":"example_model","temperature":1,"max_tokens":1,"search_domain_filter":"example_search_domain_filter","return_images":true,"return_related_questions":true,"search_recency_filter":"example_search_recency_filter"}' --json

perplexity.perplexity_list_models

Read read

List all available Perplexity AI models. Returns model IDs and their capabilities for use in chat and ask tools.

Parameters
none

Generic CLI call

kosmo integrations:call perplexity.perplexity_list_models '{}' --json

Provider shortcut

kosmo integrations:perplexity perplexity_list_models '{}' --json

perplexity.perplexity_get_current_user

Read read

Get information about the currently authenticated Perplexity API user, including account details and usage.

Parameters
none

Generic CLI call

kosmo integrations:call perplexity.perplexity_get_current_user '{}' --json

Provider shortcut

kosmo integrations:perplexity perplexity_get_current_user '{}' --json

Function Schemas

Use these parameter tables when building CLI payloads without calling integrations:schema first.

perplexity.perplexity_chat

Send messages to Perplexity AI for a chat completion response. Supports multi-turn conversations with message history. Returns the assistant response with optional citations and search results.

Operation
Read read
Schema command
kosmo integrations:schema perplexity.perplexity_chat --json
ParameterTypeRequiredDescription
messages array yes Array of message objects, each with "role" (system, user, or assistant) and "content" (string). Example: [{"role": "user", "content": "What is AI?"}].
model string no Model to use: "sonar" (fast, lightweight), "sonar-pro" (advanced), "sonar-reasoning" (reasoning), or "sonar-reasoning-pro" (advanced reasoning). Defaults to "sonar".
temperature number no Sampling temperature (0.0–2.0). Lower values are more focused, higher values more creative. Defaults to 0.2.
max_tokens integer no Maximum number of tokens in the response.
search_domain_filter array no List of domains to limit search results to (e.g., ["wikipedia.org"]). Pass empty array to exclude, or omit for no filter.
return_images boolean no Whether to return images in the response. Defaults to false.
return_related_questions boolean no Whether to return related questions. Defaults to false.
search_recency_filter string no Filter search results by recency: "month", "week", "day", or "hour".

perplexity.perplexity_ask

Ask Perplexity AI a question and get a concise answer with cited sources. Best for factual queries, research, and knowledge questions.

Operation
Read read
Schema command
kosmo integrations:schema perplexity.perplexity_ask --json
ParameterTypeRequiredDescription
query string yes The question or prompt to ask Perplexity AI.
model string no Model to use: "sonar", "sonar-pro", "sonar-reasoning", or "sonar-reasoning-pro". Defaults to "sonar".
temperature number no Sampling temperature (0.0–2.0). Lower values are more focused. Defaults to 0.2.
max_tokens integer no Maximum number of tokens in the response.
search_domain_filter array no List of domains to limit search results to (e.g., ["wikipedia.org"]).
return_images boolean no Whether to return images in the response. Defaults to false.
return_related_questions boolean no Whether to return related questions. Defaults to false.
search_recency_filter string no Filter search results by recency: "month", "week", "day", or "hour".

perplexity.perplexity_list_models

List all available Perplexity AI models. Returns model IDs and their capabilities for use in chat and ask tools.

Operation
Read read
Schema command
kosmo integrations:schema perplexity.perplexity_list_models --json
ParameterTypeRequiredDescription
No parameters.

perplexity.perplexity_get_current_user

Get information about the currently authenticated Perplexity API user, including account details and usage.

Operation
Read read
Schema command
kosmo integrations:schema perplexity.perplexity_get_current_user --json
ParameterTypeRequiredDescription
No parameters.

Permissions

Headless calls still follow the integration read/write permission policy. Configure read/write defaults with integrations:configure. Add --force only for trusted automation that should bypass that policy.