ChatCompletion
ChatCompletion
yaml
type: "io.kestra.plugin.anthropic.ChatCompletion"Examples
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."
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.
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: ASSISTANT
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?"
yaml
id: anthropic_structured_output
namespace: company.team
tasks:
- id: extract_data
type: io.kestra.plugin.anthropic.ChatCompletion
apiKey: "{{ secret('ANTHROPIC_API_KEY') }}"
model: "claude-3-5-sonnet-20241022"
maxTokens: 1024
messages:
- type: USER
content: |
Extract the following information from this text:
"John Doe is 30 years old and works as a Software Engineer in San Francisco."
tools:
- name: extract_person_info
description: "Extract structured information about a person"
input_schema:
type: object
properties:
name:
type: string
description: "The person's full name"
age:
type: integer
description: "The person's age"
occupation:
type: string
description: "The person's job title"
location:
type: string
description: "The person's location"
required:
- name
- age
Properties
apiKey *Requiredstring
messages *Requiredarray
Definitions
io.kestra.plugin.anthropic.ChatCompletion-ChatMessage
contentstring
typestring
Possible Values
ASSISTANTUSERmodel *Requiredstring
maxTokens integerstring
Default
1024system string
temperature numberstring
Default
1.0tools array
Definitions
io.kestra.plugin.anthropic.ChatCompletion-Tool
descriptionstring
inputSchemaobject
namestring
topK integerstring
topP numberstring
Outputs
outputText string
rawResponse string
stopReason string
toolUses array
Definitions
io.kestra.plugin.anthropic.ChatCompletion-ToolUse
idstring
inputobject
namestring
Metrics
usage.input.tokens counter
Unit
tokenusage.output.tokens counter
Unit
token