v2026.11.2
All Bundles
Bundle

Anthropic Messages API client (Claude). Plain and multi-turn chat with a system prompt, tool use, streaming over server-sent events, structured (JSON) output through a forced tool, and extended-thinking blocks. Responses and errors follow the other AI client libraries: a failed call returns Nil and EndPoint->GetLastError() says why. The key comes from SetApiKey, the ANTHROPIC_API_KEY environment variable, or anthropic_api_key.dat in the working directory. Requests go over HTTPS. Compile with -lib anthropic.

Reply

A model reply: its text, tool calls, thinking, stop reason and token counts

Operations

GetContent #

Get the content blocks as the API returned them

method : public : GetContent() ~ JsonElement

Return

TypeDescription
JsonElementJSON array

GetId #

Get the message id

method : public : GetId() ~ String

Return

TypeDescription
Stringid

GetInputTokens #

Get the tokens the prompt used

method : public : GetInputTokens() ~ Int

Return

TypeDescription
Intinput tokens

GetModel #

Get the model that answered

method : public : GetModel() ~ String

Return

TypeDescription
Stringmodel name

GetOutputTokens #

Get the tokens the reply used

method : public : GetOutputTokens() ~ Int

Return

TypeDescription
Intoutput tokens

GetStopReason #

Get why the model stopped: end_turn, max_tokens, stop_sequence, tool_use or refusal

method : public : GetStopReason() ~ String

Return

TypeDescription
Stringstop reason

GetText #

Get the reply text, every text block joined

method : public : GetText() ~ String

Return

TypeDescription
Stringtext, empty when the reply is only tool calls

GetThinking #

Get the thinking text, when extended thinking was on

method : public : GetThinking() ~ String

Return

TypeDescription
Stringthinking text, empty when there is none

GetToolUses #

Get the tool calls

method : public : GetToolUses() ~ Vector<ToolUse>

Return

TypeDescription
Vector<ToolUse>tool calls

HasToolUses #

Check for tool calls

method : public : HasToolUses() ~ Bool

Return

TypeDescription
Booltrue when the model asked for tools

Parse # function

Parses a response body without a server, for tests and for replaying recorded responses

function : Parse(body:String) ~ Reply

Parameters

NameTypeDescription
bodyStringresponse text

Return

TypeDescription
Replyreply, or Nil with the last error set