anthropic@v1
Communicate with Anthropic's Messages API, no API key needed.
| Version | anthropic@v1 |
| Runs in | inbound-call and your own branches · api-initiated and inbound-sms · hangup, postHangup and events.ready |
Parameters
| Name | Type | Required | Default | Description |
|---|---|---|---|---|
feedback | object | Sound played to the caller while the action runs: a built-in sound or an audio file of your library (at most one of sound / audioFile). | ||
feedback.enabled | boolean | false | Turns the sound on. accepts ${{ }} | |
feedback.sound | beep, loading, heartbeat | "heartbeat" | Built-in sound to play, unless audioFile is set.accepts ${{ }} | |
feedback.audioFile | object | An audio file of your library, by its SID (REST API v2 identifier). audio file of your library: sid | ||
feedback.delay | number | 0 | Seconds to wait before playing: 0..60 accepts ${{ }} | |
secret | string | Optional: your own Anthropic API key, to have Anthropic bill the tokens on your account (any of its models then works). Without it, nothing to set up: Callr bills the tokens, and properties.model must be one of the Anthropic models listed in the AI section of your rates (Billing > Pricing).1..255 characters | ||
timeout | integer | 20 | Seconds to wait for the response. 1..60 · accepts ${{ }} | |
properties | object | yes | Body of the request, as documented by Anthropic for the Messages API (POST /v1/messages): model, max_tokens, system, messages... |
Every parameter that accepts ${{ }} can be computed from an expression.
How it works
The request is the body of the Messages API (POST /v1/messages), sent as is: model, max_tokens, system, messages... The result has the fields of the response (content, stop_reason, usage...) and ok.
Nothing to set up: without secret, no API key is needed and Callr bills the tokens per model (see the AI section of your rates, Billing > Pricing). properties.model must then be one of the Anthropic models listed in the AI section of your rates (Billing > Pricing). Without properties.model, the default model of your account answers when it is an Anthropic one, else claude-sonnet-5-5. When the model asked is no longer available (deprecated by Anthropic), the closest model answers instead.
Your own Anthropic API key (optional): with secret, Anthropic bills the tokens on your account, and any model you have access to works.
Examples
No API key needed
No key and no model: the default model of your account answers, the tokens are billed by Callr. The reply is in content[0].text.
- label: ask
action: recognize@v3
params:
tts:
text: Ask me anything
result: $question
- action: anthropic@v1
params:
properties:
max_tokens: 200
system: You answer on the phone, in one short sentence.
messages:
- role: user
content: ${{ $question.text }}
timeout: 10
# feedback: sound played to the caller while waiting for Anthropic,
# disabled by default
feedback:
enabled: true
sound: heartbeat
result: $anthropic
- if: >
!$anthropic.ok || !$anthropic?.content?.length
then:
- action: play@v3
params:
tts:
text: I am sorry, I was not able to reply within the time limit.
- goto:
label: ask
- action: play@v3
params:
tts:
text: ${{ $anthropic.content?.[0]?.text }}With your Anthropic key
With secret, Anthropic bills your account: keep the key in the secrets of the account (Secrets button of the Actions page) rather than in the scenario.
- action: anthropic@v1
params:
secret: ${{ secrets.ANTHROPIC_KEY }}
properties:
model: claude-sonnet-5-5
max_tokens: 1024
messages:
- role: user
content: Hello
result: $anthropicResult
Set result: $myVariable to keep it. Response of the Anthropic Messages API. On success, the fields of the response (id, content, stop_reason, usage...) and ok: true
| Field | Type | Description |
|---|---|---|
ok | boolean | true when Anthropic answered with HTTP 200 |
error | string | Only when ok is false: timeout, code != 200, no properties, or the network error |
{
"ok": true,
"id": "msg_01XFDUDYJgAACzvnptvVoYEL",
"type": "message",
"role": "assistant",
"model": "claude-sonnet-5-5",
"content": [
{ "type": "text", "text": "Hello! How can I help you today?" }
],
"stop_reason": "end_turn",
"stop_sequence": null,
"usage": {
"input_tokens": 12,
"output_tokens": 10
}
}Updated about 2 hours ago
