
Anthropic ChatCompletion
CertifiedSend chat messages with Claude
Anthropic ChatCompletion
Send chat messages with Claude
Calls the Anthropic Messages API with rendered inputs, optional system prompt, and sampling controls; defaults to maxTokens 1024 and temperature 1.0 while emitting token usage counters. Refer to the Anthropic Console Settings to create an API key and the Anthropic API documentation for more information.
type: io.kestra.plugin.anthropic.ChatCompletionExamples
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-sonnet-4-6"
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-sonnet-4-6"
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-sonnet-4-6"
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?"
Chat completion with prompt caching
id: anthropic_cached_chat
namespace: company.team
tasks:
- id: cached_chat
type: io.kestra.plugin.anthropic.ChatCompletion
apiKey: "{{ secret('ANTHROPIC_API_KEY') }}"
model: "claude-sonnet-4-6"
maxTokens: 1024
promptCaching: true
system: "You are a helpful assistant with extensive knowledge about Kestra, the open-source orchestration platform."
messages:
- type: USER
content: "What are the key features of Kestra?"
Tool-assisted structured extraction
id: anthropic_structured_output
namespace: company.team
tasks:
- id: extract_data
type: io.kestra.plugin.anthropic.ChatCompletion
apiKey: "{{ secret('ANTHROPIC_API_KEY') }}"
model: "claude-sonnet-4-6"
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
Anthropic API Key
messages *Requiredarray
Messages
Ordered chat turns rendered from properties; include at least one USER message.
io.kestra.plugin.anthropic.ChatCompletion-ChatMessage
ASSISTANTUSERmodel *Requiredstring
Model
Claude model name to invoke (e.g., claude-sonnet-4-6); must match an Anthropic model available to your API key.
maxTokens integerstring
1024Max Tokens
Maximum tokens Anthropic can generate; defaults to 1024 if unset.
pluginDefaultsRef Non-dynamicstring
Reference (ref) of the pluginDefaults to apply to this task.
promptCaching booleanstring
falsePrompt caching
Enable prompt caching to reduce costs and latency for repetitive prompts. When enabled, the API automatically caches the longest cacheable prefix of the request. Cached tokens are billed at a reduced rate. See the Anthropic prompt caching documentation for details.
system string
System prompt
Optional system instructions applied to the whole conversation; rendered before sending to Claude.
temperature numberstring
1.0Temperature
Sampling randomness; range 0.0–1.0 with default 1.0. Lower for deterministic replies.
tools array
Tools
Optional tools Claude can invoke; each entry needs a unique name, an optional description, and an input_schema JSON Schema that defines the parameters the tool accepts.
io.kestra.plugin.anthropic.ChatCompletion-Tool
Tool description
Optional description of what the tool does.
Input schema
JSON Schema object defining the expected parameters for the tool.
Tool name
Unique identifier for the tool (1-128 characters).
topK integerstring
Top K
Samples only from the top K tokens for each step; leave unset to let the model choose.
topP numberstring
Top P
Nucleus sampling cap; 0.1 keeps only tokens in top 10% probability mass.
Outputs
cacheCreationInputTokens integer
Cache creation input tokens
Number of tokens written to the cache.
cacheReadInputTokens integer
Cache read input tokens
Number of tokens read from the cache.
outputText string
Assistant text extracted from the response
rawResponse string
The full response from Claude
stopReason string
Stop reason
The reason the model stopped generating (e.g., end_turn, tool_use, max_tokens).
toolUses array
Tool uses
List of tools that Claude requested to use, if any.
io.kestra.plugin.anthropic.ChatCompletion-ToolUse
Tool use ID
Unique identifier for this tool use.
Tool input
Parameters passed to the tool as a map.
Tool name
Name of the tool being called.
Metrics
usage.cache.creation.tokens counter
tokenNumber of tokens written to the prompt cache.
usage.cache.read.tokens counter
tokenNumber of tokens read from the prompt cache.
usage.input.tokens counter
tokenNumber of input tokens processed by the model.
usage.output.tokens counter
tokenNumber of output tokens generated by the model.