ChatCompletion
yaml
type: "io.kestra.plugin.openai.chatcompletion"
Examples
yaml
id: openai_chat
namespace: company.team
inputs:
- id: prompt
type: STRING
defaults: What is data orchestration?
tasks:
- id: completion
type: io.kestra.plugin.openai.ChatCompletion
apiKey: "{{ secret('OPENAI_API_KEY') }}"
model: gpt-4o
prompt: "{{ inputs.prompt }}"
- id: log_output
type: io.kestra.plugin.core.log.Log
message: "{{ outputs.completion.choices[0].message.content }}"
yaml
id: openai_chat
namespace: company.team
tasks:
- id: prompt
type: io.kestra.plugin.openai.ChatCompletion
apiKey: "{{ secret('OPENAI_API_KEY') }}"
model: gpt-4o
prompt: Explain in one sentence why data engineers build data pipelines
- id: use_output
type: io.kestra.plugin.core.log.Log
message: "{{ outputs.prompt.choices | jq('.[].message.content') | first }}"
yaml
id: openai_chat
namespace: company.team
inputs:
- id: prompt
type: STRING
defaults: I love your product and would purchase it again!
tasks:
- id: prioritize_response
type: io.kestra.plugin.openai.ChatCompletion
apiKey: "yourOpenAIapiKey"
model: gpt-4o
messages:
- role: user
content: "{{ inputs.prompt }}"
functions:
- name: respond_to_review
description: Given the customer product review provided as input, determines how urgently a reply is required and then provides suggested response text.
parameters:
- name: response_urgency
type: string
description: How urgently this customer review needs a reply. Bad reviews
must be addressed immediately before anyone sees them. Good reviews can
wait until later.
required: true
enumValues:
- reply_immediately
- reply_later
- name: response_text
type: string
description: The text to post online in response to this review.
required: true
- id: response_urgency
type: io.kestra.plugin.core.debug.Return
format: "{{ outputs.prioritize_response | jq('.choices[0].message.tool_calls[0].function.arguments | fromjson | .response_urgency') | first }}"
- id: response_text
type: io.kestra.plugin.core.debug.Return
format: "{{ outputs.prioritize_response | jq('.choices[0].message.tool_calls[0].function.arguments | fromjson | .response_text') | first }}"
Properties
apiKey *Requiredstring
model *Requiredstring
clientTimeout Non-dynamicinteger
Default
10
frequencyPenalty numberstring
functionCall string
Default
auto
jsonResponseSchema string
logitBias object
SubType integer
maxTokens integerstring
n integerstring
Default
1
presencePenalty numberstring
prompt string
stop array
SubType string
temperature numberstring
Default
1.0
topP numberstring
Default
1.0
user string
Outputs
Definitions
com.openai.models.completions.CompletionUsage
com.openai.core.JsonField
com.openai.models.chat.completions.ChatCompletion-Choice
com.openai.core.JsonField
io.kestra.plugin.openai.ChatCompletion-ChatMessage
content string
name string
role string
io.kestra.plugin.openai.ChatCompletion-PluginChatFunctionParameter
description *Requiredstring
name *Requiredstring
type *Requiredstring
enumValues array
SubType string