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.
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 --jsonkosmokrator integrations:doctor perplexity --jsonkosmokrator integrations:status --json
Credentials
Authentication type: API keyapi_key. Configure credentials once, then use the same stored profile from
scripts, coding CLIs, Lua code mode, and the MCP gateway.
Key
Env var
Type
Required
Label
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.
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.
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.
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.
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.