ChatCompletion​Chat​Completion

Complete a chat using the Anthropic Claude API.

Send messages to Claude models and receive responses. Refer to the Anthropic Console Settings to create an API key and the Anthropic API documentation for more information.

yaml
type: "io.kestra.plugin.anthropic.ChatCompletion"

Chat completion using Claude.

yaml
id: anthropic_chat_completion
namespace: company.team

tasks:
  - id: chat_completion
    type: io.kestra.plugin.anthropic.ChatCompletion
    apiKey: "{{ secret('ANTHROPIC_API_KEY') }}"
    model: "claude-3-5-sonnet-20241022"
    maxTokens: 1024
    messages:
      - type: USER
        content: "What is the capital of Japan? Answer with a unique word and without any punctuation."

Code generation using Claude.

yaml
id: anthropic_code_generation
namespace: company.team

tasks:
  - id: code_generation
    type: io.kestra.plugin.anthropic.ChatCompletion
    apiKey: "{{ secret('ANTHROPIC_API_KEY') }}"
    model: "claude-3-5-sonnet-20241022"
    maxTokens: 1500
    temperature: 0.3
    messages:
      - type: USER
        content: |
          Write a Python function that:
          1. Takes a list of numbers as input
          2. Filters out negative numbers
          3. Calculates the average of remaining positive numbers
          4. Returns the result rounded to 2 decimal places
          5. Include error handling for empty lists
          Also provide 3 test cases with expected outputs.

Conversation with follow-up context.

yaml
id: anthropic_context_conversation
namespace: company.team

tasks:
  - id: code_generation
    type: io.kestra.plugin.anthropic.ChatCompletion
    apiKey: "{{ secret('ANTHROPIC_API_KEY') }}"
    model: "claude-3-5-sonnet-20241022"
    maxTokens: 800
    temperature: 0.5
    messages:
      - type: USER
        content: "Explain quantum computing in simple terms."
      - type: AI
        content: "Quantum computing uses quantum mechanical phenomena like superposition and entanglement to process information differently than classical computers. Instead of bits that are either 0 or 1, quantum computers use quantum bits (qubits) that can exist in multiple states simultaneously."
      - type: USER
        content: "That is helpful! Can you give me a practical example of how this could be used in everyday life in the next 10 years?"
Properties

Anthropic API Key

Messages

List of messages to send to Claude

Model

Specifies which Claude model to use for the completion (e.g., 'claude-3-5-sonnet-20241022', 'claude-3-opus-20240229').

Default 1024

Max Tokens

The maximum number of tokens to generate in the response.

System prompt

System prompt to set the behavior of the assistant

Default 1.0

Temperature

Controls randomness in the response. Higher values make output more random.

Top K

Only sample from the top K options for each subsequent token.

Top P

Controls diversity via nucleus sampling. 0.1 means only the tokens comprising the top 10% probability mass are considered.

The content generated by Claude.

The full response from Claude.

Possible Values
AIUSER