ChatCompletion
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.
type: "io.kestra.plugin.anthropic.ChatCompletion"
Examples
Chat completion using Claude.
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.
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.
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
apiKey *Requiredstring
Anthropic API Key
model *Requiredstring
Model
Specifies which Claude model to use for the completion (e.g., 'claude-3-5-sonnet-20241022', 'claude-3-opus-20240229').
maxTokens integerstring
1024
Max Tokens
The maximum number of tokens to generate in the response.
system string
System prompt
System prompt to set the behavior of the assistant
temperature numberstring
1.0
Temperature
Controls randomness in the response. Higher values make output more random.
topK integerstring
Top K
Only sample from the top K options for each subsequent token.
topP numberstring
Top P
Controls diversity via nucleus sampling. 0.1 means only the tokens comprising the top 10% probability mass are considered.
Outputs
outputText string
The content generated by Claude.
rawResponse string
The full response from Claude.
Definitions
io.kestra.plugin.anthropic.ChatCompletion-ChatMessage
content string
type string
AI
USER