Perplexity ChatCompletion

Perplexity ChatCompletion

Certified

Send chat completion to Perplexity

Calls Perplexity /chat/completions with rendered messages and returns the first choice. Requires an API key bearer token; defaults: temperature 0.2, top_p 0.9, top_k 0, stream false, penalties 0.0. Supports optional JSON Schema structured output via response_format.

yaml
type: io.kestra.plugin.perplexity.ChatCompletion

Ask a question to Perplexity

yaml
id: perplexity_chat
namespace: company.team

tasks:
  - id: ask_ai
    type: io.kestra.plugin.perplexity.ChatCompletion
    apiKey: "{{ secret('PERPLEXITY_API_KEY') }}"
    model: sonar
    messages:
      - type: USER
        content: "What is Kestra?"
    temperature: 0.7

Perplexity chat with Structured Output (JSON Schema)

yaml
id: perplexity_structured
namespace: company.name

tasks:
  - id: chat_completion_structured
    type: io.kestra.plugin.perplexity.ChatCompletion
    apiKey: "{{ secret('PERPLEXITY_API_KEY') }}"
    model: sonar
    messages:
      - type: USER
        content: "Make a JSON todo from this casual note: schedule team check-in next week; tags: work, planning;"
    jsonResponseSchema: |
      {
        "type": "object",
        "additionalProperties": false,
        "required": ["title", "done", "tags"],
        "properties": {
          "title": { "type": "string" },
          "done":  { "type": "boolean" },
          "tags":  { "type": "array", "items": { "type": "string" } },
          "notes": { "type": "string" }
        }
      }

System prompt with length and repetition controls

yaml
id: perplexity_guarded
namespace: company.team

tasks:
  - id: chat_completion_guarded
    type: io.kestra.plugin.perplexity.ChatCompletion
    apiKey: "{{ secret('PERPLEXITY_API_KEY') }}"
    model: sonar-pro
    messages:
      - type: SYSTEM
        content: "You are a brief release-notes generator."
      - type: USER
        content: "Summarize changes: added metrics; fixed retry bug; improved docs."
    maxTokens: 120
    presencePenalty: 0.8
    frequencyPenalty: 0.6
Properties

Perplexity API key

Bearer token sent in the Authorization header; store as a secret.

Conversation messages

Ordered chat turns; roles are mapped to system, assistant, or user before sending.

Definitions
contentstring
typestring
Possible Values
SYSTEMASSISTANTUSER

Model name

Model identifier accepted by Perplexity (for example sonar, sonar-pro).

Default0.0

Frequency Penalty

Penalty based on token frequency; range 0–2; default 0.0.

JSON Response Schema

JSON Schema string for Structured Output; passed as response_format with type: json_schema and json_schema.schema set to the provided document.

Maximum tokens

Upper bound on completion tokens; omit to let the model decide.

Reference (ref) of the pluginDefaults to apply to this task.

Default0.0

Presence Penalty

Penalty for repeating topics; range 0–2; default 0.0.

Defaultfalse

Stream

Passes stream to the API; keep false (default) because the task reads only the final response body.

Default0.2

Temperature

Randomness factor between 0 and 2; default 0.2.

Default0

Top K

Top-k filter size; 0 keeps all tokens (default).

Default0.9

Top P

Nucleus sampling probability cap (0–1); default 0.9.

Completion text

First choice message.content returned by Perplexity.

Raw response

Full JSON payload returned by the Perplexity API as a string.