ChatCompletion​Chat​Completion

Chat completion with AI models

Handles chat interactions using AI models (OpenAI, Ollama, Gemini, Anthropic, MistralAI, Deepseek).

yaml
type: "io.kestra.plugin.ai.completion.ChatCompletion"

Chat completion with Google Gemini

yaml
id: chat_completion
namespace: company.ai

inputs:
  - id: prompt
    type: STRING

tasks:
  - id: chat_completion
    type: io.kestra.plugin.ai.completion.ChatCompletion
    provider:
      type: io.kestra.plugin.ai.provider.GoogleGemini
      apiKey: "{{ kv('GOOGLE_API_KEY') }}"
      modelName: gemini-2.5-flash
    messages:
      - type: SYSTEM
        content: You are a helpful assistant, answer concisely, avoid overly casual language or unnecessary verbosity.
      - type: USER
        content: "{{inputs.prompt}}"

Chat Completion with Google Gemini and a WebSearch tool

yaml
id: chat_completion_with_tools
namespace: company.ai

inputs:
  - id: prompt
    type: STRING

tasks:
  - id: chat_completion_with_tools
    type: io.kestra.plugin.ai.completion.ChatCompletion
    provider:
      type: io.kestra.plugin.ai.provider.GoogleGemini
      apiKey: "{{ kv('GOOGLE_API_KEY') }}"
      modelName: gemini-2.5-flash
    messages:
      - type: SYSTEM
        content: You are a helpful assistant, answer concisely, avoid overly casual language or unnecessary verbosity.
      - type: USER
        content: "{{inputs.prompt}}"
    tools:
      - type: io.kestra.plugin.ai.tool.GoogleCustomWebSearch
        apiKey: "{{ kv('GOOGLE_SEARCH_API_KEY') }}"
        csi: "{{ kv('GOOGLE_SEARCH_CSI') }}"

Extract structured outputs with a JSON schema. Not all model providers support JSON schema; in those cases, you have to specify the schema in the prompt.

yaml
id: structured-output
namespace: company.ai

inputs:
  - id: prompt
    type: STRING
    defaults: |
      Hello, my name is John. I was born on January 1, 2000.

tasks:
  - id: ai-agent
    type: io.kestra.plugin.ai.completion.ChatCompletion
    provider:
      type: io.kestra.plugin.ai.provider.GoogleGemini
      modelName: gemini-2.5-flash
      apiKey: "{{ kv('GEMINI_API_KEY') }}"
    configuration:
      responseFormat:
        type: JSON
        jsonSchema:
          type: object
          properties:
            name:
              type: string
            birth:
              type: string
      messages:
      - type: USER
        content: "{{inputs.prompt}}"
Properties
SubType

Chat Messages

The list of chat messages for the current conversation. There can be only one system message, and the last message must be a user message

Language Model Provider

Default {}

Chat configuration

Tools that the LLM may use to augment its response

Possible Values
STOPLENGTHTOOL_EXECUTIONCONTENT_FILTEROTHER

Finish reason

Intermediate responses

LLM output for JSON response format

The result of the LLM completion for response format of type JSON, null otherwise.

SubType string

URIs of the generated files in Kestra's internal storage

Request duration in milliseconds

Content sources used during RAG retrieval

LLM output for TEXT response format

The result of the LLM completion for response format of type TEXT (default), null otherwise.

Model's Thinking Output

Contains the model's internal reasoning or 'thinking' text, if the model supports it and 'returnThinking' is enabled. This may include intermediate reasoning steps, such as chain-of-thought explanations. Null if thinking is not supported, not enabled, or not returned by the model.

Token usage

Tool executions

Unit token

Large Language Model (LLM) input token count

Unit token

Large Language Model (LLM) output token count

Unit token

Large Language Model (LLM) total token count

Possible Values
SYSTEMAIUSER

API Key

Model name

Base URL

Custom base URL to override the default endpoint (useful for local tests, WireMock, or enterprise gateways).

CA PEM certificate content

CA certificate as text, used to verify SSL/TLS connections when using custom endpoints.

Client PEM certificate content

PEM client certificate as text, used to authenticate the connection to enterprise AI endpoints.

SubType string

MCP client command, as a list of command parts

SubType string

Environment variables

Default false

Log events

API Key

Model name

Default https://open.bigmodel.cn/

API base URL

The base URL for ZhiPu API (defaults to https://open.bigmodel.cn/)

CA PEM certificate content

CA certificate as text, used to verify SSL/TLS connections when using custom endpoints.

Client PEM certificate content

PEM client certificate as text, used to authenticate the connection to enterprise AI endpoints.

The maximum retry times to request

The maximum number of tokens returned by this request

SubType string

With the stop parameter, the model will automatically stop generating text when it is about to contain the specified string or token_id

Description of the flow if not already provided inside the flow itself

Use it only if you define the flow in the tool definition. The LLM needs a tool description to identify whether to call it. If the flow has a description, the tool will use it. Otherwise, the description property must be explicitly defined.

Flow ID of the flow that should be called

Default false

Whether the flow should inherit labels from this execution that triggered it

By default, labels are not inherited. If you set this option to true, the flow execution will inherit all labels from the agent's execution. Any labels passed by the LLM will override those defined here.

Input values that should be passed to flow's execution

Any inputs passed by the LLM will override those defined here.

Labels that should be added to the flow's execution

Any labels passed by the LLM will override those defined here.

Namespace of the flow that should be called

Revision of the flow that should be called

Format date-time

Schedule the flow execution at a later date

If the LLM sets a scheduleDate, it will override the one defined here.

URL of the MCP server

SubType string

Custom headers

Useful, for example, for adding authentication tokens via the Authorization header.

Default false

Log requests

Default false

Log responses

Format duration

Connection timeout duration

SubType

List of Kestra runnable tasks

API Key

Model name

Default https://api.deepseek.com/v1

API base URL

CA PEM certificate content

CA certificate as text, used to verify SSL/TLS connections when using custom endpoints.

Client PEM certificate content

PEM client certificate as text, used to authenticate the connection to enterprise AI endpoints.

Agent description

The description will be used to instruct the LLM what the tool is doing.

Language model provider

Default {}

Language model configuration

Content retrievers

Some content retrievers, like WebSearch, can also be used as tools. However, when configured as content retrievers, they will always be used, whereas tools are only invoked when the LLM decides to use them.

Maximum sequential tools invocations

Default tool

Agent name

It must be set to a different value than the default in case you want to have multiple agents used as tools in the same task.

System message

The system message for the language model

Tools that the LLM may use to augment its response

Generated text completion

The result of the text completion

Possible Values
STOPLENGTHTOOL_EXECUTIONCONTENT_FILTEROTHER

Finish reason

Response identifier

Request duration in milliseconds

Token usage

Tool execution requests

JSON Schema (used when type = JSON)

Provide a JSON Schema describing the expected structure of the response. In Kestra flows, define the schema in YAML (it is still a JSON Schema object). Example (YAML):

text
responseFormat: 
    type: JSON
    jsonSchema: 
      type: object
      required: ["category", "priority"]
      properties: 
        category: 
          type: string
          enum: ["ACCOUNT", "BILLING", "TECHNICAL", "GENERAL"]
        priority: 
          type: string
          enum: ["LOW", "MEDIUM", "HIGH"]

Note: Provider support for strict schema enforcement varies. If unsupported, guide the model about the expected output structure via the prompt and validate downstream.

Schema description (optional)

Natural-language description of the schema to help the model produce the right fields. Example: "Classify a customer ticket into category and priority."

Default TEXT
Possible Values
TEXTJSON

Response format type

Specifies how the LLM should return output. Allowed values:

  • TEXT (default): free-form natural language.
  • JSON: structured output validated against a JSON Schema.

API Key

Model name

Base URL

Custom base URL to override the default endpoint (useful for local tests, WireMock, or enterprise gateways).

CA PEM certificate content

CA certificate as text, used to verify SSL/TLS connections when using custom endpoints.

Client PEM certificate content

PEM client certificate as text, used to authenticate the connection to enterprise AI endpoints.

Container image

API version

SubType string

Volume binds

SubType string

MCP client command, as a list of command parts

Docker certificate path

Docker configuration

Docker context

Docker host

Whether Docker should verify TLS certificates

SubType string

Environment variables

Default false

Whether to log events

Container registry email

Container registry password

Container registry URL

Container registry username

API key

Custom search engine ID (cx)

Model endpoint

Model name

Base URL

Custom base URL to override the default endpoint (useful for local tests, WireMock, or enterprise gateways).

CA PEM certificate content

CA certificate as text, used to verify SSL/TLS connections when using custom endpoints.

Client PEM certificate content

PEM client certificate as text, used to authenticate the connection to enterprise AI endpoints.

RapidAPI key for Judge0

You can obtain it from the RapidAPI website.

API Key

Model name

Default https://api.openai.com/v1

API base URL

CA PEM certificate content

CA certificate as text, used to verify SSL/TLS connections when using custom endpoints.

Client PEM certificate content

PEM client certificate as text, used to authenticate the connection to enterprise AI endpoints.

Possible Values
POSTGRESQLMYSQLH2

Type of database to connect to (PostgreSQL, MySQL, or H2)

Determines the default JDBC driver and connection format.

Database password

Language model provider

Database username

Default {}

Language model configuration

Optional JDBC driver class name – automatically resolved if not provided.

JDBC connection URL to the target database

Default 2

Maximum number of database connections in the pool

Extracted text segment

A snippet of text relevant to the user's query, typically a sentence, paragraph, or other discrete unit of text.

Source metadata

Key-value pairs providing context about the origin of the content, such as URLs, document titles, or other relevant attributes.

API key

Custom search engine ID (cx)

Default 3

Maximum number of results

Log LLM requests

If true, prompts and configuration sent to the LLM will be logged at INFO level.

Log LLM responses

If true, raw responses from the LLM will be logged at INFO level.

Maximum number of tokens the model can generate in the completion (response). This limits the length of the output.

Response format

Defines the expected output format. Default is plain text. Some providers allow requesting JSON or schema-constrained outputs, but support varies and may be incompatible with tool use. When using a JSON schema, the output will be returned under the key jsonOutput.

Return Thinking

Controls whether to return the model's internal reasoning or 'thinking' text, if available. When enabled, the reasoning content is extracted from the response and made available in the AiMessage object. It Does not trigger the thinking process itself—only affects whether the output is parsed and returned.

Seed

Optional random seed for reproducibility. Provide a positive integer (e.g., 42, 1234). Using the same seed with identical settings produces repeatable outputs.

Temperature

Controls randomness in generation. Typical range is 0.0–1.0. Lower values (e.g., 0.2) make outputs more focused and deterministic, while higher values (e.g., 0.7–1.0) increase creativity and variability.

Thinking Token Budget

Specifies the maximum number of tokens allocated as a budget for internal reasoning processes, such as generating intermediate thoughts or chain-of-thought sequences, allowing the model to perform multi-step reasoning before producing the final output.

Enable Thinking

Enables internal reasoning ('thinking') in supported language models, allowing the model to perform intermediate reasoning steps before producing a final output; this is useful for complex tasks like multi-step problem solving or decision making, but may increase token usage and response time, and is only applicable to compatible models.

Top-K

Limits sampling to the top K most likely tokens at each step. Typical values are between 20 and 100. Smaller values reduce randomness; larger values allow more diverse outputs.

Top-P (nucleus sampling)

Selects from the smallest set of tokens whose cumulative probability is ≤ topP. Typical values are 0.8–0.95. Lower values make the output more focused, higher values increase diversity.

Tool request arguments

Tool execution request identifier

Tool name

Account Identifier

Unique identifier assigned to an account

API Key

Model name

Base URL

Custom base URL to override the default endpoint (useful for local tests, WireMock, or enterprise gateways).

CA PEM certificate content

CA certificate as text, used to verify SSL/TLS connections when using custom endpoints.

Client PEM certificate content

PEM client certificate as text, used to authenticate the connection to enterprise AI endpoints.

API endpoint

The Azure OpenAI endpoint in the format: https://{resource}.openai.azure.com/

Model name

API Key

Base URL

Custom base URL to override the default endpoint (useful for local tests, WireMock, or enterprise gateways).

CA PEM certificate content

CA certificate as text, used to verify SSL/TLS connections when using custom endpoints.

Client ID

Client PEM certificate content

PEM client certificate as text, used to authenticate the connection to enterprise AI endpoints.

Client secret

API version

Tenant ID

Endpoint URL

Project location

Model name

Project ID

Base URL

Custom base URL to override the default endpoint (useful for local tests, WireMock, or enterprise gateways).

CA PEM certificate content

CA certificate as text, used to verify SSL/TLS connections when using custom endpoints.

Client PEM certificate content

PEM client certificate as text, used to authenticate the connection to enterprise AI endpoints.

API Key

Model name

Base URL

Custom base URL to override the default endpoint (useful for local tests, WireMock, or enterprise gateways).

CA PEM certificate content

CA certificate as text, used to verify SSL/TLS connections when using custom endpoints.

Client PEM certificate content

PEM client certificate as text, used to authenticate the connection to enterprise AI endpoints.

OCID of OCI Compartment with the model

Model name

OCI Region to connect the client to

OCI SDK Authentication provider

Base URL

Custom base URL to override the default endpoint (useful for local tests, WireMock, or enterprise gateways).

CA PEM certificate content

CA certificate as text, used to verify SSL/TLS connections when using custom endpoints.

Client PEM certificate content

PEM client certificate as text, used to authenticate the connection to enterprise AI endpoints.

Agent description

The description will be used to instruct the LLM what the tool is doing.

Server URL

The URL of the remote agent A2A server

Default tool

Agent name

It must be set to a different value than the default in case you want to have multiple agents used as tools in the same task.

SSE URL of the MCP server

SubType string

Custom headers

Could be useful, for example, to add authentication tokens via the Authorization header.

Default false

Log requests

Default false

Log responses

Format duration

Connection timeout duration

API Key

Default 3

Maximum number of results to return

API Key

Model name

Base URL

Custom base URL to override the default endpoint (useful for local tests, WireMock, or enterprise gateways).

CA PEM certificate content

CA certificate as text, used to verify SSL/TLS connections when using custom endpoints.

Client PEM certificate content

PEM client certificate as text, used to authenticate the connection to enterprise AI endpoints.

Maximum Tokens

Specifies the maximum number of tokens that the model is allowed to generate in its response.

Tavily API Key - you can obtain one from the Tavily website

API Key

Model name

Default https://dashscope-intl.aliyuncs.com/api/v1

API base URL

text
If you use a model in the China (Beijing) region, you need to replace the URL with: https://dashscope.aliyuncs.com/api/v1,
otherwise use the Singapore region of: "https://dashscope-intl.aliyuncs.com/api/v1.
The default value is computed based on the system timezone.

CA PEM certificate content

CA certificate as text, used to verify SSL/TLS connections when using custom endpoints.

Client PEM certificate content

PEM client certificate as text, used to authenticate the connection to enterprise AI endpoints.

Whether the model uses Internet search results for reference when generating text or not

The maximum number of tokens returned by this request

Repetition in a continuous sequence during model generation

text
Increasing repetition_penalty reduces the repetition in model generation,
1.0 means no penalty. Value range: (0, +inf)

API base URL

Model name

CA PEM certificate content

CA certificate as text, used to verify SSL/TLS connections when using custom endpoints.

Client PEM certificate content

PEM client certificate as text, used to authenticate the connection to enterprise AI endpoints.

AWS Access Key ID

Model name

AWS Secret Access Key

Base URL

Custom base URL to override the default endpoint (useful for local tests, WireMock, or enterprise gateways).

CA PEM certificate content

CA certificate as text, used to verify SSL/TLS connections when using custom endpoints.

Client PEM certificate content

PEM client certificate as text, used to authenticate the connection to enterprise AI endpoints.

Default COHERE
Possible Values
COHERETITAN

Amazon Bedrock Embedding Model Type

API Key

Model name

Default https://router.huggingface.co/v1

API base URL

CA PEM certificate content

CA certificate as text, used to verify SSL/TLS connections when using custom endpoints.

Client PEM certificate content

PEM client certificate as text, used to authenticate the connection to enterprise AI endpoints.