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.

StreamAssembler

Builds a reply from the server-sent events of a streamed response. Feed every event to Apply; it returns the text that event added. Public so a recorded stream can be replayed without a server.

Operations

Apply #

Handles one event

method : public : Apply(event:String, data:String) ~ String

Parameters

NameTypeDescription
eventStringevent name (message_start, content_block_delta, ...)
dataStringevent data, JSON text

Return

TypeDescription
Stringthe text this event added, or Nil

GetReply #

Builds the reply from what has been applied

method : public : GetReply() ~ Reply

Return

TypeDescription
Replyreply, or Nil with the last error set when the stream failed or has not finished

IsDone #

Check for the end of the message

method : public : IsDone() ~ Bool

Return

TypeDescription
Booltrue after message_stop

IsFailed #

Check for an error event

method : public : IsFailed() ~ Bool

Return

TypeDescription
Booltrue when the stream carried an error; EndPoint->GetLastError() says which